babylon.d.txt 2.6 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865
  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. export const Epsilon = 0.001;
  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. * Inserts the translation vector in the current matrix
  2941. * @param vector3 defines the translation to insert
  2942. * @returns the current updated matrix
  2943. */
  2944. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2945. /**
  2946. * Gets the translation value of the current matrix
  2947. * @returns a new Vector3 as the extracted translation from the matrix
  2948. */
  2949. getTranslation(): Vector3;
  2950. /**
  2951. * Fill a Vector3 with the extracted translation from the matrix
  2952. * @param result defines the Vector3 where to store the translation
  2953. * @returns the current matrix
  2954. */
  2955. getTranslationToRef(result: Vector3): Matrix;
  2956. /**
  2957. * Remove rotation and scaling part from the matrix
  2958. * @returns the updated matrix
  2959. */
  2960. removeRotationAndScaling(): Matrix;
  2961. /**
  2962. * Multiply two matrices
  2963. * @param other defines the second operand
  2964. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2965. */
  2966. multiply(other: DeepImmutable<Matrix>): Matrix;
  2967. /**
  2968. * Copy the current matrix from the given one
  2969. * @param other defines the source matrix
  2970. * @returns the current updated matrix
  2971. */
  2972. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2973. /**
  2974. * Populates the given array from the starting index with the current matrix values
  2975. * @param array defines the target array
  2976. * @param offset defines the offset in the target array where to start storing values
  2977. * @returns the current matrix
  2978. */
  2979. copyToArray(array: Float32Array, offset?: number): Matrix;
  2980. /**
  2981. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2982. * @param other defines the second operand
  2983. * @param result defines the matrix where to store the multiplication
  2984. * @returns the current matrix
  2985. */
  2986. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2987. /**
  2988. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2989. * @param other defines the second operand
  2990. * @param result defines the array where to store the multiplication
  2991. * @param offset defines the offset in the target array where to start storing values
  2992. * @returns the current matrix
  2993. */
  2994. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2995. /**
  2996. * Check equality between this matrix and a second one
  2997. * @param value defines the second matrix to compare
  2998. * @returns true is the current matrix and the given one values are strictly equal
  2999. */
  3000. equals(value: DeepImmutable<Matrix>): boolean;
  3001. /**
  3002. * Clone the current matrix
  3003. * @returns a new matrix from the current matrix
  3004. */
  3005. clone(): Matrix;
  3006. /**
  3007. * Returns the name of the current matrix class
  3008. * @returns the string "Matrix"
  3009. */
  3010. getClassName(): string;
  3011. /**
  3012. * Gets the hash code of the current matrix
  3013. * @returns the hash code
  3014. */
  3015. getHashCode(): number;
  3016. /**
  3017. * Decomposes the current Matrix into a translation, rotation and scaling components
  3018. * @param scale defines the scale vector3 given as a reference to update
  3019. * @param rotation defines the rotation quaternion given as a reference to update
  3020. * @param translation defines the translation vector3 given as a reference to update
  3021. * @returns true if operation was successful
  3022. */
  3023. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3024. /**
  3025. * Gets specific row of the matrix
  3026. * @param index defines the number of the row to get
  3027. * @returns the index-th row of the current matrix as a new Vector4
  3028. */
  3029. getRow(index: number): Nullable<Vector4>;
  3030. /**
  3031. * Sets the index-th row of the current matrix to the vector4 values
  3032. * @param index defines the number of the row to set
  3033. * @param row defines the target vector4
  3034. * @returns the updated current matrix
  3035. */
  3036. setRow(index: number, row: Vector4): Matrix;
  3037. /**
  3038. * Compute the transpose of the matrix
  3039. * @returns the new transposed matrix
  3040. */
  3041. transpose(): Matrix;
  3042. /**
  3043. * Compute the transpose of the matrix and store it in a given matrix
  3044. * @param result defines the target matrix
  3045. * @returns the current matrix
  3046. */
  3047. transposeToRef(result: Matrix): Matrix;
  3048. /**
  3049. * Sets the index-th row of the current matrix with the given 4 x float values
  3050. * @param index defines the row index
  3051. * @param x defines the x component to set
  3052. * @param y defines the y component to set
  3053. * @param z defines the z component to set
  3054. * @param w defines the w component to set
  3055. * @returns the updated current matrix
  3056. */
  3057. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3058. /**
  3059. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3060. * @param scale defines the scale factor
  3061. * @returns a new matrix
  3062. */
  3063. scale(scale: number): Matrix;
  3064. /**
  3065. * Scale the current matrix values by a factor to a given result matrix
  3066. * @param scale defines the scale factor
  3067. * @param result defines the matrix to store the result
  3068. * @returns the current matrix
  3069. */
  3070. scaleToRef(scale: number, result: Matrix): Matrix;
  3071. /**
  3072. * Scale the current matrix values by a factor and add the result to a given matrix
  3073. * @param scale defines the scale factor
  3074. * @param result defines the Matrix to store the result
  3075. * @returns the current matrix
  3076. */
  3077. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3078. /**
  3079. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3080. * @param ref matrix to store the result
  3081. */
  3082. toNormalMatrix(ref: Matrix): void;
  3083. /**
  3084. * Gets only rotation part of the current matrix
  3085. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3086. */
  3087. getRotationMatrix(): Matrix;
  3088. /**
  3089. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3090. * @param result defines the target matrix to store data to
  3091. * @returns the current matrix
  3092. */
  3093. getRotationMatrixToRef(result: Matrix): Matrix;
  3094. /**
  3095. * Toggles model matrix from being right handed to left handed in place and vice versa
  3096. */
  3097. toggleModelMatrixHandInPlace(): void;
  3098. /**
  3099. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3100. */
  3101. toggleProjectionMatrixHandInPlace(): void;
  3102. /**
  3103. * Creates a matrix from an array
  3104. * @param array defines the source array
  3105. * @param offset defines an offset in the source array
  3106. * @returns a new Matrix set from the starting index of the given array
  3107. */
  3108. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3109. /**
  3110. * Copy the content of an array into a given matrix
  3111. * @param array defines the source array
  3112. * @param offset defines an offset in the source array
  3113. * @param result defines the target matrix
  3114. */
  3115. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3116. /**
  3117. * Stores an array into a matrix after having multiplied each component by a given factor
  3118. * @param array defines the source array
  3119. * @param offset defines the offset in the source array
  3120. * @param scale defines the scaling factor
  3121. * @param result defines the target matrix
  3122. */
  3123. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3124. /**
  3125. * Gets an identity matrix that must not be updated
  3126. */
  3127. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3128. /**
  3129. * Stores a list of values (16) inside a given matrix
  3130. * @param initialM11 defines 1st value of 1st row
  3131. * @param initialM12 defines 2nd value of 1st row
  3132. * @param initialM13 defines 3rd value of 1st row
  3133. * @param initialM14 defines 4th value of 1st row
  3134. * @param initialM21 defines 1st value of 2nd row
  3135. * @param initialM22 defines 2nd value of 2nd row
  3136. * @param initialM23 defines 3rd value of 2nd row
  3137. * @param initialM24 defines 4th value of 2nd row
  3138. * @param initialM31 defines 1st value of 3rd row
  3139. * @param initialM32 defines 2nd value of 3rd row
  3140. * @param initialM33 defines 3rd value of 3rd row
  3141. * @param initialM34 defines 4th value of 3rd row
  3142. * @param initialM41 defines 1st value of 4th row
  3143. * @param initialM42 defines 2nd value of 4th row
  3144. * @param initialM43 defines 3rd value of 4th row
  3145. * @param initialM44 defines 4th value of 4th row
  3146. * @param result defines the target matrix
  3147. */
  3148. 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;
  3149. /**
  3150. * Creates new matrix from a list of values (16)
  3151. * @param initialM11 defines 1st value of 1st row
  3152. * @param initialM12 defines 2nd value of 1st row
  3153. * @param initialM13 defines 3rd value of 1st row
  3154. * @param initialM14 defines 4th value of 1st row
  3155. * @param initialM21 defines 1st value of 2nd row
  3156. * @param initialM22 defines 2nd value of 2nd row
  3157. * @param initialM23 defines 3rd value of 2nd row
  3158. * @param initialM24 defines 4th value of 2nd row
  3159. * @param initialM31 defines 1st value of 3rd row
  3160. * @param initialM32 defines 2nd value of 3rd row
  3161. * @param initialM33 defines 3rd value of 3rd row
  3162. * @param initialM34 defines 4th value of 3rd row
  3163. * @param initialM41 defines 1st value of 4th row
  3164. * @param initialM42 defines 2nd value of 4th row
  3165. * @param initialM43 defines 3rd value of 4th row
  3166. * @param initialM44 defines 4th value of 4th row
  3167. * @returns the new matrix
  3168. */
  3169. 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;
  3170. /**
  3171. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3172. * @param scale defines the scale vector3
  3173. * @param rotation defines the rotation quaternion
  3174. * @param translation defines the translation vector3
  3175. * @returns a new matrix
  3176. */
  3177. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3178. /**
  3179. * Sets a matrix to a value 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. * @param result defines the target matrix
  3184. */
  3185. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3186. /**
  3187. * Creates a new identity matrix
  3188. * @returns a new identity matrix
  3189. */
  3190. static Identity(): Matrix;
  3191. /**
  3192. * Creates a new identity matrix and stores the result in a given matrix
  3193. * @param result defines the target matrix
  3194. */
  3195. static IdentityToRef(result: Matrix): void;
  3196. /**
  3197. * Creates a new zero matrix
  3198. * @returns a new zero matrix
  3199. */
  3200. static Zero(): Matrix;
  3201. /**
  3202. * Creates a new rotation matrix for "angle" radians around the X axis
  3203. * @param angle defines the angle (in radians) to use
  3204. * @return the new matrix
  3205. */
  3206. static RotationX(angle: number): Matrix;
  3207. /**
  3208. * Creates a new matrix as the invert of a given matrix
  3209. * @param source defines the source matrix
  3210. * @returns the new matrix
  3211. */
  3212. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3213. /**
  3214. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3215. * @param angle defines the angle (in radians) to use
  3216. * @param result defines the target matrix
  3217. */
  3218. static RotationXToRef(angle: number, result: Matrix): void;
  3219. /**
  3220. * Creates a new rotation matrix for "angle" radians around the Y axis
  3221. * @param angle defines the angle (in radians) to use
  3222. * @return the new matrix
  3223. */
  3224. static RotationY(angle: number): Matrix;
  3225. /**
  3226. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3227. * @param angle defines the angle (in radians) to use
  3228. * @param result defines the target matrix
  3229. */
  3230. static RotationYToRef(angle: number, result: Matrix): void;
  3231. /**
  3232. * Creates a new rotation matrix for "angle" radians around the Z axis
  3233. * @param angle defines the angle (in radians) to use
  3234. * @return the new matrix
  3235. */
  3236. static RotationZ(angle: number): Matrix;
  3237. /**
  3238. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3239. * @param angle defines the angle (in radians) to use
  3240. * @param result defines the target matrix
  3241. */
  3242. static RotationZToRef(angle: number, result: Matrix): void;
  3243. /**
  3244. * Creates a new rotation matrix for "angle" radians around the given axis
  3245. * @param axis defines the axis to use
  3246. * @param angle defines the angle (in radians) to use
  3247. * @return the new matrix
  3248. */
  3249. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3250. /**
  3251. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3252. * @param axis defines the axis to use
  3253. * @param angle defines the angle (in radians) to use
  3254. * @param result defines the target matrix
  3255. */
  3256. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3257. /**
  3258. * Creates a rotation matrix
  3259. * @param yaw defines the yaw angle in radians (Y axis)
  3260. * @param pitch defines the pitch angle in radians (X axis)
  3261. * @param roll defines the roll angle in radians (X axis)
  3262. * @returns the new rotation matrix
  3263. */
  3264. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3265. /**
  3266. * Creates a rotation matrix and stores it in a given matrix
  3267. * @param yaw defines the yaw angle in radians (Y axis)
  3268. * @param pitch defines the pitch angle in radians (X axis)
  3269. * @param roll defines the roll angle in radians (X axis)
  3270. * @param result defines the target matrix
  3271. */
  3272. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3273. /**
  3274. * Creates a scaling matrix
  3275. * @param x defines the scale factor on X axis
  3276. * @param y defines the scale factor on Y axis
  3277. * @param z defines the scale factor on Z axis
  3278. * @returns the new matrix
  3279. */
  3280. static Scaling(x: number, y: number, z: number): Matrix;
  3281. /**
  3282. * Creates a scaling matrix and stores it in a given matrix
  3283. * @param x defines the scale factor on X axis
  3284. * @param y defines the scale factor on Y axis
  3285. * @param z defines the scale factor on Z axis
  3286. * @param result defines the target matrix
  3287. */
  3288. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3289. /**
  3290. * Creates a translation matrix
  3291. * @param x defines the translation on X axis
  3292. * @param y defines the translation on Y axis
  3293. * @param z defines the translationon Z axis
  3294. * @returns the new matrix
  3295. */
  3296. static Translation(x: number, y: number, z: number): Matrix;
  3297. /**
  3298. * Creates a translation matrix and stores it in a given matrix
  3299. * @param x defines the translation on X axis
  3300. * @param y defines the translation on Y axis
  3301. * @param z defines the translationon Z axis
  3302. * @param result defines the target matrix
  3303. */
  3304. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3305. /**
  3306. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3307. * @param startValue defines the start value
  3308. * @param endValue defines the end value
  3309. * @param gradient defines the gradient factor
  3310. * @returns the new matrix
  3311. */
  3312. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3313. /**
  3314. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3315. * @param startValue defines the start value
  3316. * @param endValue defines the end value
  3317. * @param gradient defines the gradient factor
  3318. * @param result defines the Matrix object where to store data
  3319. */
  3320. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3321. /**
  3322. * Builds a new matrix whose values are computed by:
  3323. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3324. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3325. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3326. * @param startValue defines the first matrix
  3327. * @param endValue defines the second matrix
  3328. * @param gradient defines the gradient between the two matrices
  3329. * @returns the new matrix
  3330. */
  3331. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3332. /**
  3333. * Update a matrix to values which are computed by:
  3334. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3335. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3336. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3337. * @param startValue defines the first matrix
  3338. * @param endValue defines the second matrix
  3339. * @param gradient defines the gradient between the two matrices
  3340. * @param result defines the target matrix
  3341. */
  3342. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3343. /**
  3344. * 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"
  3345. * This function works in left handed mode
  3346. * @param eye defines the final position of the entity
  3347. * @param target defines where the entity should look at
  3348. * @param up defines the up vector for the entity
  3349. * @returns the new matrix
  3350. */
  3351. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3352. /**
  3353. * 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".
  3354. * This function works in left handed mode
  3355. * @param eye defines the final position of the entity
  3356. * @param target defines where the entity should look at
  3357. * @param up defines the up vector for the entity
  3358. * @param result defines the target matrix
  3359. */
  3360. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3361. /**
  3362. * 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"
  3363. * This function works in right handed mode
  3364. * @param eye defines the final position of the entity
  3365. * @param target defines where the entity should look at
  3366. * @param up defines the up vector for the entity
  3367. * @returns the new matrix
  3368. */
  3369. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3370. /**
  3371. * 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".
  3372. * This function works in right handed mode
  3373. * @param eye defines the final position of the entity
  3374. * @param target defines where the entity should look at
  3375. * @param up defines the up vector for the entity
  3376. * @param result defines the target matrix
  3377. */
  3378. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3379. /**
  3380. * Create a left-handed orthographic projection matrix
  3381. * @param width defines the viewport width
  3382. * @param height defines the viewport height
  3383. * @param znear defines the near clip plane
  3384. * @param zfar defines the far clip plane
  3385. * @returns a new matrix as a left-handed orthographic projection matrix
  3386. */
  3387. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3388. /**
  3389. * Store a left-handed orthographic projection to a given matrix
  3390. * @param width defines the viewport width
  3391. * @param height defines the viewport height
  3392. * @param znear defines the near clip plane
  3393. * @param zfar defines the far clip plane
  3394. * @param result defines the target matrix
  3395. */
  3396. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3397. /**
  3398. * Create a left-handed orthographic projection matrix
  3399. * @param left defines the viewport left coordinate
  3400. * @param right defines the viewport right coordinate
  3401. * @param bottom defines the viewport bottom coordinate
  3402. * @param top defines the viewport top coordinate
  3403. * @param znear defines the near clip plane
  3404. * @param zfar defines the far clip plane
  3405. * @returns a new matrix as a left-handed orthographic projection matrix
  3406. */
  3407. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3408. /**
  3409. * Stores a left-handed orthographic projection into a given matrix
  3410. * @param left defines the viewport left coordinate
  3411. * @param right defines the viewport right coordinate
  3412. * @param bottom defines the viewport bottom coordinate
  3413. * @param top defines the viewport top coordinate
  3414. * @param znear defines the near clip plane
  3415. * @param zfar defines the far clip plane
  3416. * @param result defines the target matrix
  3417. */
  3418. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3419. /**
  3420. * Creates a right-handed orthographic projection matrix
  3421. * @param left defines the viewport left coordinate
  3422. * @param right defines the viewport right coordinate
  3423. * @param bottom defines the viewport bottom coordinate
  3424. * @param top defines the viewport top coordinate
  3425. * @param znear defines the near clip plane
  3426. * @param zfar defines the far clip plane
  3427. * @returns a new matrix as a right-handed orthographic projection matrix
  3428. */
  3429. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3430. /**
  3431. * Stores a right-handed orthographic projection into a given matrix
  3432. * @param left defines the viewport left coordinate
  3433. * @param right defines the viewport right coordinate
  3434. * @param bottom defines the viewport bottom coordinate
  3435. * @param top defines the viewport top coordinate
  3436. * @param znear defines the near clip plane
  3437. * @param zfar defines the far clip plane
  3438. * @param result defines the target matrix
  3439. */
  3440. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3441. /**
  3442. * Creates a left-handed perspective projection matrix
  3443. * @param width defines the viewport width
  3444. * @param height defines the viewport height
  3445. * @param znear defines the near clip plane
  3446. * @param zfar defines the far clip plane
  3447. * @returns a new matrix as a left-handed perspective projection matrix
  3448. */
  3449. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3450. /**
  3451. * Creates a left-handed perspective projection matrix
  3452. * @param fov defines the horizontal field of view
  3453. * @param aspect defines the aspect ratio
  3454. * @param znear defines the near clip plane
  3455. * @param zfar defines the far clip plane
  3456. * @returns a new matrix as a left-handed perspective projection matrix
  3457. */
  3458. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3459. /**
  3460. * Stores a left-handed perspective projection into a given matrix
  3461. * @param fov defines the horizontal field of view
  3462. * @param aspect defines the aspect ratio
  3463. * @param znear defines the near clip plane
  3464. * @param zfar defines the far clip plane
  3465. * @param result defines the target matrix
  3466. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3467. */
  3468. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3469. /**
  3470. * Creates a right-handed perspective projection matrix
  3471. * @param fov defines the horizontal field of view
  3472. * @param aspect defines the aspect ratio
  3473. * @param znear defines the near clip plane
  3474. * @param zfar defines the far clip plane
  3475. * @returns a new matrix as a right-handed perspective projection matrix
  3476. */
  3477. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3478. /**
  3479. * Stores a right-handed perspective projection into a given matrix
  3480. * @param fov defines the horizontal field of view
  3481. * @param aspect defines the aspect ratio
  3482. * @param znear defines the near clip plane
  3483. * @param zfar defines the far clip plane
  3484. * @param result defines the target matrix
  3485. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3486. */
  3487. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3488. /**
  3489. * Stores a perspective projection for WebVR info a given matrix
  3490. * @param fov defines the field of view
  3491. * @param znear defines the near clip plane
  3492. * @param zfar defines the far clip plane
  3493. * @param result defines the target matrix
  3494. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3495. */
  3496. static PerspectiveFovWebVRToRef(fov: {
  3497. upDegrees: number;
  3498. downDegrees: number;
  3499. leftDegrees: number;
  3500. rightDegrees: number;
  3501. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3502. /**
  3503. * Computes a complete transformation matrix
  3504. * @param viewport defines the viewport to use
  3505. * @param world defines the world matrix
  3506. * @param view defines the view matrix
  3507. * @param projection defines the projection matrix
  3508. * @param zmin defines the near clip plane
  3509. * @param zmax defines the far clip plane
  3510. * @returns the transformation matrix
  3511. */
  3512. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3513. /**
  3514. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3515. * @param matrix defines the matrix to use
  3516. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3517. */
  3518. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3519. /**
  3520. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3521. * @param matrix defines the matrix to use
  3522. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3523. */
  3524. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3525. /**
  3526. * Compute the transpose of a given matrix
  3527. * @param matrix defines the matrix to transpose
  3528. * @returns the new matrix
  3529. */
  3530. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3531. /**
  3532. * Compute the transpose of a matrix and store it in a target matrix
  3533. * @param matrix defines the matrix to transpose
  3534. * @param result defines the target matrix
  3535. */
  3536. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3537. /**
  3538. * Computes a reflection matrix from a plane
  3539. * @param plane defines the reflection plane
  3540. * @returns a new matrix
  3541. */
  3542. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3543. /**
  3544. * Computes a reflection matrix from a plane
  3545. * @param plane defines the reflection plane
  3546. * @param result defines the target matrix
  3547. */
  3548. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3549. /**
  3550. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3551. * @param xaxis defines the value of the 1st axis
  3552. * @param yaxis defines the value of the 2nd axis
  3553. * @param zaxis defines the value of the 3rd axis
  3554. * @param result defines the target matrix
  3555. */
  3556. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3557. /**
  3558. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3559. * @param quat defines the quaternion to use
  3560. * @param result defines the target matrix
  3561. */
  3562. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3563. }
  3564. /**
  3565. * Represens a plane by the equation ax + by + cz + d = 0
  3566. */
  3567. export class Plane {
  3568. /**
  3569. * Normal of the plane (a,b,c)
  3570. */
  3571. normal: Vector3;
  3572. /**
  3573. * d component of the plane
  3574. */
  3575. d: number;
  3576. /**
  3577. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3578. * @param a a component of the plane
  3579. * @param b b component of the plane
  3580. * @param c c component of the plane
  3581. * @param d d component of the plane
  3582. */
  3583. constructor(a: number, b: number, c: number, d: number);
  3584. /**
  3585. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3586. */
  3587. asArray(): number[];
  3588. /**
  3589. * @returns a new plane copied from the current Plane.
  3590. */
  3591. clone(): Plane;
  3592. /**
  3593. * @returns the string "Plane".
  3594. */
  3595. getClassName(): string;
  3596. /**
  3597. * @returns the Plane hash code.
  3598. */
  3599. getHashCode(): number;
  3600. /**
  3601. * Normalize the current Plane in place.
  3602. * @returns the updated Plane.
  3603. */
  3604. normalize(): Plane;
  3605. /**
  3606. * Applies a transformation the plane and returns the result
  3607. * @param transformation the transformation matrix to be applied to the plane
  3608. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3609. */
  3610. transform(transformation: DeepImmutable<Matrix>): Plane;
  3611. /**
  3612. * Calcualtte the dot product between the point and the plane normal
  3613. * @param point point to calculate the dot product with
  3614. * @returns the dot product (float) of the point coordinates and the plane normal.
  3615. */
  3616. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3617. /**
  3618. * Updates the current Plane from the plane defined by the three given points.
  3619. * @param point1 one of the points used to contruct the plane
  3620. * @param point2 one of the points used to contruct the plane
  3621. * @param point3 one of the points used to contruct the plane
  3622. * @returns the updated Plane.
  3623. */
  3624. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3625. /**
  3626. * Checks if the plane is facing a given direction
  3627. * @param direction the direction to check if the plane is facing
  3628. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3629. * @returns True is the vector "direction" is the same side than the plane normal.
  3630. */
  3631. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3632. /**
  3633. * Calculates the distance to a point
  3634. * @param point point to calculate distance to
  3635. * @returns the signed distance (float) from the given point to the Plane.
  3636. */
  3637. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3638. /**
  3639. * Creates a plane from an array
  3640. * @param array the array to create a plane from
  3641. * @returns a new Plane from the given array.
  3642. */
  3643. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3644. /**
  3645. * Creates a plane from three points
  3646. * @param point1 point used to create the plane
  3647. * @param point2 point used to create the plane
  3648. * @param point3 point used to create the plane
  3649. * @returns a new Plane defined by the three given points.
  3650. */
  3651. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3652. /**
  3653. * Creates a plane from an origin point and a normal
  3654. * @param origin origin of the plane to be constructed
  3655. * @param normal normal of the plane to be constructed
  3656. * @returns a new Plane the normal vector to this plane at the given origin point.
  3657. * Note : the vector "normal" is updated because normalized.
  3658. */
  3659. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3660. /**
  3661. * Calculates the distance from a plane and a point
  3662. * @param origin origin of the plane to be constructed
  3663. * @param normal normal of the plane to be constructed
  3664. * @param point point to calculate distance to
  3665. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3666. */
  3667. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3668. }
  3669. /**
  3670. * Class used to represent a viewport on screen
  3671. */
  3672. export class Viewport {
  3673. /** viewport left coordinate */
  3674. x: number;
  3675. /** viewport top coordinate */
  3676. y: number;
  3677. /**viewport width */
  3678. width: number;
  3679. /** viewport height */
  3680. height: number;
  3681. /**
  3682. * Creates a Viewport object located at (x, y) and sized (width, height)
  3683. * @param x defines viewport left coordinate
  3684. * @param y defines viewport top coordinate
  3685. * @param width defines the viewport width
  3686. * @param height defines the viewport height
  3687. */
  3688. constructor(
  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 new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3699. * @param renderWidth defines the rendering width
  3700. * @param renderHeight defines the rendering height
  3701. * @returns a new Viewport
  3702. */
  3703. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3704. /**
  3705. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3706. * @param renderWidth defines the rendering width
  3707. * @param renderHeight defines the rendering height
  3708. * @param ref defines the target viewport
  3709. * @returns the current viewport
  3710. */
  3711. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3712. /**
  3713. * Returns a new Viewport copied from the current one
  3714. * @returns a new Viewport
  3715. */
  3716. clone(): Viewport;
  3717. }
  3718. /**
  3719. * Reprasents a camera frustum
  3720. */
  3721. export class Frustum {
  3722. /**
  3723. * Gets the planes representing the frustum
  3724. * @param transform matrix to be applied to the returned planes
  3725. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3726. */
  3727. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3728. /**
  3729. * Gets the near frustum plane transformed by the transform matrix
  3730. * @param transform transformation matrix to be applied to the resulting frustum plane
  3731. * @param frustumPlane the resuling frustum plane
  3732. */
  3733. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3734. /**
  3735. * Gets the far frustum plane transformed by the transform matrix
  3736. * @param transform transformation matrix to be applied to the resulting frustum plane
  3737. * @param frustumPlane the resuling frustum plane
  3738. */
  3739. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3740. /**
  3741. * Gets the left frustum plane transformed by the transform matrix
  3742. * @param transform transformation matrix to be applied to the resulting frustum plane
  3743. * @param frustumPlane the resuling frustum plane
  3744. */
  3745. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3746. /**
  3747. * Gets the right frustum plane transformed by the transform matrix
  3748. * @param transform transformation matrix to be applied to the resulting frustum plane
  3749. * @param frustumPlane the resuling frustum plane
  3750. */
  3751. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3752. /**
  3753. * Gets the top frustum plane transformed by the transform matrix
  3754. * @param transform transformation matrix to be applied to the resulting frustum plane
  3755. * @param frustumPlane the resuling frustum plane
  3756. */
  3757. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3758. /**
  3759. * Gets the bottom frustum plane transformed by the transform matrix
  3760. * @param transform transformation matrix to be applied to the resulting frustum plane
  3761. * @param frustumPlane the resuling frustum plane
  3762. */
  3763. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3764. /**
  3765. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3766. * @param transform transformation matrix to be applied to the resulting frustum planes
  3767. * @param frustumPlanes the resuling frustum planes
  3768. */
  3769. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3770. }
  3771. /** Defines supported spaces */
  3772. export enum Space {
  3773. /** Local (object) space */
  3774. LOCAL = 0,
  3775. /** World space */
  3776. WORLD = 1,
  3777. /** Bone space */
  3778. BONE = 2
  3779. }
  3780. /** Defines the 3 main axes */
  3781. export class Axis {
  3782. /** X axis */
  3783. static X: Vector3;
  3784. /** Y axis */
  3785. static Y: Vector3;
  3786. /** Z axis */
  3787. static Z: Vector3;
  3788. }
  3789. /** Class used to represent a Bezier curve */
  3790. export class BezierCurve {
  3791. /**
  3792. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3793. * @param t defines the time
  3794. * @param x1 defines the left coordinate on X axis
  3795. * @param y1 defines the left coordinate on Y axis
  3796. * @param x2 defines the right coordinate on X axis
  3797. * @param y2 defines the right coordinate on Y axis
  3798. * @returns the interpolated value
  3799. */
  3800. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3801. }
  3802. /**
  3803. * Defines potential orientation for back face culling
  3804. */
  3805. export enum Orientation {
  3806. /**
  3807. * Clockwise
  3808. */
  3809. CW = 0,
  3810. /** Counter clockwise */
  3811. CCW = 1
  3812. }
  3813. /**
  3814. * Defines angle representation
  3815. */
  3816. export class Angle {
  3817. private _radians;
  3818. /**
  3819. * Creates an Angle object of "radians" radians (float).
  3820. * @param radians the angle in radians
  3821. */
  3822. constructor(radians: number);
  3823. /**
  3824. * Get value in degrees
  3825. * @returns the Angle value in degrees (float)
  3826. */
  3827. degrees(): number;
  3828. /**
  3829. * Get value in radians
  3830. * @returns the Angle value in radians (float)
  3831. */
  3832. radians(): number;
  3833. /**
  3834. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3835. * @param a defines first vector
  3836. * @param b defines second vector
  3837. * @returns a new Angle
  3838. */
  3839. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3840. /**
  3841. * Gets a new Angle object from the given float in radians
  3842. * @param radians defines the angle value in radians
  3843. * @returns a new Angle
  3844. */
  3845. static FromRadians(radians: number): Angle;
  3846. /**
  3847. * Gets a new Angle object from the given float in degrees
  3848. * @param degrees defines the angle value in degrees
  3849. * @returns a new Angle
  3850. */
  3851. static FromDegrees(degrees: number): Angle;
  3852. }
  3853. /**
  3854. * This represents an arc in a 2d space.
  3855. */
  3856. export class Arc2 {
  3857. /** Defines the start point of the arc */
  3858. startPoint: Vector2;
  3859. /** Defines the mid point of the arc */
  3860. midPoint: Vector2;
  3861. /** Defines the end point of the arc */
  3862. endPoint: Vector2;
  3863. /**
  3864. * Defines the center point of the arc.
  3865. */
  3866. centerPoint: Vector2;
  3867. /**
  3868. * Defines the radius of the arc.
  3869. */
  3870. radius: number;
  3871. /**
  3872. * Defines the angle of the arc (from mid point to end point).
  3873. */
  3874. angle: Angle;
  3875. /**
  3876. * Defines the start angle of the arc (from start point to middle point).
  3877. */
  3878. startAngle: Angle;
  3879. /**
  3880. * Defines the orientation of the arc (clock wise/counter clock wise).
  3881. */
  3882. orientation: Orientation;
  3883. /**
  3884. * Creates an Arc object from the three given points : start, middle and end.
  3885. * @param startPoint Defines the start point of the arc
  3886. * @param midPoint Defines the midlle point of the arc
  3887. * @param endPoint Defines the end point of the arc
  3888. */
  3889. constructor(
  3890. /** Defines the start point of the arc */
  3891. startPoint: Vector2,
  3892. /** Defines the mid point of the arc */
  3893. midPoint: Vector2,
  3894. /** Defines the end point of the arc */
  3895. endPoint: Vector2);
  3896. }
  3897. /**
  3898. * Represents a 2D path made up of multiple 2D points
  3899. */
  3900. export class Path2 {
  3901. private _points;
  3902. private _length;
  3903. /**
  3904. * If the path start and end point are the same
  3905. */
  3906. closed: boolean;
  3907. /**
  3908. * Creates a Path2 object from the starting 2D coordinates x and y.
  3909. * @param x the starting points x value
  3910. * @param y the starting points y value
  3911. */
  3912. constructor(x: number, y: number);
  3913. /**
  3914. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3915. * @param x the added points x value
  3916. * @param y the added points y value
  3917. * @returns the updated Path2.
  3918. */
  3919. addLineTo(x: number, y: number): Path2;
  3920. /**
  3921. * 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.
  3922. * @param midX middle point x value
  3923. * @param midY middle point y value
  3924. * @param endX end point x value
  3925. * @param endY end point y value
  3926. * @param numberOfSegments (default: 36)
  3927. * @returns the updated Path2.
  3928. */
  3929. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3930. /**
  3931. * Closes the Path2.
  3932. * @returns the Path2.
  3933. */
  3934. close(): Path2;
  3935. /**
  3936. * Gets the sum of the distance between each sequential point in the path
  3937. * @returns the Path2 total length (float).
  3938. */
  3939. length(): number;
  3940. /**
  3941. * Gets the points which construct the path
  3942. * @returns the Path2 internal array of points.
  3943. */
  3944. getPoints(): Vector2[];
  3945. /**
  3946. * Retreives the point at the distance aways from the starting point
  3947. * @param normalizedLengthPosition the length along the path to retreive the point from
  3948. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3949. */
  3950. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3951. /**
  3952. * Creates a new path starting from an x and y position
  3953. * @param x starting x value
  3954. * @param y starting y value
  3955. * @returns a new Path2 starting at the coordinates (x, y).
  3956. */
  3957. static StartingAt(x: number, y: number): Path2;
  3958. }
  3959. /**
  3960. * Represents a 3D path made up of multiple 3D points
  3961. */
  3962. export class Path3D {
  3963. /**
  3964. * an array of Vector3, the curve axis of the Path3D
  3965. */
  3966. path: Vector3[];
  3967. private _curve;
  3968. private _distances;
  3969. private _tangents;
  3970. private _normals;
  3971. private _binormals;
  3972. private _raw;
  3973. /**
  3974. * new Path3D(path, normal, raw)
  3975. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3976. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3977. * @param path an array of Vector3, the curve axis of the Path3D
  3978. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3979. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3980. */
  3981. constructor(
  3982. /**
  3983. * an array of Vector3, the curve axis of the Path3D
  3984. */
  3985. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  3986. /**
  3987. * Returns the Path3D array of successive Vector3 designing its curve.
  3988. * @returns the Path3D array of successive Vector3 designing its curve.
  3989. */
  3990. getCurve(): Vector3[];
  3991. /**
  3992. * Returns an array populated with tangent vectors on each Path3D curve point.
  3993. * @returns an array populated with tangent vectors on each Path3D curve point.
  3994. */
  3995. getTangents(): Vector3[];
  3996. /**
  3997. * Returns an array populated with normal vectors on each Path3D curve point.
  3998. * @returns an array populated with normal vectors on each Path3D curve point.
  3999. */
  4000. getNormals(): Vector3[];
  4001. /**
  4002. * Returns an array populated with binormal vectors on each Path3D curve point.
  4003. * @returns an array populated with binormal vectors on each Path3D curve point.
  4004. */
  4005. getBinormals(): Vector3[];
  4006. /**
  4007. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4008. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4009. */
  4010. getDistances(): number[];
  4011. /**
  4012. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4013. * @param path path which all values are copied into the curves points
  4014. * @param firstNormal which should be projected onto the curve
  4015. * @returns the same object updated.
  4016. */
  4017. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4018. private _compute;
  4019. private _getFirstNonNullVector;
  4020. private _getLastNonNullVector;
  4021. private _normalVector;
  4022. }
  4023. /**
  4024. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4025. * A Curve3 is designed from a series of successive Vector3.
  4026. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4027. */
  4028. export class Curve3 {
  4029. private _points;
  4030. private _length;
  4031. /**
  4032. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4033. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4034. * @param v1 (Vector3) the control point
  4035. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4036. * @param nbPoints (integer) the wanted number of points in the curve
  4037. * @returns the created Curve3
  4038. */
  4039. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4040. /**
  4041. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4042. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4043. * @param v1 (Vector3) the first control point
  4044. * @param v2 (Vector3) the second control point
  4045. * @param v3 (Vector3) the end point of the Cubic Bezier
  4046. * @param nbPoints (integer) the wanted number of points in the curve
  4047. * @returns the created Curve3
  4048. */
  4049. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4050. /**
  4051. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4052. * @param p1 (Vector3) the origin point of the Hermite Spline
  4053. * @param t1 (Vector3) the tangent vector at the origin point
  4054. * @param p2 (Vector3) the end point of the Hermite Spline
  4055. * @param t2 (Vector3) the tangent vector at the end point
  4056. * @param nbPoints (integer) the wanted number of points in the curve
  4057. * @returns the created Curve3
  4058. */
  4059. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4060. /**
  4061. * Returns a Curve3 object along a CatmullRom Spline curve :
  4062. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4063. * @param nbPoints (integer) the wanted number of points between each curve control points
  4064. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4065. * @returns the created Curve3
  4066. */
  4067. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4068. /**
  4069. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4070. * A Curve3 is designed from a series of successive Vector3.
  4071. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4072. * @param points points which make up the curve
  4073. */
  4074. constructor(points: Vector3[]);
  4075. /**
  4076. * @returns the Curve3 stored array of successive Vector3
  4077. */
  4078. getPoints(): Vector3[];
  4079. /**
  4080. * @returns the computed length (float) of the curve.
  4081. */
  4082. length(): number;
  4083. /**
  4084. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4085. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4086. * curveA and curveB keep unchanged.
  4087. * @param curve the curve to continue from this curve
  4088. * @returns the newly constructed curve
  4089. */
  4090. continue(curve: DeepImmutable<Curve3>): Curve3;
  4091. private _computeLength;
  4092. }
  4093. /**
  4094. * Contains position and normal vectors for a vertex
  4095. */
  4096. export class PositionNormalVertex {
  4097. /** the position of the vertex (defaut: 0,0,0) */
  4098. position: Vector3;
  4099. /** the normal of the vertex (defaut: 0,1,0) */
  4100. normal: Vector3;
  4101. /**
  4102. * Creates a PositionNormalVertex
  4103. * @param position the position of the vertex (defaut: 0,0,0)
  4104. * @param normal the normal of the vertex (defaut: 0,1,0)
  4105. */
  4106. constructor(
  4107. /** the position of the vertex (defaut: 0,0,0) */
  4108. position?: Vector3,
  4109. /** the normal of the vertex (defaut: 0,1,0) */
  4110. normal?: Vector3);
  4111. /**
  4112. * Clones the PositionNormalVertex
  4113. * @returns the cloned PositionNormalVertex
  4114. */
  4115. clone(): PositionNormalVertex;
  4116. }
  4117. /**
  4118. * Contains position, normal and uv vectors for a vertex
  4119. */
  4120. export class PositionNormalTextureVertex {
  4121. /** the position of the vertex (defaut: 0,0,0) */
  4122. position: Vector3;
  4123. /** the normal of the vertex (defaut: 0,1,0) */
  4124. normal: Vector3;
  4125. /** the uv of the vertex (default: 0,0) */
  4126. uv: Vector2;
  4127. /**
  4128. * Creates a PositionNormalTextureVertex
  4129. * @param position the position of the vertex (defaut: 0,0,0)
  4130. * @param normal the normal of the vertex (defaut: 0,1,0)
  4131. * @param uv the uv of the vertex (default: 0,0)
  4132. */
  4133. constructor(
  4134. /** the position of the vertex (defaut: 0,0,0) */
  4135. position?: Vector3,
  4136. /** the normal of the vertex (defaut: 0,1,0) */
  4137. normal?: Vector3,
  4138. /** the uv of the vertex (default: 0,0) */
  4139. uv?: Vector2);
  4140. /**
  4141. * Clones the PositionNormalTextureVertex
  4142. * @returns the cloned PositionNormalTextureVertex
  4143. */
  4144. clone(): PositionNormalTextureVertex;
  4145. }
  4146. /**
  4147. * @hidden
  4148. */
  4149. export class Tmp {
  4150. static Color3: Color3[];
  4151. static Color4: Color4[];
  4152. static Vector2: Vector2[];
  4153. static Vector3: Vector3[];
  4154. static Vector4: Vector4[];
  4155. static Quaternion: Quaternion[];
  4156. static Matrix: Matrix[];
  4157. }
  4158. }
  4159. declare module BABYLON {
  4160. /**
  4161. * Class used to enable access to offline support
  4162. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4163. */
  4164. export interface IOfflineProvider {
  4165. /**
  4166. * Gets a boolean indicating if scene must be saved in the database
  4167. */
  4168. enableSceneOffline: boolean;
  4169. /**
  4170. * Gets a boolean indicating if textures must be saved in the database
  4171. */
  4172. enableTexturesOffline: boolean;
  4173. /**
  4174. * Open the offline support and make it available
  4175. * @param successCallback defines the callback to call on success
  4176. * @param errorCallback defines the callback to call on error
  4177. */
  4178. open(successCallback: () => void, errorCallback: () => void): void;
  4179. /**
  4180. * Loads an image from the offline support
  4181. * @param url defines the url to load from
  4182. * @param image defines the target DOM image
  4183. */
  4184. loadImage(url: string, image: HTMLImageElement): void;
  4185. /**
  4186. * Loads a file from offline support
  4187. * @param url defines the URL to load from
  4188. * @param sceneLoaded defines a callback to call on success
  4189. * @param progressCallBack defines a callback to call when progress changed
  4190. * @param errorCallback defines a callback to call on error
  4191. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4192. */
  4193. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4194. }
  4195. }
  4196. declare module BABYLON {
  4197. /**
  4198. * A class serves as a medium between the observable and its observers
  4199. */
  4200. export class EventState {
  4201. /**
  4202. * Create a new EventState
  4203. * @param mask defines the mask associated with this state
  4204. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4205. * @param target defines the original target of the state
  4206. * @param currentTarget defines the current target of the state
  4207. */
  4208. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4209. /**
  4210. * Initialize the current event state
  4211. * @param mask defines the mask associated with this state
  4212. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4213. * @param target defines the original target of the state
  4214. * @param currentTarget defines the current target of the state
  4215. * @returns the current event state
  4216. */
  4217. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4218. /**
  4219. * An Observer can set this property to true to prevent subsequent observers of being notified
  4220. */
  4221. skipNextObservers: boolean;
  4222. /**
  4223. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4224. */
  4225. mask: number;
  4226. /**
  4227. * The object that originally notified the event
  4228. */
  4229. target?: any;
  4230. /**
  4231. * The current object in the bubbling phase
  4232. */
  4233. currentTarget?: any;
  4234. /**
  4235. * This will be populated with the return value of the last function that was executed.
  4236. * If it is the first function in the callback chain it will be the event data.
  4237. */
  4238. lastReturnValue?: any;
  4239. }
  4240. /**
  4241. * Represent an Observer registered to a given Observable object.
  4242. */
  4243. export class Observer<T> {
  4244. /**
  4245. * Defines the callback to call when the observer is notified
  4246. */
  4247. callback: (eventData: T, eventState: EventState) => void;
  4248. /**
  4249. * Defines the mask of the observer (used to filter notifications)
  4250. */
  4251. mask: number;
  4252. /**
  4253. * Defines the current scope used to restore the JS context
  4254. */
  4255. scope: any;
  4256. /** @hidden */ willBeUnregistered: boolean;
  4257. /**
  4258. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4259. */
  4260. unregisterOnNextCall: boolean;
  4261. /**
  4262. * Creates a new observer
  4263. * @param callback defines the callback to call when the observer is notified
  4264. * @param mask defines the mask of the observer (used to filter notifications)
  4265. * @param scope defines the current scope used to restore the JS context
  4266. */
  4267. constructor(
  4268. /**
  4269. * Defines the callback to call when the observer is notified
  4270. */
  4271. callback: (eventData: T, eventState: EventState) => void,
  4272. /**
  4273. * Defines the mask of the observer (used to filter notifications)
  4274. */
  4275. mask: number,
  4276. /**
  4277. * Defines the current scope used to restore the JS context
  4278. */
  4279. scope?: any);
  4280. }
  4281. /**
  4282. * Represent a list of observers registered to multiple Observables object.
  4283. */
  4284. export class MultiObserver<T> {
  4285. private _observers;
  4286. private _observables;
  4287. /**
  4288. * Release associated resources
  4289. */
  4290. dispose(): void;
  4291. /**
  4292. * Raise a callback when one of the observable will notify
  4293. * @param observables defines a list of observables to watch
  4294. * @param callback defines the callback to call on notification
  4295. * @param mask defines the mask used to filter notifications
  4296. * @param scope defines the current scope used to restore the JS context
  4297. * @returns the new MultiObserver
  4298. */
  4299. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4300. }
  4301. /**
  4302. * The Observable class is a simple implementation of the Observable pattern.
  4303. *
  4304. * 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.
  4305. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4306. * 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).
  4307. * 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.
  4308. */
  4309. export class Observable<T> {
  4310. private _observers;
  4311. private _eventState;
  4312. private _onObserverAdded;
  4313. /**
  4314. * Creates a new observable
  4315. * @param onObserverAdded defines a callback to call when a new observer is added
  4316. */
  4317. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4318. /**
  4319. * Create a new Observer with the specified callback
  4320. * @param callback the callback that will be executed for that Observer
  4321. * @param mask the mask used to filter observers
  4322. * @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.
  4323. * @param scope optional scope for the callback to be called from
  4324. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4325. * @returns the new observer created for the callback
  4326. */
  4327. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4328. /**
  4329. * Create a new Observer with the specified callback and unregisters after the next notification
  4330. * @param callback the callback that will be executed for that Observer
  4331. * @returns the new observer created for the callback
  4332. */
  4333. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4334. /**
  4335. * Remove an Observer from the Observable object
  4336. * @param observer the instance of the Observer to remove
  4337. * @returns false if it doesn't belong to this Observable
  4338. */
  4339. remove(observer: Nullable<Observer<T>>): boolean;
  4340. /**
  4341. * Remove a callback from the Observable object
  4342. * @param callback the callback to remove
  4343. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4344. * @returns false if it doesn't belong to this Observable
  4345. */
  4346. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4347. private _deferUnregister;
  4348. private _remove;
  4349. /**
  4350. * Notify all Observers by calling their respective callback with the given data
  4351. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4352. * @param eventData defines the data to send to all observers
  4353. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4354. * @param target defines the original target of the state
  4355. * @param currentTarget defines the current target of the state
  4356. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4357. */
  4358. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4359. /**
  4360. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4361. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4362. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4363. * and it is crucial that all callbacks will be executed.
  4364. * The order of the callbacks is kept, callbacks are not executed parallel.
  4365. *
  4366. * @param eventData The data to be sent to each callback
  4367. * @param mask is used to filter observers defaults to -1
  4368. * @param target defines the callback target (see EventState)
  4369. * @param currentTarget defines he current object in the bubbling phase
  4370. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4371. */
  4372. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4373. /**
  4374. * Notify a specific observer
  4375. * @param observer defines the observer to notify
  4376. * @param eventData defines the data to be sent to each callback
  4377. * @param mask is used to filter observers defaults to -1
  4378. */
  4379. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4380. /**
  4381. * Gets a boolean indicating if the observable has at least one observer
  4382. * @returns true is the Observable has at least one Observer registered
  4383. */
  4384. hasObservers(): boolean;
  4385. /**
  4386. * Clear the list of observers
  4387. */
  4388. clear(): void;
  4389. /**
  4390. * Clone the current observable
  4391. * @returns a new observable
  4392. */
  4393. clone(): Observable<T>;
  4394. /**
  4395. * Does this observable handles observer registered with a given mask
  4396. * @param mask defines the mask to be tested
  4397. * @return whether or not one observer registered with the given mask is handeled
  4398. **/
  4399. hasSpecificMask(mask?: number): boolean;
  4400. }
  4401. }
  4402. declare module BABYLON {
  4403. /**
  4404. * Class used to help managing file picking and drag'n'drop
  4405. * File Storage
  4406. */
  4407. export class FilesInputStore {
  4408. /**
  4409. * List of files ready to be loaded
  4410. */
  4411. static FilesToLoad: {
  4412. [key: string]: File;
  4413. };
  4414. }
  4415. }
  4416. declare module BABYLON {
  4417. /** Defines the cross module used constants to avoid circular dependncies */
  4418. export class Constants {
  4419. /** Defines that alpha blending is disabled */
  4420. static readonly ALPHA_DISABLE: number;
  4421. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4422. static readonly ALPHA_ADD: number;
  4423. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4424. static readonly ALPHA_COMBINE: number;
  4425. /** Defines that alpha blending to DEST - SRC * DEST */
  4426. static readonly ALPHA_SUBTRACT: number;
  4427. /** Defines that alpha blending to SRC * DEST */
  4428. static readonly ALPHA_MULTIPLY: number;
  4429. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4430. static readonly ALPHA_MAXIMIZED: number;
  4431. /** Defines that alpha blending to SRC + DEST */
  4432. static readonly ALPHA_ONEONE: number;
  4433. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4434. static readonly ALPHA_PREMULTIPLIED: number;
  4435. /**
  4436. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4437. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4438. */
  4439. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4440. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4441. static readonly ALPHA_INTERPOLATE: number;
  4442. /**
  4443. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4444. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4445. */
  4446. static readonly ALPHA_SCREENMODE: number;
  4447. /** Defines that the ressource is not delayed*/
  4448. static readonly DELAYLOADSTATE_NONE: number;
  4449. /** Defines that the ressource was successfully delay loaded */
  4450. static readonly DELAYLOADSTATE_LOADED: number;
  4451. /** Defines that the ressource is currently delay loading */
  4452. static readonly DELAYLOADSTATE_LOADING: number;
  4453. /** Defines that the ressource is delayed and has not started loading */
  4454. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4455. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4456. static readonly NEVER: number;
  4457. /** 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 */
  4458. static readonly ALWAYS: number;
  4459. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4460. static readonly LESS: number;
  4461. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4462. static readonly EQUAL: number;
  4463. /** 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 */
  4464. static readonly LEQUAL: number;
  4465. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4466. static readonly GREATER: number;
  4467. /** 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 */
  4468. static readonly GEQUAL: number;
  4469. /** 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 */
  4470. static readonly NOTEQUAL: number;
  4471. /** Passed to stencilOperation to specify that stencil value must be kept */
  4472. static readonly KEEP: number;
  4473. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4474. static readonly REPLACE: number;
  4475. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4476. static readonly INCR: number;
  4477. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4478. static readonly DECR: number;
  4479. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4480. static readonly INVERT: number;
  4481. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4482. static readonly INCR_WRAP: number;
  4483. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4484. static readonly DECR_WRAP: number;
  4485. /** Texture is not repeating outside of 0..1 UVs */
  4486. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4487. /** Texture is repeating outside of 0..1 UVs */
  4488. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4489. /** Texture is repeating and mirrored */
  4490. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4491. /** ALPHA */
  4492. static readonly TEXTUREFORMAT_ALPHA: number;
  4493. /** LUMINANCE */
  4494. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4495. /** LUMINANCE_ALPHA */
  4496. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4497. /** RGB */
  4498. static readonly TEXTUREFORMAT_RGB: number;
  4499. /** RGBA */
  4500. static readonly TEXTUREFORMAT_RGBA: number;
  4501. /** RED */
  4502. static readonly TEXTUREFORMAT_RED: number;
  4503. /** RED (2nd reference) */
  4504. static readonly TEXTUREFORMAT_R: number;
  4505. /** RG */
  4506. static readonly TEXTUREFORMAT_RG: number;
  4507. /** RED_INTEGER */
  4508. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4509. /** RED_INTEGER (2nd reference) */
  4510. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4511. /** RG_INTEGER */
  4512. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4513. /** RGB_INTEGER */
  4514. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4515. /** RGBA_INTEGER */
  4516. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4517. /** UNSIGNED_BYTE */
  4518. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4519. /** UNSIGNED_BYTE (2nd reference) */
  4520. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4521. /** FLOAT */
  4522. static readonly TEXTURETYPE_FLOAT: number;
  4523. /** HALF_FLOAT */
  4524. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4525. /** BYTE */
  4526. static readonly TEXTURETYPE_BYTE: number;
  4527. /** SHORT */
  4528. static readonly TEXTURETYPE_SHORT: number;
  4529. /** UNSIGNED_SHORT */
  4530. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4531. /** INT */
  4532. static readonly TEXTURETYPE_INT: number;
  4533. /** UNSIGNED_INT */
  4534. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4535. /** UNSIGNED_SHORT_4_4_4_4 */
  4536. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4537. /** UNSIGNED_SHORT_5_5_5_1 */
  4538. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4539. /** UNSIGNED_SHORT_5_6_5 */
  4540. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4541. /** UNSIGNED_INT_2_10_10_10_REV */
  4542. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4543. /** UNSIGNED_INT_24_8 */
  4544. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4545. /** UNSIGNED_INT_10F_11F_11F_REV */
  4546. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4547. /** UNSIGNED_INT_5_9_9_9_REV */
  4548. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4549. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4550. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4551. /** nearest is mag = nearest and min = nearest and mip = linear */
  4552. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4553. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4554. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4555. /** Trilinear is mag = linear and min = linear and mip = linear */
  4556. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4557. /** nearest is mag = nearest and min = nearest and mip = linear */
  4558. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4559. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4560. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4561. /** Trilinear is mag = linear and min = linear and mip = linear */
  4562. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4563. /** mag = nearest and min = nearest and mip = nearest */
  4564. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4565. /** mag = nearest and min = linear and mip = nearest */
  4566. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4567. /** mag = nearest and min = linear and mip = linear */
  4568. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4569. /** mag = nearest and min = linear and mip = none */
  4570. static readonly TEXTURE_NEAREST_LINEAR: number;
  4571. /** mag = nearest and min = nearest and mip = none */
  4572. static readonly TEXTURE_NEAREST_NEAREST: number;
  4573. /** mag = linear and min = nearest and mip = nearest */
  4574. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4575. /** mag = linear and min = nearest and mip = linear */
  4576. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4577. /** mag = linear and min = linear and mip = none */
  4578. static readonly TEXTURE_LINEAR_LINEAR: number;
  4579. /** mag = linear and min = nearest and mip = none */
  4580. static readonly TEXTURE_LINEAR_NEAREST: number;
  4581. /** Explicit coordinates mode */
  4582. static readonly TEXTURE_EXPLICIT_MODE: number;
  4583. /** Spherical coordinates mode */
  4584. static readonly TEXTURE_SPHERICAL_MODE: number;
  4585. /** Planar coordinates mode */
  4586. static readonly TEXTURE_PLANAR_MODE: number;
  4587. /** Cubic coordinates mode */
  4588. static readonly TEXTURE_CUBIC_MODE: number;
  4589. /** Projection coordinates mode */
  4590. static readonly TEXTURE_PROJECTION_MODE: number;
  4591. /** Skybox coordinates mode */
  4592. static readonly TEXTURE_SKYBOX_MODE: number;
  4593. /** Inverse Cubic coordinates mode */
  4594. static readonly TEXTURE_INVCUBIC_MODE: number;
  4595. /** Equirectangular coordinates mode */
  4596. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4597. /** Equirectangular Fixed coordinates mode */
  4598. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4599. /** Equirectangular Fixed Mirrored coordinates mode */
  4600. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4601. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4602. static readonly SCALEMODE_FLOOR: number;
  4603. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4604. static readonly SCALEMODE_NEAREST: number;
  4605. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4606. static readonly SCALEMODE_CEILING: number;
  4607. /**
  4608. * The dirty texture flag value
  4609. */
  4610. static readonly MATERIAL_TextureDirtyFlag: number;
  4611. /**
  4612. * The dirty light flag value
  4613. */
  4614. static readonly MATERIAL_LightDirtyFlag: number;
  4615. /**
  4616. * The dirty fresnel flag value
  4617. */
  4618. static readonly MATERIAL_FresnelDirtyFlag: number;
  4619. /**
  4620. * The dirty attribute flag value
  4621. */
  4622. static readonly MATERIAL_AttributesDirtyFlag: number;
  4623. /**
  4624. * The dirty misc flag value
  4625. */
  4626. static readonly MATERIAL_MiscDirtyFlag: number;
  4627. /**
  4628. * The all dirty flag value
  4629. */
  4630. static readonly MATERIAL_AllDirtyFlag: number;
  4631. /**
  4632. * Returns the triangle fill mode
  4633. */
  4634. static readonly MATERIAL_TriangleFillMode: number;
  4635. /**
  4636. * Returns the wireframe mode
  4637. */
  4638. static readonly MATERIAL_WireFrameFillMode: number;
  4639. /**
  4640. * Returns the point fill mode
  4641. */
  4642. static readonly MATERIAL_PointFillMode: number;
  4643. /**
  4644. * Returns the point list draw mode
  4645. */
  4646. static readonly MATERIAL_PointListDrawMode: number;
  4647. /**
  4648. * Returns the line list draw mode
  4649. */
  4650. static readonly MATERIAL_LineListDrawMode: number;
  4651. /**
  4652. * Returns the line loop draw mode
  4653. */
  4654. static readonly MATERIAL_LineLoopDrawMode: number;
  4655. /**
  4656. * Returns the line strip draw mode
  4657. */
  4658. static readonly MATERIAL_LineStripDrawMode: number;
  4659. /**
  4660. * Returns the triangle strip draw mode
  4661. */
  4662. static readonly MATERIAL_TriangleStripDrawMode: number;
  4663. /**
  4664. * Returns the triangle fan draw mode
  4665. */
  4666. static readonly MATERIAL_TriangleFanDrawMode: number;
  4667. /**
  4668. * Stores the clock-wise side orientation
  4669. */
  4670. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4671. /**
  4672. * Stores the counter clock-wise side orientation
  4673. */
  4674. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4675. /**
  4676. * Nothing
  4677. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4678. */
  4679. static readonly ACTION_NothingTrigger: number;
  4680. /**
  4681. * On pick
  4682. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4683. */
  4684. static readonly ACTION_OnPickTrigger: number;
  4685. /**
  4686. * On left pick
  4687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4688. */
  4689. static readonly ACTION_OnLeftPickTrigger: number;
  4690. /**
  4691. * On right pick
  4692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4693. */
  4694. static readonly ACTION_OnRightPickTrigger: number;
  4695. /**
  4696. * On center pick
  4697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4698. */
  4699. static readonly ACTION_OnCenterPickTrigger: number;
  4700. /**
  4701. * On pick down
  4702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4703. */
  4704. static readonly ACTION_OnPickDownTrigger: number;
  4705. /**
  4706. * On double pick
  4707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4708. */
  4709. static readonly ACTION_OnDoublePickTrigger: number;
  4710. /**
  4711. * On pick up
  4712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4713. */
  4714. static readonly ACTION_OnPickUpTrigger: number;
  4715. /**
  4716. * On pick out.
  4717. * This trigger will only be raised if you also declared a OnPickDown
  4718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4719. */
  4720. static readonly ACTION_OnPickOutTrigger: number;
  4721. /**
  4722. * On long press
  4723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4724. */
  4725. static readonly ACTION_OnLongPressTrigger: number;
  4726. /**
  4727. * On pointer over
  4728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4729. */
  4730. static readonly ACTION_OnPointerOverTrigger: number;
  4731. /**
  4732. * On pointer out
  4733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4734. */
  4735. static readonly ACTION_OnPointerOutTrigger: number;
  4736. /**
  4737. * On every frame
  4738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4739. */
  4740. static readonly ACTION_OnEveryFrameTrigger: number;
  4741. /**
  4742. * On intersection enter
  4743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4744. */
  4745. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4746. /**
  4747. * On intersection exit
  4748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4749. */
  4750. static readonly ACTION_OnIntersectionExitTrigger: number;
  4751. /**
  4752. * On key down
  4753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4754. */
  4755. static readonly ACTION_OnKeyDownTrigger: number;
  4756. /**
  4757. * On key up
  4758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4759. */
  4760. static readonly ACTION_OnKeyUpTrigger: number;
  4761. /**
  4762. * Billboard mode will only apply to Y axis
  4763. */
  4764. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4765. /**
  4766. * Billboard mode will apply to all axes
  4767. */
  4768. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4769. /**
  4770. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4771. */
  4772. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4773. /**
  4774. * Gets or sets base Assets URL
  4775. */
  4776. static readonly PARTICLES_BaseAssetsUrl: string;
  4777. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4778. * Test order :
  4779. * Is the bounding sphere outside the frustum ?
  4780. * If not, are the bounding box vertices outside the frustum ?
  4781. * It not, then the cullable object is in the frustum.
  4782. */
  4783. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4784. /** Culling strategy : Bounding Sphere Only.
  4785. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4786. * It's also less accurate than the standard because some not visible objects can still be selected.
  4787. * Test : is the bounding sphere outside the frustum ?
  4788. * If not, then the cullable object is in the frustum.
  4789. */
  4790. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4791. /** Culling strategy : Optimistic Inclusion.
  4792. * This in an inclusion test first, then the standard exclusion test.
  4793. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4794. * 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.
  4795. * Anyway, it's as accurate as the standard strategy.
  4796. * Test :
  4797. * Is the cullable object bounding sphere center in the frustum ?
  4798. * If not, apply the default culling strategy.
  4799. */
  4800. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4801. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4802. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4803. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4804. * 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.
  4805. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4806. * Test :
  4807. * Is the cullable object bounding sphere center in the frustum ?
  4808. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4809. */
  4810. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4811. /**
  4812. * No logging while loading
  4813. */
  4814. static readonly SCENELOADER_NO_LOGGING: number;
  4815. /**
  4816. * Minimal logging while loading
  4817. */
  4818. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4819. /**
  4820. * Summary logging while loading
  4821. */
  4822. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4823. /**
  4824. * Detailled logging while loading
  4825. */
  4826. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4827. }
  4828. }
  4829. declare module BABYLON {
  4830. /**
  4831. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4832. * Babylon.js
  4833. */
  4834. export class DomManagement {
  4835. /**
  4836. * Checks if the window object exists
  4837. * @returns true if the window object exists
  4838. */
  4839. static IsWindowObjectExist(): boolean;
  4840. /**
  4841. * Extracts text content from a DOM element hierarchy
  4842. * @param element defines the root element
  4843. * @returns a string
  4844. */
  4845. static GetDOMTextContent(element: HTMLElement): string;
  4846. }
  4847. }
  4848. declare module BABYLON {
  4849. /**
  4850. * Logger used througouht the application to allow configuration of
  4851. * the log level required for the messages.
  4852. */
  4853. export class Logger {
  4854. /**
  4855. * No log
  4856. */
  4857. static readonly NoneLogLevel: number;
  4858. /**
  4859. * Only message logs
  4860. */
  4861. static readonly MessageLogLevel: number;
  4862. /**
  4863. * Only warning logs
  4864. */
  4865. static readonly WarningLogLevel: number;
  4866. /**
  4867. * Only error logs
  4868. */
  4869. static readonly ErrorLogLevel: number;
  4870. /**
  4871. * All logs
  4872. */
  4873. static readonly AllLogLevel: number;
  4874. private static _LogCache;
  4875. /**
  4876. * Gets a value indicating the number of loading errors
  4877. * @ignorenaming
  4878. */
  4879. static errorsCount: number;
  4880. /**
  4881. * Callback called when a new log is added
  4882. */
  4883. static OnNewCacheEntry: (entry: string) => void;
  4884. private static _AddLogEntry;
  4885. private static _FormatMessage;
  4886. private static _LogDisabled;
  4887. private static _LogEnabled;
  4888. private static _WarnDisabled;
  4889. private static _WarnEnabled;
  4890. private static _ErrorDisabled;
  4891. private static _ErrorEnabled;
  4892. /**
  4893. * Log a message to the console
  4894. */
  4895. static Log: (message: string) => void;
  4896. /**
  4897. * Write a warning message to the console
  4898. */
  4899. static Warn: (message: string) => void;
  4900. /**
  4901. * Write an error message to the console
  4902. */
  4903. static Error: (message: string) => void;
  4904. /**
  4905. * Gets current log cache (list of logs)
  4906. */
  4907. static readonly LogCache: string;
  4908. /**
  4909. * Clears the log cache
  4910. */
  4911. static ClearLogCache(): void;
  4912. /**
  4913. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4914. */
  4915. static LogLevels: number;
  4916. }
  4917. }
  4918. declare module BABYLON {
  4919. /** @hidden */
  4920. export class _TypeStore {
  4921. /** @hidden */
  4922. static RegisteredTypes: {
  4923. [key: string]: Object;
  4924. };
  4925. /** @hidden */
  4926. static GetClass(fqdn: string): any;
  4927. }
  4928. }
  4929. declare module BABYLON {
  4930. /**
  4931. * Class containing a set of static utilities functions for deep copy.
  4932. */
  4933. export class DeepCopier {
  4934. /**
  4935. * Tries to copy an object by duplicating every property
  4936. * @param source defines the source object
  4937. * @param destination defines the target object
  4938. * @param doNotCopyList defines a list of properties to avoid
  4939. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4940. */
  4941. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4942. }
  4943. }
  4944. declare module BABYLON {
  4945. /**
  4946. * Class containing a set of static utilities functions for precision date
  4947. */
  4948. export class PrecisionDate {
  4949. /**
  4950. * Gets either window.performance.now() if supported or Date.now() else
  4951. */
  4952. static readonly Now: number;
  4953. }
  4954. }
  4955. declare module BABYLON {
  4956. /** @hidden */
  4957. export class _DevTools {
  4958. static WarnImport(name: string): string;
  4959. }
  4960. }
  4961. declare module BABYLON {
  4962. /**
  4963. * Class used to evalaute queries containing `and` and `or` operators
  4964. */
  4965. export class AndOrNotEvaluator {
  4966. /**
  4967. * Evaluate a query
  4968. * @param query defines the query to evaluate
  4969. * @param evaluateCallback defines the callback used to filter result
  4970. * @returns true if the query matches
  4971. */
  4972. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  4973. private static _HandleParenthesisContent;
  4974. private static _SimplifyNegation;
  4975. }
  4976. }
  4977. declare module BABYLON {
  4978. /**
  4979. * Class used to store custom tags
  4980. */
  4981. export class Tags {
  4982. /**
  4983. * Adds support for tags on the given object
  4984. * @param obj defines the object to use
  4985. */
  4986. static EnableFor(obj: any): void;
  4987. /**
  4988. * Removes tags support
  4989. * @param obj defines the object to use
  4990. */
  4991. static DisableFor(obj: any): void;
  4992. /**
  4993. * Gets a boolean indicating if the given object has tags
  4994. * @param obj defines the object to use
  4995. * @returns a boolean
  4996. */
  4997. static HasTags(obj: any): boolean;
  4998. /**
  4999. * Gets the tags available on a given object
  5000. * @param obj defines the object to use
  5001. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5002. * @returns the tags
  5003. */
  5004. static GetTags(obj: any, asString?: boolean): any;
  5005. /**
  5006. * Adds tags to an object
  5007. * @param obj defines the object to use
  5008. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5009. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5010. */
  5011. static AddTagsTo(obj: any, tagsString: string): void;
  5012. /**
  5013. * @hidden
  5014. */ private static _AddTagTo(obj: any, tag: string): void;
  5015. /**
  5016. * Removes specific tags from a specific object
  5017. * @param obj defines the object to use
  5018. * @param tagsString defines the tags to remove
  5019. */
  5020. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5021. /**
  5022. * @hidden
  5023. */ private static _RemoveTagFrom(obj: any, tag: string): void;
  5024. /**
  5025. * Defines if tags hosted on an object match a given query
  5026. * @param obj defines the object to use
  5027. * @param tagsQuery defines the tag query
  5028. * @returns a boolean
  5029. */
  5030. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5031. }
  5032. }
  5033. declare module BABYLON {
  5034. /**
  5035. * Manages the defines for the Material
  5036. */
  5037. export class MaterialDefines {
  5038. private _keys;
  5039. private _isDirty;
  5040. /** @hidden */ renderId: number;
  5041. /** @hidden */ areLightsDirty: boolean;
  5042. /** @hidden */ areAttributesDirty: boolean;
  5043. /** @hidden */ areTexturesDirty: boolean;
  5044. /** @hidden */ areFresnelDirty: boolean;
  5045. /** @hidden */ areMiscDirty: boolean;
  5046. /** @hidden */ areImageProcessingDirty: boolean;
  5047. /** @hidden */ normals: boolean;
  5048. /** @hidden */ uvs: boolean;
  5049. /** @hidden */ needNormals: boolean;
  5050. /** @hidden */ needUVs: boolean;
  5051. /**
  5052. * Specifies if the material needs to be re-calculated
  5053. */
  5054. readonly isDirty: boolean;
  5055. /**
  5056. * Marks the material to indicate that it has been re-calculated
  5057. */
  5058. markAsProcessed(): void;
  5059. /**
  5060. * Marks the material to indicate that it needs to be re-calculated
  5061. */
  5062. markAsUnprocessed(): void;
  5063. /**
  5064. * Marks the material to indicate all of its defines need to be re-calculated
  5065. */
  5066. markAllAsDirty(): void;
  5067. /**
  5068. * Marks the material to indicate that image processing needs to be re-calculated
  5069. */
  5070. markAsImageProcessingDirty(): void;
  5071. /**
  5072. * Marks the material to indicate the lights need to be re-calculated
  5073. */
  5074. markAsLightDirty(): void;
  5075. /**
  5076. * Marks the attribute state as changed
  5077. */
  5078. markAsAttributesDirty(): void;
  5079. /**
  5080. * Marks the texture state as changed
  5081. */
  5082. markAsTexturesDirty(): void;
  5083. /**
  5084. * Marks the fresnel state as changed
  5085. */
  5086. markAsFresnelDirty(): void;
  5087. /**
  5088. * Marks the misc state as changed
  5089. */
  5090. markAsMiscDirty(): void;
  5091. /**
  5092. * Rebuilds the material defines
  5093. */
  5094. rebuild(): void;
  5095. /**
  5096. * Specifies if two material defines are equal
  5097. * @param other - A material define instance to compare to
  5098. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5099. */
  5100. isEqual(other: MaterialDefines): boolean;
  5101. /**
  5102. * Clones this instance's defines to another instance
  5103. * @param other - material defines to clone values to
  5104. */
  5105. cloneTo(other: MaterialDefines): void;
  5106. /**
  5107. * Resets the material define values
  5108. */
  5109. reset(): void;
  5110. /**
  5111. * Converts the material define values to a string
  5112. * @returns - String of material define information
  5113. */
  5114. toString(): string;
  5115. }
  5116. }
  5117. declare module BABYLON {
  5118. /**
  5119. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5120. */
  5121. export class PerformanceMonitor {
  5122. private _enabled;
  5123. private _rollingFrameTime;
  5124. private _lastFrameTimeMs;
  5125. /**
  5126. * constructor
  5127. * @param frameSampleSize The number of samples required to saturate the sliding window
  5128. */
  5129. constructor(frameSampleSize?: number);
  5130. /**
  5131. * Samples current frame
  5132. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5133. */
  5134. sampleFrame(timeMs?: number): void;
  5135. /**
  5136. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5137. */
  5138. readonly averageFrameTime: number;
  5139. /**
  5140. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5141. */
  5142. readonly averageFrameTimeVariance: number;
  5143. /**
  5144. * Returns the frame time of the most recent frame
  5145. */
  5146. readonly instantaneousFrameTime: number;
  5147. /**
  5148. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5149. */
  5150. readonly averageFPS: number;
  5151. /**
  5152. * Returns the average framerate in frames per second using the most recent frame time
  5153. */
  5154. readonly instantaneousFPS: number;
  5155. /**
  5156. * Returns true if enough samples have been taken to completely fill the sliding window
  5157. */
  5158. readonly isSaturated: boolean;
  5159. /**
  5160. * Enables contributions to the sliding window sample set
  5161. */
  5162. enable(): void;
  5163. /**
  5164. * Disables contributions to the sliding window sample set
  5165. * Samples will not be interpolated over the disabled period
  5166. */
  5167. disable(): void;
  5168. /**
  5169. * Returns true if sampling is enabled
  5170. */
  5171. readonly isEnabled: boolean;
  5172. /**
  5173. * Resets performance monitor
  5174. */
  5175. reset(): void;
  5176. }
  5177. /**
  5178. * RollingAverage
  5179. *
  5180. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5181. */
  5182. export class RollingAverage {
  5183. /**
  5184. * Current average
  5185. */
  5186. average: number;
  5187. /**
  5188. * Current variance
  5189. */
  5190. variance: number;
  5191. protected _samples: Array<number>;
  5192. protected _sampleCount: number;
  5193. protected _pos: number;
  5194. protected _m2: number;
  5195. /**
  5196. * constructor
  5197. * @param length The number of samples required to saturate the sliding window
  5198. */
  5199. constructor(length: number);
  5200. /**
  5201. * Adds a sample to the sample set
  5202. * @param v The sample value
  5203. */
  5204. add(v: number): void;
  5205. /**
  5206. * Returns previously added values or null if outside of history or outside the sliding window domain
  5207. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5208. * @return Value previously recorded with add() or null if outside of range
  5209. */
  5210. history(i: number): number;
  5211. /**
  5212. * Returns true if enough samples have been taken to completely fill the sliding window
  5213. * @return true if sample-set saturated
  5214. */
  5215. isSaturated(): boolean;
  5216. /**
  5217. * Resets the rolling average (equivalent to 0 samples taken so far)
  5218. */
  5219. reset(): void;
  5220. /**
  5221. * Wraps a value around the sample range boundaries
  5222. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5223. * @return Wrapped position in sample range
  5224. */
  5225. protected _wrapPosition(i: number): number;
  5226. }
  5227. }
  5228. declare module BABYLON {
  5229. /**
  5230. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5231. * The underlying implementation relies on an associative array to ensure the best performances.
  5232. * The value can be anything including 'null' but except 'undefined'
  5233. */
  5234. export class StringDictionary<T> {
  5235. /**
  5236. * This will clear this dictionary and copy the content from the 'source' one.
  5237. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5238. * @param source the dictionary to take the content from and copy to this dictionary
  5239. */
  5240. copyFrom(source: StringDictionary<T>): void;
  5241. /**
  5242. * Get a value based from its key
  5243. * @param key the given key to get the matching value from
  5244. * @return the value if found, otherwise undefined is returned
  5245. */
  5246. get(key: string): T | undefined;
  5247. /**
  5248. * Get a value from its key or add it if it doesn't exist.
  5249. * This method will ensure you that a given key/data will be present in the dictionary.
  5250. * @param key the given key to get the matching value from
  5251. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5252. * The factory will only be invoked if there's no data for the given key.
  5253. * @return the value corresponding to the key.
  5254. */
  5255. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5256. /**
  5257. * Get a value from its key if present in the dictionary otherwise add it
  5258. * @param key the key to get the value from
  5259. * @param val if there's no such key/value pair in the dictionary add it with this value
  5260. * @return the value corresponding to the key
  5261. */
  5262. getOrAdd(key: string, val: T): T;
  5263. /**
  5264. * Check if there's a given key in the dictionary
  5265. * @param key the key to check for
  5266. * @return true if the key is present, false otherwise
  5267. */
  5268. contains(key: string): boolean;
  5269. /**
  5270. * Add a new key and its corresponding value
  5271. * @param key the key to add
  5272. * @param value the value corresponding to the key
  5273. * @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
  5274. */
  5275. add(key: string, value: T): boolean;
  5276. /**
  5277. * Update a specific value associated to a key
  5278. * @param key defines the key to use
  5279. * @param value defines the value to store
  5280. * @returns true if the value was updated (or false if the key was not found)
  5281. */
  5282. set(key: string, value: T): boolean;
  5283. /**
  5284. * Get the element of the given key and remove it from the dictionary
  5285. * @param key defines the key to search
  5286. * @returns the value associated with the key or null if not found
  5287. */
  5288. getAndRemove(key: string): Nullable<T>;
  5289. /**
  5290. * Remove a key/value from the dictionary.
  5291. * @param key the key to remove
  5292. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5293. */
  5294. remove(key: string): boolean;
  5295. /**
  5296. * Clear the whole content of the dictionary
  5297. */
  5298. clear(): void;
  5299. /**
  5300. * Gets the current count
  5301. */
  5302. readonly count: number;
  5303. /**
  5304. * Execute a callback on each key/val of the dictionary.
  5305. * Note that you can remove any element in this dictionary in the callback implementation
  5306. * @param callback the callback to execute on a given key/value pair
  5307. */
  5308. forEach(callback: (key: string, val: T) => void): void;
  5309. /**
  5310. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5311. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5312. * Note that you can remove any element in this dictionary in the callback implementation
  5313. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5314. * @returns the first item
  5315. */
  5316. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5317. private _count;
  5318. private _data;
  5319. }
  5320. }
  5321. declare module BABYLON {
  5322. /**
  5323. * Helper class that provides a small promise polyfill
  5324. */
  5325. export class PromisePolyfill {
  5326. /**
  5327. * Static function used to check if the polyfill is required
  5328. * If this is the case then the function will inject the polyfill to window.Promise
  5329. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5330. */
  5331. static Apply(force?: boolean): void;
  5332. }
  5333. }
  5334. declare module BABYLON {
  5335. /**
  5336. * Class used to store data that will be store in GPU memory
  5337. */
  5338. export class Buffer {
  5339. private _engine;
  5340. private _buffer;
  5341. /** @hidden */ data: Nullable<DataArray>;
  5342. private _updatable;
  5343. private _instanced;
  5344. /**
  5345. * Gets the byte stride.
  5346. */
  5347. readonly byteStride: number;
  5348. /**
  5349. * Constructor
  5350. * @param engine the engine
  5351. * @param data the data to use for this buffer
  5352. * @param updatable whether the data is updatable
  5353. * @param stride the stride (optional)
  5354. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5355. * @param instanced whether the buffer is instanced (optional)
  5356. * @param useBytes set to true if the stride in in bytes (optional)
  5357. */
  5358. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5359. /**
  5360. * Create a new VertexBuffer based on the current buffer
  5361. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5362. * @param offset defines offset in the buffer (0 by default)
  5363. * @param size defines the size in floats of attributes (position is 3 for instance)
  5364. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5365. * @param instanced defines if the vertex buffer contains indexed data
  5366. * @param useBytes defines if the offset and stride are in bytes
  5367. * @returns the new vertex buffer
  5368. */
  5369. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5370. /**
  5371. * Gets a boolean indicating if the Buffer is updatable?
  5372. * @returns true if the buffer is updatable
  5373. */
  5374. isUpdatable(): boolean;
  5375. /**
  5376. * Gets current buffer's data
  5377. * @returns a DataArray or null
  5378. */
  5379. getData(): Nullable<DataArray>;
  5380. /**
  5381. * Gets underlying native buffer
  5382. * @returns underlying native buffer
  5383. */
  5384. getBuffer(): Nullable<WebGLBuffer>;
  5385. /**
  5386. * Gets the stride in float32 units (i.e. byte stride / 4).
  5387. * May not be an integer if the byte stride is not divisible by 4.
  5388. * DEPRECATED. Use byteStride instead.
  5389. * @returns the stride in float32 units
  5390. */
  5391. getStrideSize(): number;
  5392. /**
  5393. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5394. * @param data defines the data to store
  5395. */
  5396. create(data?: Nullable<DataArray>): void;
  5397. /** @hidden */ rebuild(): void;
  5398. /**
  5399. * Update current buffer data
  5400. * @param data defines the data to store
  5401. */
  5402. update(data: DataArray): void;
  5403. /**
  5404. * Updates the data directly.
  5405. * @param data the new data
  5406. * @param offset the new offset
  5407. * @param vertexCount the vertex count (optional)
  5408. * @param useBytes set to true if the offset is in bytes
  5409. */
  5410. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5411. /**
  5412. * Release all resources
  5413. */
  5414. dispose(): void;
  5415. }
  5416. /**
  5417. * Specialized buffer used to store vertex data
  5418. */
  5419. export class VertexBuffer {
  5420. /** @hidden */ buffer: Buffer;
  5421. private _kind;
  5422. private _size;
  5423. private _ownsBuffer;
  5424. private _instanced;
  5425. private _instanceDivisor;
  5426. /**
  5427. * The byte type.
  5428. */
  5429. static readonly BYTE: number;
  5430. /**
  5431. * The unsigned byte type.
  5432. */
  5433. static readonly UNSIGNED_BYTE: number;
  5434. /**
  5435. * The short type.
  5436. */
  5437. static readonly SHORT: number;
  5438. /**
  5439. * The unsigned short type.
  5440. */
  5441. static readonly UNSIGNED_SHORT: number;
  5442. /**
  5443. * The integer type.
  5444. */
  5445. static readonly INT: number;
  5446. /**
  5447. * The unsigned integer type.
  5448. */
  5449. static readonly UNSIGNED_INT: number;
  5450. /**
  5451. * The float type.
  5452. */
  5453. static readonly FLOAT: number;
  5454. /**
  5455. * Gets or sets the instance divisor when in instanced mode
  5456. */
  5457. instanceDivisor: number;
  5458. /**
  5459. * Gets the byte stride.
  5460. */
  5461. readonly byteStride: number;
  5462. /**
  5463. * Gets the byte offset.
  5464. */
  5465. readonly byteOffset: number;
  5466. /**
  5467. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5468. */
  5469. readonly normalized: boolean;
  5470. /**
  5471. * Gets the data type of each component in the array.
  5472. */
  5473. readonly type: number;
  5474. /**
  5475. * Constructor
  5476. * @param engine the engine
  5477. * @param data the data to use for this vertex buffer
  5478. * @param kind the vertex buffer kind
  5479. * @param updatable whether the data is updatable
  5480. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5481. * @param stride the stride (optional)
  5482. * @param instanced whether the buffer is instanced (optional)
  5483. * @param offset the offset of the data (optional)
  5484. * @param size the number of components (optional)
  5485. * @param type the type of the component (optional)
  5486. * @param normalized whether the data contains normalized data (optional)
  5487. * @param useBytes set to true if stride and offset are in bytes (optional)
  5488. */
  5489. 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);
  5490. /** @hidden */ rebuild(): void;
  5491. /**
  5492. * Returns the kind of the VertexBuffer (string)
  5493. * @returns a string
  5494. */
  5495. getKind(): string;
  5496. /**
  5497. * Gets a boolean indicating if the VertexBuffer is updatable?
  5498. * @returns true if the buffer is updatable
  5499. */
  5500. isUpdatable(): boolean;
  5501. /**
  5502. * Gets current buffer's data
  5503. * @returns a DataArray or null
  5504. */
  5505. getData(): Nullable<DataArray>;
  5506. /**
  5507. * Gets underlying native buffer
  5508. * @returns underlying native buffer
  5509. */
  5510. getBuffer(): Nullable<WebGLBuffer>;
  5511. /**
  5512. * Gets the stride in float32 units (i.e. byte stride / 4).
  5513. * May not be an integer if the byte stride is not divisible by 4.
  5514. * DEPRECATED. Use byteStride instead.
  5515. * @returns the stride in float32 units
  5516. */
  5517. getStrideSize(): number;
  5518. /**
  5519. * Returns the offset as a multiple of the type byte length.
  5520. * DEPRECATED. Use byteOffset instead.
  5521. * @returns the offset in bytes
  5522. */
  5523. getOffset(): number;
  5524. /**
  5525. * Returns the number of components per vertex attribute (integer)
  5526. * @returns the size in float
  5527. */
  5528. getSize(): number;
  5529. /**
  5530. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5531. * @returns true if this buffer is instanced
  5532. */
  5533. getIsInstanced(): boolean;
  5534. /**
  5535. * Returns the instancing divisor, zero for non-instanced (integer).
  5536. * @returns a number
  5537. */
  5538. getInstanceDivisor(): number;
  5539. /**
  5540. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5541. * @param data defines the data to store
  5542. */
  5543. create(data?: DataArray): void;
  5544. /**
  5545. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5546. * This function will create a new buffer if the current one is not updatable
  5547. * @param data defines the data to store
  5548. */
  5549. update(data: DataArray): void;
  5550. /**
  5551. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5552. * Returns the directly updated WebGLBuffer.
  5553. * @param data the new data
  5554. * @param offset the new offset
  5555. * @param useBytes set to true if the offset is in bytes
  5556. */
  5557. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5558. /**
  5559. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5560. */
  5561. dispose(): void;
  5562. /**
  5563. * Enumerates each value of this vertex buffer as numbers.
  5564. * @param count the number of values to enumerate
  5565. * @param callback the callback function called for each value
  5566. */
  5567. forEach(count: number, callback: (value: number, index: number) => void): void;
  5568. /**
  5569. * Positions
  5570. */
  5571. static readonly PositionKind: string;
  5572. /**
  5573. * Normals
  5574. */
  5575. static readonly NormalKind: string;
  5576. /**
  5577. * Tangents
  5578. */
  5579. static readonly TangentKind: string;
  5580. /**
  5581. * Texture coordinates
  5582. */
  5583. static readonly UVKind: string;
  5584. /**
  5585. * Texture coordinates 2
  5586. */
  5587. static readonly UV2Kind: string;
  5588. /**
  5589. * Texture coordinates 3
  5590. */
  5591. static readonly UV3Kind: string;
  5592. /**
  5593. * Texture coordinates 4
  5594. */
  5595. static readonly UV4Kind: string;
  5596. /**
  5597. * Texture coordinates 5
  5598. */
  5599. static readonly UV5Kind: string;
  5600. /**
  5601. * Texture coordinates 6
  5602. */
  5603. static readonly UV6Kind: string;
  5604. /**
  5605. * Colors
  5606. */
  5607. static readonly ColorKind: string;
  5608. /**
  5609. * Matrix indices (for bones)
  5610. */
  5611. static readonly MatricesIndicesKind: string;
  5612. /**
  5613. * Matrix weights (for bones)
  5614. */
  5615. static readonly MatricesWeightsKind: string;
  5616. /**
  5617. * Additional matrix indices (for bones)
  5618. */
  5619. static readonly MatricesIndicesExtraKind: string;
  5620. /**
  5621. * Additional matrix weights (for bones)
  5622. */
  5623. static readonly MatricesWeightsExtraKind: string;
  5624. /**
  5625. * Deduces the stride given a kind.
  5626. * @param kind The kind string to deduce
  5627. * @returns The deduced stride
  5628. */
  5629. static DeduceStride(kind: string): number;
  5630. /**
  5631. * Gets the byte length of the given type.
  5632. * @param type the type
  5633. * @returns the number of bytes
  5634. */
  5635. static GetTypeByteLength(type: number): number;
  5636. /**
  5637. * Enumerates each value of the given parameters as numbers.
  5638. * @param data the data to enumerate
  5639. * @param byteOffset the byte offset of the data
  5640. * @param byteStride the byte stride of the data
  5641. * @param componentCount the number of components per element
  5642. * @param componentType the type of the component
  5643. * @param count the total number of components
  5644. * @param normalized whether the data is normalized
  5645. * @param callback the callback function called for each value
  5646. */
  5647. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5648. private static _GetFloatValue;
  5649. }
  5650. }
  5651. declare module BABYLON {
  5652. /**
  5653. * Class representing spherical polynomial coefficients to the 3rd degree
  5654. */
  5655. export class SphericalPolynomial {
  5656. /**
  5657. * The x coefficients of the spherical polynomial
  5658. */
  5659. x: Vector3;
  5660. /**
  5661. * The y coefficients of the spherical polynomial
  5662. */
  5663. y: Vector3;
  5664. /**
  5665. * The z coefficients of the spherical polynomial
  5666. */
  5667. z: Vector3;
  5668. /**
  5669. * The xx coefficients of the spherical polynomial
  5670. */
  5671. xx: Vector3;
  5672. /**
  5673. * The yy coefficients of the spherical polynomial
  5674. */
  5675. yy: Vector3;
  5676. /**
  5677. * The zz coefficients of the spherical polynomial
  5678. */
  5679. zz: Vector3;
  5680. /**
  5681. * The xy coefficients of the spherical polynomial
  5682. */
  5683. xy: Vector3;
  5684. /**
  5685. * The yz coefficients of the spherical polynomial
  5686. */
  5687. yz: Vector3;
  5688. /**
  5689. * The zx coefficients of the spherical polynomial
  5690. */
  5691. zx: Vector3;
  5692. /**
  5693. * Adds an ambient color to the spherical polynomial
  5694. * @param color the color to add
  5695. */
  5696. addAmbient(color: Color3): void;
  5697. /**
  5698. * Scales the spherical polynomial by the given amount
  5699. * @param scale the amount to scale
  5700. */
  5701. scale(scale: number): void;
  5702. /**
  5703. * Gets the spherical polynomial from harmonics
  5704. * @param harmonics the spherical harmonics
  5705. * @returns the spherical polynomial
  5706. */
  5707. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5708. /**
  5709. * Constructs a spherical polynomial from an array.
  5710. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5711. * @returns the spherical polynomial
  5712. */
  5713. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5714. }
  5715. /**
  5716. * Class representing spherical harmonics coefficients to the 3rd degree
  5717. */
  5718. export class SphericalHarmonics {
  5719. /**
  5720. * The l0,0 coefficients of the spherical harmonics
  5721. */
  5722. l00: Vector3;
  5723. /**
  5724. * The l1,-1 coefficients of the spherical harmonics
  5725. */
  5726. l1_1: Vector3;
  5727. /**
  5728. * The l1,0 coefficients of the spherical harmonics
  5729. */
  5730. l10: Vector3;
  5731. /**
  5732. * The l1,1 coefficients of the spherical harmonics
  5733. */
  5734. l11: Vector3;
  5735. /**
  5736. * The l2,-2 coefficients of the spherical harmonics
  5737. */
  5738. l2_2: Vector3;
  5739. /**
  5740. * The l2,-1 coefficients of the spherical harmonics
  5741. */
  5742. l2_1: Vector3;
  5743. /**
  5744. * The l2,0 coefficients of the spherical harmonics
  5745. */
  5746. l20: Vector3;
  5747. /**
  5748. * The l2,1 coefficients of the spherical harmonics
  5749. */
  5750. l21: Vector3;
  5751. /**
  5752. * The l2,2 coefficients of the spherical harmonics
  5753. */
  5754. lL22: Vector3;
  5755. /**
  5756. * Adds a light to the spherical harmonics
  5757. * @param direction the direction of the light
  5758. * @param color the color of the light
  5759. * @param deltaSolidAngle the delta solid angle of the light
  5760. */
  5761. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5762. /**
  5763. * Scales the spherical harmonics by the given amount
  5764. * @param scale the amount to scale
  5765. */
  5766. scale(scale: number): void;
  5767. /**
  5768. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5769. *
  5770. * ```
  5771. * E_lm = A_l * L_lm
  5772. * ```
  5773. *
  5774. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5775. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5776. * the scaling factors are given in equation 9.
  5777. */
  5778. convertIncidentRadianceToIrradiance(): void;
  5779. /**
  5780. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5781. *
  5782. * ```
  5783. * L = (1/pi) * E * rho
  5784. * ```
  5785. *
  5786. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5787. */
  5788. convertIrradianceToLambertianRadiance(): void;
  5789. /**
  5790. * Gets the spherical harmonics from polynomial
  5791. * @param polynomial the spherical polynomial
  5792. * @returns the spherical harmonics
  5793. */
  5794. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5795. /**
  5796. * Constructs a spherical harmonics from an array.
  5797. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5798. * @returns the spherical harmonics
  5799. */
  5800. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5801. }
  5802. }
  5803. declare module BABYLON {
  5804. /**
  5805. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5806. */
  5807. export interface CubeMapInfo {
  5808. /**
  5809. * The pixel array for the front face.
  5810. * This is stored in format, left to right, up to down format.
  5811. */
  5812. front: Nullable<ArrayBufferView>;
  5813. /**
  5814. * The pixel array for the back face.
  5815. * This is stored in format, left to right, up to down format.
  5816. */
  5817. back: Nullable<ArrayBufferView>;
  5818. /**
  5819. * The pixel array for the left face.
  5820. * This is stored in format, left to right, up to down format.
  5821. */
  5822. left: Nullable<ArrayBufferView>;
  5823. /**
  5824. * The pixel array for the right face.
  5825. * This is stored in format, left to right, up to down format.
  5826. */
  5827. right: Nullable<ArrayBufferView>;
  5828. /**
  5829. * The pixel array for the up face.
  5830. * This is stored in format, left to right, up to down format.
  5831. */
  5832. up: Nullable<ArrayBufferView>;
  5833. /**
  5834. * The pixel array for the down face.
  5835. * This is stored in format, left to right, up to down format.
  5836. */
  5837. down: Nullable<ArrayBufferView>;
  5838. /**
  5839. * The size of the cubemap stored.
  5840. *
  5841. * Each faces will be size * size pixels.
  5842. */
  5843. size: number;
  5844. /**
  5845. * The format of the texture.
  5846. *
  5847. * RGBA, RGB.
  5848. */
  5849. format: number;
  5850. /**
  5851. * The type of the texture data.
  5852. *
  5853. * UNSIGNED_INT, FLOAT.
  5854. */
  5855. type: number;
  5856. /**
  5857. * Specifies whether the texture is in gamma space.
  5858. */
  5859. gammaSpace: boolean;
  5860. }
  5861. /**
  5862. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5863. */
  5864. export class PanoramaToCubeMapTools {
  5865. private static FACE_FRONT;
  5866. private static FACE_BACK;
  5867. private static FACE_RIGHT;
  5868. private static FACE_LEFT;
  5869. private static FACE_DOWN;
  5870. private static FACE_UP;
  5871. /**
  5872. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5873. *
  5874. * @param float32Array The source data.
  5875. * @param inputWidth The width of the input panorama.
  5876. * @param inputHeight The height of the input panorama.
  5877. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5878. * @return The cubemap data
  5879. */
  5880. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5881. private static CreateCubemapTexture;
  5882. private static CalcProjectionSpherical;
  5883. }
  5884. }
  5885. declare module BABYLON {
  5886. /**
  5887. * Helper class dealing with the extraction of spherical polynomial dataArray
  5888. * from a cube map.
  5889. */
  5890. export class CubeMapToSphericalPolynomialTools {
  5891. private static FileFaces;
  5892. /**
  5893. * Converts a texture to the according Spherical Polynomial data.
  5894. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5895. *
  5896. * @param texture The texture to extract the information from.
  5897. * @return The Spherical Polynomial data.
  5898. */
  5899. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  5900. /**
  5901. * Converts a cubemap to the according Spherical Polynomial data.
  5902. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5903. *
  5904. * @param cubeInfo The Cube map to extract the information from.
  5905. * @return The Spherical Polynomial data.
  5906. */
  5907. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  5908. }
  5909. }
  5910. declare module BABYLON {
  5911. /**
  5912. * The engine store class is responsible to hold all the instances of Engine and Scene created
  5913. * during the life time of the application.
  5914. */
  5915. export class EngineStore {
  5916. /** Gets the list of created engines */
  5917. static Instances: Engine[];
  5918. /**
  5919. * Gets the latest created engine
  5920. */
  5921. static readonly LastCreatedEngine: Nullable<Engine>;
  5922. /**
  5923. * Gets the latest created scene
  5924. */
  5925. static readonly LastCreatedScene: Nullable<Scene>;
  5926. }
  5927. }
  5928. declare module BABYLON {
  5929. /**
  5930. * Define options used to create a render target texture
  5931. */
  5932. export class RenderTargetCreationOptions {
  5933. /**
  5934. * Specifies is mipmaps must be generated
  5935. */
  5936. generateMipMaps?: boolean;
  5937. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5938. generateDepthBuffer?: boolean;
  5939. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5940. generateStencilBuffer?: boolean;
  5941. /** Defines texture type (int by default) */
  5942. type?: number;
  5943. /** Defines sampling mode (trilinear by default) */
  5944. samplingMode?: number;
  5945. /** Defines format (RGBA by default) */
  5946. format?: number;
  5947. }
  5948. }
  5949. declare module BABYLON {
  5950. /**
  5951. * @hidden
  5952. **/
  5953. export class _AlphaState {
  5954. private _isAlphaBlendDirty;
  5955. private _isBlendFunctionParametersDirty;
  5956. private _isBlendEquationParametersDirty;
  5957. private _isBlendConstantsDirty;
  5958. private _alphaBlend;
  5959. private _blendFunctionParameters;
  5960. private _blendEquationParameters;
  5961. private _blendConstants;
  5962. /**
  5963. * Initializes the state.
  5964. */
  5965. constructor();
  5966. readonly isDirty: boolean;
  5967. alphaBlend: boolean;
  5968. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5969. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5970. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5971. reset(): void;
  5972. apply(gl: WebGLRenderingContext): void;
  5973. }
  5974. }
  5975. declare module BABYLON {
  5976. /**
  5977. * @hidden
  5978. **/
  5979. export class _DepthCullingState {
  5980. private _isDepthTestDirty;
  5981. private _isDepthMaskDirty;
  5982. private _isDepthFuncDirty;
  5983. private _isCullFaceDirty;
  5984. private _isCullDirty;
  5985. private _isZOffsetDirty;
  5986. private _isFrontFaceDirty;
  5987. private _depthTest;
  5988. private _depthMask;
  5989. private _depthFunc;
  5990. private _cull;
  5991. private _cullFace;
  5992. private _zOffset;
  5993. private _frontFace;
  5994. /**
  5995. * Initializes the state.
  5996. */
  5997. constructor();
  5998. readonly isDirty: boolean;
  5999. zOffset: number;
  6000. cullFace: Nullable<number>;
  6001. cull: Nullable<boolean>;
  6002. depthFunc: Nullable<number>;
  6003. depthMask: boolean;
  6004. depthTest: boolean;
  6005. frontFace: Nullable<number>;
  6006. reset(): void;
  6007. apply(gl: WebGLRenderingContext): void;
  6008. }
  6009. }
  6010. declare module BABYLON {
  6011. /**
  6012. * @hidden
  6013. **/
  6014. export class _StencilState {
  6015. /** 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 */
  6016. static readonly ALWAYS: number;
  6017. /** Passed to stencilOperation to specify that stencil value must be kept */
  6018. static readonly KEEP: number;
  6019. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6020. static readonly REPLACE: number;
  6021. private _isStencilTestDirty;
  6022. private _isStencilMaskDirty;
  6023. private _isStencilFuncDirty;
  6024. private _isStencilOpDirty;
  6025. private _stencilTest;
  6026. private _stencilMask;
  6027. private _stencilFunc;
  6028. private _stencilFuncRef;
  6029. private _stencilFuncMask;
  6030. private _stencilOpStencilFail;
  6031. private _stencilOpDepthFail;
  6032. private _stencilOpStencilDepthPass;
  6033. readonly isDirty: boolean;
  6034. stencilFunc: number;
  6035. stencilFuncRef: number;
  6036. stencilFuncMask: number;
  6037. stencilOpStencilFail: number;
  6038. stencilOpDepthFail: number;
  6039. stencilOpStencilDepthPass: number;
  6040. stencilMask: number;
  6041. stencilTest: boolean;
  6042. constructor();
  6043. reset(): void;
  6044. apply(gl: WebGLRenderingContext): void;
  6045. }
  6046. }
  6047. declare module BABYLON {
  6048. /**
  6049. * @hidden
  6050. **/
  6051. export class _TimeToken { startTimeQuery: Nullable<WebGLQuery>; endTimeQuery: Nullable<WebGLQuery>; timeElapsedQuery: Nullable<WebGLQuery>; timeElapsedQueryEnded: boolean;
  6052. }
  6053. }
  6054. declare module BABYLON {
  6055. /**
  6056. * Internal interface used to track InternalTexture already bound to the GL context
  6057. */
  6058. export interface IInternalTextureTracker {
  6059. /**
  6060. * Gets or set the previous tracker in the list
  6061. */
  6062. previous: Nullable<IInternalTextureTracker>;
  6063. /**
  6064. * Gets or set the next tracker in the list
  6065. */
  6066. next: Nullable<IInternalTextureTracker>;
  6067. }
  6068. /**
  6069. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6070. */
  6071. export class DummyInternalTextureTracker {
  6072. /**
  6073. * Gets or set the previous tracker in the list
  6074. */
  6075. previous: Nullable<IInternalTextureTracker>;
  6076. /**
  6077. * Gets or set the next tracker in the list
  6078. */
  6079. next: Nullable<IInternalTextureTracker>;
  6080. }
  6081. }
  6082. declare module BABYLON {
  6083. /**
  6084. * Class used to store data associated with WebGL texture data for the engine
  6085. * This class should not be used directly
  6086. */
  6087. export class InternalTexture implements IInternalTextureTracker {
  6088. /** hidden */ private static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6089. /**
  6090. * The source of the texture data is unknown
  6091. */
  6092. static DATASOURCE_UNKNOWN: number;
  6093. /**
  6094. * Texture data comes from an URL
  6095. */
  6096. static DATASOURCE_URL: number;
  6097. /**
  6098. * Texture data is only used for temporary storage
  6099. */
  6100. static DATASOURCE_TEMP: number;
  6101. /**
  6102. * Texture data comes from raw data (ArrayBuffer)
  6103. */
  6104. static DATASOURCE_RAW: number;
  6105. /**
  6106. * Texture content is dynamic (video or dynamic texture)
  6107. */
  6108. static DATASOURCE_DYNAMIC: number;
  6109. /**
  6110. * Texture content is generated by rendering to it
  6111. */
  6112. static DATASOURCE_RENDERTARGET: number;
  6113. /**
  6114. * Texture content is part of a multi render target process
  6115. */
  6116. static DATASOURCE_MULTIRENDERTARGET: number;
  6117. /**
  6118. * Texture data comes from a cube data file
  6119. */
  6120. static DATASOURCE_CUBE: number;
  6121. /**
  6122. * Texture data comes from a raw cube data
  6123. */
  6124. static DATASOURCE_CUBERAW: number;
  6125. /**
  6126. * Texture data come from a prefiltered cube data file
  6127. */
  6128. static DATASOURCE_CUBEPREFILTERED: number;
  6129. /**
  6130. * Texture content is raw 3D data
  6131. */
  6132. static DATASOURCE_RAW3D: number;
  6133. /**
  6134. * Texture content is a depth texture
  6135. */
  6136. static DATASOURCE_DEPTHTEXTURE: number;
  6137. /**
  6138. * Texture data comes from a raw cube data encoded with RGBD
  6139. */
  6140. static DATASOURCE_CUBERAW_RGBD: number;
  6141. /**
  6142. * Defines if the texture is ready
  6143. */
  6144. isReady: boolean;
  6145. /**
  6146. * Defines if the texture is a cube texture
  6147. */
  6148. isCube: boolean;
  6149. /**
  6150. * Defines if the texture contains 3D data
  6151. */
  6152. is3D: boolean;
  6153. /**
  6154. * Gets the URL used to load this texture
  6155. */
  6156. url: string;
  6157. /**
  6158. * Gets the sampling mode of the texture
  6159. */
  6160. samplingMode: number;
  6161. /**
  6162. * Gets a boolean indicating if the texture needs mipmaps generation
  6163. */
  6164. generateMipMaps: boolean;
  6165. /**
  6166. * Gets the number of samples used by the texture (WebGL2+ only)
  6167. */
  6168. samples: number;
  6169. /**
  6170. * Gets the type of the texture (int, float...)
  6171. */
  6172. type: number;
  6173. /**
  6174. * Gets the format of the texture (RGB, RGBA...)
  6175. */
  6176. format: number;
  6177. /**
  6178. * Observable called when the texture is loaded
  6179. */
  6180. onLoadedObservable: Observable<InternalTexture>;
  6181. /**
  6182. * Gets the width of the texture
  6183. */
  6184. width: number;
  6185. /**
  6186. * Gets the height of the texture
  6187. */
  6188. height: number;
  6189. /**
  6190. * Gets the depth of the texture
  6191. */
  6192. depth: number;
  6193. /**
  6194. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6195. */
  6196. baseWidth: number;
  6197. /**
  6198. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6199. */
  6200. baseHeight: number;
  6201. /**
  6202. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6203. */
  6204. baseDepth: number;
  6205. /**
  6206. * Gets a boolean indicating if the texture is inverted on Y axis
  6207. */
  6208. invertY: boolean;
  6209. /**
  6210. * Gets or set the previous tracker in the list
  6211. */
  6212. previous: Nullable<IInternalTextureTracker>;
  6213. /**
  6214. * Gets or set the next tracker in the list
  6215. */
  6216. next: Nullable<IInternalTextureTracker>;
  6217. /** @hidden */ invertVScale: boolean;
  6218. /** @hidden */ initialSlot: number;
  6219. /** @hidden */ designatedSlot: number;
  6220. /** @hidden */ dataSource: number;
  6221. /** @hidden */ buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6222. /** @hidden */ bufferView: Nullable<ArrayBufferView>;
  6223. /** @hidden */ bufferViewArray: Nullable<ArrayBufferView[]>;
  6224. /** @hidden */ bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6225. /** @hidden */ size: number;
  6226. /** @hidden */ extension: string;
  6227. /** @hidden */ files: Nullable<string[]>;
  6228. /** @hidden */ workingCanvas: HTMLCanvasElement;
  6229. /** @hidden */ workingContext: CanvasRenderingContext2D;
  6230. /** @hidden */ framebuffer: Nullable<WebGLFramebuffer>;
  6231. /** @hidden */ depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6232. /** @hidden */ MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6233. /** @hidden */ MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6234. /** @hidden */ attachments: Nullable<number[]>;
  6235. /** @hidden */ cachedCoordinatesMode: Nullable<number>;
  6236. /** @hidden */ cachedWrapU: Nullable<number>;
  6237. /** @hidden */ cachedWrapV: Nullable<number>;
  6238. /** @hidden */ cachedWrapR: Nullable<number>;
  6239. /** @hidden */ cachedAnisotropicFilteringLevel: Nullable<number>;
  6240. /** @hidden */ isDisabled: boolean;
  6241. /** @hidden */ compression: Nullable<string>;
  6242. /** @hidden */ generateStencilBuffer: boolean;
  6243. /** @hidden */ generateDepthBuffer: boolean;
  6244. /** @hidden */ comparisonFunction: number;
  6245. /** @hidden */ sphericalPolynomial: Nullable<SphericalPolynomial>;
  6246. /** @hidden */ lodGenerationScale: number;
  6247. /** @hidden */ lodGenerationOffset: number;
  6248. /** @hidden */ lodTextureHigh: BaseTexture;
  6249. /** @hidden */ lodTextureMid: BaseTexture;
  6250. /** @hidden */ lodTextureLow: BaseTexture;
  6251. /** @hidden */ isRGBD: boolean;
  6252. /** @hidden */ webGLTexture: Nullable<WebGLTexture>;
  6253. /** @hidden */ references: number;
  6254. private _engine;
  6255. /**
  6256. * Gets the Engine the texture belongs to.
  6257. * @returns The babylon engine
  6258. */
  6259. getEngine(): Engine;
  6260. /**
  6261. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6262. */
  6263. readonly dataSource: number;
  6264. /**
  6265. * Creates a new InternalTexture
  6266. * @param engine defines the engine to use
  6267. * @param dataSource defines the type of data that will be used
  6268. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6269. */
  6270. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6271. /**
  6272. * Increments the number of references (ie. the number of Texture that point to it)
  6273. */
  6274. incrementReferences(): void;
  6275. /**
  6276. * Change the size of the texture (not the size of the content)
  6277. * @param width defines the new width
  6278. * @param height defines the new height
  6279. * @param depth defines the new depth (1 by default)
  6280. */
  6281. updateSize(width: int, height: int, depth?: int): void;
  6282. /** @hidden */ rebuild(): void;
  6283. /** @hidden */ swapAndDie(target: InternalTexture): void;
  6284. /**
  6285. * Dispose the current allocated resources
  6286. */
  6287. dispose(): void;
  6288. }
  6289. }
  6290. declare module BABYLON {
  6291. /**
  6292. * This represents the main contract an easing function should follow.
  6293. * Easing functions are used throughout the animation system.
  6294. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6295. */
  6296. export interface IEasingFunction {
  6297. /**
  6298. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6299. * of the easing function.
  6300. * The link below provides some of the most common examples of easing functions.
  6301. * @see https://easings.net/
  6302. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6303. * @returns the corresponding value on the curve defined by the easing function
  6304. */
  6305. ease(gradient: number): number;
  6306. }
  6307. /**
  6308. * Base class used for every default easing function.
  6309. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6310. */
  6311. export class EasingFunction implements IEasingFunction {
  6312. /**
  6313. * Interpolation follows the mathematical formula associated with the easing function.
  6314. */
  6315. static readonly EASINGMODE_EASEIN: number;
  6316. /**
  6317. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6318. */
  6319. static readonly EASINGMODE_EASEOUT: number;
  6320. /**
  6321. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6322. */
  6323. static readonly EASINGMODE_EASEINOUT: number;
  6324. private _easingMode;
  6325. /**
  6326. * Sets the easing mode of the current function.
  6327. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6328. */
  6329. setEasingMode(easingMode: number): void;
  6330. /**
  6331. * Gets the current easing mode.
  6332. * @returns the easing mode
  6333. */
  6334. getEasingMode(): number;
  6335. /**
  6336. * @hidden
  6337. */
  6338. easeInCore(gradient: number): number;
  6339. /**
  6340. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6341. * of the easing function.
  6342. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6343. * @returns the corresponding value on the curve defined by the easing function
  6344. */
  6345. ease(gradient: number): number;
  6346. }
  6347. /**
  6348. * Easing function with a circle shape (see link below).
  6349. * @see https://easings.net/#easeInCirc
  6350. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6351. */
  6352. export class CircleEase extends EasingFunction implements IEasingFunction {
  6353. /** @hidden */
  6354. easeInCore(gradient: number): number;
  6355. }
  6356. /**
  6357. * Easing function with a ease back shape (see link below).
  6358. * @see https://easings.net/#easeInBack
  6359. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6360. */
  6361. export class BackEase extends EasingFunction implements IEasingFunction {
  6362. /** Defines the amplitude of the function */
  6363. amplitude: number;
  6364. /**
  6365. * Instantiates a back ease easing
  6366. * @see https://easings.net/#easeInBack
  6367. * @param amplitude Defines the amplitude of the function
  6368. */
  6369. constructor(
  6370. /** Defines the amplitude of the function */
  6371. amplitude?: number);
  6372. /** @hidden */
  6373. easeInCore(gradient: number): number;
  6374. }
  6375. /**
  6376. * Easing function with a bouncing shape (see link below).
  6377. * @see https://easings.net/#easeInBounce
  6378. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6379. */
  6380. export class BounceEase extends EasingFunction implements IEasingFunction {
  6381. /** Defines the number of bounces */
  6382. bounces: number;
  6383. /** Defines the amplitude of the bounce */
  6384. bounciness: number;
  6385. /**
  6386. * Instantiates a bounce easing
  6387. * @see https://easings.net/#easeInBounce
  6388. * @param bounces Defines the number of bounces
  6389. * @param bounciness Defines the amplitude of the bounce
  6390. */
  6391. constructor(
  6392. /** Defines the number of bounces */
  6393. bounces?: number,
  6394. /** Defines the amplitude of the bounce */
  6395. bounciness?: number);
  6396. /** @hidden */
  6397. easeInCore(gradient: number): number;
  6398. }
  6399. /**
  6400. * Easing function with a power of 3 shape (see link below).
  6401. * @see https://easings.net/#easeInCubic
  6402. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6403. */
  6404. export class CubicEase extends EasingFunction implements IEasingFunction {
  6405. /** @hidden */
  6406. easeInCore(gradient: number): number;
  6407. }
  6408. /**
  6409. * Easing function with an elastic shape (see link below).
  6410. * @see https://easings.net/#easeInElastic
  6411. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6412. */
  6413. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6414. /** Defines the number of oscillations*/
  6415. oscillations: number;
  6416. /** Defines the amplitude of the oscillations*/
  6417. springiness: number;
  6418. /**
  6419. * Instantiates an elastic easing function
  6420. * @see https://easings.net/#easeInElastic
  6421. * @param oscillations Defines the number of oscillations
  6422. * @param springiness Defines the amplitude of the oscillations
  6423. */
  6424. constructor(
  6425. /** Defines the number of oscillations*/
  6426. oscillations?: number,
  6427. /** Defines the amplitude of the oscillations*/
  6428. springiness?: number);
  6429. /** @hidden */
  6430. easeInCore(gradient: number): number;
  6431. }
  6432. /**
  6433. * Easing function with an exponential shape (see link below).
  6434. * @see https://easings.net/#easeInExpo
  6435. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6436. */
  6437. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6438. /** Defines the exponent of the function */
  6439. exponent: number;
  6440. /**
  6441. * Instantiates an exponential easing function
  6442. * @see https://easings.net/#easeInExpo
  6443. * @param exponent Defines the exponent of the function
  6444. */
  6445. constructor(
  6446. /** Defines the exponent of the function */
  6447. exponent?: number);
  6448. /** @hidden */
  6449. easeInCore(gradient: number): number;
  6450. }
  6451. /**
  6452. * Easing function with a power shape (see link below).
  6453. * @see https://easings.net/#easeInQuad
  6454. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6455. */
  6456. export class PowerEase extends EasingFunction implements IEasingFunction {
  6457. /** Defines the power of the function */
  6458. power: number;
  6459. /**
  6460. * Instantiates an power base easing function
  6461. * @see https://easings.net/#easeInQuad
  6462. * @param power Defines the power of the function
  6463. */
  6464. constructor(
  6465. /** Defines the power of the function */
  6466. power?: number);
  6467. /** @hidden */
  6468. easeInCore(gradient: number): number;
  6469. }
  6470. /**
  6471. * Easing function with a power of 2 shape (see link below).
  6472. * @see https://easings.net/#easeInQuad
  6473. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6474. */
  6475. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6476. /** @hidden */
  6477. easeInCore(gradient: number): number;
  6478. }
  6479. /**
  6480. * Easing function with a power of 4 shape (see link below).
  6481. * @see https://easings.net/#easeInQuart
  6482. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6483. */
  6484. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6485. /** @hidden */
  6486. easeInCore(gradient: number): number;
  6487. }
  6488. /**
  6489. * Easing function with a power of 5 shape (see link below).
  6490. * @see https://easings.net/#easeInQuint
  6491. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6492. */
  6493. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6494. /** @hidden */
  6495. easeInCore(gradient: number): number;
  6496. }
  6497. /**
  6498. * Easing function with a sin shape (see link below).
  6499. * @see https://easings.net/#easeInSine
  6500. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6501. */
  6502. export class SineEase extends EasingFunction implements IEasingFunction {
  6503. /** @hidden */
  6504. easeInCore(gradient: number): number;
  6505. }
  6506. /**
  6507. * Easing function with a bezier shape (see link below).
  6508. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6509. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6510. */
  6511. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6512. /** Defines the x component of the start tangent in the bezier curve */
  6513. x1: number;
  6514. /** Defines the y component of the start tangent in the bezier curve */
  6515. y1: number;
  6516. /** Defines the x component of the end tangent in the bezier curve */
  6517. x2: number;
  6518. /** Defines the y component of the end tangent in the bezier curve */
  6519. y2: number;
  6520. /**
  6521. * Instantiates a bezier function
  6522. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6523. * @param x1 Defines the x component of the start tangent in the bezier curve
  6524. * @param y1 Defines the y component of the start tangent in the bezier curve
  6525. * @param x2 Defines the x component of the end tangent in the bezier curve
  6526. * @param y2 Defines the y component of the end tangent in the bezier curve
  6527. */
  6528. constructor(
  6529. /** Defines the x component of the start tangent in the bezier curve */
  6530. x1?: number,
  6531. /** Defines the y component of the start tangent in the bezier curve */
  6532. y1?: number,
  6533. /** Defines the x component of the end tangent in the bezier curve */
  6534. x2?: number,
  6535. /** Defines the y component of the end tangent in the bezier curve */
  6536. y2?: number);
  6537. /** @hidden */
  6538. easeInCore(gradient: number): number;
  6539. }
  6540. }
  6541. declare module BABYLON {
  6542. /**
  6543. * Defines an interface which represents an animation key frame
  6544. */
  6545. export interface IAnimationKey {
  6546. /**
  6547. * Frame of the key frame
  6548. */
  6549. frame: number;
  6550. /**
  6551. * Value at the specifies key frame
  6552. */
  6553. value: any;
  6554. /**
  6555. * The input tangent for the cubic hermite spline
  6556. */
  6557. inTangent?: any;
  6558. /**
  6559. * The output tangent for the cubic hermite spline
  6560. */
  6561. outTangent?: any;
  6562. /**
  6563. * The animation interpolation type
  6564. */
  6565. interpolation?: AnimationKeyInterpolation;
  6566. }
  6567. /**
  6568. * Enum for the animation key frame interpolation type
  6569. */
  6570. export enum AnimationKeyInterpolation {
  6571. /**
  6572. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6573. */
  6574. STEP = 1
  6575. }
  6576. }
  6577. declare module BABYLON {
  6578. /**
  6579. * Represents the range of an animation
  6580. */
  6581. export class AnimationRange {
  6582. /**The name of the animation range**/
  6583. name: string;
  6584. /**The starting frame of the animation */
  6585. from: number;
  6586. /**The ending frame of the animation*/
  6587. to: number;
  6588. /**
  6589. * Initializes the range of an animation
  6590. * @param name The name of the animation range
  6591. * @param from The starting frame of the animation
  6592. * @param to The ending frame of the animation
  6593. */
  6594. constructor(
  6595. /**The name of the animation range**/
  6596. name: string,
  6597. /**The starting frame of the animation */
  6598. from: number,
  6599. /**The ending frame of the animation*/
  6600. to: number);
  6601. /**
  6602. * Makes a copy of the animation range
  6603. * @returns A copy of the animation range
  6604. */
  6605. clone(): AnimationRange;
  6606. }
  6607. }
  6608. declare module BABYLON {
  6609. /**
  6610. * Composed of a frame, and an action function
  6611. */
  6612. export class AnimationEvent {
  6613. /** The frame for which the event is triggered **/
  6614. frame: number;
  6615. /** The event to perform when triggered **/
  6616. action: (currentFrame: number) => void;
  6617. /** Specifies if the event should be triggered only once**/
  6618. onlyOnce?: boolean | undefined;
  6619. /**
  6620. * Specifies if the animation event is done
  6621. */
  6622. isDone: boolean;
  6623. /**
  6624. * Initializes the animation event
  6625. * @param frame The frame for which the event is triggered
  6626. * @param action The event to perform when triggered
  6627. * @param onlyOnce Specifies if the event should be triggered only once
  6628. */
  6629. constructor(
  6630. /** The frame for which the event is triggered **/
  6631. frame: number,
  6632. /** The event to perform when triggered **/
  6633. action: (currentFrame: number) => void,
  6634. /** Specifies if the event should be triggered only once**/
  6635. onlyOnce?: boolean | undefined);
  6636. /** @hidden */ clone(): AnimationEvent;
  6637. }
  6638. }
  6639. declare module BABYLON {
  6640. /**
  6641. * Interface used to define a behavior
  6642. */
  6643. export interface Behavior<T> {
  6644. /** gets or sets behavior's name */
  6645. name: string;
  6646. /**
  6647. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6648. */
  6649. init(): void;
  6650. /**
  6651. * Called when the behavior is attached to a target
  6652. * @param target defines the target where the behavior is attached to
  6653. */
  6654. attach(target: T): void;
  6655. /**
  6656. * Called when the behavior is detached from its target
  6657. */
  6658. detach(): void;
  6659. }
  6660. /**
  6661. * Interface implemented by classes supporting behaviors
  6662. */
  6663. export interface IBehaviorAware<T> {
  6664. /**
  6665. * Attach a behavior
  6666. * @param behavior defines the behavior to attach
  6667. * @returns the current host
  6668. */
  6669. addBehavior(behavior: Behavior<T>): T;
  6670. /**
  6671. * Remove a behavior from the current object
  6672. * @param behavior defines the behavior to detach
  6673. * @returns the current host
  6674. */
  6675. removeBehavior(behavior: Behavior<T>): T;
  6676. /**
  6677. * Gets a behavior using its name to search
  6678. * @param name defines the name to search
  6679. * @returns the behavior or null if not found
  6680. */
  6681. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6682. }
  6683. }
  6684. declare module BABYLON {
  6685. /**
  6686. * Defines a runtime animation
  6687. */
  6688. export class RuntimeAnimation {
  6689. private _events;
  6690. /**
  6691. * The current frame of the runtime animation
  6692. */
  6693. private _currentFrame;
  6694. /**
  6695. * The animation used by the runtime animation
  6696. */
  6697. private _animation;
  6698. /**
  6699. * The target of the runtime animation
  6700. */
  6701. private _target;
  6702. /**
  6703. * The initiating animatable
  6704. */
  6705. private _host;
  6706. /**
  6707. * The original value of the runtime animation
  6708. */
  6709. private _originalValue;
  6710. /**
  6711. * The original blend value of the runtime animation
  6712. */
  6713. private _originalBlendValue;
  6714. /**
  6715. * The offsets cache of the runtime animation
  6716. */
  6717. private _offsetsCache;
  6718. /**
  6719. * The high limits cache of the runtime animation
  6720. */
  6721. private _highLimitsCache;
  6722. /**
  6723. * Specifies if the runtime animation has been stopped
  6724. */
  6725. private _stopped;
  6726. /**
  6727. * The blending factor of the runtime animation
  6728. */
  6729. private _blendingFactor;
  6730. /**
  6731. * The BabylonJS scene
  6732. */
  6733. private _scene;
  6734. /**
  6735. * The current value of the runtime animation
  6736. */
  6737. private _currentValue;
  6738. /** @hidden */ workValue: any;
  6739. /**
  6740. * The active target of the runtime animation
  6741. */
  6742. private _activeTarget;
  6743. /**
  6744. * The target path of the runtime animation
  6745. */
  6746. private _targetPath;
  6747. /**
  6748. * The weight of the runtime animation
  6749. */
  6750. private _weight;
  6751. /**
  6752. * The ratio offset of the runtime animation
  6753. */
  6754. private _ratioOffset;
  6755. /**
  6756. * The previous delay of the runtime animation
  6757. */
  6758. private _previousDelay;
  6759. /**
  6760. * The previous ratio of the runtime animation
  6761. */
  6762. private _previousRatio;
  6763. /**
  6764. * Gets the current frame of the runtime animation
  6765. */
  6766. readonly currentFrame: number;
  6767. /**
  6768. * Gets the weight of the runtime animation
  6769. */
  6770. readonly weight: number;
  6771. /**
  6772. * Gets the current value of the runtime animation
  6773. */
  6774. readonly currentValue: any;
  6775. /**
  6776. * Gets the target path of the runtime animation
  6777. */
  6778. readonly targetPath: string;
  6779. /**
  6780. * Gets the actual target of the runtime animation
  6781. */
  6782. readonly target: any;
  6783. /**
  6784. * Create a new RuntimeAnimation object
  6785. * @param target defines the target of the animation
  6786. * @param animation defines the source animation object
  6787. * @param scene defines the hosting scene
  6788. * @param host defines the initiating Animatable
  6789. */
  6790. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  6791. /**
  6792. * Gets the animation from the runtime animation
  6793. */
  6794. readonly animation: Animation;
  6795. /**
  6796. * Resets the runtime animation to the beginning
  6797. * @param restoreOriginal defines whether to restore the target property to the original value
  6798. */
  6799. reset(restoreOriginal?: boolean): void;
  6800. /**
  6801. * Specifies if the runtime animation is stopped
  6802. * @returns Boolean specifying if the runtime animation is stopped
  6803. */
  6804. isStopped(): boolean;
  6805. /**
  6806. * Disposes of the runtime animation
  6807. */
  6808. dispose(): void;
  6809. /**
  6810. * Interpolates the animation from the current frame
  6811. * @param currentFrame The frame to interpolate the animation to
  6812. * @param repeatCount The number of times that the animation should loop
  6813. * @param loopMode The type of looping mode to use
  6814. * @param offsetValue Animation offset value
  6815. * @param highLimitValue The high limit value
  6816. * @returns The interpolated value
  6817. */
  6818. private _interpolate;
  6819. /**
  6820. * Apply the interpolated value to the target
  6821. * @param currentValue defines the value computed by the animation
  6822. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  6823. */
  6824. setValue(currentValue: any, weight?: number): void;
  6825. private _setValue;
  6826. /**
  6827. * Gets the loop pmode of the runtime animation
  6828. * @returns Loop Mode
  6829. */
  6830. private _getCorrectLoopMode;
  6831. /**
  6832. * Move the current animation to a given frame
  6833. * @param frame defines the frame to move to
  6834. */
  6835. goToFrame(frame: number): void;
  6836. /**
  6837. * @hidden Internal use only
  6838. */ prepareForSpeedRatioChange(newSpeedRatio: number): void;
  6839. /**
  6840. * Execute the current animation
  6841. * @param delay defines the delay to add to the current frame
  6842. * @param from defines the lower bound of the animation range
  6843. * @param to defines the upper bound of the animation range
  6844. * @param loop defines if the current animation must loop
  6845. * @param speedRatio defines the current speed ratio
  6846. * @param weight defines the weight of the animation (default is -1 so no weight)
  6847. * @param onLoop optional callback called when animation loops
  6848. * @returns a boolean indicating if the animation is running
  6849. */
  6850. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  6851. }
  6852. }
  6853. declare module BABYLON {
  6854. /**
  6855. * @hidden
  6856. */
  6857. export class IntersectionInfo {
  6858. bu: Nullable<number>;
  6859. bv: Nullable<number>;
  6860. distance: number;
  6861. faceId: number;
  6862. subMeshId: number;
  6863. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6864. }
  6865. }
  6866. declare module BABYLON {
  6867. /**
  6868. * Class used to store bounding sphere information
  6869. */
  6870. export class BoundingSphere {
  6871. /**
  6872. * Gets the center of the bounding sphere in local space
  6873. */
  6874. readonly center: Vector3;
  6875. /**
  6876. * Radius of the bounding sphere in local space
  6877. */
  6878. radius: number;
  6879. /**
  6880. * Gets the center of the bounding sphere in world space
  6881. */
  6882. readonly centerWorld: Vector3;
  6883. /**
  6884. * Radius of the bounding sphere in world space
  6885. */
  6886. radiusWorld: number;
  6887. /**
  6888. * Gets the minimum vector in local space
  6889. */
  6890. readonly minimum: Vector3;
  6891. /**
  6892. * Gets the maximum vector in local space
  6893. */
  6894. readonly maximum: Vector3;
  6895. private _worldMatrix;
  6896. private static readonly TmpVector3;
  6897. /**
  6898. * Creates a new bounding sphere
  6899. * @param min defines the minimum vector (in local space)
  6900. * @param max defines the maximum vector (in local space)
  6901. * @param worldMatrix defines the new world matrix
  6902. */
  6903. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6904. /**
  6905. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6906. * @param min defines the new minimum vector (in local space)
  6907. * @param max defines the new maximum vector (in local space)
  6908. * @param worldMatrix defines the new world matrix
  6909. */
  6910. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6911. /**
  6912. * Scale the current bounding sphere by applying a scale factor
  6913. * @param factor defines the scale factor to apply
  6914. * @returns the current bounding box
  6915. */
  6916. scale(factor: number): BoundingSphere;
  6917. /**
  6918. * Gets the world matrix of the bounding box
  6919. * @returns a matrix
  6920. */
  6921. getWorldMatrix(): DeepImmutable<Matrix>;
  6922. /** @hidden */ update(worldMatrix: DeepImmutable<Matrix>): void;
  6923. /**
  6924. * Tests if the bounding sphere is intersecting the frustum planes
  6925. * @param frustumPlanes defines the frustum planes to test
  6926. * @returns true if there is an intersection
  6927. */
  6928. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6929. /**
  6930. * Tests if the bounding sphere center is in between the frustum planes.
  6931. * Used for optimistic fast inclusion.
  6932. * @param frustumPlanes defines the frustum planes to test
  6933. * @returns true if the sphere center is in between the frustum planes
  6934. */
  6935. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6936. /**
  6937. * Tests if a point is inside the bounding sphere
  6938. * @param point defines the point to test
  6939. * @returns true if the point is inside the bounding sphere
  6940. */
  6941. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6942. /**
  6943. * Checks if two sphere intersct
  6944. * @param sphere0 sphere 0
  6945. * @param sphere1 sphere 1
  6946. * @returns true if the speres intersect
  6947. */
  6948. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6949. }
  6950. }
  6951. declare module BABYLON {
  6952. /**
  6953. * Class used to store bounding box information
  6954. */
  6955. export class BoundingBox implements ICullable {
  6956. /**
  6957. * Gets the 8 vectors representing the bounding box in local space
  6958. */
  6959. readonly vectors: Vector3[];
  6960. /**
  6961. * Gets the center of the bounding box in local space
  6962. */
  6963. readonly center: Vector3;
  6964. /**
  6965. * Gets the center of the bounding box in world space
  6966. */
  6967. readonly centerWorld: Vector3;
  6968. /**
  6969. * Gets the extend size in local space
  6970. */
  6971. readonly extendSize: Vector3;
  6972. /**
  6973. * Gets the extend size in world space
  6974. */
  6975. readonly extendSizeWorld: Vector3;
  6976. /**
  6977. * Gets the OBB (object bounding box) directions
  6978. */
  6979. readonly directions: Vector3[];
  6980. /**
  6981. * Gets the 8 vectors representing the bounding box in world space
  6982. */
  6983. readonly vectorsWorld: Vector3[];
  6984. /**
  6985. * Gets the minimum vector in world space
  6986. */
  6987. readonly minimumWorld: Vector3;
  6988. /**
  6989. * Gets the maximum vector in world space
  6990. */
  6991. readonly maximumWorld: Vector3;
  6992. /**
  6993. * Gets the minimum vector in local space
  6994. */
  6995. readonly minimum: Vector3;
  6996. /**
  6997. * Gets the maximum vector in local space
  6998. */
  6999. readonly maximum: Vector3;
  7000. private _worldMatrix;
  7001. private static readonly TmpVector3;
  7002. /**
  7003. * @hidden
  7004. */ tag: number;
  7005. /**
  7006. * Creates a new bounding box
  7007. * @param min defines the minimum vector (in local space)
  7008. * @param max defines the maximum vector (in local space)
  7009. * @param worldMatrix defines the new world matrix
  7010. */
  7011. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7012. /**
  7013. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7014. * @param min defines the new minimum vector (in local space)
  7015. * @param max defines the new maximum vector (in local space)
  7016. * @param worldMatrix defines the new world matrix
  7017. */
  7018. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7019. /**
  7020. * Scale the current bounding box by applying a scale factor
  7021. * @param factor defines the scale factor to apply
  7022. * @returns the current bounding box
  7023. */
  7024. scale(factor: number): BoundingBox;
  7025. /**
  7026. * Gets the world matrix of the bounding box
  7027. * @returns a matrix
  7028. */
  7029. getWorldMatrix(): DeepImmutable<Matrix>;
  7030. /** @hidden */ update(world: DeepImmutable<Matrix>): void;
  7031. /**
  7032. * Tests if the bounding box is intersecting the frustum planes
  7033. * @param frustumPlanes defines the frustum planes to test
  7034. * @returns true if there is an intersection
  7035. */
  7036. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7037. /**
  7038. * Tests if the bounding box is entirely inside the frustum planes
  7039. * @param frustumPlanes defines the frustum planes to test
  7040. * @returns true if there is an inclusion
  7041. */
  7042. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7043. /**
  7044. * Tests if a point is inside the bounding box
  7045. * @param point defines the point to test
  7046. * @returns true if the point is inside the bounding box
  7047. */
  7048. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7049. /**
  7050. * Tests if the bounding box intersects with a bounding sphere
  7051. * @param sphere defines the sphere to test
  7052. * @returns true if there is an intersection
  7053. */
  7054. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7055. /**
  7056. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7057. * @param min defines the min vector to use
  7058. * @param max defines the max vector to use
  7059. * @returns true if there is an intersection
  7060. */
  7061. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7062. /**
  7063. * Tests if two bounding boxes are intersections
  7064. * @param box0 defines the first box to test
  7065. * @param box1 defines the second box to test
  7066. * @returns true if there is an intersection
  7067. */
  7068. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7069. /**
  7070. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7071. * @param minPoint defines the minimum vector of the bounding box
  7072. * @param maxPoint defines the maximum vector of the bounding box
  7073. * @param sphereCenter defines the sphere center
  7074. * @param sphereRadius defines the sphere radius
  7075. * @returns true if there is an intersection
  7076. */
  7077. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7078. /**
  7079. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7080. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7081. * @param frustumPlanes defines the frustum planes to test
  7082. * @return true if there is an inclusion
  7083. */
  7084. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7085. /**
  7086. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7087. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7088. * @param frustumPlanes defines the frustum planes to test
  7089. * @return true if there is an intersection
  7090. */
  7091. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7092. }
  7093. }
  7094. declare module BABYLON {
  7095. /** @hidden */
  7096. export class Collider {
  7097. /** Define if a collision was found */
  7098. collisionFound: boolean;
  7099. /**
  7100. * Define last intersection point in local space
  7101. */
  7102. intersectionPoint: Vector3;
  7103. /**
  7104. * Define last collided mesh
  7105. */
  7106. collidedMesh: Nullable<AbstractMesh>;
  7107. private _collisionPoint;
  7108. private _planeIntersectionPoint;
  7109. private _tempVector;
  7110. private _tempVector2;
  7111. private _tempVector3;
  7112. private _tempVector4;
  7113. private _edge;
  7114. private _baseToVertex;
  7115. private _destinationPoint;
  7116. private _slidePlaneNormal;
  7117. private _displacementVector;
  7118. /** @hidden */ radius: Vector3;
  7119. /** @hidden */ retry: number;
  7120. private _velocity;
  7121. private _basePoint;
  7122. private _epsilon;
  7123. /** @hidden */ velocityWorldLength: number;
  7124. /** @hidden */ basePointWorld: Vector3;
  7125. private _velocityWorld;
  7126. private _normalizedVelocity;
  7127. /** @hidden */ initialVelocity: Vector3;
  7128. /** @hidden */ initialPosition: Vector3;
  7129. private _nearestDistance;
  7130. private _collisionMask;
  7131. collisionMask: number;
  7132. /**
  7133. * Gets the plane normal used to compute the sliding response (in local space)
  7134. */
  7135. readonly slidePlaneNormal: Vector3;
  7136. /** @hidden */ initialize(source: Vector3, dir: Vector3, e: number): void;
  7137. /** @hidden */ checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7138. /** @hidden */ canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7139. /** @hidden */ testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7140. /** @hidden */ collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7141. /** @hidden */ getResponse(pos: Vector3, vel: Vector3): void;
  7142. }
  7143. }
  7144. declare module BABYLON {
  7145. /**
  7146. * Interface for cullable objects
  7147. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7148. */
  7149. export interface ICullable {
  7150. /**
  7151. * Checks if the object or part of the object is in the frustum
  7152. * @param frustumPlanes Camera near/planes
  7153. * @returns true if the object is in frustum otherwise false
  7154. */
  7155. isInFrustum(frustumPlanes: Plane[]): boolean;
  7156. /**
  7157. * Checks if a cullable object (mesh...) is in the camera frustum
  7158. * Unlike isInFrustum this cheks the full bounding box
  7159. * @param frustumPlanes Camera near/planes
  7160. * @returns true if the object is in frustum otherwise false
  7161. */
  7162. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7163. }
  7164. /**
  7165. * Info for a bounding data of a mesh
  7166. */
  7167. export class BoundingInfo implements ICullable {
  7168. /**
  7169. * Bounding box for the mesh
  7170. */
  7171. readonly boundingBox: BoundingBox;
  7172. /**
  7173. * Bounding sphere for the mesh
  7174. */
  7175. readonly boundingSphere: BoundingSphere;
  7176. private _isLocked;
  7177. private static readonly TmpVector3;
  7178. /**
  7179. * Constructs bounding info
  7180. * @param minimum min vector of the bounding box/sphere
  7181. * @param maximum max vector of the bounding box/sphere
  7182. * @param worldMatrix defines the new world matrix
  7183. */
  7184. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7185. /**
  7186. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7187. * @param min defines the new minimum vector (in local space)
  7188. * @param max defines the new maximum vector (in local space)
  7189. * @param worldMatrix defines the new world matrix
  7190. */
  7191. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7192. /**
  7193. * min vector of the bounding box/sphere
  7194. */
  7195. readonly minimum: Vector3;
  7196. /**
  7197. * max vector of the bounding box/sphere
  7198. */
  7199. readonly maximum: Vector3;
  7200. /**
  7201. * If the info is locked and won't be updated to avoid perf overhead
  7202. */
  7203. isLocked: boolean;
  7204. /**
  7205. * Updates the bounding sphere and box
  7206. * @param world world matrix to be used to update
  7207. */
  7208. update(world: DeepImmutable<Matrix>): void;
  7209. /**
  7210. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7211. * @param center New center of the bounding info
  7212. * @param extend New extend of the bounding info
  7213. * @returns the current bounding info
  7214. */
  7215. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7216. /**
  7217. * Scale the current bounding info by applying a scale factor
  7218. * @param factor defines the scale factor to apply
  7219. * @returns the current bounding info
  7220. */
  7221. scale(factor: number): BoundingInfo;
  7222. /**
  7223. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7224. * @param frustumPlanes defines the frustum to test
  7225. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7226. * @returns true if the bounding info is in the frustum planes
  7227. */
  7228. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7229. /**
  7230. * Gets the world distance between the min and max points of the bounding box
  7231. */
  7232. readonly diagonalLength: number;
  7233. /**
  7234. * Checks if a cullable object (mesh...) is in the camera frustum
  7235. * Unlike isInFrustum this cheks the full bounding box
  7236. * @param frustumPlanes Camera near/planes
  7237. * @returns true if the object is in frustum otherwise false
  7238. */
  7239. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7240. /** @hidden */ checkCollision(collider: Collider): boolean;
  7241. /**
  7242. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7243. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7244. * @param point the point to check intersection with
  7245. * @returns if the point intersects
  7246. */
  7247. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7248. /**
  7249. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7250. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7251. * @param boundingInfo the bounding info to check intersection with
  7252. * @param precise if the intersection should be done using OBB
  7253. * @returns if the bounding info intersects
  7254. */
  7255. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7256. }
  7257. }
  7258. declare module BABYLON {
  7259. /**
  7260. * Defines an array and its length.
  7261. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7262. */
  7263. export interface ISmartArrayLike<T> {
  7264. /**
  7265. * The data of the array.
  7266. */
  7267. data: Array<T>;
  7268. /**
  7269. * The active length of the array.
  7270. */
  7271. length: number;
  7272. }
  7273. /**
  7274. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7275. */
  7276. export class SmartArray<T> implements ISmartArrayLike<T> {
  7277. /**
  7278. * The full set of data from the array.
  7279. */
  7280. data: Array<T>;
  7281. /**
  7282. * The active length of the array.
  7283. */
  7284. length: number;
  7285. protected _id: number;
  7286. /**
  7287. * Instantiates a Smart Array.
  7288. * @param capacity defines the default capacity of the array.
  7289. */
  7290. constructor(capacity: number);
  7291. /**
  7292. * Pushes a value at the end of the active data.
  7293. * @param value defines the object to push in the array.
  7294. */
  7295. push(value: T): void;
  7296. /**
  7297. * Iterates over the active data and apply the lambda to them.
  7298. * @param func defines the action to apply on each value.
  7299. */
  7300. forEach(func: (content: T) => void): void;
  7301. /**
  7302. * Sorts the full sets of data.
  7303. * @param compareFn defines the comparison function to apply.
  7304. */
  7305. sort(compareFn: (a: T, b: T) => number): void;
  7306. /**
  7307. * Resets the active data to an empty array.
  7308. */
  7309. reset(): void;
  7310. /**
  7311. * Releases all the data from the array as well as the array.
  7312. */
  7313. dispose(): void;
  7314. /**
  7315. * Concats the active data with a given array.
  7316. * @param array defines the data to concatenate with.
  7317. */
  7318. concat(array: any): void;
  7319. /**
  7320. * Returns the position of a value in the active data.
  7321. * @param value defines the value to find the index for
  7322. * @returns the index if found in the active data otherwise -1
  7323. */
  7324. indexOf(value: T): number;
  7325. /**
  7326. * Returns whether an element is part of the active data.
  7327. * @param value defines the value to look for
  7328. * @returns true if found in the active data otherwise false
  7329. */
  7330. contains(value: T): boolean;
  7331. private static _GlobalId;
  7332. }
  7333. /**
  7334. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7335. * The data in this array can only be present once
  7336. */
  7337. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7338. private _duplicateId;
  7339. /**
  7340. * Pushes a value at the end of the active data.
  7341. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7342. * @param value defines the object to push in the array.
  7343. */
  7344. push(value: T): void;
  7345. /**
  7346. * Pushes a value at the end of the active data.
  7347. * If the data is already present, it won t be added again
  7348. * @param value defines the object to push in the array.
  7349. * @returns true if added false if it was already present
  7350. */
  7351. pushNoDuplicate(value: T): boolean;
  7352. /**
  7353. * Resets the active data to an empty array.
  7354. */
  7355. reset(): void;
  7356. /**
  7357. * Concats the active data with a given array.
  7358. * This ensures no dupplicate will be present in the result.
  7359. * @param array defines the data to concatenate with.
  7360. */
  7361. concatWithNoDuplicate(array: any): void;
  7362. }
  7363. }
  7364. declare module BABYLON {
  7365. /**
  7366. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7367. * separate meshes. This can be use to improve performances.
  7368. * @see http://doc.babylonjs.com/how_to/multi_materials
  7369. */
  7370. export class MultiMaterial extends Material {
  7371. private _subMaterials;
  7372. /**
  7373. * Gets or Sets the list of Materials used within the multi material.
  7374. * They need to be ordered according to the submeshes order in the associated mesh
  7375. */
  7376. subMaterials: Nullable<Material>[];
  7377. /**
  7378. * Function used to align with Node.getChildren()
  7379. * @returns the list of Materials used within the multi material
  7380. */
  7381. getChildren(): Nullable<Material>[];
  7382. /**
  7383. * Instantiates a new Multi Material
  7384. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7385. * separate meshes. This can be use to improve performances.
  7386. * @see http://doc.babylonjs.com/how_to/multi_materials
  7387. * @param name Define the name in the scene
  7388. * @param scene Define the scene the material belongs to
  7389. */
  7390. constructor(name: string, scene: Scene);
  7391. private _hookArray;
  7392. /**
  7393. * Get one of the submaterial by its index in the submaterials array
  7394. * @param index The index to look the sub material at
  7395. * @returns The Material if the index has been defined
  7396. */
  7397. getSubMaterial(index: number): Nullable<Material>;
  7398. /**
  7399. * Get the list of active textures for the whole sub materials list.
  7400. * @returns All the textures that will be used during the rendering
  7401. */
  7402. getActiveTextures(): BaseTexture[];
  7403. /**
  7404. * Gets the current class name of the material e.g. "MultiMaterial"
  7405. * Mainly use in serialization.
  7406. * @returns the class name
  7407. */
  7408. getClassName(): string;
  7409. /**
  7410. * Checks if the material is ready to render the requested sub mesh
  7411. * @param mesh Define the mesh the submesh belongs to
  7412. * @param subMesh Define the sub mesh to look readyness for
  7413. * @param useInstances Define whether or not the material is used with instances
  7414. * @returns true if ready, otherwise false
  7415. */
  7416. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7417. /**
  7418. * Clones the current material and its related sub materials
  7419. * @param name Define the name of the newly cloned material
  7420. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7421. * @returns the cloned material
  7422. */
  7423. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7424. /**
  7425. * Serializes the materials into a JSON representation.
  7426. * @returns the JSON representation
  7427. */
  7428. serialize(): any;
  7429. /**
  7430. * Dispose the material and release its associated resources
  7431. * @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)
  7432. * @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)
  7433. * @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)
  7434. */
  7435. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7436. /**
  7437. * Creates a MultiMaterial from parsed MultiMaterial data.
  7438. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7439. * @param scene defines the hosting scene
  7440. * @returns a new MultiMaterial
  7441. */
  7442. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7443. }
  7444. }
  7445. declare module BABYLON {
  7446. /**
  7447. * Class used to represent data loading progression
  7448. */
  7449. export class SceneLoaderFlags {
  7450. private static _ForceFullSceneLoadingForIncremental;
  7451. private static _ShowLoadingScreen;
  7452. private static _CleanBoneMatrixWeights;
  7453. private static _loggingLevel;
  7454. /**
  7455. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7456. */
  7457. static ForceFullSceneLoadingForIncremental: boolean;
  7458. /**
  7459. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7460. */
  7461. static ShowLoadingScreen: boolean;
  7462. /**
  7463. * Defines the current logging level (while loading the scene)
  7464. * @ignorenaming
  7465. */
  7466. static loggingLevel: number;
  7467. /**
  7468. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7469. */
  7470. static CleanBoneMatrixWeights: boolean;
  7471. }
  7472. }
  7473. declare module BABYLON {
  7474. /**
  7475. * Class used to override all child animations of a given target
  7476. */
  7477. export class AnimationPropertiesOverride {
  7478. /**
  7479. * Gets or sets a value indicating if animation blending must be used
  7480. */
  7481. enableBlending: boolean;
  7482. /**
  7483. * Gets or sets the blending speed to use when enableBlending is true
  7484. */
  7485. blendingSpeed: number;
  7486. /**
  7487. * Gets or sets the default loop mode to use
  7488. */
  7489. loopMode: number;
  7490. }
  7491. }
  7492. declare module BABYLON {
  7493. /**
  7494. * Defines a target to use with MorphTargetManager
  7495. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  7496. */
  7497. export class MorphTarget implements IAnimatable {
  7498. /** defines the name of the target */
  7499. name: string;
  7500. /**
  7501. * Gets or sets the list of animations
  7502. */
  7503. animations: Animation[];
  7504. private _scene;
  7505. private _positions;
  7506. private _normals;
  7507. private _tangents;
  7508. private _influence;
  7509. /**
  7510. * Observable raised when the influence changes
  7511. */
  7512. onInfluenceChanged: Observable<boolean>;
  7513. /** @hidden */ onDataLayoutChanged: Observable<void>;
  7514. /**
  7515. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  7516. */
  7517. influence: number;
  7518. /**
  7519. * Gets or sets the id of the morph Target
  7520. */
  7521. id: string;
  7522. private _animationPropertiesOverride;
  7523. /**
  7524. * Gets or sets the animation properties override
  7525. */
  7526. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  7527. /**
  7528. * Creates a new MorphTarget
  7529. * @param name defines the name of the target
  7530. * @param influence defines the influence to use
  7531. * @param scene defines the scene the morphtarget belongs to
  7532. */
  7533. constructor(
  7534. /** defines the name of the target */
  7535. name: string, influence?: number, scene?: Nullable<Scene>);
  7536. /**
  7537. * Gets a boolean defining if the target contains position data
  7538. */
  7539. readonly hasPositions: boolean;
  7540. /**
  7541. * Gets a boolean defining if the target contains normal data
  7542. */
  7543. readonly hasNormals: boolean;
  7544. /**
  7545. * Gets a boolean defining if the target contains tangent data
  7546. */
  7547. readonly hasTangents: boolean;
  7548. /**
  7549. * Affects position data to this target
  7550. * @param data defines the position data to use
  7551. */
  7552. setPositions(data: Nullable<FloatArray>): void;
  7553. /**
  7554. * Gets the position data stored in this target
  7555. * @returns a FloatArray containing the position data (or null if not present)
  7556. */
  7557. getPositions(): Nullable<FloatArray>;
  7558. /**
  7559. * Affects normal data to this target
  7560. * @param data defines the normal data to use
  7561. */
  7562. setNormals(data: Nullable<FloatArray>): void;
  7563. /**
  7564. * Gets the normal data stored in this target
  7565. * @returns a FloatArray containing the normal data (or null if not present)
  7566. */
  7567. getNormals(): Nullable<FloatArray>;
  7568. /**
  7569. * Affects tangent data to this target
  7570. * @param data defines the tangent data to use
  7571. */
  7572. setTangents(data: Nullable<FloatArray>): void;
  7573. /**
  7574. * Gets the tangent data stored in this target
  7575. * @returns a FloatArray containing the tangent data (or null if not present)
  7576. */
  7577. getTangents(): Nullable<FloatArray>;
  7578. /**
  7579. * Serializes the current target into a Serialization object
  7580. * @returns the serialized object
  7581. */
  7582. serialize(): any;
  7583. /**
  7584. * Returns the string "MorphTarget"
  7585. * @returns "MorphTarget"
  7586. */
  7587. getClassName(): string;
  7588. /**
  7589. * Creates a new target from serialized data
  7590. * @param serializationObject defines the serialized data to use
  7591. * @returns a new MorphTarget
  7592. */
  7593. static Parse(serializationObject: any): MorphTarget;
  7594. /**
  7595. * Creates a MorphTarget from mesh data
  7596. * @param mesh defines the source mesh
  7597. * @param name defines the name to use for the new target
  7598. * @param influence defines the influence to attach to the target
  7599. * @returns a new MorphTarget
  7600. */
  7601. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  7602. }
  7603. }
  7604. declare module BABYLON {
  7605. /**
  7606. * This class is used to deform meshes using morphing between different targets
  7607. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  7608. */
  7609. export class MorphTargetManager {
  7610. private _targets;
  7611. private _targetInfluenceChangedObservers;
  7612. private _targetDataLayoutChangedObservers;
  7613. private _activeTargets;
  7614. private _scene;
  7615. private _influences;
  7616. private _supportsNormals;
  7617. private _supportsTangents;
  7618. private _vertexCount;
  7619. private _uniqueId;
  7620. private _tempInfluences;
  7621. /**
  7622. * Creates a new MorphTargetManager
  7623. * @param scene defines the current scene
  7624. */
  7625. constructor(scene?: Nullable<Scene>);
  7626. /**
  7627. * Gets the unique ID of this manager
  7628. */
  7629. readonly uniqueId: number;
  7630. /**
  7631. * Gets the number of vertices handled by this manager
  7632. */
  7633. readonly vertexCount: number;
  7634. /**
  7635. * Gets a boolean indicating if this manager supports morphing of normals
  7636. */
  7637. readonly supportsNormals: boolean;
  7638. /**
  7639. * Gets a boolean indicating if this manager supports morphing of tangents
  7640. */
  7641. readonly supportsTangents: boolean;
  7642. /**
  7643. * Gets the number of targets stored in this manager
  7644. */
  7645. readonly numTargets: number;
  7646. /**
  7647. * Gets the number of influencers (ie. the number of targets with influences > 0)
  7648. */
  7649. readonly numInfluencers: number;
  7650. /**
  7651. * Gets the list of influences (one per target)
  7652. */
  7653. readonly influences: Float32Array;
  7654. /**
  7655. * Gets the active target at specified index. An active target is a target with an influence > 0
  7656. * @param index defines the index to check
  7657. * @returns the requested target
  7658. */
  7659. getActiveTarget(index: number): MorphTarget;
  7660. /**
  7661. * Gets the target at specified index
  7662. * @param index defines the index to check
  7663. * @returns the requested target
  7664. */
  7665. getTarget(index: number): MorphTarget;
  7666. /**
  7667. * Add a new target to this manager
  7668. * @param target defines the target to add
  7669. */
  7670. addTarget(target: MorphTarget): void;
  7671. /**
  7672. * Removes a target from the manager
  7673. * @param target defines the target to remove
  7674. */
  7675. removeTarget(target: MorphTarget): void;
  7676. /**
  7677. * Serializes the current manager into a Serialization object
  7678. * @returns the serialized object
  7679. */
  7680. serialize(): any;
  7681. private _syncActiveTargets;
  7682. /**
  7683. * Syncrhonize the targets with all the meshes using this morph target manager
  7684. */
  7685. synchronize(): void;
  7686. /**
  7687. * Creates a new MorphTargetManager from serialized data
  7688. * @param serializationObject defines the serialized data
  7689. * @param scene defines the hosting scene
  7690. * @returns the new MorphTargetManager
  7691. */
  7692. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  7693. }
  7694. }
  7695. declare module BABYLON {
  7696. /**
  7697. * Creates an instance based on a source mesh.
  7698. */
  7699. export class InstancedMesh extends AbstractMesh {
  7700. private _sourceMesh;
  7701. private _currentLOD;
  7702. /** @hidden */ indexInSourceMeshInstanceArray: number;
  7703. constructor(name: string, source: Mesh);
  7704. /**
  7705. * Returns the string "InstancedMesh".
  7706. */
  7707. getClassName(): string;
  7708. /**
  7709. * If the source mesh receives shadows
  7710. */
  7711. readonly receiveShadows: boolean;
  7712. /**
  7713. * The material of the source mesh
  7714. */
  7715. readonly material: Nullable<Material>;
  7716. /**
  7717. * Visibility of the source mesh
  7718. */
  7719. readonly visibility: number;
  7720. /**
  7721. * Skeleton of the source mesh
  7722. */
  7723. readonly skeleton: Nullable<Skeleton>;
  7724. /**
  7725. * Rendering ground id of the source mesh
  7726. */
  7727. renderingGroupId: number;
  7728. /**
  7729. * Returns the total number of vertices (integer).
  7730. */
  7731. getTotalVertices(): number;
  7732. /**
  7733. * Returns a positive integer : the total number of indices in this mesh geometry.
  7734. * @returns the numner of indices or zero if the mesh has no geometry.
  7735. */
  7736. getTotalIndices(): number;
  7737. /**
  7738. * The source mesh of the instance
  7739. */
  7740. readonly sourceMesh: Mesh;
  7741. /**
  7742. * Is this node ready to be used/rendered
  7743. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  7744. * @return {boolean} is it ready
  7745. */
  7746. isReady(completeCheck?: boolean): boolean;
  7747. /**
  7748. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  7749. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  7750. * @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.
  7751. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  7752. */
  7753. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  7754. /**
  7755. * Sets the vertex data of the mesh geometry for the requested `kind`.
  7756. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  7757. * The `data` are either a numeric array either a Float32Array.
  7758. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  7759. * 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).
  7760. * Note that a new underlying VertexBuffer object is created each call.
  7761. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  7762. *
  7763. * Possible `kind` values :
  7764. * - VertexBuffer.PositionKind
  7765. * - VertexBuffer.UVKind
  7766. * - VertexBuffer.UV2Kind
  7767. * - VertexBuffer.UV3Kind
  7768. * - VertexBuffer.UV4Kind
  7769. * - VertexBuffer.UV5Kind
  7770. * - VertexBuffer.UV6Kind
  7771. * - VertexBuffer.ColorKind
  7772. * - VertexBuffer.MatricesIndicesKind
  7773. * - VertexBuffer.MatricesIndicesExtraKind
  7774. * - VertexBuffer.MatricesWeightsKind
  7775. * - VertexBuffer.MatricesWeightsExtraKind
  7776. *
  7777. * Returns the Mesh.
  7778. */
  7779. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  7780. /**
  7781. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  7782. * If the mesh has no geometry, it is simply returned as it is.
  7783. * The `data` are either a numeric array either a Float32Array.
  7784. * No new underlying VertexBuffer object is created.
  7785. * 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.
  7786. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  7787. *
  7788. * Possible `kind` values :
  7789. * - VertexBuffer.PositionKind
  7790. * - VertexBuffer.UVKind
  7791. * - VertexBuffer.UV2Kind
  7792. * - VertexBuffer.UV3Kind
  7793. * - VertexBuffer.UV4Kind
  7794. * - VertexBuffer.UV5Kind
  7795. * - VertexBuffer.UV6Kind
  7796. * - VertexBuffer.ColorKind
  7797. * - VertexBuffer.MatricesIndicesKind
  7798. * - VertexBuffer.MatricesIndicesExtraKind
  7799. * - VertexBuffer.MatricesWeightsKind
  7800. * - VertexBuffer.MatricesWeightsExtraKind
  7801. *
  7802. * Returns the Mesh.
  7803. */
  7804. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  7805. /**
  7806. * Sets the mesh indices.
  7807. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  7808. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  7809. * This method creates a new index buffer each call.
  7810. * Returns the Mesh.
  7811. */
  7812. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  7813. /**
  7814. * Boolean : True if the mesh owns the requested kind of data.
  7815. */
  7816. isVerticesDataPresent(kind: string): boolean;
  7817. /**
  7818. * Returns an array of indices (IndicesArray).
  7819. */
  7820. getIndices(): Nullable<IndicesArray>; protected readonly _positions: Nullable<Vector3[]>;
  7821. /**
  7822. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  7823. * This means the mesh underlying bounding box and sphere are recomputed.
  7824. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  7825. * @returns the current mesh
  7826. */
  7827. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  7828. /** @hidden */ preActivate(): InstancedMesh;
  7829. /** @hidden */ activate(renderId: number): InstancedMesh;
  7830. /**
  7831. * Returns the current associated LOD AbstractMesh.
  7832. */
  7833. getLOD(camera: Camera): AbstractMesh;
  7834. /** @hidden */ syncSubMeshes(): InstancedMesh;
  7835. /** @hidden */ generatePointsArray(): boolean;
  7836. /**
  7837. * Creates a new InstancedMesh from the current mesh.
  7838. * - name (string) : the cloned mesh name
  7839. * - newParent (optional Node) : the optional Node to parent the clone to.
  7840. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  7841. *
  7842. * Returns the clone.
  7843. */
  7844. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  7845. /**
  7846. * Disposes the InstancedMesh.
  7847. * Returns nothing.
  7848. */
  7849. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7850. }
  7851. }
  7852. declare module BABYLON {
  7853. /**
  7854. * Class for creating a cube texture
  7855. */
  7856. export class CubeTexture extends BaseTexture {
  7857. private _delayedOnLoad;
  7858. /**
  7859. * The url of the texture
  7860. */
  7861. url: string;
  7862. /**
  7863. * Gets or sets the center of the bounding box associated with the cube texture.
  7864. * It must define where the camera used to render the texture was set
  7865. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7866. */
  7867. boundingBoxPosition: Vector3;
  7868. private _boundingBoxSize;
  7869. /**
  7870. * Gets or sets the size of the bounding box associated with the cube texture
  7871. * When defined, the cubemap will switch to local mode
  7872. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7873. * @example https://www.babylonjs-playground.com/#RNASML
  7874. */
  7875. /**
  7876. * Returns the bounding box size
  7877. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7878. */
  7879. boundingBoxSize: Vector3;
  7880. protected _rotationY: number;
  7881. /**
  7882. * Sets texture matrix rotation angle around Y axis in radians.
  7883. */
  7884. /**
  7885. * Gets texture matrix rotation angle around Y axis radians.
  7886. */
  7887. rotationY: number;
  7888. /**
  7889. * Are mip maps generated for this texture or not.
  7890. */
  7891. readonly noMipmap: boolean;
  7892. private _noMipmap;
  7893. private _files;
  7894. private _extensions;
  7895. private _textureMatrix;
  7896. private _format;
  7897. private _createPolynomials;
  7898. /** @hidden */ prefiltered: boolean;
  7899. /**
  7900. * Creates a cube texture from an array of image urls
  7901. * @param files defines an array of image urls
  7902. * @param scene defines the hosting scene
  7903. * @param noMipmap specifies if mip maps are not used
  7904. * @returns a cube texture
  7905. */
  7906. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7907. /**
  7908. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7909. * @param url defines the url of the prefiltered texture
  7910. * @param scene defines the scene the texture is attached to
  7911. * @param forcedExtension defines the extension of the file if different from the url
  7912. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7913. * @return the prefiltered texture
  7914. */
  7915. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7916. /**
  7917. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7918. * as prefiltered data.
  7919. * @param rootUrl defines the url of the texture or the root name of the six images
  7920. * @param scene defines the scene the texture is attached to
  7921. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7922. * @param noMipmap defines if mipmaps should be created or not
  7923. * @param files defines the six files to load for the different faces
  7924. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7925. * @param onError defines a callback triggered in case of error during load
  7926. * @param format defines the internal format to use for the texture once loaded
  7927. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7928. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7929. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7930. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7931. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7932. * @return the cube texture
  7933. */
  7934. 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);
  7935. /**
  7936. * Get the current class name of the texture useful for serialization or dynamic coding.
  7937. * @returns "CubeTexture"
  7938. */
  7939. getClassName(): string;
  7940. /**
  7941. * Update the url (and optional buffer) of this texture if url was null during construction.
  7942. * @param url the url of the texture
  7943. * @param forcedExtension defines the extension to use
  7944. * @param onLoad callback called when the texture is loaded (defaults to null)
  7945. */
  7946. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7947. /**
  7948. * Delays loading of the cube texture
  7949. * @param forcedExtension defines the extension to use
  7950. */
  7951. delayLoad(forcedExtension?: string): void;
  7952. /**
  7953. * Returns the reflection texture matrix
  7954. * @returns the reflection texture matrix
  7955. */
  7956. getReflectionTextureMatrix(): Matrix;
  7957. /**
  7958. * Sets the reflection texture matrix
  7959. * @param value Reflection texture matrix
  7960. */
  7961. setReflectionTextureMatrix(value: Matrix): void;
  7962. /**
  7963. * Parses text to create a cube texture
  7964. * @param parsedTexture define the serialized text to read from
  7965. * @param scene defines the hosting scene
  7966. * @param rootUrl defines the root url of the cube texture
  7967. * @returns a cube texture
  7968. */
  7969. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7970. /**
  7971. * Makes a clone, or deep copy, of the cube texture
  7972. * @returns a new cube texture
  7973. */
  7974. clone(): CubeTexture;
  7975. }
  7976. }
  7977. declare module BABYLON {
  7978. /** @hidden */
  7979. export var postprocessVertexShader: {
  7980. name: string;
  7981. shader: string;
  7982. };
  7983. }
  7984. declare module BABYLON {
  7985. /**
  7986. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  7987. * This is the base of the follow, arc rotate cameras and Free camera
  7988. * @see http://doc.babylonjs.com/features/cameras
  7989. */
  7990. export class TargetCamera extends Camera {
  7991. private static _RigCamTransformMatrix;
  7992. private static _TargetTransformMatrix;
  7993. private static _TargetFocalPoint;
  7994. /**
  7995. * Define the current direction the camera is moving to
  7996. */
  7997. cameraDirection: Vector3;
  7998. /**
  7999. * Define the current rotation the camera is rotating to
  8000. */
  8001. cameraRotation: Vector2;
  8002. /**
  8003. * When set, the up vector of the camera will be updated by the rotation of the camera
  8004. */
  8005. updateUpVectorFromRotation: boolean;
  8006. private _tmpQuaternion;
  8007. /**
  8008. * Define the current rotation of the camera
  8009. */
  8010. rotation: Vector3;
  8011. /**
  8012. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8013. */
  8014. rotationQuaternion: Quaternion;
  8015. /**
  8016. * Define the current speed of the camera
  8017. */
  8018. speed: number;
  8019. /**
  8020. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8021. * around all axis.
  8022. */
  8023. noRotationConstraint: boolean;
  8024. /**
  8025. * Define the current target of the camera as an object or a position.
  8026. */
  8027. lockedTarget: any;
  8028. /** @hidden */ currentTarget: Vector3;
  8029. /** @hidden */ initialFocalDistance: number;
  8030. /** @hidden */ viewMatrix: Matrix;
  8031. /** @hidden */ camMatrix: Matrix;
  8032. /** @hidden */ cameraTransformMatrix: Matrix;
  8033. /** @hidden */ cameraRotationMatrix: Matrix;
  8034. /** @hidden */ referencePoint: Vector3;
  8035. /** @hidden */ transformedReferencePoint: Vector3;
  8036. protected _globalCurrentTarget: Vector3;
  8037. protected _globalCurrentUpVector: Vector3;
  8038. /** @hidden */ reset: () => void;
  8039. private _defaultUp;
  8040. /**
  8041. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8042. * This is the base of the follow, arc rotate cameras and Free camera
  8043. * @see http://doc.babylonjs.com/features/cameras
  8044. * @param name Defines the name of the camera in the scene
  8045. * @param position Defines the start position of the camera in the scene
  8046. * @param scene Defines the scene the camera belongs to
  8047. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8048. */
  8049. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8050. /**
  8051. * Gets the position in front of the camera at a given distance.
  8052. * @param distance The distance from the camera we want the position to be
  8053. * @returns the position
  8054. */
  8055. getFrontPosition(distance: number): Vector3;
  8056. /** @hidden */ getLockedTargetPosition(): Nullable<Vector3>;
  8057. private _storedPosition;
  8058. private _storedRotation;
  8059. private _storedRotationQuaternion;
  8060. /**
  8061. * Store current camera state of the camera (fov, position, rotation, etc..)
  8062. * @returns the camera
  8063. */
  8064. storeState(): Camera;
  8065. /**
  8066. * Restored camera state. You must call storeState() first
  8067. * @returns whether it was successful or not
  8068. * @hidden
  8069. */ restoreStateValues(): boolean;
  8070. /** @hidden */ initCache(): void;
  8071. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  8072. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  8073. /** @hidden */ computeLocalCameraSpeed(): number;
  8074. /** @hidden */
  8075. setTarget(target: Vector3): void;
  8076. /**
  8077. * Return the current target position of the camera. This value is expressed in local space.
  8078. * @returns the target position
  8079. */
  8080. getTarget(): Vector3;
  8081. /** @hidden */ decideIfNeedsToMove(): boolean;
  8082. /** @hidden */ updatePosition(): void;
  8083. /** @hidden */ checkInputs(): void;
  8084. protected _updateCameraRotationMatrix(): void;
  8085. /**
  8086. * 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)
  8087. * @returns the current camera
  8088. */
  8089. private _rotateUpVectorWithCameraRotationMatrix;
  8090. private _cachedRotationZ;
  8091. private _cachedQuaternionRotationZ;
  8092. /** @hidden */ getViewMatrix(): Matrix;
  8093. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8094. /**
  8095. * @hidden
  8096. */
  8097. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8098. /**
  8099. * @hidden
  8100. */ updateRigCameras(): void;
  8101. private _getRigCamPositionAndTarget;
  8102. /**
  8103. * Gets the current object class name.
  8104. * @return the class name
  8105. */
  8106. getClassName(): string;
  8107. }
  8108. }
  8109. declare module BABYLON {
  8110. /**
  8111. * @ignore
  8112. * This is a list of all the different input types that are available in the application.
  8113. * Fo instance: ArcRotateCameraGamepadInput...
  8114. */
  8115. export var CameraInputTypes: {};
  8116. /**
  8117. * This is the contract to implement in order to create a new input class.
  8118. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8119. */
  8120. export interface ICameraInput<TCamera extends Camera> {
  8121. /**
  8122. * Defines the camera the input is attached to.
  8123. */
  8124. camera: Nullable<TCamera>;
  8125. /**
  8126. * Gets the class name of the current intput.
  8127. * @returns the class name
  8128. */
  8129. getClassName(): string;
  8130. /**
  8131. * Get the friendly name associated with the input class.
  8132. * @returns the input friendly name
  8133. */
  8134. getSimpleName(): string;
  8135. /**
  8136. * Attach the input controls to a specific dom element to get the input from.
  8137. * @param element Defines the element the controls should be listened from
  8138. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8139. */
  8140. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8141. /**
  8142. * Detach the current controls from the specified dom element.
  8143. * @param element Defines the element to stop listening the inputs from
  8144. */
  8145. detachControl(element: Nullable<HTMLElement>): void;
  8146. /**
  8147. * Update the current camera state depending on the inputs that have been used this frame.
  8148. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8149. */
  8150. checkInputs?: () => void;
  8151. }
  8152. /**
  8153. * Represents a map of input types to input instance or input index to input instance.
  8154. */
  8155. export interface CameraInputsMap<TCamera extends Camera> {
  8156. /**
  8157. * Accessor to the input by input type.
  8158. */
  8159. [name: string]: ICameraInput<TCamera>;
  8160. /**
  8161. * Accessor to the input by input index.
  8162. */
  8163. [idx: number]: ICameraInput<TCamera>;
  8164. }
  8165. /**
  8166. * This represents the input manager used within a camera.
  8167. * It helps dealing with all the different kind of input attached to a camera.
  8168. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8169. */
  8170. export class CameraInputsManager<TCamera extends Camera> {
  8171. /**
  8172. * Defines the list of inputs attahed to the camera.
  8173. */
  8174. attached: CameraInputsMap<TCamera>;
  8175. /**
  8176. * Defines the dom element the camera is collecting inputs from.
  8177. * This is null if the controls have not been attached.
  8178. */
  8179. attachedElement: Nullable<HTMLElement>;
  8180. /**
  8181. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8182. */
  8183. noPreventDefault: boolean;
  8184. /**
  8185. * Defined the camera the input manager belongs to.
  8186. */
  8187. camera: TCamera;
  8188. /**
  8189. * Update the current camera state depending on the inputs that have been used this frame.
  8190. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8191. */
  8192. checkInputs: () => void;
  8193. /**
  8194. * Instantiate a new Camera Input Manager.
  8195. * @param camera Defines the camera the input manager blongs to
  8196. */
  8197. constructor(camera: TCamera);
  8198. /**
  8199. * Add an input method to a camera
  8200. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8201. * @param input camera input method
  8202. */
  8203. add(input: ICameraInput<TCamera>): void;
  8204. /**
  8205. * Remove a specific input method from a camera
  8206. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8207. * @param inputToRemove camera input method
  8208. */
  8209. remove(inputToRemove: ICameraInput<TCamera>): void;
  8210. /**
  8211. * Remove a specific input type from a camera
  8212. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8213. * @param inputType the type of the input to remove
  8214. */
  8215. removeByType(inputType: string): void;
  8216. private _addCheckInputs;
  8217. /**
  8218. * Attach the input controls to the currently attached dom element to listen the events from.
  8219. * @param input Defines the input to attach
  8220. */
  8221. attachInput(input: ICameraInput<TCamera>): void;
  8222. /**
  8223. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8224. * @param element Defines the dom element to collect the events from
  8225. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8226. */
  8227. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8228. /**
  8229. * Detach the current manager inputs controls from a specific dom element.
  8230. * @param element Defines the dom element to collect the events from
  8231. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8232. */
  8233. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8234. /**
  8235. * Rebuild the dynamic inputCheck function from the current list of
  8236. * defined inputs in the manager.
  8237. */
  8238. rebuildInputCheck(): void;
  8239. /**
  8240. * Remove all attached input methods from a camera
  8241. */
  8242. clear(): void;
  8243. /**
  8244. * Serialize the current input manager attached to a camera.
  8245. * This ensures than once parsed,
  8246. * the input associated to the camera will be identical to the current ones
  8247. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8248. */
  8249. serialize(serializedCamera: any): void;
  8250. /**
  8251. * Parses an input manager serialized JSON to restore the previous list of inputs
  8252. * and states associated to a camera.
  8253. * @param parsedCamera Defines the JSON to parse
  8254. */
  8255. parse(parsedCamera: any): void;
  8256. }
  8257. }
  8258. declare module BABYLON {
  8259. /**
  8260. * Gather the list of keyboard event types as constants.
  8261. */
  8262. export class KeyboardEventTypes {
  8263. /**
  8264. * The keydown event is fired when a key becomes active (pressed).
  8265. */
  8266. static readonly KEYDOWN: number;
  8267. /**
  8268. * The keyup event is fired when a key has been released.
  8269. */
  8270. static readonly KEYUP: number;
  8271. }
  8272. /**
  8273. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8274. */
  8275. export class KeyboardInfo {
  8276. /**
  8277. * Defines the type of event (KeyboardEventTypes)
  8278. */
  8279. type: number;
  8280. /**
  8281. * Defines the related dom event
  8282. */
  8283. event: KeyboardEvent;
  8284. /**
  8285. * Instantiates a new keyboard info.
  8286. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8287. * @param type Defines the type of event (KeyboardEventTypes)
  8288. * @param event Defines the related dom event
  8289. */
  8290. constructor(
  8291. /**
  8292. * Defines the type of event (KeyboardEventTypes)
  8293. */
  8294. type: number,
  8295. /**
  8296. * Defines the related dom event
  8297. */
  8298. event: KeyboardEvent);
  8299. }
  8300. /**
  8301. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8302. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8303. */
  8304. export class KeyboardInfoPre extends KeyboardInfo {
  8305. /**
  8306. * Defines the type of event (KeyboardEventTypes)
  8307. */
  8308. type: number;
  8309. /**
  8310. * Defines the related dom event
  8311. */
  8312. event: KeyboardEvent;
  8313. /**
  8314. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8315. */
  8316. skipOnPointerObservable: boolean;
  8317. /**
  8318. * Instantiates a new keyboard pre info.
  8319. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8320. * @param type Defines the type of event (KeyboardEventTypes)
  8321. * @param event Defines the related dom event
  8322. */
  8323. constructor(
  8324. /**
  8325. * Defines the type of event (KeyboardEventTypes)
  8326. */
  8327. type: number,
  8328. /**
  8329. * Defines the related dom event
  8330. */
  8331. event: KeyboardEvent);
  8332. }
  8333. }
  8334. declare module BABYLON {
  8335. /**
  8336. * Manage the keyboard inputs to control the movement of a free camera.
  8337. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8338. */
  8339. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8340. /**
  8341. * Defines the camera the input is attached to.
  8342. */
  8343. camera: FreeCamera;
  8344. /**
  8345. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8346. */
  8347. keysUp: number[];
  8348. /**
  8349. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8350. */
  8351. keysDown: number[];
  8352. /**
  8353. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8354. */
  8355. keysLeft: number[];
  8356. /**
  8357. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8358. */
  8359. keysRight: number[];
  8360. private _keys;
  8361. private _onCanvasBlurObserver;
  8362. private _onKeyboardObserver;
  8363. private _engine;
  8364. private _scene;
  8365. /**
  8366. * Attach the input controls to a specific dom element to get the input from.
  8367. * @param element Defines the element the controls should be listened from
  8368. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8369. */
  8370. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8371. /**
  8372. * Detach the current controls from the specified dom element.
  8373. * @param element Defines the element to stop listening the inputs from
  8374. */
  8375. detachControl(element: Nullable<HTMLElement>): void;
  8376. /**
  8377. * Update the current camera state depending on the inputs that have been used this frame.
  8378. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8379. */
  8380. checkInputs(): void;
  8381. /**
  8382. * Gets the class name of the current intput.
  8383. * @returns the class name
  8384. */
  8385. getClassName(): string;
  8386. /** @hidden */ onLostFocus(): void;
  8387. /**
  8388. * Get the friendly name associated with the input class.
  8389. * @returns the input friendly name
  8390. */
  8391. getSimpleName(): string;
  8392. }
  8393. }
  8394. declare module BABYLON {
  8395. /**
  8396. * Interface used to define ActionEvent
  8397. */
  8398. export interface IActionEvent {
  8399. /** The mesh or sprite that triggered the action */
  8400. source: any;
  8401. /** The X mouse cursor position at the time of the event */
  8402. pointerX: number;
  8403. /** The Y mouse cursor position at the time of the event */
  8404. pointerY: number;
  8405. /** The mesh that is currently pointed at (can be null) */
  8406. meshUnderPointer: Nullable<AbstractMesh>;
  8407. /** the original (browser) event that triggered the ActionEvent */
  8408. sourceEvent?: any;
  8409. /** additional data for the event */
  8410. additionalData?: any;
  8411. }
  8412. /**
  8413. * ActionEvent is the event being sent when an action is triggered.
  8414. */
  8415. export class ActionEvent implements IActionEvent {
  8416. /** The mesh or sprite that triggered the action */
  8417. source: any;
  8418. /** The X mouse cursor position at the time of the event */
  8419. pointerX: number;
  8420. /** The Y mouse cursor position at the time of the event */
  8421. pointerY: number;
  8422. /** The mesh that is currently pointed at (can be null) */
  8423. meshUnderPointer: Nullable<AbstractMesh>;
  8424. /** the original (browser) event that triggered the ActionEvent */
  8425. sourceEvent?: any;
  8426. /** additional data for the event */
  8427. additionalData?: any;
  8428. /**
  8429. * Creates a new ActionEvent
  8430. * @param source The mesh or sprite that triggered the action
  8431. * @param pointerX The X mouse cursor position at the time of the event
  8432. * @param pointerY The Y mouse cursor position at the time of the event
  8433. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  8434. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  8435. * @param additionalData additional data for the event
  8436. */
  8437. constructor(
  8438. /** The mesh or sprite that triggered the action */
  8439. source: any,
  8440. /** The X mouse cursor position at the time of the event */
  8441. pointerX: number,
  8442. /** The Y mouse cursor position at the time of the event */
  8443. pointerY: number,
  8444. /** The mesh that is currently pointed at (can be null) */
  8445. meshUnderPointer: Nullable<AbstractMesh>,
  8446. /** the original (browser) event that triggered the ActionEvent */
  8447. sourceEvent?: any,
  8448. /** additional data for the event */
  8449. additionalData?: any);
  8450. /**
  8451. * Helper function to auto-create an ActionEvent from a source mesh.
  8452. * @param source The source mesh that triggered the event
  8453. * @param evt The original (browser) event
  8454. * @param additionalData additional data for the event
  8455. * @returns the new ActionEvent
  8456. */
  8457. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  8458. /**
  8459. * Helper function to auto-create an ActionEvent from a source sprite
  8460. * @param source The source sprite that triggered the event
  8461. * @param scene Scene associated with the sprite
  8462. * @param evt The original (browser) event
  8463. * @param additionalData additional data for the event
  8464. * @returns the new ActionEvent
  8465. */
  8466. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  8467. /**
  8468. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  8469. * @param scene the scene where the event occurred
  8470. * @param evt The original (browser) event
  8471. * @returns the new ActionEvent
  8472. */
  8473. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  8474. /**
  8475. * Helper function to auto-create an ActionEvent from a primitive
  8476. * @param prim defines the target primitive
  8477. * @param pointerPos defines the pointer position
  8478. * @param evt The original (browser) event
  8479. * @param additionalData additional data for the event
  8480. * @returns the new ActionEvent
  8481. */
  8482. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  8483. }
  8484. }
  8485. declare module BABYLON {
  8486. /**
  8487. * Interface describing all the common properties and methods a shadow light needs to implement.
  8488. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8489. * as well as binding the different shadow properties to the effects.
  8490. */
  8491. export interface IShadowLight extends Light {
  8492. /**
  8493. * The light id in the scene (used in scene.findLighById for instance)
  8494. */
  8495. id: string;
  8496. /**
  8497. * The position the shdow will be casted from.
  8498. */
  8499. position: Vector3;
  8500. /**
  8501. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8502. */
  8503. direction: Vector3;
  8504. /**
  8505. * The transformed position. Position of the light in world space taking parenting in account.
  8506. */
  8507. transformedPosition: Vector3;
  8508. /**
  8509. * The transformed direction. Direction of the light in world space taking parenting in account.
  8510. */
  8511. transformedDirection: Vector3;
  8512. /**
  8513. * The friendly name of the light in the scene.
  8514. */
  8515. name: string;
  8516. /**
  8517. * Defines the shadow projection clipping minimum z value.
  8518. */
  8519. shadowMinZ: number;
  8520. /**
  8521. * Defines the shadow projection clipping maximum z value.
  8522. */
  8523. shadowMaxZ: number;
  8524. /**
  8525. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8526. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8527. */
  8528. computeTransformedInformation(): boolean;
  8529. /**
  8530. * Gets the scene the light belongs to.
  8531. * @returns The scene
  8532. */
  8533. getScene(): Scene;
  8534. /**
  8535. * Callback defining a custom Projection Matrix Builder.
  8536. * This can be used to override the default projection matrix computation.
  8537. */
  8538. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8539. /**
  8540. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8541. * @param matrix The materix to updated with the projection information
  8542. * @param viewMatrix The transform matrix of the light
  8543. * @param renderList The list of mesh to render in the map
  8544. * @returns The current light
  8545. */
  8546. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8547. /**
  8548. * Gets the current depth scale used in ESM.
  8549. * @returns The scale
  8550. */
  8551. getDepthScale(): number;
  8552. /**
  8553. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8554. * @returns true if a cube texture needs to be use
  8555. */
  8556. needCube(): boolean;
  8557. /**
  8558. * Detects if the projection matrix requires to be recomputed this frame.
  8559. * @returns true if it requires to be recomputed otherwise, false.
  8560. */
  8561. needProjectionMatrixCompute(): boolean;
  8562. /**
  8563. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8564. */
  8565. forceProjectionMatrixCompute(): void;
  8566. /**
  8567. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8568. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8569. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8570. */
  8571. getShadowDirection(faceIndex?: number): Vector3;
  8572. /**
  8573. * Gets the minZ used for shadow according to both the scene and the light.
  8574. * @param activeCamera The camera we are returning the min for
  8575. * @returns the depth min z
  8576. */
  8577. getDepthMinZ(activeCamera: Camera): number;
  8578. /**
  8579. * Gets the maxZ used for shadow according to both the scene and the light.
  8580. * @param activeCamera The camera we are returning the max for
  8581. * @returns the depth max z
  8582. */
  8583. getDepthMaxZ(activeCamera: Camera): number;
  8584. }
  8585. /**
  8586. * Base implementation IShadowLight
  8587. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8588. */
  8589. export abstract class ShadowLight extends Light implements IShadowLight {
  8590. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8591. protected _position: Vector3;
  8592. protected _setPosition(value: Vector3): void;
  8593. /**
  8594. * Sets the position the shadow will be casted from. Also use as the light position for both
  8595. * point and spot lights.
  8596. */
  8597. /**
  8598. * Sets the position the shadow will be casted from. Also use as the light position for both
  8599. * point and spot lights.
  8600. */
  8601. position: Vector3;
  8602. protected _direction: Vector3;
  8603. protected _setDirection(value: Vector3): void;
  8604. /**
  8605. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8606. * Also use as the light direction on spot and directional lights.
  8607. */
  8608. /**
  8609. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8610. * Also use as the light direction on spot and directional lights.
  8611. */
  8612. direction: Vector3;
  8613. private _shadowMinZ;
  8614. /**
  8615. * Gets the shadow projection clipping minimum z value.
  8616. */
  8617. /**
  8618. * Sets the shadow projection clipping minimum z value.
  8619. */
  8620. shadowMinZ: number;
  8621. private _shadowMaxZ;
  8622. /**
  8623. * Sets the shadow projection clipping maximum z value.
  8624. */
  8625. /**
  8626. * Gets the shadow projection clipping maximum z value.
  8627. */
  8628. shadowMaxZ: number;
  8629. /**
  8630. * Callback defining a custom Projection Matrix Builder.
  8631. * This can be used to override the default projection matrix computation.
  8632. */
  8633. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8634. /**
  8635. * The transformed position. Position of the light in world space taking parenting in account.
  8636. */
  8637. transformedPosition: Vector3;
  8638. /**
  8639. * The transformed direction. Direction of the light in world space taking parenting in account.
  8640. */
  8641. transformedDirection: Vector3;
  8642. private _needProjectionMatrixCompute;
  8643. /**
  8644. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8645. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8646. */
  8647. computeTransformedInformation(): boolean;
  8648. /**
  8649. * Return the depth scale used for the shadow map.
  8650. * @returns the depth scale.
  8651. */
  8652. getDepthScale(): number;
  8653. /**
  8654. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8655. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8656. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8657. */
  8658. getShadowDirection(faceIndex?: number): Vector3;
  8659. /**
  8660. * Returns the ShadowLight absolute position in the World.
  8661. * @returns the position vector in world space
  8662. */
  8663. getAbsolutePosition(): Vector3;
  8664. /**
  8665. * Sets the ShadowLight direction toward the passed target.
  8666. * @param target The point tot target in local space
  8667. * @returns the updated ShadowLight direction
  8668. */
  8669. setDirectionToTarget(target: Vector3): Vector3;
  8670. /**
  8671. * Returns the light rotation in euler definition.
  8672. * @returns the x y z rotation in local space.
  8673. */
  8674. getRotation(): Vector3;
  8675. /**
  8676. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8677. * @returns true if a cube texture needs to be use
  8678. */
  8679. needCube(): boolean;
  8680. /**
  8681. * Detects if the projection matrix requires to be recomputed this frame.
  8682. * @returns true if it requires to be recomputed otherwise, false.
  8683. */
  8684. needProjectionMatrixCompute(): boolean;
  8685. /**
  8686. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8687. */
  8688. forceProjectionMatrixCompute(): void;
  8689. /** @hidden */ initCache(): void;
  8690. /** @hidden */ isSynchronized(): boolean;
  8691. /**
  8692. * Computes the world matrix of the node
  8693. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8694. * @returns the world matrix
  8695. */
  8696. computeWorldMatrix(force?: boolean): Matrix;
  8697. /**
  8698. * Gets the minZ used for shadow according to both the scene and the light.
  8699. * @param activeCamera The camera we are returning the min for
  8700. * @returns the depth min z
  8701. */
  8702. getDepthMinZ(activeCamera: Camera): number;
  8703. /**
  8704. * Gets the maxZ used for shadow according to both the scene and the light.
  8705. * @param activeCamera The camera we are returning the max for
  8706. * @returns the depth max z
  8707. */
  8708. getDepthMaxZ(activeCamera: Camera): number;
  8709. /**
  8710. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8711. * @param matrix The materix to updated with the projection information
  8712. * @param viewMatrix The transform matrix of the light
  8713. * @param renderList The list of mesh to render in the map
  8714. * @returns The current light
  8715. */
  8716. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8717. }
  8718. }
  8719. declare module BABYLON {
  8720. /**
  8721. * "Static Class" containing the most commonly used helper while dealing with material for
  8722. * rendering purpose.
  8723. *
  8724. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8725. *
  8726. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8727. */
  8728. export class MaterialHelper {
  8729. /**
  8730. * Bind the current view position to an effect.
  8731. * @param effect The effect to be bound
  8732. * @param scene The scene the eyes position is used from
  8733. */
  8734. static BindEyePosition(effect: Effect, scene: Scene): void;
  8735. /**
  8736. * Helps preparing the defines values about the UVs in used in the effect.
  8737. * UVs are shared as much as we can accross channels in the shaders.
  8738. * @param texture The texture we are preparing the UVs for
  8739. * @param defines The defines to update
  8740. * @param key The channel key "diffuse", "specular"... used in the shader
  8741. */
  8742. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8743. /**
  8744. * Binds a texture matrix value to its corrsponding uniform
  8745. * @param texture The texture to bind the matrix for
  8746. * @param uniformBuffer The uniform buffer receivin the data
  8747. * @param key The channel key "diffuse", "specular"... used in the shader
  8748. */
  8749. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8750. /**
  8751. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8752. * @param mesh defines the current mesh
  8753. * @param scene defines the current scene
  8754. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8755. * @param pointsCloud defines if point cloud rendering has to be turned on
  8756. * @param fogEnabled defines if fog has to be turned on
  8757. * @param alphaTest defines if alpha testing has to be turned on
  8758. * @param defines defines the current list of defines
  8759. */
  8760. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8761. /**
  8762. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8763. * @param scene defines the current scene
  8764. * @param engine defines the current engine
  8765. * @param defines specifies the list of active defines
  8766. * @param useInstances defines if instances have to be turned on
  8767. * @param useClipPlane defines if clip plane have to be turned on
  8768. */
  8769. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8770. /**
  8771. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8772. * @param mesh The mesh containing the geometry data we will draw
  8773. * @param defines The defines to update
  8774. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8775. * @param useBones Precise whether bones should be used or not (override mesh info)
  8776. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8777. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8778. * @returns false if defines are considered not dirty and have not been checked
  8779. */
  8780. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8781. /**
  8782. * Prepares the defines related to the light information passed in parameter
  8783. * @param scene The scene we are intending to draw
  8784. * @param mesh The mesh the effect is compiling for
  8785. * @param defines The defines to update
  8786. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8787. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8788. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8789. * @returns true if normals will be required for the rest of the effect
  8790. */
  8791. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8792. /**
  8793. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  8794. * that won t be acctive due to defines being turned off.
  8795. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8796. * @param samplersList The samplers list
  8797. * @param defines The defines helping in the list generation
  8798. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8799. */
  8800. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8801. /**
  8802. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8803. * @param defines The defines to update while falling back
  8804. * @param fallbacks The authorized effect fallbacks
  8805. * @param maxSimultaneousLights The maximum number of lights allowed
  8806. * @param rank the current rank of the Effect
  8807. * @returns The newly affected rank
  8808. */
  8809. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8810. /**
  8811. * Prepares the list of attributes required for morph targets according to the effect defines.
  8812. * @param attribs The current list of supported attribs
  8813. * @param mesh The mesh to prepare the morph targets attributes for
  8814. * @param defines The current Defines of the effect
  8815. */
  8816. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8817. /**
  8818. * Prepares the list of attributes required for bones according to the effect defines.
  8819. * @param attribs The current list of supported attribs
  8820. * @param mesh The mesh to prepare the bones attributes for
  8821. * @param defines The current Defines of the effect
  8822. * @param fallbacks The current efffect fallback strategy
  8823. */
  8824. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  8825. /**
  8826. * Prepares the list of attributes required for instances according to the effect defines.
  8827. * @param attribs The current list of supported attribs
  8828. * @param defines The current Defines of the effect
  8829. */
  8830. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  8831. /**
  8832. * Binds the light shadow information to the effect for the given mesh.
  8833. * @param light The light containing the generator
  8834. * @param scene The scene the lights belongs to
  8835. * @param mesh The mesh we are binding the information to render
  8836. * @param lightIndex The light index in the effect used to render the mesh
  8837. * @param effect The effect we are binding the data to
  8838. */
  8839. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  8840. /**
  8841. * Binds the light information to the effect.
  8842. * @param light The light containing the generator
  8843. * @param effect The effect we are binding the data to
  8844. * @param lightIndex The light index in the effect used to render
  8845. */
  8846. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  8847. /**
  8848. * Binds the lights information from the scene to the effect for the given mesh.
  8849. * @param scene The scene the lights belongs to
  8850. * @param mesh The mesh we are binding the information to render
  8851. * @param effect The effect we are binding the data to
  8852. * @param defines The generated defines for the effect
  8853. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  8854. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8855. */
  8856. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  8857. private static _tempFogColor;
  8858. /**
  8859. * Binds the fog information from the scene to the effect for the given mesh.
  8860. * @param scene The scene the lights belongs to
  8861. * @param mesh The mesh we are binding the information to render
  8862. * @param effect The effect we are binding the data to
  8863. * @param linearSpace Defines if the fog effect is applied in linear space
  8864. */
  8865. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  8866. /**
  8867. * Binds the bones information from the mesh to the effect.
  8868. * @param mesh The mesh we are binding the information to render
  8869. * @param effect The effect we are binding the data to
  8870. */
  8871. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  8872. /**
  8873. * Binds the morph targets information from the mesh to the effect.
  8874. * @param abstractMesh The mesh we are binding the information to render
  8875. * @param effect The effect we are binding the data to
  8876. */
  8877. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  8878. /**
  8879. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  8880. * @param defines The generated defines used in the effect
  8881. * @param effect The effect we are binding the data to
  8882. * @param scene The scene we are willing to render with logarithmic scale for
  8883. */
  8884. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  8885. /**
  8886. * Binds the clip plane information from the scene to the effect.
  8887. * @param scene The scene the clip plane information are extracted from
  8888. * @param effect The effect we are binding the data to
  8889. */
  8890. static BindClipPlane(effect: Effect, scene: Scene): void;
  8891. }
  8892. }
  8893. declare module BABYLON {
  8894. /** @hidden */
  8895. export var kernelBlurVaryingDeclaration: {
  8896. name: string;
  8897. shader: string;
  8898. };
  8899. }
  8900. declare module BABYLON {
  8901. /** @hidden */
  8902. export var kernelBlurFragment: {
  8903. name: string;
  8904. shader: string;
  8905. };
  8906. }
  8907. declare module BABYLON {
  8908. /** @hidden */
  8909. export var kernelBlurFragment2: {
  8910. name: string;
  8911. shader: string;
  8912. };
  8913. }
  8914. declare module BABYLON {
  8915. /** @hidden */
  8916. export var kernelBlurPixelShader: {
  8917. name: string;
  8918. shader: string;
  8919. };
  8920. }
  8921. declare module BABYLON {
  8922. /** @hidden */
  8923. export var kernelBlurVertex: {
  8924. name: string;
  8925. shader: string;
  8926. };
  8927. }
  8928. declare module BABYLON {
  8929. /** @hidden */
  8930. export var kernelBlurVertexShader: {
  8931. name: string;
  8932. shader: string;
  8933. };
  8934. }
  8935. declare module BABYLON {
  8936. /**
  8937. * The Blur Post Process which blurs an image based on a kernel and direction.
  8938. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  8939. */
  8940. export class BlurPostProcess extends PostProcess {
  8941. /** The direction in which to blur the image. */
  8942. direction: Vector2;
  8943. private blockCompilation;
  8944. protected _kernel: number;
  8945. protected _idealKernel: number;
  8946. protected _packedFloat: boolean;
  8947. private _staticDefines;
  8948. /**
  8949. * Sets the length in pixels of the blur sample region
  8950. */
  8951. /**
  8952. * Gets the length in pixels of the blur sample region
  8953. */
  8954. kernel: number;
  8955. /**
  8956. * Sets wether or not the blur needs to unpack/repack floats
  8957. */
  8958. /**
  8959. * Gets wether or not the blur is unpacking/repacking floats
  8960. */
  8961. packedFloat: boolean;
  8962. /**
  8963. * Creates a new instance BlurPostProcess
  8964. * @param name The name of the effect.
  8965. * @param direction The direction in which to blur the image.
  8966. * @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.
  8967. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  8968. * @param camera The camera to apply the render pass to.
  8969. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  8970. * @param engine The engine which the post process will be applied. (default: current engine)
  8971. * @param reusable If the post process can be reused on the same frame. (default: false)
  8972. * @param textureType Type of textures used when performing the post process. (default: 0)
  8973. * @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)
  8974. */
  8975. constructor(name: string,
  8976. /** The direction in which to blur the image. */
  8977. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  8978. /**
  8979. * Updates the effect with the current post process compile time values and recompiles the shader.
  8980. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  8981. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  8982. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  8983. * @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
  8984. * @param onCompiled Called when the shader has been compiled.
  8985. * @param onError Called if there is an error when compiling a shader.
  8986. */
  8987. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  8988. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  8989. /**
  8990. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  8991. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  8992. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  8993. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  8994. * The gaps between physical kernels are compensated for in the weighting of the samples
  8995. * @param idealKernel Ideal blur kernel.
  8996. * @return Nearest best kernel.
  8997. */
  8998. protected _nearestBestKernel(idealKernel: number): number;
  8999. /**
  9000. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9001. * @param x The point on the Gaussian distribution to sample.
  9002. * @return the value of the Gaussian function at x.
  9003. */
  9004. protected _gaussianWeight(x: number): number;
  9005. /**
  9006. * Generates a string that can be used as a floating point number in GLSL.
  9007. * @param x Value to print.
  9008. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9009. * @return GLSL float string.
  9010. */
  9011. protected _glslFloat(x: number, decimalFigures?: number): string;
  9012. }
  9013. }
  9014. declare module BABYLON {
  9015. /** @hidden */
  9016. export var shadowMapPixelShader: {
  9017. name: string;
  9018. shader: string;
  9019. };
  9020. }
  9021. declare module BABYLON {
  9022. /** @hidden */
  9023. export var bonesDeclaration: {
  9024. name: string;
  9025. shader: string;
  9026. };
  9027. }
  9028. declare module BABYLON {
  9029. /** @hidden */
  9030. export var morphTargetsVertexGlobalDeclaration: {
  9031. name: string;
  9032. shader: string;
  9033. };
  9034. }
  9035. declare module BABYLON {
  9036. /** @hidden */
  9037. export var morphTargetsVertexDeclaration: {
  9038. name: string;
  9039. shader: string;
  9040. };
  9041. }
  9042. declare module BABYLON {
  9043. /** @hidden */
  9044. export var instancesDeclaration: {
  9045. name: string;
  9046. shader: string;
  9047. };
  9048. }
  9049. declare module BABYLON {
  9050. /** @hidden */
  9051. export var helperFunctions: {
  9052. name: string;
  9053. shader: string;
  9054. };
  9055. }
  9056. declare module BABYLON {
  9057. /** @hidden */
  9058. export var morphTargetsVertex: {
  9059. name: string;
  9060. shader: string;
  9061. };
  9062. }
  9063. declare module BABYLON {
  9064. /** @hidden */
  9065. export var instancesVertex: {
  9066. name: string;
  9067. shader: string;
  9068. };
  9069. }
  9070. declare module BABYLON {
  9071. /** @hidden */
  9072. export var bonesVertex: {
  9073. name: string;
  9074. shader: string;
  9075. };
  9076. }
  9077. declare module BABYLON {
  9078. /** @hidden */
  9079. export var shadowMapVertexShader: {
  9080. name: string;
  9081. shader: string;
  9082. };
  9083. }
  9084. declare module BABYLON {
  9085. /** @hidden */
  9086. export var depthBoxBlurPixelShader: {
  9087. name: string;
  9088. shader: string;
  9089. };
  9090. }
  9091. declare module BABYLON {
  9092. /**
  9093. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9094. */
  9095. export interface ICustomShaderOptions {
  9096. /**
  9097. * Gets or sets the custom shader name to use
  9098. */
  9099. shaderName: string;
  9100. /**
  9101. * The list of attribute names used in the shader
  9102. */
  9103. attributes?: string[];
  9104. /**
  9105. * The list of unifrom names used in the shader
  9106. */
  9107. uniforms?: string[];
  9108. /**
  9109. * The list of sampler names used in the shader
  9110. */
  9111. samplers?: string[];
  9112. /**
  9113. * The list of defines used in the shader
  9114. */
  9115. defines?: string[];
  9116. }
  9117. /**
  9118. * Interface to implement to create a shadow generator compatible with BJS.
  9119. */
  9120. export interface IShadowGenerator {
  9121. /**
  9122. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9123. * @returns The render target texture if present otherwise, null
  9124. */
  9125. getShadowMap(): Nullable<RenderTargetTexture>;
  9126. /**
  9127. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9128. * @returns The render target texture if the shadow map is present otherwise, null
  9129. */
  9130. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9131. /**
  9132. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9133. * @param subMesh The submesh we want to render in the shadow map
  9134. * @param useInstances Defines wether will draw in the map using instances
  9135. * @returns true if ready otherwise, false
  9136. */
  9137. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9138. /**
  9139. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9140. * @param defines Defines of the material we want to update
  9141. * @param lightIndex Index of the light in the enabled light list of the material
  9142. */
  9143. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9144. /**
  9145. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9146. * defined in the generator but impacting the effect).
  9147. * It implies the unifroms available on the materials are the standard BJS ones.
  9148. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9149. * @param effect The effect we are binfing the information for
  9150. */
  9151. bindShadowLight(lightIndex: string, effect: Effect): void;
  9152. /**
  9153. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9154. * (eq to shadow prjection matrix * light transform matrix)
  9155. * @returns The transform matrix used to create the shadow map
  9156. */
  9157. getTransformMatrix(): Matrix;
  9158. /**
  9159. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9160. * Cube and 2D textures for instance.
  9161. */
  9162. recreateShadowMap(): void;
  9163. /**
  9164. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9165. * @param onCompiled Callback triggered at the and of the effects compilation
  9166. * @param options Sets of optional options forcing the compilation with different modes
  9167. */
  9168. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9169. useInstances: boolean;
  9170. }>): void;
  9171. /**
  9172. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9173. * @param options Sets of optional options forcing the compilation with different modes
  9174. * @returns A promise that resolves when the compilation completes
  9175. */
  9176. forceCompilationAsync(options?: Partial<{
  9177. useInstances: boolean;
  9178. }>): Promise<void>;
  9179. /**
  9180. * Serializes the shadow generator setup to a json object.
  9181. * @returns The serialized JSON object
  9182. */
  9183. serialize(): any;
  9184. /**
  9185. * Disposes the Shadow map and related Textures and effects.
  9186. */
  9187. dispose(): void;
  9188. }
  9189. /**
  9190. * Default implementation IShadowGenerator.
  9191. * This is the main object responsible of generating shadows in the framework.
  9192. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9193. */
  9194. export class ShadowGenerator implements IShadowGenerator {
  9195. /**
  9196. * Shadow generator mode None: no filtering applied.
  9197. */
  9198. static readonly FILTER_NONE: number;
  9199. /**
  9200. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9201. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9202. */
  9203. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9204. /**
  9205. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9206. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9207. */
  9208. static readonly FILTER_POISSONSAMPLING: number;
  9209. /**
  9210. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9211. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9212. */
  9213. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9214. /**
  9215. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9216. * edge artifacts on steep falloff.
  9217. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9218. */
  9219. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9220. /**
  9221. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9222. * edge artifacts on steep falloff.
  9223. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9224. */
  9225. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9226. /**
  9227. * Shadow generator mode PCF: Percentage Closer Filtering
  9228. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9229. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9230. */
  9231. static readonly FILTER_PCF: number;
  9232. /**
  9233. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9234. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9235. * Contact Hardening
  9236. */
  9237. static readonly FILTER_PCSS: number;
  9238. /**
  9239. * Reserved for PCF and PCSS
  9240. * Highest Quality.
  9241. *
  9242. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9243. *
  9244. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9245. */
  9246. static readonly QUALITY_HIGH: number;
  9247. /**
  9248. * Reserved for PCF and PCSS
  9249. * Good tradeoff for quality/perf cross devices
  9250. *
  9251. * Execute PCF on a 3*3 kernel.
  9252. *
  9253. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9254. */
  9255. static readonly QUALITY_MEDIUM: number;
  9256. /**
  9257. * Reserved for PCF and PCSS
  9258. * The lowest quality but the fastest.
  9259. *
  9260. * Execute PCF on a 1*1 kernel.
  9261. *
  9262. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9263. */
  9264. static readonly QUALITY_LOW: number;
  9265. /** Gets or sets the custom shader name to use */
  9266. customShaderOptions: ICustomShaderOptions;
  9267. /**
  9268. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9269. */
  9270. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9271. private _bias;
  9272. /**
  9273. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9274. */
  9275. /**
  9276. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9277. */
  9278. bias: number;
  9279. private _normalBias;
  9280. /**
  9281. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9282. */
  9283. /**
  9284. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9285. */
  9286. normalBias: number;
  9287. private _blurBoxOffset;
  9288. /**
  9289. * Gets the blur box offset: offset applied during the blur pass.
  9290. * Only useful if useKernelBlur = false
  9291. */
  9292. /**
  9293. * Sets the blur box offset: offset applied during the blur pass.
  9294. * Only useful if useKernelBlur = false
  9295. */
  9296. blurBoxOffset: number;
  9297. private _blurScale;
  9298. /**
  9299. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9300. * 2 means half of the size.
  9301. */
  9302. /**
  9303. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9304. * 2 means half of the size.
  9305. */
  9306. blurScale: number;
  9307. private _blurKernel;
  9308. /**
  9309. * Gets the blur kernel: kernel size of the blur pass.
  9310. * Only useful if useKernelBlur = true
  9311. */
  9312. /**
  9313. * Sets the blur kernel: kernel size of the blur pass.
  9314. * Only useful if useKernelBlur = true
  9315. */
  9316. blurKernel: number;
  9317. private _useKernelBlur;
  9318. /**
  9319. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9320. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9321. */
  9322. /**
  9323. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9324. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9325. */
  9326. useKernelBlur: boolean;
  9327. private _depthScale;
  9328. /**
  9329. * Gets the depth scale used in ESM mode.
  9330. */
  9331. /**
  9332. * Sets the depth scale used in ESM mode.
  9333. * This can override the scale stored on the light.
  9334. */
  9335. depthScale: number;
  9336. private _filter;
  9337. /**
  9338. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9339. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9340. */
  9341. /**
  9342. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9343. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9344. */
  9345. filter: number;
  9346. /**
  9347. * Gets if the current filter is set to Poisson Sampling.
  9348. */
  9349. /**
  9350. * Sets the current filter to Poisson Sampling.
  9351. */
  9352. usePoissonSampling: boolean;
  9353. /**
  9354. * Gets if the current filter is set to ESM.
  9355. */
  9356. /**
  9357. * Sets the current filter is to ESM.
  9358. */
  9359. useExponentialShadowMap: boolean;
  9360. /**
  9361. * Gets if the current filter is set to filtered ESM.
  9362. */
  9363. /**
  9364. * Gets if the current filter is set to filtered ESM.
  9365. */
  9366. useBlurExponentialShadowMap: boolean;
  9367. /**
  9368. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9369. * exponential to prevent steep falloff artifacts).
  9370. */
  9371. /**
  9372. * Sets the current filter to "close ESM" (using the inverse of the
  9373. * exponential to prevent steep falloff artifacts).
  9374. */
  9375. useCloseExponentialShadowMap: boolean;
  9376. /**
  9377. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9378. * exponential to prevent steep falloff artifacts).
  9379. */
  9380. /**
  9381. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9382. * exponential to prevent steep falloff artifacts).
  9383. */
  9384. useBlurCloseExponentialShadowMap: boolean;
  9385. /**
  9386. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9387. */
  9388. /**
  9389. * Sets the current filter to "PCF" (percentage closer filtering).
  9390. */
  9391. usePercentageCloserFiltering: boolean;
  9392. private _filteringQuality;
  9393. /**
  9394. * Gets the PCF or PCSS Quality.
  9395. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9396. */
  9397. /**
  9398. * Sets the PCF or PCSS Quality.
  9399. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9400. */
  9401. filteringQuality: number;
  9402. /**
  9403. * Gets if the current filter is set to "PCSS" (contact hardening).
  9404. */
  9405. /**
  9406. * Sets the current filter to "PCSS" (contact hardening).
  9407. */
  9408. useContactHardeningShadow: boolean;
  9409. private _contactHardeningLightSizeUVRatio;
  9410. /**
  9411. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9412. * Using a ratio helps keeping shape stability independently of the map size.
  9413. *
  9414. * It does not account for the light projection as it was having too much
  9415. * instability during the light setup or during light position changes.
  9416. *
  9417. * Only valid if useContactHardeningShadow is true.
  9418. */
  9419. /**
  9420. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9421. * Using a ratio helps keeping shape stability independently of the map size.
  9422. *
  9423. * It does not account for the light projection as it was having too much
  9424. * instability during the light setup or during light position changes.
  9425. *
  9426. * Only valid if useContactHardeningShadow is true.
  9427. */
  9428. contactHardeningLightSizeUVRatio: number;
  9429. private _darkness;
  9430. /**
  9431. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9432. * 0 means strongest and 1 would means no shadow.
  9433. * @returns the darkness.
  9434. */
  9435. getDarkness(): number;
  9436. /**
  9437. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9438. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9439. * @returns the shadow generator allowing fluent coding.
  9440. */
  9441. setDarkness(darkness: number): ShadowGenerator;
  9442. private _transparencyShadow;
  9443. /**
  9444. * Sets the ability to have transparent shadow (boolean).
  9445. * @param transparent True if transparent else False
  9446. * @returns the shadow generator allowing fluent coding
  9447. */
  9448. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9449. private _shadowMap;
  9450. private _shadowMap2;
  9451. /**
  9452. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9453. * @returns The render target texture if present otherwise, null
  9454. */
  9455. getShadowMap(): Nullable<RenderTargetTexture>;
  9456. /**
  9457. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9458. * @returns The render target texture if the shadow map is present otherwise, null
  9459. */
  9460. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9461. /**
  9462. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9463. * @param mesh Mesh to add
  9464. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9465. * @returns the Shadow Generator itself
  9466. */
  9467. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9468. /**
  9469. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9470. * @param mesh Mesh to remove
  9471. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9472. * @returns the Shadow Generator itself
  9473. */
  9474. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9475. /**
  9476. * Controls the extent to which the shadows fade out at the edge of the frustum
  9477. * Used only by directionals and spots
  9478. */
  9479. frustumEdgeFalloff: number;
  9480. private _light;
  9481. /**
  9482. * Returns the associated light object.
  9483. * @returns the light generating the shadow
  9484. */
  9485. getLight(): IShadowLight;
  9486. /**
  9487. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9488. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9489. * It might on the other hand introduce peter panning.
  9490. */
  9491. forceBackFacesOnly: boolean;
  9492. private _scene;
  9493. private _lightDirection;
  9494. private _effect;
  9495. private _viewMatrix;
  9496. private _projectionMatrix;
  9497. private _transformMatrix;
  9498. private _cachedPosition;
  9499. private _cachedDirection;
  9500. private _cachedDefines;
  9501. private _currentRenderID;
  9502. private _boxBlurPostprocess;
  9503. private _kernelBlurXPostprocess;
  9504. private _kernelBlurYPostprocess;
  9505. private _blurPostProcesses;
  9506. private _mapSize;
  9507. private _currentFaceIndex;
  9508. private _currentFaceIndexCache;
  9509. private _textureType;
  9510. private _defaultTextureMatrix;
  9511. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  9512. /**
  9513. * Creates a ShadowGenerator object.
  9514. * A ShadowGenerator is the required tool to use the shadows.
  9515. * Each light casting shadows needs to use its own ShadowGenerator.
  9516. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9517. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9518. * @param light The light object generating the shadows.
  9519. * @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.
  9520. */
  9521. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9522. private _initializeGenerator;
  9523. private _initializeShadowMap;
  9524. private _initializeBlurRTTAndPostProcesses;
  9525. private _renderForShadowMap;
  9526. private _renderSubMeshForShadowMap;
  9527. private _applyFilterValues;
  9528. /**
  9529. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9530. * @param onCompiled Callback triggered at the and of the effects compilation
  9531. * @param options Sets of optional options forcing the compilation with different modes
  9532. */
  9533. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9534. useInstances: boolean;
  9535. }>): void;
  9536. /**
  9537. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9538. * @param options Sets of optional options forcing the compilation with different modes
  9539. * @returns A promise that resolves when the compilation completes
  9540. */
  9541. forceCompilationAsync(options?: Partial<{
  9542. useInstances: boolean;
  9543. }>): Promise<void>;
  9544. /**
  9545. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9546. * @param subMesh The submesh we want to render in the shadow map
  9547. * @param useInstances Defines wether will draw in the map using instances
  9548. * @returns true if ready otherwise, false
  9549. */
  9550. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9551. /**
  9552. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9553. * @param defines Defines of the material we want to update
  9554. * @param lightIndex Index of the light in the enabled light list of the material
  9555. */
  9556. prepareDefines(defines: any, lightIndex: number): void;
  9557. /**
  9558. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9559. * defined in the generator but impacting the effect).
  9560. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9561. * @param effect The effect we are binfing the information for
  9562. */
  9563. bindShadowLight(lightIndex: string, effect: Effect): void;
  9564. /**
  9565. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9566. * (eq to shadow prjection matrix * light transform matrix)
  9567. * @returns The transform matrix used to create the shadow map
  9568. */
  9569. getTransformMatrix(): Matrix;
  9570. /**
  9571. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9572. * Cube and 2D textures for instance.
  9573. */
  9574. recreateShadowMap(): void;
  9575. private _disposeBlurPostProcesses;
  9576. private _disposeRTTandPostProcesses;
  9577. /**
  9578. * Disposes the ShadowGenerator.
  9579. * Returns nothing.
  9580. */
  9581. dispose(): void;
  9582. /**
  9583. * Serializes the shadow generator setup to a json object.
  9584. * @returns The serialized JSON object
  9585. */
  9586. serialize(): any;
  9587. /**
  9588. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9589. * @param parsedShadowGenerator The JSON object to parse
  9590. * @param scene The scene to create the shadow map for
  9591. * @returns The parsed shadow generator
  9592. */
  9593. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9594. }
  9595. }
  9596. declare module BABYLON {
  9597. /**
  9598. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9599. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9600. * 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.
  9601. */
  9602. export abstract class Light extends Node {
  9603. /**
  9604. * Falloff Default: light is falling off following the material specification:
  9605. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9606. */
  9607. static readonly FALLOFF_DEFAULT: number;
  9608. /**
  9609. * Falloff Physical: light is falling off following the inverse squared distance law.
  9610. */
  9611. static readonly FALLOFF_PHYSICAL: number;
  9612. /**
  9613. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9614. * to enhance interoperability with other engines.
  9615. */
  9616. static readonly FALLOFF_GLTF: number;
  9617. /**
  9618. * Falloff Standard: light is falling off like in the standard material
  9619. * to enhance interoperability with other materials.
  9620. */
  9621. static readonly FALLOFF_STANDARD: number;
  9622. /**
  9623. * If every light affecting the material is in this lightmapMode,
  9624. * material.lightmapTexture adds or multiplies
  9625. * (depends on material.useLightmapAsShadowmap)
  9626. * after every other light calculations.
  9627. */
  9628. static readonly LIGHTMAP_DEFAULT: number;
  9629. /**
  9630. * material.lightmapTexture as only diffuse lighting from this light
  9631. * adds only specular lighting from this light
  9632. * adds dynamic shadows
  9633. */
  9634. static readonly LIGHTMAP_SPECULAR: number;
  9635. /**
  9636. * material.lightmapTexture as only lighting
  9637. * no light calculation from this light
  9638. * only adds dynamic shadows from this light
  9639. */
  9640. static readonly LIGHTMAP_SHADOWSONLY: number;
  9641. /**
  9642. * Each light type uses the default quantity according to its type:
  9643. * point/spot lights use luminous intensity
  9644. * directional lights use illuminance
  9645. */
  9646. static readonly INTENSITYMODE_AUTOMATIC: number;
  9647. /**
  9648. * lumen (lm)
  9649. */
  9650. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9651. /**
  9652. * candela (lm/sr)
  9653. */
  9654. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9655. /**
  9656. * lux (lm/m^2)
  9657. */
  9658. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9659. /**
  9660. * nit (cd/m^2)
  9661. */
  9662. static readonly INTENSITYMODE_LUMINANCE: number;
  9663. /**
  9664. * Light type const id of the point light.
  9665. */
  9666. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9667. /**
  9668. * Light type const id of the directional light.
  9669. */
  9670. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9671. /**
  9672. * Light type const id of the spot light.
  9673. */
  9674. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9675. /**
  9676. * Light type const id of the hemispheric light.
  9677. */
  9678. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9679. /**
  9680. * Diffuse gives the basic color to an object.
  9681. */
  9682. diffuse: Color3;
  9683. /**
  9684. * Specular produces a highlight color on an object.
  9685. * Note: This is note affecting PBR materials.
  9686. */
  9687. specular: Color3;
  9688. /**
  9689. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9690. * falling off base on range or angle.
  9691. * This can be set to any values in Light.FALLOFF_x.
  9692. *
  9693. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9694. * other types of materials.
  9695. */
  9696. falloffType: number;
  9697. /**
  9698. * Strength of the light.
  9699. * Note: By default it is define in the framework own unit.
  9700. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9701. */
  9702. intensity: number;
  9703. private _range;
  9704. protected _inverseSquaredRange: number;
  9705. /**
  9706. * Defines how far from the source the light is impacting in scene units.
  9707. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9708. */
  9709. /**
  9710. * Defines how far from the source the light is impacting in scene units.
  9711. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9712. */
  9713. range: number;
  9714. /**
  9715. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9716. * of light.
  9717. */
  9718. private _photometricScale;
  9719. private _intensityMode;
  9720. /**
  9721. * Gets the photometric scale used to interpret the intensity.
  9722. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9723. */
  9724. /**
  9725. * Sets the photometric scale used to interpret the intensity.
  9726. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9727. */
  9728. intensityMode: number;
  9729. private _radius;
  9730. /**
  9731. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9732. */
  9733. /**
  9734. * sets the light radius used by PBR Materials to simulate soft area lights.
  9735. */
  9736. radius: number;
  9737. private _renderPriority;
  9738. /**
  9739. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9740. * exceeding the number allowed of the materials.
  9741. */
  9742. renderPriority: number;
  9743. private _shadowEnabled;
  9744. /**
  9745. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9746. * the current shadow generator.
  9747. */
  9748. /**
  9749. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9750. * the current shadow generator.
  9751. */
  9752. shadowEnabled: boolean;
  9753. private _includedOnlyMeshes;
  9754. /**
  9755. * Gets the only meshes impacted by this light.
  9756. */
  9757. /**
  9758. * Sets the only meshes impacted by this light.
  9759. */
  9760. includedOnlyMeshes: AbstractMesh[];
  9761. private _excludedMeshes;
  9762. /**
  9763. * Gets the meshes not impacted by this light.
  9764. */
  9765. /**
  9766. * Sets the meshes not impacted by this light.
  9767. */
  9768. excludedMeshes: AbstractMesh[];
  9769. private _excludeWithLayerMask;
  9770. /**
  9771. * Gets the layer id use to find what meshes are not impacted by the light.
  9772. * Inactive if 0
  9773. */
  9774. /**
  9775. * Sets the layer id use to find what meshes are not impacted by the light.
  9776. * Inactive if 0
  9777. */
  9778. excludeWithLayerMask: number;
  9779. private _includeOnlyWithLayerMask;
  9780. /**
  9781. * Gets the layer id use to find what meshes are impacted by the light.
  9782. * Inactive if 0
  9783. */
  9784. /**
  9785. * Sets the layer id use to find what meshes are impacted by the light.
  9786. * Inactive if 0
  9787. */
  9788. includeOnlyWithLayerMask: number;
  9789. private _lightmapMode;
  9790. /**
  9791. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9792. */
  9793. /**
  9794. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9795. */
  9796. lightmapMode: number;
  9797. /**
  9798. * Shadow generator associted to the light.
  9799. * @hidden Internal use only.
  9800. */ shadowGenerator: Nullable<IShadowGenerator>;
  9801. /**
  9802. * @hidden Internal use only.
  9803. */ excludedMeshesIds: string[];
  9804. /**
  9805. * @hidden Internal use only.
  9806. */ includedOnlyMeshesIds: string[];
  9807. /**
  9808. * The current light unifom buffer.
  9809. * @hidden Internal use only.
  9810. */ uniformBuffer: UniformBuffer;
  9811. /**
  9812. * Creates a Light object in the scene.
  9813. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9814. * @param name The firendly name of the light
  9815. * @param scene The scene the light belongs too
  9816. */
  9817. constructor(name: string, scene: Scene);
  9818. protected abstract _buildUniformLayout(): void;
  9819. /**
  9820. * Sets the passed Effect "effect" with the Light information.
  9821. * @param effect The effect to update
  9822. * @param lightIndex The index of the light in the effect to update
  9823. * @returns The light
  9824. */
  9825. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9826. /**
  9827. * Returns the string "Light".
  9828. * @returns the class name
  9829. */
  9830. getClassName(): string;
  9831. /** @hidden */ protected readonly _isLight: boolean;
  9832. /**
  9833. * Converts the light information to a readable string for debug purpose.
  9834. * @param fullDetails Supports for multiple levels of logging within scene loading
  9835. * @returns the human readable light info
  9836. */
  9837. toString(fullDetails?: boolean): string;
  9838. /** @hidden */
  9839. protected _syncParentEnabledState(): void;
  9840. /**
  9841. * Set the enabled state of this node.
  9842. * @param value - the new enabled state
  9843. */
  9844. setEnabled(value: boolean): void;
  9845. /**
  9846. * Returns the Light associated shadow generator if any.
  9847. * @return the associated shadow generator.
  9848. */
  9849. getShadowGenerator(): Nullable<IShadowGenerator>;
  9850. /**
  9851. * Returns a Vector3, the absolute light position in the World.
  9852. * @returns the world space position of the light
  9853. */
  9854. getAbsolutePosition(): Vector3;
  9855. /**
  9856. * Specifies if the light will affect the passed mesh.
  9857. * @param mesh The mesh to test against the light
  9858. * @return true the mesh is affected otherwise, false.
  9859. */
  9860. canAffectMesh(mesh: AbstractMesh): boolean;
  9861. /**
  9862. * Sort function to order lights for rendering.
  9863. * @param a First Light object to compare to second.
  9864. * @param b Second Light object to compare first.
  9865. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9866. */
  9867. static CompareLightsPriority(a: Light, b: Light): number;
  9868. /**
  9869. * Releases resources associated with this node.
  9870. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9871. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9872. */
  9873. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9874. /**
  9875. * Returns the light type ID (integer).
  9876. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9877. */
  9878. getTypeID(): number;
  9879. /**
  9880. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9881. * @returns the scaled intensity in intensity mode unit
  9882. */
  9883. getScaledIntensity(): number;
  9884. /**
  9885. * Returns a new Light object, named "name", from the current one.
  9886. * @param name The name of the cloned light
  9887. * @returns the new created light
  9888. */
  9889. clone(name: string): Nullable<Light>;
  9890. /**
  9891. * Serializes the current light into a Serialization object.
  9892. * @returns the serialized object.
  9893. */
  9894. serialize(): any;
  9895. /**
  9896. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9897. * This new light is named "name" and added to the passed scene.
  9898. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9899. * @param name The friendly name of the light
  9900. * @param scene The scene the new light will belong to
  9901. * @returns the constructor function
  9902. */
  9903. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9904. /**
  9905. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9906. * @param parsedLight The JSON representation of the light
  9907. * @param scene The scene to create the parsed light in
  9908. * @returns the created light after parsing
  9909. */
  9910. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9911. private _hookArrayForExcluded;
  9912. private _hookArrayForIncludedOnly;
  9913. private _resyncMeshes;
  9914. /**
  9915. * Forces the meshes to update their light related information in their rendering used effects
  9916. * @hidden Internal Use Only
  9917. */ markMeshesAsLightDirty(): void;
  9918. /**
  9919. * Recomputes the cached photometric scale if needed.
  9920. */
  9921. private _computePhotometricScale;
  9922. /**
  9923. * Returns the Photometric Scale according to the light type and intensity mode.
  9924. */
  9925. private _getPhotometricScale;
  9926. /**
  9927. * Reorder the light in the scene according to their defined priority.
  9928. * @hidden Internal Use Only
  9929. */ reorderLightsInScene(): void;
  9930. /**
  9931. * Prepares the list of defines specific to the light type.
  9932. * @param defines the list of defines
  9933. * @param lightIndex defines the index of the light for the effect
  9934. */
  9935. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9936. }
  9937. }
  9938. declare module BABYLON {
  9939. /**
  9940. * Interface used to define Action
  9941. */
  9942. export interface IAction {
  9943. /**
  9944. * Trigger for the action
  9945. */
  9946. trigger: number;
  9947. /** the trigger, with or without parameters, for the action */
  9948. triggerOptions: any;
  9949. /**
  9950. * Gets the trigger parameters
  9951. * @returns the trigger parameters
  9952. */
  9953. getTriggerParameter(): any;
  9954. /**
  9955. * Internal only - executes current action event
  9956. * @hidden
  9957. */ executeCurrent(evt?: ActionEvent): void;
  9958. /**
  9959. * Serialize placeholder for child classes
  9960. * @param parent of child
  9961. * @returns the serialized object
  9962. */
  9963. serialize(parent: any): any;
  9964. }
  9965. /**
  9966. * The action to be carried out following a trigger
  9967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9968. */
  9969. export class Action implements IAction {
  9970. /** the trigger, with or without parameters, for the action */
  9971. triggerOptions: any;
  9972. /**
  9973. * Trigger for the action
  9974. */
  9975. trigger: number;
  9976. /**
  9977. * Internal only - manager for action
  9978. * @hidden
  9979. */ actionManager: ActionManager;
  9980. private _nextActiveAction;
  9981. private _child;
  9982. private _condition?;
  9983. private _triggerParameter;
  9984. /**
  9985. * An event triggered prior to action being executed.
  9986. */
  9987. onBeforeExecuteObservable: Observable<Action>;
  9988. /**
  9989. * Creates a new Action
  9990. * @param triggerOptions the trigger, with or without parameters, for the action
  9991. * @param condition an optional determinant of action
  9992. */
  9993. constructor(
  9994. /** the trigger, with or without parameters, for the action */
  9995. triggerOptions: any, condition?: Condition);
  9996. /**
  9997. * Internal only
  9998. * @hidden
  9999. */ prepare(): void;
  10000. /**
  10001. * Gets the trigger parameters
  10002. * @returns the trigger parameters
  10003. */
  10004. getTriggerParameter(): any;
  10005. /**
  10006. * Internal only - executes current action event
  10007. * @hidden
  10008. */ executeCurrent(evt?: ActionEvent): void;
  10009. /**
  10010. * Execute placeholder for child classes
  10011. * @param evt optional action event
  10012. */
  10013. execute(evt?: ActionEvent): void;
  10014. /**
  10015. * Skips to next active action
  10016. */
  10017. skipToNextActiveAction(): void;
  10018. /**
  10019. * Adds action to chain of actions, may be a DoNothingAction
  10020. * @param action defines the next action to execute
  10021. * @returns The action passed in
  10022. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10023. */
  10024. then(action: Action): Action;
  10025. /**
  10026. * Internal only
  10027. * @hidden
  10028. */ getProperty(propertyPath: string): string;
  10029. /**
  10030. * Internal only
  10031. * @hidden
  10032. */ getEffectiveTarget(target: any, propertyPath: string): any;
  10033. /**
  10034. * Serialize placeholder for child classes
  10035. * @param parent of child
  10036. * @returns the serialized object
  10037. */
  10038. serialize(parent: any): any;
  10039. /**
  10040. * Internal only called by serialize
  10041. * @hidden
  10042. */
  10043. protected _serialize(serializedAction: any, parent?: any): any;
  10044. /**
  10045. * Internal only
  10046. * @hidden
  10047. */ private static _SerializeValueAsString: (value: any) => string;
  10048. /**
  10049. * Internal only
  10050. * @hidden
  10051. */ private static _GetTargetProperty: (target: Scene | Node) => {
  10052. name: string;
  10053. targetType: string;
  10054. value: string;
  10055. };
  10056. }
  10057. }
  10058. declare module BABYLON {
  10059. /**
  10060. * A Condition applied to an Action
  10061. */
  10062. export class Condition {
  10063. /**
  10064. * Internal only - manager for action
  10065. * @hidden
  10066. */ actionManager: ActionManager;
  10067. /**
  10068. * Internal only
  10069. * @hidden
  10070. */ evaluationId: number;
  10071. /**
  10072. * Internal only
  10073. * @hidden
  10074. */ currentResult: boolean;
  10075. /**
  10076. * Creates a new Condition
  10077. * @param actionManager the manager of the action the condition is applied to
  10078. */
  10079. constructor(actionManager: ActionManager);
  10080. /**
  10081. * Check if the current condition is valid
  10082. * @returns a boolean
  10083. */
  10084. isValid(): boolean;
  10085. /**
  10086. * Internal only
  10087. * @hidden
  10088. */ getProperty(propertyPath: string): string;
  10089. /**
  10090. * Internal only
  10091. * @hidden
  10092. */ getEffectiveTarget(target: any, propertyPath: string): any;
  10093. /**
  10094. * Serialize placeholder for child classes
  10095. * @returns the serialized object
  10096. */
  10097. serialize(): any;
  10098. /**
  10099. * Internal only
  10100. * @hidden
  10101. */
  10102. protected _serialize(serializedCondition: any): any;
  10103. }
  10104. /**
  10105. * Defines specific conditional operators as extensions of Condition
  10106. */
  10107. export class ValueCondition extends Condition {
  10108. /** path to specify the property of the target the conditional operator uses */
  10109. propertyPath: string;
  10110. /** the value compared by the conditional operator against the current value of the property */
  10111. value: any;
  10112. /** the conditional operator, default ValueCondition.IsEqual */
  10113. operator: number;
  10114. /**
  10115. * Internal only
  10116. * @hidden
  10117. */
  10118. private static _IsEqual;
  10119. /**
  10120. * Internal only
  10121. * @hidden
  10122. */
  10123. private static _IsDifferent;
  10124. /**
  10125. * Internal only
  10126. * @hidden
  10127. */
  10128. private static _IsGreater;
  10129. /**
  10130. * Internal only
  10131. * @hidden
  10132. */
  10133. private static _IsLesser;
  10134. /**
  10135. * returns the number for IsEqual
  10136. */
  10137. static readonly IsEqual: number;
  10138. /**
  10139. * Returns the number for IsDifferent
  10140. */
  10141. static readonly IsDifferent: number;
  10142. /**
  10143. * Returns the number for IsGreater
  10144. */
  10145. static readonly IsGreater: number;
  10146. /**
  10147. * Returns the number for IsLesser
  10148. */
  10149. static readonly IsLesser: number;
  10150. /**
  10151. * Internal only The action manager for the condition
  10152. * @hidden
  10153. */ actionManager: ActionManager;
  10154. /**
  10155. * Internal only
  10156. * @hidden
  10157. */
  10158. private _target;
  10159. /**
  10160. * Internal only
  10161. * @hidden
  10162. */
  10163. private _effectiveTarget;
  10164. /**
  10165. * Internal only
  10166. * @hidden
  10167. */
  10168. private _property;
  10169. /**
  10170. * Creates a new ValueCondition
  10171. * @param actionManager manager for the action the condition applies to
  10172. * @param target for the action
  10173. * @param propertyPath path to specify the property of the target the conditional operator uses
  10174. * @param value the value compared by the conditional operator against the current value of the property
  10175. * @param operator the conditional operator, default ValueCondition.IsEqual
  10176. */
  10177. constructor(actionManager: ActionManager, target: any,
  10178. /** path to specify the property of the target the conditional operator uses */
  10179. propertyPath: string,
  10180. /** the value compared by the conditional operator against the current value of the property */
  10181. value: any,
  10182. /** the conditional operator, default ValueCondition.IsEqual */
  10183. operator?: number);
  10184. /**
  10185. * Compares the given value with the property value for the specified conditional operator
  10186. * @returns the result of the comparison
  10187. */
  10188. isValid(): boolean;
  10189. /**
  10190. * Serialize the ValueCondition into a JSON compatible object
  10191. * @returns serialization object
  10192. */
  10193. serialize(): any;
  10194. /**
  10195. * Gets the name of the conditional operator for the ValueCondition
  10196. * @param operator the conditional operator
  10197. * @returns the name
  10198. */
  10199. static GetOperatorName(operator: number): string;
  10200. }
  10201. /**
  10202. * Defines a predicate condition as an extension of Condition
  10203. */
  10204. export class PredicateCondition extends Condition {
  10205. /** defines the predicate function used to validate the condition */
  10206. predicate: () => boolean;
  10207. /**
  10208. * Internal only - manager for action
  10209. * @hidden
  10210. */ actionManager: ActionManager;
  10211. /**
  10212. * Creates a new PredicateCondition
  10213. * @param actionManager manager for the action the condition applies to
  10214. * @param predicate defines the predicate function used to validate the condition
  10215. */
  10216. constructor(actionManager: ActionManager,
  10217. /** defines the predicate function used to validate the condition */
  10218. predicate: () => boolean);
  10219. /**
  10220. * @returns the validity of the predicate condition
  10221. */
  10222. isValid(): boolean;
  10223. }
  10224. /**
  10225. * Defines a state condition as an extension of Condition
  10226. */
  10227. export class StateCondition extends Condition {
  10228. /** Value to compare with target state */
  10229. value: string;
  10230. /**
  10231. * Internal only - manager for action
  10232. * @hidden
  10233. */ actionManager: ActionManager;
  10234. /**
  10235. * Internal only
  10236. * @hidden
  10237. */
  10238. private _target;
  10239. /**
  10240. * Creates a new StateCondition
  10241. * @param actionManager manager for the action the condition applies to
  10242. * @param target of the condition
  10243. * @param value to compare with target state
  10244. */
  10245. constructor(actionManager: ActionManager, target: any,
  10246. /** Value to compare with target state */
  10247. value: string);
  10248. /**
  10249. * Gets a boolean indicating if the current condition is met
  10250. * @returns the validity of the state
  10251. */
  10252. isValid(): boolean;
  10253. /**
  10254. * Serialize the StateCondition into a JSON compatible object
  10255. * @returns serialization object
  10256. */
  10257. serialize(): any;
  10258. }
  10259. }
  10260. declare module BABYLON {
  10261. /**
  10262. * This defines an action responsible to toggle a boolean once triggered.
  10263. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10264. */
  10265. export class SwitchBooleanAction extends Action {
  10266. /**
  10267. * The path to the boolean property in the target object
  10268. */
  10269. propertyPath: string;
  10270. private _target;
  10271. private _effectiveTarget;
  10272. private _property;
  10273. /**
  10274. * Instantiate the action
  10275. * @param triggerOptions defines the trigger options
  10276. * @param target defines the object containing the boolean
  10277. * @param propertyPath defines the path to the boolean property in the target object
  10278. * @param condition defines the trigger related conditions
  10279. */
  10280. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10281. /** @hidden */ prepare(): void;
  10282. /**
  10283. * Execute the action toggle the boolean value.
  10284. */
  10285. execute(): void;
  10286. /**
  10287. * Serializes the actions and its related information.
  10288. * @param parent defines the object to serialize in
  10289. * @returns the serialized object
  10290. */
  10291. serialize(parent: any): any;
  10292. }
  10293. /**
  10294. * This defines an action responsible to set a the state field of the target
  10295. * to a desired value once triggered.
  10296. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10297. */
  10298. export class SetStateAction extends Action {
  10299. /**
  10300. * The value to store in the state field.
  10301. */
  10302. value: string;
  10303. private _target;
  10304. /**
  10305. * Instantiate the action
  10306. * @param triggerOptions defines the trigger options
  10307. * @param target defines the object containing the state property
  10308. * @param value defines the value to store in the state field
  10309. * @param condition defines the trigger related conditions
  10310. */
  10311. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10312. /**
  10313. * Execute the action and store the value on the target state property.
  10314. */
  10315. execute(): void;
  10316. /**
  10317. * Serializes the actions and its related information.
  10318. * @param parent defines the object to serialize in
  10319. * @returns the serialized object
  10320. */
  10321. serialize(parent: any): any;
  10322. }
  10323. /**
  10324. * This defines an action responsible to set a property of the target
  10325. * to a desired value once triggered.
  10326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10327. */
  10328. export class SetValueAction extends Action {
  10329. /**
  10330. * The path of the property to set in the target.
  10331. */
  10332. propertyPath: string;
  10333. /**
  10334. * The value to set in the property
  10335. */
  10336. value: any;
  10337. private _target;
  10338. private _effectiveTarget;
  10339. private _property;
  10340. /**
  10341. * Instantiate the action
  10342. * @param triggerOptions defines the trigger options
  10343. * @param target defines the object containing the property
  10344. * @param propertyPath defines the path of the property to set in the target
  10345. * @param value defines the value to set in the property
  10346. * @param condition defines the trigger related conditions
  10347. */
  10348. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10349. /** @hidden */ prepare(): void;
  10350. /**
  10351. * Execute the action and set the targetted property to the desired value.
  10352. */
  10353. execute(): void;
  10354. /**
  10355. * Serializes the actions and its related information.
  10356. * @param parent defines the object to serialize in
  10357. * @returns the serialized object
  10358. */
  10359. serialize(parent: any): any;
  10360. }
  10361. /**
  10362. * This defines an action responsible to increment the target value
  10363. * to a desired value once triggered.
  10364. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10365. */
  10366. export class IncrementValueAction extends Action {
  10367. /**
  10368. * The path of the property to increment in the target.
  10369. */
  10370. propertyPath: string;
  10371. /**
  10372. * The value we should increment the property by.
  10373. */
  10374. value: any;
  10375. private _target;
  10376. private _effectiveTarget;
  10377. private _property;
  10378. /**
  10379. * Instantiate the action
  10380. * @param triggerOptions defines the trigger options
  10381. * @param target defines the object containing the property
  10382. * @param propertyPath defines the path of the property to increment in the target
  10383. * @param value defines the value value we should increment the property by
  10384. * @param condition defines the trigger related conditions
  10385. */
  10386. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10387. /** @hidden */ prepare(): void;
  10388. /**
  10389. * Execute the action and increment the target of the value amount.
  10390. */
  10391. execute(): void;
  10392. /**
  10393. * Serializes the actions and its related information.
  10394. * @param parent defines the object to serialize in
  10395. * @returns the serialized object
  10396. */
  10397. serialize(parent: any): any;
  10398. }
  10399. /**
  10400. * This defines an action responsible to start an animation once triggered.
  10401. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10402. */
  10403. export class PlayAnimationAction extends Action {
  10404. /**
  10405. * Where the animation should start (animation frame)
  10406. */
  10407. from: number;
  10408. /**
  10409. * Where the animation should stop (animation frame)
  10410. */
  10411. to: number;
  10412. /**
  10413. * Define if the animation should loop or stop after the first play.
  10414. */
  10415. loop?: boolean;
  10416. private _target;
  10417. /**
  10418. * Instantiate the action
  10419. * @param triggerOptions defines the trigger options
  10420. * @param target defines the target animation or animation name
  10421. * @param from defines from where the animation should start (animation frame)
  10422. * @param end defines where the animation should stop (animation frame)
  10423. * @param loop defines if the animation should loop or stop after the first play
  10424. * @param condition defines the trigger related conditions
  10425. */
  10426. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10427. /** @hidden */ prepare(): void;
  10428. /**
  10429. * Execute the action and play the animation.
  10430. */
  10431. execute(): void;
  10432. /**
  10433. * Serializes the actions and its related information.
  10434. * @param parent defines the object to serialize in
  10435. * @returns the serialized object
  10436. */
  10437. serialize(parent: any): any;
  10438. }
  10439. /**
  10440. * This defines an action responsible to stop an animation once triggered.
  10441. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10442. */
  10443. export class StopAnimationAction extends Action {
  10444. private _target;
  10445. /**
  10446. * Instantiate the action
  10447. * @param triggerOptions defines the trigger options
  10448. * @param target defines the target animation or animation name
  10449. * @param condition defines the trigger related conditions
  10450. */
  10451. constructor(triggerOptions: any, target: any, condition?: Condition);
  10452. /** @hidden */ prepare(): void;
  10453. /**
  10454. * Execute the action and stop the animation.
  10455. */
  10456. execute(): void;
  10457. /**
  10458. * Serializes the actions and its related information.
  10459. * @param parent defines the object to serialize in
  10460. * @returns the serialized object
  10461. */
  10462. serialize(parent: any): any;
  10463. }
  10464. /**
  10465. * This defines an action responsible that does nothing once triggered.
  10466. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10467. */
  10468. export class DoNothingAction extends Action {
  10469. /**
  10470. * Instantiate the action
  10471. * @param triggerOptions defines the trigger options
  10472. * @param condition defines the trigger related conditions
  10473. */
  10474. constructor(triggerOptions?: any, condition?: Condition);
  10475. /**
  10476. * Execute the action and do nothing.
  10477. */
  10478. execute(): void;
  10479. /**
  10480. * Serializes the actions and its related information.
  10481. * @param parent defines the object to serialize in
  10482. * @returns the serialized object
  10483. */
  10484. serialize(parent: any): any;
  10485. }
  10486. /**
  10487. * This defines an action responsible to trigger several actions once triggered.
  10488. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10489. */
  10490. export class CombineAction extends Action {
  10491. /**
  10492. * The list of aggregated animations to run.
  10493. */
  10494. children: Action[];
  10495. /**
  10496. * Instantiate the action
  10497. * @param triggerOptions defines the trigger options
  10498. * @param children defines the list of aggregated animations to run
  10499. * @param condition defines the trigger related conditions
  10500. */
  10501. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10502. /** @hidden */ prepare(): void;
  10503. /**
  10504. * Execute the action and executes all the aggregated actions.
  10505. */
  10506. execute(evt: ActionEvent): void;
  10507. /**
  10508. * Serializes the actions and its related information.
  10509. * @param parent defines the object to serialize in
  10510. * @returns the serialized object
  10511. */
  10512. serialize(parent: any): any;
  10513. }
  10514. /**
  10515. * This defines an action responsible to run code (external event) once triggered.
  10516. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10517. */
  10518. export class ExecuteCodeAction extends Action {
  10519. /**
  10520. * The callback function to run.
  10521. */
  10522. func: (evt: ActionEvent) => void;
  10523. /**
  10524. * Instantiate the action
  10525. * @param triggerOptions defines the trigger options
  10526. * @param func defines the callback function to run
  10527. * @param condition defines the trigger related conditions
  10528. */
  10529. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10530. /**
  10531. * Execute the action and run the attached code.
  10532. */
  10533. execute(evt: ActionEvent): void;
  10534. }
  10535. /**
  10536. * This defines an action responsible to set the parent property of the target once triggered.
  10537. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10538. */
  10539. export class SetParentAction extends Action {
  10540. private _parent;
  10541. private _target;
  10542. /**
  10543. * Instantiate the action
  10544. * @param triggerOptions defines the trigger options
  10545. * @param target defines the target containing the parent property
  10546. * @param parent defines from where the animation should start (animation frame)
  10547. * @param condition defines the trigger related conditions
  10548. */
  10549. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10550. /** @hidden */ prepare(): void;
  10551. /**
  10552. * Execute the action and set the parent property.
  10553. */
  10554. execute(): void;
  10555. /**
  10556. * Serializes the actions and its related information.
  10557. * @param parent defines the object to serialize in
  10558. * @returns the serialized object
  10559. */
  10560. serialize(parent: any): any;
  10561. }
  10562. }
  10563. declare module BABYLON {
  10564. /**
  10565. * Abstract class used to decouple action Manager from scene and meshes.
  10566. * Do not instantiate.
  10567. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10568. */
  10569. export abstract class AbstractActionManager implements IDisposable {
  10570. /** Gets the list of active triggers */
  10571. static Triggers: {
  10572. [key: string]: number;
  10573. };
  10574. /** Gets the cursor to use when hovering items */
  10575. hoverCursor: string;
  10576. /** Gets the list of actions */
  10577. actions: IAction[];
  10578. /**
  10579. * Releases all associated resources
  10580. */
  10581. abstract dispose(): void;
  10582. /**
  10583. * Does this action manager has pointer triggers
  10584. */
  10585. abstract readonly hasPointerTriggers: boolean;
  10586. /**
  10587. * Does this action manager has pick triggers
  10588. */
  10589. abstract readonly hasPickTriggers: boolean;
  10590. /**
  10591. * Process a specific trigger
  10592. * @param trigger defines the trigger to process
  10593. * @param evt defines the event details to be processed
  10594. */
  10595. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  10596. /**
  10597. * Does this action manager handles actions of any of the given triggers
  10598. * @param triggers defines the triggers to be tested
  10599. * @return a boolean indicating whether one (or more) of the triggers is handled
  10600. */
  10601. abstract hasSpecificTriggers(triggers: number[]): boolean;
  10602. /**
  10603. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10604. * speed.
  10605. * @param triggerA defines the trigger to be tested
  10606. * @param triggerB defines the trigger to be tested
  10607. * @return a boolean indicating whether one (or more) of the triggers is handled
  10608. */
  10609. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10610. /**
  10611. * Does this action manager handles actions of a given trigger
  10612. * @param trigger defines the trigger to be tested
  10613. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10614. * @return whether the trigger is handled
  10615. */
  10616. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10617. /**
  10618. * Serialize this manager to a JSON object
  10619. * @param name defines the property name to store this manager
  10620. * @returns a JSON representation of this manager
  10621. */
  10622. abstract serialize(name: string): any;
  10623. /**
  10624. * Does exist one action manager with at least one trigger
  10625. **/
  10626. static readonly HasTriggers: boolean;
  10627. /**
  10628. * Does exist one action manager with at least one pick trigger
  10629. **/
  10630. static readonly HasPickTriggers: boolean;
  10631. /**
  10632. * Does exist one action manager that handles actions of a given trigger
  10633. * @param trigger defines the trigger to be tested
  10634. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  10635. **/
  10636. static HasSpecificTrigger(trigger: number): boolean;
  10637. }
  10638. }
  10639. declare module BABYLON {
  10640. /**
  10641. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10642. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10643. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10644. */
  10645. export class ActionManager extends AbstractActionManager {
  10646. /**
  10647. * Nothing
  10648. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10649. */
  10650. static readonly NothingTrigger: number;
  10651. /**
  10652. * On pick
  10653. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10654. */
  10655. static readonly OnPickTrigger: number;
  10656. /**
  10657. * On left pick
  10658. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10659. */
  10660. static readonly OnLeftPickTrigger: number;
  10661. /**
  10662. * On right pick
  10663. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10664. */
  10665. static readonly OnRightPickTrigger: number;
  10666. /**
  10667. * On center pick
  10668. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10669. */
  10670. static readonly OnCenterPickTrigger: number;
  10671. /**
  10672. * On pick down
  10673. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10674. */
  10675. static readonly OnPickDownTrigger: number;
  10676. /**
  10677. * On double pick
  10678. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10679. */
  10680. static readonly OnDoublePickTrigger: number;
  10681. /**
  10682. * On pick up
  10683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10684. */
  10685. static readonly OnPickUpTrigger: number;
  10686. /**
  10687. * On pick out.
  10688. * This trigger will only be raised if you also declared a OnPickDown
  10689. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10690. */
  10691. static readonly OnPickOutTrigger: number;
  10692. /**
  10693. * On long press
  10694. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10695. */
  10696. static readonly OnLongPressTrigger: number;
  10697. /**
  10698. * On pointer over
  10699. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10700. */
  10701. static readonly OnPointerOverTrigger: number;
  10702. /**
  10703. * On pointer out
  10704. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10705. */
  10706. static readonly OnPointerOutTrigger: number;
  10707. /**
  10708. * On every frame
  10709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10710. */
  10711. static readonly OnEveryFrameTrigger: number;
  10712. /**
  10713. * On intersection enter
  10714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10715. */
  10716. static readonly OnIntersectionEnterTrigger: number;
  10717. /**
  10718. * On intersection exit
  10719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10720. */
  10721. static readonly OnIntersectionExitTrigger: number;
  10722. /**
  10723. * On key down
  10724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10725. */
  10726. static readonly OnKeyDownTrigger: number;
  10727. /**
  10728. * On key up
  10729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10730. */
  10731. static readonly OnKeyUpTrigger: number;
  10732. private _scene;
  10733. /**
  10734. * Creates a new action manager
  10735. * @param scene defines the hosting scene
  10736. */
  10737. constructor(scene: Scene);
  10738. /**
  10739. * Releases all associated resources
  10740. */
  10741. dispose(): void;
  10742. /**
  10743. * Gets hosting scene
  10744. * @returns the hosting scene
  10745. */
  10746. getScene(): Scene;
  10747. /**
  10748. * Does this action manager handles actions of any of the given triggers
  10749. * @param triggers defines the triggers to be tested
  10750. * @return a boolean indicating whether one (or more) of the triggers is handled
  10751. */
  10752. hasSpecificTriggers(triggers: number[]): boolean;
  10753. /**
  10754. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10755. * speed.
  10756. * @param triggerA defines the trigger to be tested
  10757. * @param triggerB defines the trigger to be tested
  10758. * @return a boolean indicating whether one (or more) of the triggers is handled
  10759. */
  10760. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10761. /**
  10762. * Does this action manager handles actions of a given trigger
  10763. * @param trigger defines the trigger to be tested
  10764. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10765. * @return whether the trigger is handled
  10766. */
  10767. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10768. /**
  10769. * Does this action manager has pointer triggers
  10770. */
  10771. readonly hasPointerTriggers: boolean;
  10772. /**
  10773. * Does this action manager has pick triggers
  10774. */
  10775. readonly hasPickTriggers: boolean;
  10776. /**
  10777. * Registers an action to this action manager
  10778. * @param action defines the action to be registered
  10779. * @return the action amended (prepared) after registration
  10780. */
  10781. registerAction(action: Action): Nullable<Action>;
  10782. /**
  10783. * Unregisters an action to this action manager
  10784. * @param action defines the action to be unregistered
  10785. * @return a boolean indicating whether the action has been unregistered
  10786. */
  10787. unregisterAction(action: Action): Boolean;
  10788. /**
  10789. * Process a specific trigger
  10790. * @param trigger defines the trigger to process
  10791. * @param evt defines the event details to be processed
  10792. */
  10793. processTrigger(trigger: number, evt?: IActionEvent): void;
  10794. /** @hidden */ getEffectiveTarget(target: any, propertyPath: string): any;
  10795. /** @hidden */ getProperty(propertyPath: string): string;
  10796. /**
  10797. * Serialize this manager to a JSON object
  10798. * @param name defines the property name to store this manager
  10799. * @returns a JSON representation of this manager
  10800. */
  10801. serialize(name: string): any;
  10802. /**
  10803. * Creates a new ActionManager from a JSON data
  10804. * @param parsedActions defines the JSON data to read from
  10805. * @param object defines the hosting mesh
  10806. * @param scene defines the hosting scene
  10807. */
  10808. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10809. /**
  10810. * Get a trigger name by index
  10811. * @param trigger defines the trigger index
  10812. * @returns a trigger name
  10813. */
  10814. static GetTriggerName(trigger: number): string;
  10815. }
  10816. }
  10817. declare module BABYLON {
  10818. /**
  10819. * Class representing a ray with position and direction
  10820. */
  10821. export class Ray {
  10822. /** origin point */
  10823. origin: Vector3;
  10824. /** direction */
  10825. direction: Vector3;
  10826. /** length of the ray */
  10827. length: number;
  10828. private static readonly TmpVector3;
  10829. private _tmpRay;
  10830. /**
  10831. * Creates a new ray
  10832. * @param origin origin point
  10833. * @param direction direction
  10834. * @param length length of the ray
  10835. */
  10836. constructor(
  10837. /** origin point */
  10838. origin: Vector3,
  10839. /** direction */
  10840. direction: Vector3,
  10841. /** length of the ray */
  10842. length?: number);
  10843. /**
  10844. * Checks if the ray intersects a box
  10845. * @param minimum bound of the box
  10846. * @param maximum bound of the box
  10847. * @param intersectionTreshold extra extend to be added to the box in all direction
  10848. * @returns if the box was hit
  10849. */
  10850. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10851. /**
  10852. * Checks if the ray intersects a box
  10853. * @param box the bounding box to check
  10854. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10855. * @returns if the box was hit
  10856. */
  10857. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10858. /**
  10859. * If the ray hits a sphere
  10860. * @param sphere the bounding sphere to check
  10861. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10862. * @returns true if it hits the sphere
  10863. */
  10864. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10865. /**
  10866. * If the ray hits a triange
  10867. * @param vertex0 triangle vertex
  10868. * @param vertex1 triangle vertex
  10869. * @param vertex2 triangle vertex
  10870. * @returns intersection information if hit
  10871. */
  10872. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10873. /**
  10874. * Checks if ray intersects a plane
  10875. * @param plane the plane to check
  10876. * @returns the distance away it was hit
  10877. */
  10878. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10879. /**
  10880. * Checks if ray intersects a mesh
  10881. * @param mesh the mesh to check
  10882. * @param fastCheck if only the bounding box should checked
  10883. * @returns picking info of the intersecton
  10884. */
  10885. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10886. /**
  10887. * Checks if ray intersects a mesh
  10888. * @param meshes the meshes to check
  10889. * @param fastCheck if only the bounding box should checked
  10890. * @param results array to store result in
  10891. * @returns Array of picking infos
  10892. */
  10893. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10894. private _comparePickingInfo;
  10895. private static smallnum;
  10896. private static rayl;
  10897. /**
  10898. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10899. * @param sega the first point of the segment to test the intersection against
  10900. * @param segb the second point of the segment to test the intersection against
  10901. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10902. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10903. */
  10904. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10905. /**
  10906. * Update the ray from viewport position
  10907. * @param x position
  10908. * @param y y position
  10909. * @param viewportWidth viewport width
  10910. * @param viewportHeight viewport height
  10911. * @param world world matrix
  10912. * @param view view matrix
  10913. * @param projection projection matrix
  10914. * @returns this ray updated
  10915. */
  10916. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10917. /**
  10918. * Creates a ray with origin and direction of 0,0,0
  10919. * @returns the new ray
  10920. */
  10921. static Zero(): Ray;
  10922. /**
  10923. * Creates a new ray from screen space and viewport
  10924. * @param x position
  10925. * @param y y position
  10926. * @param viewportWidth viewport width
  10927. * @param viewportHeight viewport height
  10928. * @param world world matrix
  10929. * @param view view matrix
  10930. * @param projection projection matrix
  10931. * @returns new ray
  10932. */
  10933. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10934. /**
  10935. * 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
  10936. * transformed to the given world matrix.
  10937. * @param origin The origin point
  10938. * @param end The end point
  10939. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10940. * @returns the new ray
  10941. */
  10942. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10943. /**
  10944. * Transforms a ray by a matrix
  10945. * @param ray ray to transform
  10946. * @param matrix matrix to apply
  10947. * @returns the resulting new ray
  10948. */
  10949. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10950. /**
  10951. * Transforms a ray by a matrix
  10952. * @param ray ray to transform
  10953. * @param matrix matrix to apply
  10954. * @param result ray to store result in
  10955. */
  10956. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10957. /**
  10958. * Unproject a ray from screen space to object space
  10959. * @param sourceX defines the screen space x coordinate to use
  10960. * @param sourceY defines the screen space y coordinate to use
  10961. * @param viewportWidth defines the current width of the viewport
  10962. * @param viewportHeight defines the current height of the viewport
  10963. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10964. * @param view defines the view matrix to use
  10965. * @param projection defines the projection matrix to use
  10966. */
  10967. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10968. }
  10969. interface Scene {
  10970. /** @hidden */ tempPickingRay: Nullable<Ray>;
  10971. /** @hidden */ cachedRayForTransform: Ray;
  10972. /** @hidden */ pickWithRayInverseMatrix: Matrix;
  10973. /** @hidden */ internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10974. /** @hidden */ internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  10975. }
  10976. }
  10977. declare module BABYLON {
  10978. /**
  10979. * Groups all the scene component constants in one place to ease maintenance.
  10980. * @hidden
  10981. */
  10982. export class SceneComponentConstants {
  10983. static readonly NAME_EFFECTLAYER: string;
  10984. static readonly NAME_LAYER: string;
  10985. static readonly NAME_LENSFLARESYSTEM: string;
  10986. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10987. static readonly NAME_PARTICLESYSTEM: string;
  10988. static readonly NAME_GAMEPAD: string;
  10989. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10990. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10991. static readonly NAME_DEPTHRENDERER: string;
  10992. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10993. static readonly NAME_SPRITE: string;
  10994. static readonly NAME_OUTLINERENDERER: string;
  10995. static readonly NAME_PROCEDURALTEXTURE: string;
  10996. static readonly NAME_SHADOWGENERATOR: string;
  10997. static readonly NAME_OCTREE: string;
  10998. static readonly NAME_PHYSICSENGINE: string;
  10999. static readonly NAME_AUDIO: string;
  11000. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11001. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11002. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11003. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11004. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11005. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11006. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11007. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11008. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11009. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11010. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11011. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11012. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11013. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11014. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11015. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11016. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11017. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11018. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11019. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11020. static readonly STEP_AFTERRENDER_AUDIO: number;
  11021. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11022. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11023. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11024. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11025. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11026. static readonly STEP_POINTERMOVE_SPRITE: number;
  11027. static readonly STEP_POINTERDOWN_SPRITE: number;
  11028. static readonly STEP_POINTERUP_SPRITE: number;
  11029. }
  11030. /**
  11031. * This represents a scene component.
  11032. *
  11033. * This is used to decouple the dependency the scene is having on the different workloads like
  11034. * layers, post processes...
  11035. */
  11036. export interface ISceneComponent {
  11037. /**
  11038. * The name of the component. Each component must have a unique name.
  11039. */
  11040. name: string;
  11041. /**
  11042. * The scene the component belongs to.
  11043. */
  11044. scene: Scene;
  11045. /**
  11046. * Register the component to one instance of a scene.
  11047. */
  11048. register(): void;
  11049. /**
  11050. * Rebuilds the elements related to this component in case of
  11051. * context lost for instance.
  11052. */
  11053. rebuild(): void;
  11054. /**
  11055. * Disposes the component and the associated ressources.
  11056. */
  11057. dispose(): void;
  11058. }
  11059. /**
  11060. * This represents a SERIALIZABLE scene component.
  11061. *
  11062. * This extends Scene Component to add Serialization methods on top.
  11063. */
  11064. export interface ISceneSerializableComponent extends ISceneComponent {
  11065. /**
  11066. * Adds all the element from the container to the scene
  11067. * @param container the container holding the elements
  11068. */
  11069. addFromContainer(container: AbstractScene): void;
  11070. /**
  11071. * Removes all the elements in the container from the scene
  11072. * @param container contains the elements to remove
  11073. */
  11074. removeFromContainer(container: AbstractScene): void;
  11075. /**
  11076. * Serializes the component data to the specified json object
  11077. * @param serializationObject The object to serialize to
  11078. */
  11079. serialize(serializationObject: any): void;
  11080. }
  11081. /**
  11082. * Strong typing of a Mesh related stage step action
  11083. */
  11084. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11085. /**
  11086. * Strong typing of a Evaluate Sub Mesh related stage step action
  11087. */
  11088. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11089. /**
  11090. * Strong typing of a Active Mesh related stage step action
  11091. */
  11092. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11093. /**
  11094. * Strong typing of a Camera related stage step action
  11095. */
  11096. export type CameraStageAction = (camera: Camera) => void;
  11097. /**
  11098. * Strong typing of a Render Target related stage step action
  11099. */
  11100. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11101. /**
  11102. * Strong typing of a RenderingGroup related stage step action
  11103. */
  11104. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11105. /**
  11106. * Strong typing of a Mesh Render related stage step action
  11107. */
  11108. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11109. /**
  11110. * Strong typing of a simple stage step action
  11111. */
  11112. export type SimpleStageAction = () => void;
  11113. /**
  11114. * Strong typing of a render target action.
  11115. */
  11116. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11117. /**
  11118. * Strong typing of a pointer move action.
  11119. */
  11120. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11121. /**
  11122. * Strong typing of a pointer up/down action.
  11123. */
  11124. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11125. /**
  11126. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11127. * @hidden
  11128. */
  11129. export class Stage<T extends Function> extends Array<{
  11130. index: number;
  11131. component: ISceneComponent;
  11132. action: T;
  11133. }> {
  11134. /**
  11135. * Hide ctor from the rest of the world.
  11136. * @param items The items to add.
  11137. */
  11138. private constructor();
  11139. /**
  11140. * Creates a new Stage.
  11141. * @returns A new instance of a Stage
  11142. */
  11143. static Create<T extends Function>(): Stage<T>;
  11144. /**
  11145. * Registers a step in an ordered way in the targeted stage.
  11146. * @param index Defines the position to register the step in
  11147. * @param component Defines the component attached to the step
  11148. * @param action Defines the action to launch during the step
  11149. */
  11150. registerStep(index: number, component: ISceneComponent, action: T): void;
  11151. /**
  11152. * Clears all the steps from the stage.
  11153. */
  11154. clear(): void;
  11155. }
  11156. }
  11157. declare module BABYLON {
  11158. interface Scene {
  11159. /** @hidden */ pointerOverSprite: Nullable<Sprite>;
  11160. /** @hidden */ pickedDownSprite: Nullable<Sprite>;
  11161. /** @hidden */ tempSpritePickingRay: Nullable<Ray>;
  11162. /**
  11163. * All of the sprite managers added to this scene
  11164. * @see http://doc.babylonjs.com/babylon101/sprites
  11165. */
  11166. spriteManagers: Array<ISpriteManager>;
  11167. /**
  11168. * An event triggered when sprites rendering is about to start
  11169. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11170. */
  11171. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11172. /**
  11173. * An event triggered when sprites rendering is done
  11174. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11175. */
  11176. onAfterSpritesRenderingObservable: Observable<Scene>;
  11177. /** @hidden */ internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11178. /** Launch a ray to try to pick a sprite in the scene
  11179. * @param x position on screen
  11180. * @param y position on screen
  11181. * @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
  11182. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11183. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11184. * @returns a PickingInfo
  11185. */
  11186. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11187. /** Use the given ray to pick a sprite in the scene
  11188. * @param ray The ray (in world space) to use to pick meshes
  11189. * @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
  11190. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11191. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11192. * @returns a PickingInfo
  11193. */
  11194. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11195. /**
  11196. * Force the sprite under the pointer
  11197. * @param sprite defines the sprite to use
  11198. */
  11199. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11200. /**
  11201. * Gets the sprite under the pointer
  11202. * @returns a Sprite or null if no sprite is under the pointer
  11203. */
  11204. getPointerOverSprite(): Nullable<Sprite>;
  11205. }
  11206. /**
  11207. * Defines the sprite scene component responsible to manage sprites
  11208. * in a given scene.
  11209. */
  11210. export class SpriteSceneComponent implements ISceneComponent {
  11211. /**
  11212. * The component name helpfull to identify the component in the list of scene components.
  11213. */
  11214. readonly name: string;
  11215. /**
  11216. * The scene the component belongs to.
  11217. */
  11218. scene: Scene;
  11219. /** @hidden */
  11220. private _spritePredicate;
  11221. /**
  11222. * Creates a new instance of the component for the given scene
  11223. * @param scene Defines the scene to register the component in
  11224. */
  11225. constructor(scene: Scene);
  11226. /**
  11227. * Registers the component in a given scene
  11228. */
  11229. register(): void;
  11230. /**
  11231. * Rebuilds the elements related to this component in case of
  11232. * context lost for instance.
  11233. */
  11234. rebuild(): void;
  11235. /**
  11236. * Disposes the component and the associated ressources.
  11237. */
  11238. dispose(): void;
  11239. private _pickSpriteButKeepRay;
  11240. private _pointerMove;
  11241. private _pointerDown;
  11242. private _pointerUp;
  11243. }
  11244. }
  11245. declare module BABYLON {
  11246. /** @hidden */
  11247. export var fogFragmentDeclaration: {
  11248. name: string;
  11249. shader: string;
  11250. };
  11251. }
  11252. declare module BABYLON {
  11253. /** @hidden */
  11254. export var fogFragment: {
  11255. name: string;
  11256. shader: string;
  11257. };
  11258. }
  11259. declare module BABYLON {
  11260. /** @hidden */
  11261. export var spritesPixelShader: {
  11262. name: string;
  11263. shader: string;
  11264. };
  11265. }
  11266. declare module BABYLON {
  11267. /** @hidden */
  11268. export var fogVertexDeclaration: {
  11269. name: string;
  11270. shader: string;
  11271. };
  11272. }
  11273. declare module BABYLON {
  11274. /** @hidden */
  11275. export var spritesVertexShader: {
  11276. name: string;
  11277. shader: string;
  11278. };
  11279. }
  11280. declare module BABYLON {
  11281. /**
  11282. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11283. */
  11284. export interface ISpriteManager extends IDisposable {
  11285. /**
  11286. * Restricts the camera to viewing objects with the same layerMask.
  11287. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11288. */
  11289. layerMask: number;
  11290. /**
  11291. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11292. */
  11293. isPickable: boolean;
  11294. /**
  11295. * Specifies the rendering group id for this mesh (0 by default)
  11296. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11297. */
  11298. renderingGroupId: number;
  11299. /**
  11300. * Defines the list of sprites managed by the manager.
  11301. */
  11302. sprites: Array<Sprite>;
  11303. /**
  11304. * Tests the intersection of a sprite with a specific ray.
  11305. * @param ray The ray we are sending to test the collision
  11306. * @param camera The camera space we are sending rays in
  11307. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11308. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11309. * @returns picking info or null.
  11310. */
  11311. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11312. /**
  11313. * Renders the list of sprites on screen.
  11314. */
  11315. render(): void;
  11316. }
  11317. /**
  11318. * Class used to manage multiple sprites on the same spritesheet
  11319. * @see http://doc.babylonjs.com/babylon101/sprites
  11320. */
  11321. export class SpriteManager implements ISpriteManager {
  11322. /** defines the manager's name */
  11323. name: string;
  11324. /** Gets the list of sprites */
  11325. sprites: Sprite[];
  11326. /** Gets or sets the rendering group id (0 by default) */
  11327. renderingGroupId: number;
  11328. /** Gets or sets camera layer mask */
  11329. layerMask: number;
  11330. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11331. fogEnabled: boolean;
  11332. /** Gets or sets a boolean indicating if the sprites are pickable */
  11333. isPickable: boolean;
  11334. /** Defines the default width of a cell in the spritesheet */
  11335. cellWidth: number;
  11336. /** Defines the default height of a cell in the spritesheet */
  11337. cellHeight: number;
  11338. /**
  11339. * An event triggered when the manager is disposed.
  11340. */
  11341. onDisposeObservable: Observable<SpriteManager>;
  11342. private _onDisposeObserver;
  11343. /**
  11344. * Callback called when the manager is disposed
  11345. */
  11346. onDispose: () => void;
  11347. private _capacity;
  11348. private _spriteTexture;
  11349. private _epsilon;
  11350. private _scene;
  11351. private _vertexData;
  11352. private _buffer;
  11353. private _vertexBuffers;
  11354. private _indexBuffer;
  11355. private _effectBase;
  11356. private _effectFog;
  11357. /**
  11358. * Gets or sets the spritesheet texture
  11359. */
  11360. texture: Texture;
  11361. /**
  11362. * Creates a new sprite manager
  11363. * @param name defines the manager's name
  11364. * @param imgUrl defines the sprite sheet url
  11365. * @param capacity defines the maximum allowed number of sprites
  11366. * @param cellSize defines the size of a sprite cell
  11367. * @param scene defines the hosting scene
  11368. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11369. * @param samplingMode defines the smapling mode to use with spritesheet
  11370. */
  11371. constructor(
  11372. /** defines the manager's name */
  11373. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11374. private _appendSpriteVertex;
  11375. /**
  11376. * Intersects the sprites with a ray
  11377. * @param ray defines the ray to intersect with
  11378. * @param camera defines the current active camera
  11379. * @param predicate defines a predicate used to select candidate sprites
  11380. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11381. * @returns null if no hit or a PickingInfo
  11382. */
  11383. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11384. /**
  11385. * Render all child sprites
  11386. */
  11387. render(): void;
  11388. /**
  11389. * Release associated resources
  11390. */
  11391. dispose(): void;
  11392. }
  11393. }
  11394. declare module BABYLON {
  11395. /**
  11396. * Class used to represent a sprite
  11397. * @see http://doc.babylonjs.com/babylon101/sprites
  11398. */
  11399. export class Sprite {
  11400. /** defines the name */
  11401. name: string;
  11402. /** Gets or sets the current world position */
  11403. position: Vector3;
  11404. /** Gets or sets the main color */
  11405. color: Color4;
  11406. /** Gets or sets the width */
  11407. width: number;
  11408. /** Gets or sets the height */
  11409. height: number;
  11410. /** Gets or sets rotation angle */
  11411. angle: number;
  11412. /** Gets or sets the cell index in the sprite sheet */
  11413. cellIndex: number;
  11414. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11415. invertU: number;
  11416. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11417. invertV: number;
  11418. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11419. disposeWhenFinishedAnimating: boolean;
  11420. /** Gets the list of attached animations */
  11421. animations: Animation[];
  11422. /** Gets or sets a boolean indicating if the sprite can be picked */
  11423. isPickable: boolean;
  11424. /**
  11425. * Gets or sets the associated action manager
  11426. */
  11427. actionManager: Nullable<ActionManager>;
  11428. private _animationStarted;
  11429. private _loopAnimation;
  11430. private _fromIndex;
  11431. private _toIndex;
  11432. private _delay;
  11433. private _direction;
  11434. private _manager;
  11435. private _time;
  11436. private _onAnimationEnd;
  11437. /**
  11438. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11439. */
  11440. isVisible: boolean;
  11441. /**
  11442. * Gets or sets the sprite size
  11443. */
  11444. size: number;
  11445. /**
  11446. * Creates a new Sprite
  11447. * @param name defines the name
  11448. * @param manager defines the manager
  11449. */
  11450. constructor(
  11451. /** defines the name */
  11452. name: string, manager: ISpriteManager);
  11453. /**
  11454. * Starts an animation
  11455. * @param from defines the initial key
  11456. * @param to defines the end key
  11457. * @param loop defines if the animation must loop
  11458. * @param delay defines the start delay (in ms)
  11459. * @param onAnimationEnd defines a callback to call when animation ends
  11460. */
  11461. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11462. /** Stops current animation (if any) */
  11463. stopAnimation(): void;
  11464. /** @hidden */ animate(deltaTime: number): void;
  11465. /** Release associated resources */
  11466. dispose(): void;
  11467. }
  11468. }
  11469. declare module BABYLON {
  11470. /**
  11471. * Information about the result of picking within a scene
  11472. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11473. */
  11474. export class PickingInfo {
  11475. /** @hidden */ pickingUnavailable: boolean;
  11476. /**
  11477. * If the pick collided with an object
  11478. */
  11479. hit: boolean;
  11480. /**
  11481. * Distance away where the pick collided
  11482. */
  11483. distance: number;
  11484. /**
  11485. * The location of pick collision
  11486. */
  11487. pickedPoint: Nullable<Vector3>;
  11488. /**
  11489. * The mesh corresponding the the pick collision
  11490. */
  11491. pickedMesh: Nullable<AbstractMesh>;
  11492. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11493. bu: number;
  11494. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11495. bv: number;
  11496. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11497. faceId: number;
  11498. /** Id of the the submesh that was picked */
  11499. subMeshId: number;
  11500. /** If a sprite was picked, this will be the sprite the pick collided with */
  11501. pickedSprite: Nullable<Sprite>;
  11502. /**
  11503. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11504. */
  11505. originMesh: Nullable<AbstractMesh>;
  11506. /**
  11507. * The ray that was used to perform the picking.
  11508. */
  11509. ray: Nullable<Ray>;
  11510. /**
  11511. * Gets the normal correspodning to the face the pick collided with
  11512. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11513. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11514. * @returns The normal correspodning to the face the pick collided with
  11515. */
  11516. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11517. /**
  11518. * Gets the texture coordinates of where the pick occured
  11519. * @returns the vector containing the coordnates of the texture
  11520. */
  11521. getTextureCoordinates(): Nullable<Vector2>;
  11522. }
  11523. }
  11524. declare module BABYLON {
  11525. /**
  11526. * Gather the list of pointer event types as constants.
  11527. */
  11528. export class PointerEventTypes {
  11529. /**
  11530. * 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.
  11531. */
  11532. static readonly POINTERDOWN: number;
  11533. /**
  11534. * The pointerup event is fired when a pointer is no longer active.
  11535. */
  11536. static readonly POINTERUP: number;
  11537. /**
  11538. * The pointermove event is fired when a pointer changes coordinates.
  11539. */
  11540. static readonly POINTERMOVE: number;
  11541. /**
  11542. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11543. */
  11544. static readonly POINTERWHEEL: number;
  11545. /**
  11546. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11547. */
  11548. static readonly POINTERPICK: number;
  11549. /**
  11550. * The pointertap event is fired when a the object has been touched and released without drag.
  11551. */
  11552. static readonly POINTERTAP: number;
  11553. /**
  11554. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11555. */
  11556. static readonly POINTERDOUBLETAP: number;
  11557. }
  11558. /**
  11559. * Base class of pointer info types.
  11560. */
  11561. export class PointerInfoBase {
  11562. /**
  11563. * Defines the type of event (PointerEventTypes)
  11564. */
  11565. type: number;
  11566. /**
  11567. * Defines the related dom event
  11568. */
  11569. event: PointerEvent | MouseWheelEvent;
  11570. /**
  11571. * Instantiates the base class of pointers info.
  11572. * @param type Defines the type of event (PointerEventTypes)
  11573. * @param event Defines the related dom event
  11574. */
  11575. constructor(
  11576. /**
  11577. * Defines the type of event (PointerEventTypes)
  11578. */
  11579. type: number,
  11580. /**
  11581. * Defines the related dom event
  11582. */
  11583. event: PointerEvent | MouseWheelEvent);
  11584. }
  11585. /**
  11586. * This class is used to store pointer related info for the onPrePointerObservable event.
  11587. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11588. */
  11589. export class PointerInfoPre extends PointerInfoBase {
  11590. /**
  11591. * Ray from a pointer if availible (eg. 6dof controller)
  11592. */
  11593. ray: Nullable<Ray>;
  11594. /**
  11595. * Defines the local position of the pointer on the canvas.
  11596. */
  11597. localPosition: Vector2;
  11598. /**
  11599. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11600. */
  11601. skipOnPointerObservable: boolean;
  11602. /**
  11603. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11604. * @param type Defines the type of event (PointerEventTypes)
  11605. * @param event Defines the related dom event
  11606. * @param localX Defines the local x coordinates of the pointer when the event occured
  11607. * @param localY Defines the local y coordinates of the pointer when the event occured
  11608. */
  11609. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11610. }
  11611. /**
  11612. * This type contains all the data related to a pointer event in Babylon.js.
  11613. * 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.
  11614. */
  11615. export class PointerInfo extends PointerInfoBase {
  11616. /**
  11617. * Defines the picking info associated to the info (if any)\
  11618. */
  11619. pickInfo: Nullable<PickingInfo>;
  11620. /**
  11621. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11622. * @param type Defines the type of event (PointerEventTypes)
  11623. * @param event Defines the related dom event
  11624. * @param pickInfo Defines the picking info associated to the info (if any)\
  11625. */
  11626. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11627. /**
  11628. * Defines the picking info associated to the info (if any)\
  11629. */
  11630. pickInfo: Nullable<PickingInfo>);
  11631. }
  11632. }
  11633. declare module BABYLON {
  11634. /**
  11635. * Manage the mouse inputs to control the movement of a free camera.
  11636. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11637. */
  11638. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11639. /**
  11640. * Define if touch is enabled in the mouse input
  11641. */
  11642. touchEnabled: boolean;
  11643. /**
  11644. * Defines the camera the input is attached to.
  11645. */
  11646. camera: FreeCamera;
  11647. /**
  11648. * Defines the buttons associated with the input to handle camera move.
  11649. */
  11650. buttons: number[];
  11651. /**
  11652. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11653. */
  11654. angularSensibility: number;
  11655. private _pointerInput;
  11656. private _onMouseMove;
  11657. private _observer;
  11658. private previousPosition;
  11659. /**
  11660. * Manage the mouse inputs to control the movement of a free camera.
  11661. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11662. * @param touchEnabled Defines if touch is enabled or not
  11663. */
  11664. constructor(
  11665. /**
  11666. * Define if touch is enabled in the mouse input
  11667. */
  11668. touchEnabled?: boolean);
  11669. /**
  11670. * Attach the input controls to a specific dom element to get the input from.
  11671. * @param element Defines the element the controls should be listened from
  11672. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11673. */
  11674. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11675. /**
  11676. * Detach the current controls from the specified dom element.
  11677. * @param element Defines the element to stop listening the inputs from
  11678. */
  11679. detachControl(element: Nullable<HTMLElement>): void;
  11680. /**
  11681. * Gets the class name of the current intput.
  11682. * @returns the class name
  11683. */
  11684. getClassName(): string;
  11685. /**
  11686. * Get the friendly name associated with the input class.
  11687. * @returns the input friendly name
  11688. */
  11689. getSimpleName(): string;
  11690. }
  11691. }
  11692. declare module BABYLON {
  11693. /**
  11694. * Manage the touch inputs to control the movement of a free camera.
  11695. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11696. */
  11697. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11698. /**
  11699. * Defines the camera the input is attached to.
  11700. */
  11701. camera: FreeCamera;
  11702. /**
  11703. * Defines the touch sensibility for rotation.
  11704. * The higher the faster.
  11705. */
  11706. touchAngularSensibility: number;
  11707. /**
  11708. * Defines the touch sensibility for move.
  11709. * The higher the faster.
  11710. */
  11711. touchMoveSensibility: number;
  11712. private _offsetX;
  11713. private _offsetY;
  11714. private _pointerPressed;
  11715. private _pointerInput;
  11716. private _observer;
  11717. private _onLostFocus;
  11718. /**
  11719. * Attach the input controls to a specific dom element to get the input from.
  11720. * @param element Defines the element the controls should be listened from
  11721. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11722. */
  11723. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11724. /**
  11725. * Detach the current controls from the specified dom element.
  11726. * @param element Defines the element to stop listening the inputs from
  11727. */
  11728. detachControl(element: Nullable<HTMLElement>): void;
  11729. /**
  11730. * Update the current camera state depending on the inputs that have been used this frame.
  11731. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11732. */
  11733. checkInputs(): void;
  11734. /**
  11735. * Gets the class name of the current intput.
  11736. * @returns the class name
  11737. */
  11738. getClassName(): string;
  11739. /**
  11740. * Get the friendly name associated with the input class.
  11741. * @returns the input friendly name
  11742. */
  11743. getSimpleName(): string;
  11744. }
  11745. }
  11746. declare module BABYLON {
  11747. /**
  11748. * Default Inputs manager for the FreeCamera.
  11749. * It groups all the default supported inputs for ease of use.
  11750. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11751. */
  11752. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11753. /**
  11754. * Instantiates a new FreeCameraInputsManager.
  11755. * @param camera Defines the camera the inputs belong to
  11756. */
  11757. constructor(camera: FreeCamera);
  11758. /**
  11759. * Add keyboard input support to the input manager.
  11760. * @returns the current input manager
  11761. */
  11762. addKeyboard(): FreeCameraInputsManager;
  11763. /**
  11764. * Add mouse input support to the input manager.
  11765. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11766. * @returns the current input manager
  11767. */
  11768. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11769. /**
  11770. * Add touch input support to the input manager.
  11771. * @returns the current input manager
  11772. */
  11773. addTouch(): FreeCameraInputsManager;
  11774. }
  11775. }
  11776. declare module BABYLON {
  11777. /**
  11778. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11779. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11780. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11781. */
  11782. export class FreeCamera extends TargetCamera {
  11783. /**
  11784. * Define the collision ellipsoid of the camera.
  11785. * This is helpful to simulate a camera body like the player body around the camera
  11786. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11787. */
  11788. ellipsoid: Vector3;
  11789. /**
  11790. * Define an offset for the position of the ellipsoid around the camera.
  11791. * This can be helpful to determine the center of the body near the gravity center of the body
  11792. * instead of its head.
  11793. */
  11794. ellipsoidOffset: Vector3;
  11795. /**
  11796. * Enable or disable collisions of the camera with the rest of the scene objects.
  11797. */
  11798. checkCollisions: boolean;
  11799. /**
  11800. * Enable or disable gravity on the camera.
  11801. */
  11802. applyGravity: boolean;
  11803. /**
  11804. * Define the input manager associated to the camera.
  11805. */
  11806. inputs: FreeCameraInputsManager;
  11807. /**
  11808. * Gets the input sensibility for a mouse input. (default is 2000.0)
  11809. * Higher values reduce sensitivity.
  11810. */
  11811. /**
  11812. * Sets the input sensibility for a mouse input. (default is 2000.0)
  11813. * Higher values reduce sensitivity.
  11814. */
  11815. angularSensibility: number;
  11816. /**
  11817. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  11818. */
  11819. keysUp: number[];
  11820. /**
  11821. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  11822. */
  11823. keysDown: number[];
  11824. /**
  11825. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  11826. */
  11827. keysLeft: number[];
  11828. /**
  11829. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  11830. */
  11831. keysRight: number[];
  11832. /**
  11833. * Event raised when the camera collide with a mesh in the scene.
  11834. */
  11835. onCollide: (collidedMesh: AbstractMesh) => void;
  11836. private _collider;
  11837. private _needMoveForGravity;
  11838. private _oldPosition;
  11839. private _diffPosition;
  11840. private _newPosition;
  11841. /** @hidden */ localDirection: Vector3;
  11842. /** @hidden */ transformedDirection: Vector3;
  11843. /**
  11844. * Instantiates a Free Camera.
  11845. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11846. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  11847. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11848. * @param name Define the name of the camera in the scene
  11849. * @param position Define the start position of the camera in the scene
  11850. * @param scene Define the scene the camera belongs to
  11851. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  11852. */
  11853. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  11854. /**
  11855. * Attached controls to the current camera.
  11856. * @param element Defines the element the controls should be listened from
  11857. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11858. */
  11859. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11860. /**
  11861. * Detach the current controls from the camera.
  11862. * The camera will stop reacting to inputs.
  11863. * @param element Defines the element to stop listening the inputs from
  11864. */
  11865. detachControl(element: HTMLElement): void;
  11866. private _collisionMask;
  11867. /**
  11868. * Define a collision mask to limit the list of object the camera can collide with
  11869. */
  11870. collisionMask: number;
  11871. /** @hidden */ collideWithWorld(displacement: Vector3): void;
  11872. private _onCollisionPositionChange;
  11873. /** @hidden */ checkInputs(): void;
  11874. /** @hidden */ decideIfNeedsToMove(): boolean;
  11875. /** @hidden */ updatePosition(): void;
  11876. /**
  11877. * Destroy the camera and release the current resources hold by it.
  11878. */
  11879. dispose(): void;
  11880. /**
  11881. * Gets the current object class name.
  11882. * @return the class name
  11883. */
  11884. getClassName(): string;
  11885. }
  11886. }
  11887. declare module BABYLON {
  11888. /**
  11889. * Represents a gamepad control stick position
  11890. */
  11891. export class StickValues {
  11892. /**
  11893. * The x component of the control stick
  11894. */
  11895. x: number;
  11896. /**
  11897. * The y component of the control stick
  11898. */
  11899. y: number;
  11900. /**
  11901. * Initializes the gamepad x and y control stick values
  11902. * @param x The x component of the gamepad control stick value
  11903. * @param y The y component of the gamepad control stick value
  11904. */
  11905. constructor(
  11906. /**
  11907. * The x component of the control stick
  11908. */
  11909. x: number,
  11910. /**
  11911. * The y component of the control stick
  11912. */
  11913. y: number);
  11914. }
  11915. /**
  11916. * An interface which manages callbacks for gamepad button changes
  11917. */
  11918. export interface GamepadButtonChanges {
  11919. /**
  11920. * Called when a gamepad has been changed
  11921. */
  11922. changed: boolean;
  11923. /**
  11924. * Called when a gamepad press event has been triggered
  11925. */
  11926. pressChanged: boolean;
  11927. /**
  11928. * Called when a touch event has been triggered
  11929. */
  11930. touchChanged: boolean;
  11931. /**
  11932. * Called when a value has changed
  11933. */
  11934. valueChanged: boolean;
  11935. }
  11936. /**
  11937. * Represents a gamepad
  11938. */
  11939. export class Gamepad {
  11940. /**
  11941. * The id of the gamepad
  11942. */
  11943. id: string;
  11944. /**
  11945. * The index of the gamepad
  11946. */
  11947. index: number;
  11948. /**
  11949. * The browser gamepad
  11950. */
  11951. browserGamepad: any;
  11952. /**
  11953. * Specifies what type of gamepad this represents
  11954. */
  11955. type: number;
  11956. private _leftStick;
  11957. private _rightStick;
  11958. /** @hidden */ isConnected: boolean;
  11959. private _leftStickAxisX;
  11960. private _leftStickAxisY;
  11961. private _rightStickAxisX;
  11962. private _rightStickAxisY;
  11963. /**
  11964. * Triggered when the left control stick has been changed
  11965. */
  11966. private _onleftstickchanged;
  11967. /**
  11968. * Triggered when the right control stick has been changed
  11969. */
  11970. private _onrightstickchanged;
  11971. /**
  11972. * Represents a gamepad controller
  11973. */
  11974. static GAMEPAD: number;
  11975. /**
  11976. * Represents a generic controller
  11977. */
  11978. static GENERIC: number;
  11979. /**
  11980. * Represents an XBox controller
  11981. */
  11982. static XBOX: number;
  11983. /**
  11984. * Represents a pose-enabled controller
  11985. */
  11986. static POSE_ENABLED: number;
  11987. /**
  11988. * Specifies whether the left control stick should be Y-inverted
  11989. */
  11990. protected _invertLeftStickY: boolean;
  11991. /**
  11992. * Specifies if the gamepad has been connected
  11993. */
  11994. readonly isConnected: boolean;
  11995. /**
  11996. * Initializes the gamepad
  11997. * @param id The id of the gamepad
  11998. * @param index The index of the gamepad
  11999. * @param browserGamepad The browser gamepad
  12000. * @param leftStickX The x component of the left joystick
  12001. * @param leftStickY The y component of the left joystick
  12002. * @param rightStickX The x component of the right joystick
  12003. * @param rightStickY The y component of the right joystick
  12004. */
  12005. constructor(
  12006. /**
  12007. * The id of the gamepad
  12008. */
  12009. id: string,
  12010. /**
  12011. * The index of the gamepad
  12012. */
  12013. index: number,
  12014. /**
  12015. * The browser gamepad
  12016. */
  12017. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12018. /**
  12019. * Callback triggered when the left joystick has changed
  12020. * @param callback
  12021. */
  12022. onleftstickchanged(callback: (values: StickValues) => void): void;
  12023. /**
  12024. * Callback triggered when the right joystick has changed
  12025. * @param callback
  12026. */
  12027. onrightstickchanged(callback: (values: StickValues) => void): void;
  12028. /**
  12029. * Gets the left joystick
  12030. */
  12031. /**
  12032. * Sets the left joystick values
  12033. */
  12034. leftStick: StickValues;
  12035. /**
  12036. * Gets the right joystick
  12037. */
  12038. /**
  12039. * Sets the right joystick value
  12040. */
  12041. rightStick: StickValues;
  12042. /**
  12043. * Updates the gamepad joystick positions
  12044. */
  12045. update(): void;
  12046. /**
  12047. * Disposes the gamepad
  12048. */
  12049. dispose(): void;
  12050. }
  12051. /**
  12052. * Represents a generic gamepad
  12053. */
  12054. export class GenericPad extends Gamepad {
  12055. private _buttons;
  12056. private _onbuttondown;
  12057. private _onbuttonup;
  12058. /**
  12059. * Observable triggered when a button has been pressed
  12060. */
  12061. onButtonDownObservable: Observable<number>;
  12062. /**
  12063. * Observable triggered when a button has been released
  12064. */
  12065. onButtonUpObservable: Observable<number>;
  12066. /**
  12067. * Callback triggered when a button has been pressed
  12068. * @param callback Called when a button has been pressed
  12069. */
  12070. onbuttondown(callback: (buttonPressed: number) => void): void;
  12071. /**
  12072. * Callback triggered when a button has been released
  12073. * @param callback Called when a button has been released
  12074. */
  12075. onbuttonup(callback: (buttonReleased: number) => void): void;
  12076. /**
  12077. * Initializes the generic gamepad
  12078. * @param id The id of the generic gamepad
  12079. * @param index The index of the generic gamepad
  12080. * @param browserGamepad The browser gamepad
  12081. */
  12082. constructor(id: string, index: number, browserGamepad: any);
  12083. private _setButtonValue;
  12084. /**
  12085. * Updates the generic gamepad
  12086. */
  12087. update(): void;
  12088. /**
  12089. * Disposes the generic gamepad
  12090. */
  12091. dispose(): void;
  12092. }
  12093. }
  12094. declare module BABYLON {
  12095. /**
  12096. * 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.
  12097. * @see https://doc.babylonjs.com/how_to/transformnode
  12098. */
  12099. export class TransformNode extends Node {
  12100. /**
  12101. * Object will not rotate to face the camera
  12102. */
  12103. static BILLBOARDMODE_NONE: number;
  12104. /**
  12105. * Object will rotate to face the camera but only on the x axis
  12106. */
  12107. static BILLBOARDMODE_X: number;
  12108. /**
  12109. * Object will rotate to face the camera but only on the y axis
  12110. */
  12111. static BILLBOARDMODE_Y: number;
  12112. /**
  12113. * Object will rotate to face the camera but only on the z axis
  12114. */
  12115. static BILLBOARDMODE_Z: number;
  12116. /**
  12117. * Object will rotate to face the camera
  12118. */
  12119. static BILLBOARDMODE_ALL: number;
  12120. private _forward;
  12121. private _forwardInverted;
  12122. private _up;
  12123. private _right;
  12124. private _rightInverted;
  12125. private _position;
  12126. private _rotation;
  12127. private _rotationQuaternion;
  12128. protected _scaling: Vector3;
  12129. protected _isDirty: boolean;
  12130. private _transformToBoneReferal;
  12131. /**
  12132. * Set the billboard mode. Default is 0.
  12133. *
  12134. * | Value | Type | Description |
  12135. * | --- | --- | --- |
  12136. * | 0 | BILLBOARDMODE_NONE | |
  12137. * | 1 | BILLBOARDMODE_X | |
  12138. * | 2 | BILLBOARDMODE_Y | |
  12139. * | 4 | BILLBOARDMODE_Z | |
  12140. * | 7 | BILLBOARDMODE_ALL | |
  12141. *
  12142. */
  12143. billboardMode: number;
  12144. /**
  12145. * 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
  12146. */
  12147. scalingDeterminant: number;
  12148. /**
  12149. * Sets the distance of the object to max, often used by skybox
  12150. */
  12151. infiniteDistance: boolean;
  12152. /**
  12153. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  12154. * By default the system will update normals to compensate
  12155. */
  12156. ignoreNonUniformScaling: boolean;
  12157. /** @hidden */ poseMatrix: Matrix;
  12158. /** @hidden */ localMatrix: Matrix;
  12159. private _absolutePosition;
  12160. private _pivotMatrix;
  12161. private _pivotMatrixInverse;
  12162. protected _postMultiplyPivotMatrix: boolean;
  12163. protected _isWorldMatrixFrozen: boolean;
  12164. /** @hidden */ indexInSceneTransformNodesArray: number;
  12165. /**
  12166. * An event triggered after the world matrix is updated
  12167. */
  12168. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  12169. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  12170. /**
  12171. * Gets a string identifying the name of the class
  12172. * @returns "TransformNode" string
  12173. */
  12174. getClassName(): string;
  12175. /**
  12176. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  12177. */
  12178. position: Vector3;
  12179. /**
  12180. * 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)).
  12181. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  12182. */
  12183. rotation: Vector3;
  12184. /**
  12185. * 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)).
  12186. */
  12187. scaling: Vector3;
  12188. /**
  12189. * 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).
  12190. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  12191. */
  12192. rotationQuaternion: Nullable<Quaternion>;
  12193. /**
  12194. * The forward direction of that transform in world space.
  12195. */
  12196. readonly forward: Vector3;
  12197. /**
  12198. * The up direction of that transform in world space.
  12199. */
  12200. readonly up: Vector3;
  12201. /**
  12202. * The right direction of that transform in world space.
  12203. */
  12204. readonly right: Vector3;
  12205. /**
  12206. * Copies the parameter passed Matrix into the mesh Pose matrix.
  12207. * @param matrix the matrix to copy the pose from
  12208. * @returns this TransformNode.
  12209. */
  12210. updatePoseMatrix(matrix: Matrix): TransformNode;
  12211. /**
  12212. * Returns the mesh Pose matrix.
  12213. * @returns the pose matrix
  12214. */
  12215. getPoseMatrix(): Matrix;
  12216. /** @hidden */ isSynchronized(): boolean;
  12217. /** @hidden */ initCache(): void;
  12218. /**
  12219. * Flag the transform node as dirty (Forcing it to update everything)
  12220. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  12221. * @returns this transform node
  12222. */
  12223. markAsDirty(property: string): TransformNode;
  12224. /**
  12225. * Returns the current mesh absolute position.
  12226. * Returns a Vector3.
  12227. */
  12228. readonly absolutePosition: Vector3;
  12229. /**
  12230. * Sets a new matrix to apply before all other transformation
  12231. * @param matrix defines the transform matrix
  12232. * @returns the current TransformNode
  12233. */
  12234. setPreTransformMatrix(matrix: Matrix): TransformNode;
  12235. /**
  12236. * Sets a new pivot matrix to the current node
  12237. * @param matrix defines the new pivot matrix to use
  12238. * @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
  12239. * @returns the current TransformNode
  12240. */
  12241. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  12242. /**
  12243. * Returns the mesh pivot matrix.
  12244. * Default : Identity.
  12245. * @returns the matrix
  12246. */
  12247. getPivotMatrix(): Matrix;
  12248. /**
  12249. * Prevents the World matrix to be computed any longer.
  12250. * @returns the TransformNode.
  12251. */
  12252. freezeWorldMatrix(): TransformNode;
  12253. /**
  12254. * Allows back the World matrix computation.
  12255. * @returns the TransformNode.
  12256. */
  12257. unfreezeWorldMatrix(): this;
  12258. /**
  12259. * True if the World matrix has been frozen.
  12260. */
  12261. readonly isWorldMatrixFrozen: boolean;
  12262. /**
  12263. * Retuns the mesh absolute position in the World.
  12264. * @returns a Vector3.
  12265. */
  12266. getAbsolutePosition(): Vector3;
  12267. /**
  12268. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  12269. * @param absolutePosition the absolute position to set
  12270. * @returns the TransformNode.
  12271. */
  12272. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  12273. /**
  12274. * Sets the mesh position in its local space.
  12275. * @param vector3 the position to set in localspace
  12276. * @returns the TransformNode.
  12277. */
  12278. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  12279. /**
  12280. * Returns the mesh position in the local space from the current World matrix values.
  12281. * @returns a new Vector3.
  12282. */
  12283. getPositionExpressedInLocalSpace(): Vector3;
  12284. /**
  12285. * Translates the mesh along the passed Vector3 in its local space.
  12286. * @param vector3 the distance to translate in localspace
  12287. * @returns the TransformNode.
  12288. */
  12289. locallyTranslate(vector3: Vector3): TransformNode;
  12290. private static _lookAtVectorCache;
  12291. /**
  12292. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  12293. * @param targetPoint the position (must be in same space as current mesh) to look at
  12294. * @param yawCor optional yaw (y-axis) correction in radians
  12295. * @param pitchCor optional pitch (x-axis) correction in radians
  12296. * @param rollCor optional roll (z-axis) correction in radians
  12297. * @param space the choosen space of the target
  12298. * @returns the TransformNode.
  12299. */
  12300. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  12301. /**
  12302. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  12303. * This Vector3 is expressed in the World space.
  12304. * @param localAxis axis to rotate
  12305. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  12306. */
  12307. getDirection(localAxis: Vector3): Vector3;
  12308. /**
  12309. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  12310. * localAxis is expressed in the mesh local space.
  12311. * result is computed in the Wordl space from the mesh World matrix.
  12312. * @param localAxis axis to rotate
  12313. * @param result the resulting transformnode
  12314. * @returns this TransformNode.
  12315. */
  12316. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  12317. /**
  12318. * Sets this transform node rotation to the given local axis.
  12319. * @param localAxis the axis in local space
  12320. * @param yawCor optional yaw (y-axis) correction in radians
  12321. * @param pitchCor optional pitch (x-axis) correction in radians
  12322. * @param rollCor optional roll (z-axis) correction in radians
  12323. * @returns this TransformNode
  12324. */
  12325. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  12326. /**
  12327. * Sets a new pivot point to the current node
  12328. * @param point defines the new pivot point to use
  12329. * @param space defines if the point is in world or local space (local by default)
  12330. * @returns the current TransformNode
  12331. */
  12332. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  12333. /**
  12334. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  12335. * @returns the pivot point
  12336. */
  12337. getPivotPoint(): Vector3;
  12338. /**
  12339. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  12340. * @param result the vector3 to store the result
  12341. * @returns this TransformNode.
  12342. */
  12343. getPivotPointToRef(result: Vector3): TransformNode;
  12344. /**
  12345. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  12346. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  12347. */
  12348. getAbsolutePivotPoint(): Vector3;
  12349. /**
  12350. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  12351. * @param result vector3 to store the result
  12352. * @returns this TransformNode.
  12353. */
  12354. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  12355. /**
  12356. * Defines the passed node as the parent of the current node.
  12357. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  12358. * @param node the node ot set as the parent
  12359. * @returns this TransformNode.
  12360. */
  12361. setParent(node: Nullable<Node>): TransformNode;
  12362. private _nonUniformScaling;
  12363. /**
  12364. * True if the scaling property of this object is non uniform eg. (1,2,1)
  12365. */
  12366. readonly nonUniformScaling: boolean;
  12367. /** @hidden */ updateNonUniformScalingState(value: boolean): boolean;
  12368. /**
  12369. * Attach the current TransformNode to another TransformNode associated with a bone
  12370. * @param bone Bone affecting the TransformNode
  12371. * @param affectedTransformNode TransformNode associated with the bone
  12372. * @returns this object
  12373. */
  12374. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  12375. /**
  12376. * Detach the transform node if its associated with a bone
  12377. * @returns this object
  12378. */
  12379. detachFromBone(): TransformNode;
  12380. private static _rotationAxisCache;
  12381. /**
  12382. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  12383. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  12384. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  12385. * The passed axis is also normalized.
  12386. * @param axis the axis to rotate around
  12387. * @param amount the amount to rotate in radians
  12388. * @param space Space to rotate in (Default: local)
  12389. * @returns the TransformNode.
  12390. */
  12391. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  12392. /**
  12393. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  12394. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  12395. * The passed axis is also normalized. .
  12396. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  12397. * @param point the point to rotate around
  12398. * @param axis the axis to rotate around
  12399. * @param amount the amount to rotate in radians
  12400. * @returns the TransformNode
  12401. */
  12402. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  12403. /**
  12404. * Translates the mesh along the axis vector for the passed distance in the given space.
  12405. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  12406. * @param axis the axis to translate in
  12407. * @param distance the distance to translate
  12408. * @param space Space to rotate in (Default: local)
  12409. * @returns the TransformNode.
  12410. */
  12411. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  12412. /**
  12413. * Adds a rotation step to the mesh current rotation.
  12414. * x, y, z are Euler angles expressed in radians.
  12415. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  12416. * This means this rotation is made in the mesh local space only.
  12417. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  12418. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  12419. * ```javascript
  12420. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  12421. * ```
  12422. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  12423. * 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.
  12424. * @param x Rotation to add
  12425. * @param y Rotation to add
  12426. * @param z Rotation to add
  12427. * @returns the TransformNode.
  12428. */
  12429. addRotation(x: number, y: number, z: number): TransformNode;
  12430. /**
  12431. * Computes the world matrix of the node
  12432. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12433. * @returns the world matrix
  12434. */
  12435. computeWorldMatrix(force?: boolean): Matrix;
  12436. protected _afterComputeWorldMatrix(): void;
  12437. /**
  12438. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  12439. * @param func callback function to add
  12440. *
  12441. * @returns the TransformNode.
  12442. */
  12443. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  12444. /**
  12445. * Removes a registered callback function.
  12446. * @param func callback function to remove
  12447. * @returns the TransformNode.
  12448. */
  12449. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  12450. /**
  12451. * Gets the position of the current mesh in camera space
  12452. * @param camera defines the camera to use
  12453. * @returns a position
  12454. */
  12455. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  12456. /**
  12457. * Returns the distance from the mesh to the active camera
  12458. * @param camera defines the camera to use
  12459. * @returns the distance
  12460. */
  12461. getDistanceToCamera(camera?: Nullable<Camera>): number;
  12462. /**
  12463. * Clone the current transform node
  12464. * @param name Name of the new clone
  12465. * @param newParent New parent for the clone
  12466. * @param doNotCloneChildren Do not clone children hierarchy
  12467. * @returns the new transform node
  12468. */
  12469. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  12470. /**
  12471. * Serializes the objects information.
  12472. * @param currentSerializationObject defines the object to serialize in
  12473. * @returns the serialized object
  12474. */
  12475. serialize(currentSerializationObject?: any): any;
  12476. /**
  12477. * Returns a new TransformNode object parsed from the source provided.
  12478. * @param parsedTransformNode is the source.
  12479. * @param scene the scne the object belongs to
  12480. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  12481. * @returns a new TransformNode object parsed from the source provided.
  12482. */
  12483. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  12484. /**
  12485. * Get all child-transformNodes of this node
  12486. * @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
  12487. * @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
  12488. * @returns an array of TransformNode
  12489. */
  12490. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  12491. /**
  12492. * Releases resources associated with this transform node.
  12493. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12494. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12495. */
  12496. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12497. }
  12498. }
  12499. declare module BABYLON {
  12500. /**
  12501. * Defines the types of pose enabled controllers that are supported
  12502. */
  12503. export enum PoseEnabledControllerType {
  12504. /**
  12505. * HTC Vive
  12506. */
  12507. VIVE = 0,
  12508. /**
  12509. * Oculus Rift
  12510. */
  12511. OCULUS = 1,
  12512. /**
  12513. * Windows mixed reality
  12514. */
  12515. WINDOWS = 2,
  12516. /**
  12517. * Samsung gear VR
  12518. */
  12519. GEAR_VR = 3,
  12520. /**
  12521. * Google Daydream
  12522. */
  12523. DAYDREAM = 4,
  12524. /**
  12525. * Generic
  12526. */
  12527. GENERIC = 5
  12528. }
  12529. /**
  12530. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12531. */
  12532. export interface MutableGamepadButton {
  12533. /**
  12534. * Value of the button/trigger
  12535. */
  12536. value: number;
  12537. /**
  12538. * If the button/trigger is currently touched
  12539. */
  12540. touched: boolean;
  12541. /**
  12542. * If the button/trigger is currently pressed
  12543. */
  12544. pressed: boolean;
  12545. }
  12546. /**
  12547. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12548. * @hidden
  12549. */
  12550. export interface ExtendedGamepadButton extends GamepadButton {
  12551. /**
  12552. * If the button/trigger is currently pressed
  12553. */
  12554. readonly pressed: boolean;
  12555. /**
  12556. * If the button/trigger is currently touched
  12557. */
  12558. readonly touched: boolean;
  12559. /**
  12560. * Value of the button/trigger
  12561. */
  12562. readonly value: number;
  12563. }
  12564. /** @hidden */
  12565. export interface _GamePadFactory {
  12566. /**
  12567. * Returns wether or not the current gamepad can be created for this type of controller.
  12568. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12569. * @returns true if it can be created, otherwise false
  12570. */
  12571. canCreate(gamepadInfo: any): boolean;
  12572. /**
  12573. * Creates a new instance of the Gamepad.
  12574. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12575. * @returns the new gamepad instance
  12576. */
  12577. create(gamepadInfo: any): Gamepad;
  12578. }
  12579. /**
  12580. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12581. */
  12582. export class PoseEnabledControllerHelper {
  12583. /** @hidden */ private static _ControllerFactories: _GamePadFactory[];
  12584. /** @hidden */ private static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12585. /**
  12586. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12587. * @param vrGamepad the gamepad to initialized
  12588. * @returns a vr controller of the type the gamepad identified as
  12589. */
  12590. static InitiateController(vrGamepad: any): Gamepad;
  12591. }
  12592. /**
  12593. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12594. */
  12595. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12596. private _deviceRoomPosition;
  12597. private _deviceRoomRotationQuaternion;
  12598. /**
  12599. * The device position in babylon space
  12600. */
  12601. devicePosition: Vector3;
  12602. /**
  12603. * The device rotation in babylon space
  12604. */
  12605. deviceRotationQuaternion: Quaternion;
  12606. /**
  12607. * The scale factor of the device in babylon space
  12608. */
  12609. deviceScaleFactor: number;
  12610. /**
  12611. * (Likely devicePosition should be used instead) The device position in its room space
  12612. */
  12613. position: Vector3;
  12614. /**
  12615. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12616. */
  12617. rotationQuaternion: Quaternion;
  12618. /**
  12619. * The type of controller (Eg. Windows mixed reality)
  12620. */
  12621. controllerType: PoseEnabledControllerType;
  12622. protected _calculatedPosition: Vector3;
  12623. private _calculatedRotation;
  12624. /**
  12625. * The raw pose from the device
  12626. */
  12627. rawPose: DevicePose;
  12628. private _trackPosition;
  12629. private _maxRotationDistFromHeadset;
  12630. private _draggedRoomRotation;
  12631. /**
  12632. * @hidden
  12633. */ disableTrackPosition(fixedPosition: Vector3): void;
  12634. /**
  12635. * Internal, the mesh attached to the controller
  12636. * @hidden
  12637. */ mesh: Nullable<AbstractMesh>;
  12638. private _poseControlledCamera;
  12639. private _leftHandSystemQuaternion;
  12640. /**
  12641. * Internal, matrix used to convert room space to babylon space
  12642. * @hidden
  12643. */ deviceToWorld: Matrix;
  12644. /**
  12645. * Node to be used when casting a ray from the controller
  12646. * @hidden
  12647. */ pointingPoseNode: Nullable<TransformNode>;
  12648. /**
  12649. * Name of the child mesh that can be used to cast a ray from the controller
  12650. */
  12651. static readonly POINTING_POSE: string;
  12652. /**
  12653. * Creates a new PoseEnabledController from a gamepad
  12654. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12655. */
  12656. constructor(browserGamepad: any);
  12657. private _workingMatrix;
  12658. /**
  12659. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12660. */
  12661. update(): void;
  12662. /**
  12663. * Updates only the pose device and mesh without doing any button event checking
  12664. */
  12665. protected _updatePoseAndMesh(): void;
  12666. /**
  12667. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12668. * @param poseData raw pose fromthe device
  12669. */
  12670. updateFromDevice(poseData: DevicePose): void;
  12671. /**
  12672. * @hidden
  12673. */ meshAttachedObservable: Observable<AbstractMesh>;
  12674. /**
  12675. * Attaches a mesh to the controller
  12676. * @param mesh the mesh to be attached
  12677. */
  12678. attachToMesh(mesh: AbstractMesh): void;
  12679. /**
  12680. * Attaches the controllers mesh to a camera
  12681. * @param camera the camera the mesh should be attached to
  12682. */
  12683. attachToPoseControlledCamera(camera: TargetCamera): void;
  12684. /**
  12685. * Disposes of the controller
  12686. */
  12687. dispose(): void;
  12688. /**
  12689. * The mesh that is attached to the controller
  12690. */
  12691. readonly mesh: Nullable<AbstractMesh>;
  12692. /**
  12693. * Gets the ray of the controller in the direction the controller is pointing
  12694. * @param length the length the resulting ray should be
  12695. * @returns a ray in the direction the controller is pointing
  12696. */
  12697. getForwardRay(length?: number): Ray;
  12698. }
  12699. }
  12700. declare module BABYLON {
  12701. /**
  12702. * Defines the WebVRController object that represents controllers tracked in 3D space
  12703. */
  12704. export abstract class WebVRController extends PoseEnabledController {
  12705. /**
  12706. * Internal, the default controller model for the controller
  12707. */
  12708. protected _defaultModel: AbstractMesh;
  12709. /**
  12710. * Fired when the trigger state has changed
  12711. */
  12712. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12713. /**
  12714. * Fired when the main button state has changed
  12715. */
  12716. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12717. /**
  12718. * Fired when the secondary button state has changed
  12719. */
  12720. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12721. /**
  12722. * Fired when the pad state has changed
  12723. */
  12724. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12725. /**
  12726. * Fired when controllers stick values have changed
  12727. */
  12728. onPadValuesChangedObservable: Observable<StickValues>;
  12729. /**
  12730. * Array of button availible on the controller
  12731. */
  12732. protected _buttons: Array<MutableGamepadButton>;
  12733. private _onButtonStateChange;
  12734. /**
  12735. * Fired when a controller button's state has changed
  12736. * @param callback the callback containing the button that was modified
  12737. */
  12738. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12739. /**
  12740. * X and Y axis corrisponding to the controllers joystick
  12741. */
  12742. pad: StickValues;
  12743. /**
  12744. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12745. */
  12746. hand: string;
  12747. /**
  12748. * The default controller model for the controller
  12749. */
  12750. readonly defaultModel: AbstractMesh;
  12751. /**
  12752. * Creates a new WebVRController from a gamepad
  12753. * @param vrGamepad the gamepad that the WebVRController should be created from
  12754. */
  12755. constructor(vrGamepad: any);
  12756. /**
  12757. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12758. */
  12759. update(): void;
  12760. /**
  12761. * Function to be called when a button is modified
  12762. */
  12763. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12764. /**
  12765. * Loads a mesh and attaches it to the controller
  12766. * @param scene the scene the mesh should be added to
  12767. * @param meshLoaded callback for when the mesh has been loaded
  12768. */
  12769. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12770. private _setButtonValue;
  12771. private _changes;
  12772. private _checkChanges;
  12773. /**
  12774. * Disposes of th webVRCOntroller
  12775. */
  12776. dispose(): void;
  12777. }
  12778. }
  12779. declare module BABYLON {
  12780. /**
  12781. * The HemisphericLight simulates the ambient environment light,
  12782. * so the passed direction is the light reflection direction, not the incoming direction.
  12783. */
  12784. export class HemisphericLight extends Light {
  12785. /**
  12786. * The groundColor is the light in the opposite direction to the one specified during creation.
  12787. * 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.
  12788. */
  12789. groundColor: Color3;
  12790. /**
  12791. * The light reflection direction, not the incoming direction.
  12792. */
  12793. direction: Vector3;
  12794. /**
  12795. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12796. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12797. * The HemisphericLight can't cast shadows.
  12798. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12799. * @param name The friendly name of the light
  12800. * @param direction The direction of the light reflection
  12801. * @param scene The scene the light belongs to
  12802. */
  12803. constructor(name: string, direction: Vector3, scene: Scene);
  12804. protected _buildUniformLayout(): void;
  12805. /**
  12806. * Returns the string "HemisphericLight".
  12807. * @return The class name
  12808. */
  12809. getClassName(): string;
  12810. /**
  12811. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12812. * Returns the updated direction.
  12813. * @param target The target the direction should point to
  12814. * @return The computed direction
  12815. */
  12816. setDirectionToTarget(target: Vector3): Vector3;
  12817. /**
  12818. * Returns the shadow generator associated to the light.
  12819. * @returns Always null for hemispheric lights because it does not support shadows.
  12820. */
  12821. getShadowGenerator(): Nullable<IShadowGenerator>;
  12822. /**
  12823. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12824. * @param effect The effect to update
  12825. * @param lightIndex The index of the light in the effect to update
  12826. * @returns The hemispheric light
  12827. */
  12828. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12829. /**
  12830. * Computes the world matrix of the node
  12831. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12832. * @param useWasUpdatedFlag defines a reserved property
  12833. * @returns the world matrix
  12834. */
  12835. computeWorldMatrix(): Matrix;
  12836. /**
  12837. * Returns the integer 3.
  12838. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12839. */
  12840. getTypeID(): number;
  12841. /**
  12842. * Prepares the list of defines specific to the light type.
  12843. * @param defines the list of defines
  12844. * @param lightIndex defines the index of the light for the effect
  12845. */
  12846. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12847. }
  12848. }
  12849. declare module BABYLON {
  12850. /**
  12851. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  12852. * IMPORTANT!! The data is right-hand data.
  12853. * @export
  12854. * @interface DevicePose
  12855. */
  12856. export interface DevicePose {
  12857. /**
  12858. * The position of the device, values in array are [x,y,z].
  12859. */
  12860. readonly position: Nullable<Float32Array>;
  12861. /**
  12862. * The linearVelocity of the device, values in array are [x,y,z].
  12863. */
  12864. readonly linearVelocity: Nullable<Float32Array>;
  12865. /**
  12866. * The linearAcceleration of the device, values in array are [x,y,z].
  12867. */
  12868. readonly linearAcceleration: Nullable<Float32Array>;
  12869. /**
  12870. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  12871. */
  12872. readonly orientation: Nullable<Float32Array>;
  12873. /**
  12874. * The angularVelocity of the device, values in array are [x,y,z].
  12875. */
  12876. readonly angularVelocity: Nullable<Float32Array>;
  12877. /**
  12878. * The angularAcceleration of the device, values in array are [x,y,z].
  12879. */
  12880. readonly angularAcceleration: Nullable<Float32Array>;
  12881. }
  12882. /**
  12883. * Interface representing a pose controlled object in Babylon.
  12884. * A pose controlled object has both regular pose values as well as pose values
  12885. * from an external device such as a VR head mounted display
  12886. */
  12887. export interface PoseControlled {
  12888. /**
  12889. * The position of the object in babylon space.
  12890. */
  12891. position: Vector3;
  12892. /**
  12893. * The rotation quaternion of the object in babylon space.
  12894. */
  12895. rotationQuaternion: Quaternion;
  12896. /**
  12897. * The position of the device in babylon space.
  12898. */
  12899. devicePosition?: Vector3;
  12900. /**
  12901. * The rotation quaternion of the device in babylon space.
  12902. */
  12903. deviceRotationQuaternion: Quaternion;
  12904. /**
  12905. * The raw pose coming from the device.
  12906. */
  12907. rawPose: Nullable<DevicePose>;
  12908. /**
  12909. * The scale of the device to be used when translating from device space to babylon space.
  12910. */
  12911. deviceScaleFactor: number;
  12912. /**
  12913. * Updates the poseControlled values based on the input device pose.
  12914. * @param poseData the pose data to update the object with
  12915. */
  12916. updateFromDevice(poseData: DevicePose): void;
  12917. }
  12918. /**
  12919. * Set of options to customize the webVRCamera
  12920. */
  12921. export interface WebVROptions {
  12922. /**
  12923. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  12924. */
  12925. trackPosition?: boolean;
  12926. /**
  12927. * Sets the scale of the vrDevice in babylon space. (default: 1)
  12928. */
  12929. positionScale?: number;
  12930. /**
  12931. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  12932. */
  12933. displayName?: string;
  12934. /**
  12935. * Should the native controller meshes be initialized. (default: true)
  12936. */
  12937. controllerMeshes?: boolean;
  12938. /**
  12939. * Creating a default HemiLight only on controllers. (default: true)
  12940. */
  12941. defaultLightingOnControllers?: boolean;
  12942. /**
  12943. * If you don't want to use the default VR button of the helper. (default: false)
  12944. */
  12945. useCustomVRButton?: boolean;
  12946. /**
  12947. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  12948. */
  12949. customVRButton?: HTMLButtonElement;
  12950. /**
  12951. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  12952. */
  12953. rayLength?: number;
  12954. /**
  12955. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  12956. */
  12957. defaultHeight?: number;
  12958. }
  12959. /**
  12960. * This represents a WebVR camera.
  12961. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  12962. * @example http://doc.babylonjs.com/how_to/webvr_camera
  12963. */
  12964. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  12965. private webVROptions;
  12966. /**
  12967. * @hidden
  12968. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  12969. */ vrDevice: any;
  12970. /**
  12971. * The rawPose of the vrDevice.
  12972. */
  12973. rawPose: Nullable<DevicePose>;
  12974. private _onVREnabled;
  12975. private _specsVersion;
  12976. private _attached;
  12977. private _frameData;
  12978. protected _descendants: Array<Node>;
  12979. private _deviceRoomPosition;
  12980. /** @hidden */ deviceRoomRotationQuaternion: Quaternion;
  12981. private _standingMatrix;
  12982. /**
  12983. * Represents device position in babylon space.
  12984. */
  12985. devicePosition: Vector3;
  12986. /**
  12987. * Represents device rotation in babylon space.
  12988. */
  12989. deviceRotationQuaternion: Quaternion;
  12990. /**
  12991. * The scale of the device to be used when translating from device space to babylon space.
  12992. */
  12993. deviceScaleFactor: number;
  12994. private _deviceToWorld;
  12995. private _worldToDevice;
  12996. /**
  12997. * References to the webVR controllers for the vrDevice.
  12998. */
  12999. controllers: Array<WebVRController>;
  13000. /**
  13001. * Emits an event when a controller is attached.
  13002. */
  13003. onControllersAttachedObservable: Observable<WebVRController[]>;
  13004. /**
  13005. * Emits an event when a controller's mesh has been loaded;
  13006. */
  13007. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13008. /**
  13009. * Emits an event when the HMD's pose has been updated.
  13010. */
  13011. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13012. private _poseSet;
  13013. /**
  13014. * If the rig cameras be used as parent instead of this camera.
  13015. */
  13016. rigParenting: boolean;
  13017. private _lightOnControllers;
  13018. private _defaultHeight?;
  13019. /**
  13020. * Instantiates a WebVRFreeCamera.
  13021. * @param name The name of the WebVRFreeCamera
  13022. * @param position The starting anchor position for the camera
  13023. * @param scene The scene the camera belongs to
  13024. * @param webVROptions a set of customizable options for the webVRCamera
  13025. */
  13026. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13027. /**
  13028. * Gets the device distance from the ground in meters.
  13029. * @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.
  13030. */
  13031. deviceDistanceToRoomGround(): number;
  13032. /**
  13033. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13034. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13035. */
  13036. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13037. /**
  13038. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13039. * @returns A promise with a boolean set to if the standing matrix is supported.
  13040. */
  13041. useStandingMatrixAsync(): Promise<boolean>;
  13042. /**
  13043. * Disposes the camera
  13044. */
  13045. dispose(): void;
  13046. /**
  13047. * Gets a vrController by name.
  13048. * @param name The name of the controller to retreive
  13049. * @returns the controller matching the name specified or null if not found
  13050. */
  13051. getControllerByName(name: string): Nullable<WebVRController>;
  13052. private _leftController;
  13053. /**
  13054. * The controller corrisponding to the users left hand.
  13055. */
  13056. readonly leftController: Nullable<WebVRController>;
  13057. private _rightController;
  13058. /**
  13059. * The controller corrisponding to the users right hand.
  13060. */
  13061. readonly rightController: Nullable<WebVRController>;
  13062. /**
  13063. * Casts a ray forward from the vrCamera's gaze.
  13064. * @param length Length of the ray (default: 100)
  13065. * @returns the ray corrisponding to the gaze
  13066. */
  13067. getForwardRay(length?: number): Ray;
  13068. /**
  13069. * @hidden
  13070. * Updates the camera based on device's frame data
  13071. */ checkInputs(): void;
  13072. /**
  13073. * Updates the poseControlled values based on the input device pose.
  13074. * @param poseData Pose coming from the device
  13075. */
  13076. updateFromDevice(poseData: DevicePose): void;
  13077. private _htmlElementAttached;
  13078. private _detachIfAttached;
  13079. /**
  13080. * WebVR's attach control will start broadcasting frames to the device.
  13081. * Note that in certain browsers (chrome for example) this function must be called
  13082. * within a user-interaction callback. Example:
  13083. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13084. *
  13085. * @param element html element to attach the vrDevice to
  13086. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13087. */
  13088. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13089. /**
  13090. * Detaches the camera from the html element and disables VR
  13091. *
  13092. * @param element html element to detach from
  13093. */
  13094. detachControl(element: HTMLElement): void;
  13095. /**
  13096. * @returns the name of this class
  13097. */
  13098. getClassName(): string;
  13099. /**
  13100. * Calls resetPose on the vrDisplay
  13101. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13102. */
  13103. resetToCurrentRotation(): void;
  13104. /**
  13105. * @hidden
  13106. * Updates the rig cameras (left and right eye)
  13107. */ updateRigCameras(): void;
  13108. private _workingVector;
  13109. private _oneVector;
  13110. private _workingMatrix;
  13111. private updateCacheCalled;
  13112. private _correctPositionIfNotTrackPosition;
  13113. /**
  13114. * @hidden
  13115. * Updates the cached values of the camera
  13116. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13117. */ updateCache(ignoreParentClass?: boolean): void;
  13118. /**
  13119. * @hidden
  13120. * Get current device position in babylon world
  13121. */ computeDevicePosition(): void;
  13122. /**
  13123. * Updates the current device position and rotation in the babylon world
  13124. */
  13125. update(): void;
  13126. /**
  13127. * @hidden
  13128. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13129. * @returns an identity matrix
  13130. */ getViewMatrix(): Matrix;
  13131. private _tmpMatrix;
  13132. /**
  13133. * This function is called by the two RIG cameras.
  13134. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13135. * @hidden
  13136. */ getWebVRViewMatrix(): Matrix;
  13137. /** @hidden */ getWebVRProjectionMatrix(): Matrix;
  13138. private _onGamepadConnectedObserver;
  13139. private _onGamepadDisconnectedObserver;
  13140. private _updateCacheWhenTrackingDisabledObserver;
  13141. /**
  13142. * Initializes the controllers and their meshes
  13143. */
  13144. initControllers(): void;
  13145. }
  13146. }
  13147. declare module BABYLON {
  13148. /**
  13149. * Size options for a post process
  13150. */
  13151. export type PostProcessOptions = {
  13152. width: number;
  13153. height: number;
  13154. };
  13155. /**
  13156. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13157. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13158. */
  13159. export class PostProcess {
  13160. /** Name of the PostProcess. */
  13161. name: string;
  13162. /**
  13163. * Width of the texture to apply the post process on
  13164. */
  13165. width: number;
  13166. /**
  13167. * Height of the texture to apply the post process on
  13168. */
  13169. height: number;
  13170. /**
  13171. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13172. * @hidden
  13173. */ outputTexture: Nullable<InternalTexture>;
  13174. /**
  13175. * Sampling mode used by the shader
  13176. * See https://doc.babylonjs.com/classes/3.1/texture
  13177. */
  13178. renderTargetSamplingMode: number;
  13179. /**
  13180. * Clear color to use when screen clearing
  13181. */
  13182. clearColor: Color4;
  13183. /**
  13184. * If the buffer needs to be cleared before applying the post process. (default: true)
  13185. * Should be set to false if shader will overwrite all previous pixels.
  13186. */
  13187. autoClear: boolean;
  13188. /**
  13189. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13190. */
  13191. alphaMode: number;
  13192. /**
  13193. * Sets the setAlphaBlendConstants of the babylon engine
  13194. */
  13195. alphaConstants: Color4;
  13196. /**
  13197. * Animations to be used for the post processing
  13198. */
  13199. animations: Animation[];
  13200. /**
  13201. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13202. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13203. */
  13204. enablePixelPerfectMode: boolean;
  13205. /**
  13206. * Force the postprocess to be applied without taking in account viewport
  13207. */
  13208. forceFullscreenViewport: boolean;
  13209. /**
  13210. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13211. *
  13212. * | Value | Type | Description |
  13213. * | ----- | ----------------------------------- | ----------- |
  13214. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13215. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13216. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13217. *
  13218. */
  13219. scaleMode: number;
  13220. /**
  13221. * Force textures to be a power of two (default: false)
  13222. */
  13223. alwaysForcePOT: boolean;
  13224. private _samples;
  13225. /**
  13226. * Number of sample textures (default: 1)
  13227. */
  13228. samples: number;
  13229. /**
  13230. * Modify the scale of the post process to be the same as the viewport (default: false)
  13231. */
  13232. adaptScaleToCurrentViewport: boolean;
  13233. private _camera;
  13234. private _scene;
  13235. private _engine;
  13236. private _options;
  13237. private _reusable;
  13238. private _textureType;
  13239. /**
  13240. * Smart array of input and output textures for the post process.
  13241. * @hidden
  13242. */ textures: SmartArray<InternalTexture>;
  13243. /**
  13244. * The index in _textures that corresponds to the output texture.
  13245. * @hidden
  13246. */ currentRenderTextureInd: number;
  13247. private _effect;
  13248. private _samplers;
  13249. private _fragmentUrl;
  13250. private _vertexUrl;
  13251. private _parameters;
  13252. private _scaleRatio;
  13253. protected _indexParameters: any;
  13254. private _shareOutputWithPostProcess;
  13255. private _texelSize;
  13256. private _forcedOutputTexture;
  13257. /**
  13258. * Returns the fragment url or shader name used in the post process.
  13259. * @returns the fragment url or name in the shader store.
  13260. */
  13261. getEffectName(): string;
  13262. /**
  13263. * An event triggered when the postprocess is activated.
  13264. */
  13265. onActivateObservable: Observable<Camera>;
  13266. private _onActivateObserver;
  13267. /**
  13268. * A function that is added to the onActivateObservable
  13269. */
  13270. onActivate: Nullable<(camera: Camera) => void>;
  13271. /**
  13272. * An event triggered when the postprocess changes its size.
  13273. */
  13274. onSizeChangedObservable: Observable<PostProcess>;
  13275. private _onSizeChangedObserver;
  13276. /**
  13277. * A function that is added to the onSizeChangedObservable
  13278. */
  13279. onSizeChanged: (postProcess: PostProcess) => void;
  13280. /**
  13281. * An event triggered when the postprocess applies its effect.
  13282. */
  13283. onApplyObservable: Observable<Effect>;
  13284. private _onApplyObserver;
  13285. /**
  13286. * A function that is added to the onApplyObservable
  13287. */
  13288. onApply: (effect: Effect) => void;
  13289. /**
  13290. * An event triggered before rendering the postprocess
  13291. */
  13292. onBeforeRenderObservable: Observable<Effect>;
  13293. private _onBeforeRenderObserver;
  13294. /**
  13295. * A function that is added to the onBeforeRenderObservable
  13296. */
  13297. onBeforeRender: (effect: Effect) => void;
  13298. /**
  13299. * An event triggered after rendering the postprocess
  13300. */
  13301. onAfterRenderObservable: Observable<Effect>;
  13302. private _onAfterRenderObserver;
  13303. /**
  13304. * A function that is added to the onAfterRenderObservable
  13305. */
  13306. onAfterRender: (efect: Effect) => void;
  13307. /**
  13308. * 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
  13309. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13310. */
  13311. inputTexture: InternalTexture;
  13312. /**
  13313. * Gets the camera which post process is applied to.
  13314. * @returns The camera the post process is applied to.
  13315. */
  13316. getCamera(): Camera;
  13317. /**
  13318. * Gets the texel size of the postprocess.
  13319. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13320. */
  13321. readonly texelSize: Vector2;
  13322. /**
  13323. * Creates a new instance PostProcess
  13324. * @param name The name of the PostProcess.
  13325. * @param fragmentUrl The url of the fragment shader to be used.
  13326. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13327. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13328. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13329. * @param camera The camera to apply the render pass to.
  13330. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13331. * @param engine The engine which the post process will be applied. (default: current engine)
  13332. * @param reusable If the post process can be reused on the same frame. (default: false)
  13333. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13334. * @param textureType Type of textures used when performing the post process. (default: 0)
  13335. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13336. * @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
  13337. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13338. */
  13339. constructor(
  13340. /** Name of the PostProcess. */
  13341. 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);
  13342. /**
  13343. * Gets the engine which this post process belongs to.
  13344. * @returns The engine the post process was enabled with.
  13345. */
  13346. getEngine(): Engine;
  13347. /**
  13348. * The effect that is created when initializing the post process.
  13349. * @returns The created effect corrisponding the the postprocess.
  13350. */
  13351. getEffect(): Effect;
  13352. /**
  13353. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13354. * @param postProcess The post process to share the output with.
  13355. * @returns This post process.
  13356. */
  13357. shareOutputWith(postProcess: PostProcess): PostProcess;
  13358. /**
  13359. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13360. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13361. */
  13362. useOwnOutput(): void;
  13363. /**
  13364. * Updates the effect with the current post process compile time values and recompiles the shader.
  13365. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13366. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13367. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13368. * @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
  13369. * @param onCompiled Called when the shader has been compiled.
  13370. * @param onError Called if there is an error when compiling a shader.
  13371. */
  13372. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13373. /**
  13374. * The post process is reusable if it can be used multiple times within one frame.
  13375. * @returns If the post process is reusable
  13376. */
  13377. isReusable(): boolean;
  13378. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13379. markTextureDirty(): void;
  13380. /**
  13381. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13382. * 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.
  13383. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13384. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13385. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13386. * @returns The target texture that was bound to be written to.
  13387. */
  13388. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13389. /**
  13390. * If the post process is supported.
  13391. */
  13392. readonly isSupported: boolean;
  13393. /**
  13394. * The aspect ratio of the output texture.
  13395. */
  13396. readonly aspectRatio: number;
  13397. /**
  13398. * Get a value indicating if the post-process is ready to be used
  13399. * @returns true if the post-process is ready (shader is compiled)
  13400. */
  13401. isReady(): boolean;
  13402. /**
  13403. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13404. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13405. */
  13406. apply(): Nullable<Effect>;
  13407. private _disposeTextures;
  13408. /**
  13409. * Disposes the post process.
  13410. * @param camera The camera to dispose the post process on.
  13411. */
  13412. dispose(camera?: Camera): void;
  13413. }
  13414. }
  13415. declare module BABYLON {
  13416. /**
  13417. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13418. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13419. */
  13420. export class PostProcessManager {
  13421. private _scene;
  13422. private _indexBuffer;
  13423. private _vertexBuffers;
  13424. /**
  13425. * Creates a new instance PostProcess
  13426. * @param scene The scene that the post process is associated with.
  13427. */
  13428. constructor(scene: Scene);
  13429. private _prepareBuffers;
  13430. private _buildIndexBuffer;
  13431. /**
  13432. * Rebuilds the vertex buffers of the manager.
  13433. * @hidden
  13434. */ rebuild(): void;
  13435. /**
  13436. * Prepares a frame to be run through a post process.
  13437. * @param sourceTexture The input texture to the post procesess. (default: null)
  13438. * @param postProcesses An array of post processes to be run. (default: null)
  13439. * @returns True if the post processes were able to be run.
  13440. * @hidden
  13441. */ prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13442. /**
  13443. * Manually render a set of post processes to a texture.
  13444. * @param postProcesses An array of post processes to be run.
  13445. * @param targetTexture The target texture to render to.
  13446. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13447. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13448. * @param lodLevel defines which lod of the texture to render to
  13449. */
  13450. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13451. /**
  13452. * Finalize the result of the output of the postprocesses.
  13453. * @param doNotPresent If true the result will not be displayed to the screen.
  13454. * @param targetTexture The target texture to render to.
  13455. * @param faceIndex The index of the face to bind the target texture to.
  13456. * @param postProcesses The array of post processes to render.
  13457. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13458. * @hidden
  13459. */ finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13460. /**
  13461. * Disposes of the post process manager.
  13462. */
  13463. dispose(): void;
  13464. }
  13465. }
  13466. declare module BABYLON {
  13467. /**
  13468. * Raw texture can help creating a texture directly from an array of data.
  13469. * This can be super useful if you either get the data from an uncompressed source or
  13470. * if you wish to create your texture pixel by pixel.
  13471. */
  13472. export class RawTexture extends Texture {
  13473. /**
  13474. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13475. */
  13476. format: number;
  13477. private _engine;
  13478. /**
  13479. * Instantiates a new RawTexture.
  13480. * Raw texture can help creating a texture directly from an array of data.
  13481. * This can be super useful if you either get the data from an uncompressed source or
  13482. * if you wish to create your texture pixel by pixel.
  13483. * @param data define the array of data to use to create the texture
  13484. * @param width define the width of the texture
  13485. * @param height define the height of the texture
  13486. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13487. * @param scene define the scene the texture belongs to
  13488. * @param generateMipMaps define whether mip maps should be generated or not
  13489. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13490. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13491. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13492. */
  13493. constructor(data: ArrayBufferView, width: number, height: number,
  13494. /**
  13495. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13496. */
  13497. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  13498. /**
  13499. * Updates the texture underlying data.
  13500. * @param data Define the new data of the texture
  13501. */
  13502. update(data: ArrayBufferView): void;
  13503. /**
  13504. * Creates a luminance texture from some data.
  13505. * @param data Define the texture data
  13506. * @param width Define the width of the texture
  13507. * @param height Define the height of the texture
  13508. * @param scene Define the scene the texture belongs to
  13509. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13510. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13511. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13512. * @returns the luminance texture
  13513. */
  13514. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13515. /**
  13516. * Creates a luminance alpha texture from some data.
  13517. * @param data Define the texture data
  13518. * @param width Define the width of the texture
  13519. * @param height Define the height of the texture
  13520. * @param scene Define the scene the texture belongs to
  13521. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13522. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13523. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13524. * @returns the luminance alpha texture
  13525. */
  13526. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13527. /**
  13528. * Creates an alpha texture from some data.
  13529. * @param data Define the texture data
  13530. * @param width Define the width of the texture
  13531. * @param height Define the height of the texture
  13532. * @param scene Define the scene the texture belongs to
  13533. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13534. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13535. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13536. * @returns the alpha texture
  13537. */
  13538. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13539. /**
  13540. * Creates a RGB texture from some data.
  13541. * @param data Define the texture data
  13542. * @param width Define the width of the texture
  13543. * @param height Define the height of the texture
  13544. * @param scene Define the scene the texture belongs to
  13545. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13546. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13547. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13548. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13549. * @returns the RGB alpha texture
  13550. */
  13551. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13552. /**
  13553. * Creates a RGBA texture from some data.
  13554. * @param data Define the texture data
  13555. * @param width Define the width of the texture
  13556. * @param height Define the height of the texture
  13557. * @param scene Define the scene the texture belongs to
  13558. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13559. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13560. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13561. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13562. * @returns the RGBA texture
  13563. */
  13564. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13565. /**
  13566. * Creates a R texture from some data.
  13567. * @param data Define the texture data
  13568. * @param width Define the width of the texture
  13569. * @param height Define the height of the texture
  13570. * @param scene Define the scene the texture belongs to
  13571. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13572. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13573. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13574. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13575. * @returns the R texture
  13576. */
  13577. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13578. }
  13579. }
  13580. declare module BABYLON {
  13581. interface AbstractScene {
  13582. /**
  13583. * The list of layers (background and foreground) of the scene
  13584. */
  13585. layers: Array<Layer>;
  13586. }
  13587. /**
  13588. * Defines the layer scene component responsible to manage any layers
  13589. * in a given scene.
  13590. */
  13591. export class LayerSceneComponent implements ISceneComponent {
  13592. /**
  13593. * The component name helpfull to identify the component in the list of scene components.
  13594. */
  13595. readonly name: string;
  13596. /**
  13597. * The scene the component belongs to.
  13598. */
  13599. scene: Scene;
  13600. private _engine;
  13601. /**
  13602. * Creates a new instance of the component for the given scene
  13603. * @param scene Defines the scene to register the component in
  13604. */
  13605. constructor(scene: Scene);
  13606. /**
  13607. * Registers the component in a given scene
  13608. */
  13609. register(): void;
  13610. /**
  13611. * Rebuilds the elements related to this component in case of
  13612. * context lost for instance.
  13613. */
  13614. rebuild(): void;
  13615. /**
  13616. * Disposes the component and the associated ressources.
  13617. */
  13618. dispose(): void;
  13619. private _draw;
  13620. private _drawCameraPredicate;
  13621. private _drawCameraBackground;
  13622. private _drawCameraForeground;
  13623. private _drawRenderTargetPredicate;
  13624. private _drawRenderTargetBackground;
  13625. private _drawRenderTargetForeground;
  13626. }
  13627. }
  13628. declare module BABYLON {
  13629. /** @hidden */
  13630. export var layerPixelShader: {
  13631. name: string;
  13632. shader: string;
  13633. };
  13634. }
  13635. declare module BABYLON {
  13636. /** @hidden */
  13637. export var layerVertexShader: {
  13638. name: string;
  13639. shader: string;
  13640. };
  13641. }
  13642. declare module BABYLON {
  13643. /**
  13644. * This represents a full screen 2d layer.
  13645. * This can be useful to display a picture in the background of your scene for instance.
  13646. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13647. */
  13648. export class Layer {
  13649. /**
  13650. * Define the name of the layer.
  13651. */
  13652. name: string;
  13653. /**
  13654. * Define the texture the layer should display.
  13655. */
  13656. texture: Nullable<Texture>;
  13657. /**
  13658. * Is the layer in background or foreground.
  13659. */
  13660. isBackground: boolean;
  13661. /**
  13662. * Define the color of the layer (instead of texture).
  13663. */
  13664. color: Color4;
  13665. /**
  13666. * Define the scale of the layer in order to zoom in out of the texture.
  13667. */
  13668. scale: Vector2;
  13669. /**
  13670. * Define an offset for the layer in order to shift the texture.
  13671. */
  13672. offset: Vector2;
  13673. /**
  13674. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13675. */
  13676. alphaBlendingMode: number;
  13677. /**
  13678. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13679. * Alpha test will not mix with the background color in case of transparency.
  13680. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13681. */
  13682. alphaTest: boolean;
  13683. /**
  13684. * Define a mask to restrict the layer to only some of the scene cameras.
  13685. */
  13686. layerMask: number;
  13687. /**
  13688. * Define the list of render target the layer is visible into.
  13689. */
  13690. renderTargetTextures: RenderTargetTexture[];
  13691. /**
  13692. * Define if the layer is only used in renderTarget or if it also
  13693. * renders in the main frame buffer of the canvas.
  13694. */
  13695. renderOnlyInRenderTargetTextures: boolean;
  13696. private _scene;
  13697. private _vertexBuffers;
  13698. private _indexBuffer;
  13699. private _effect;
  13700. private _alphaTestEffect;
  13701. /**
  13702. * An event triggered when the layer is disposed.
  13703. */
  13704. onDisposeObservable: Observable<Layer>;
  13705. private _onDisposeObserver;
  13706. /**
  13707. * Back compatibility with callback before the onDisposeObservable existed.
  13708. * The set callback will be triggered when the layer has been disposed.
  13709. */
  13710. onDispose: () => void;
  13711. /**
  13712. * An event triggered before rendering the scene
  13713. */
  13714. onBeforeRenderObservable: Observable<Layer>;
  13715. private _onBeforeRenderObserver;
  13716. /**
  13717. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13718. * The set callback will be triggered just before rendering the layer.
  13719. */
  13720. onBeforeRender: () => void;
  13721. /**
  13722. * An event triggered after rendering the scene
  13723. */
  13724. onAfterRenderObservable: Observable<Layer>;
  13725. private _onAfterRenderObserver;
  13726. /**
  13727. * Back compatibility with callback before the onAfterRenderObservable existed.
  13728. * The set callback will be triggered just after rendering the layer.
  13729. */
  13730. onAfterRender: () => void;
  13731. /**
  13732. * Instantiates a new layer.
  13733. * This represents a full screen 2d layer.
  13734. * This can be useful to display a picture in the background of your scene for instance.
  13735. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13736. * @param name Define the name of the layer in the scene
  13737. * @param imgUrl Define the url of the texture to display in the layer
  13738. * @param scene Define the scene the layer belongs to
  13739. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13740. * @param color Defines a color for the layer
  13741. */
  13742. constructor(
  13743. /**
  13744. * Define the name of the layer.
  13745. */
  13746. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13747. private _createIndexBuffer;
  13748. /** @hidden */ rebuild(): void;
  13749. /**
  13750. * Renders the layer in the scene.
  13751. */
  13752. render(): void;
  13753. /**
  13754. * Disposes and releases the associated ressources.
  13755. */
  13756. dispose(): void;
  13757. }
  13758. }
  13759. declare module BABYLON {
  13760. interface AbstractScene {
  13761. /**
  13762. * The list of procedural textures added to the scene
  13763. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13764. */
  13765. proceduralTextures: Array<ProceduralTexture>;
  13766. }
  13767. /**
  13768. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13769. * in a given scene.
  13770. */
  13771. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13772. /**
  13773. * The component name helpfull to identify the component in the list of scene components.
  13774. */
  13775. readonly name: string;
  13776. /**
  13777. * The scene the component belongs to.
  13778. */
  13779. scene: Scene;
  13780. /**
  13781. * Creates a new instance of the component for the given scene
  13782. * @param scene Defines the scene to register the component in
  13783. */
  13784. constructor(scene: Scene);
  13785. /**
  13786. * Registers the component in a given scene
  13787. */
  13788. register(): void;
  13789. /**
  13790. * Rebuilds the elements related to this component in case of
  13791. * context lost for instance.
  13792. */
  13793. rebuild(): void;
  13794. /**
  13795. * Disposes the component and the associated ressources.
  13796. */
  13797. dispose(): void;
  13798. private _beforeClear;
  13799. }
  13800. }
  13801. declare module BABYLON {
  13802. /** @hidden */
  13803. export var proceduralVertexShader: {
  13804. name: string;
  13805. shader: string;
  13806. };
  13807. }
  13808. declare module BABYLON {
  13809. /**
  13810. * 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.
  13811. * This is the base class of any Procedural texture and contains most of the shareable code.
  13812. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13813. */
  13814. export class ProceduralTexture extends Texture {
  13815. isCube: boolean;
  13816. /**
  13817. * Define if the texture is enabled or not (disabled texture will not render)
  13818. */
  13819. isEnabled: boolean;
  13820. /**
  13821. * Define if the texture must be cleared before rendering (default is true)
  13822. */
  13823. autoClear: boolean;
  13824. /**
  13825. * Callback called when the texture is generated
  13826. */
  13827. onGenerated: () => void;
  13828. /**
  13829. * Event raised when the texture is generated
  13830. */
  13831. onGeneratedObservable: Observable<ProceduralTexture>;
  13832. /** @hidden */ generateMipMaps: boolean;
  13833. /** @hidden **/ effect: Effect;
  13834. /** @hidden */ textures: {
  13835. [key: string]: Texture;
  13836. };
  13837. private _size;
  13838. private _currentRefreshId;
  13839. private _refreshRate;
  13840. private _vertexBuffers;
  13841. private _indexBuffer;
  13842. private _uniforms;
  13843. private _samplers;
  13844. private _fragment;
  13845. private _floats;
  13846. private _ints;
  13847. private _floatsArrays;
  13848. private _colors3;
  13849. private _colors4;
  13850. private _vectors2;
  13851. private _vectors3;
  13852. private _matrices;
  13853. private _fallbackTexture;
  13854. private _fallbackTextureUsed;
  13855. private _engine;
  13856. private _cachedDefines;
  13857. private _contentUpdateId;
  13858. private _contentData;
  13859. /**
  13860. * Instantiates a new procedural texture.
  13861. * 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.
  13862. * This is the base class of any Procedural texture and contains most of the shareable code.
  13863. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13864. * @param name Define the name of the texture
  13865. * @param size Define the size of the texture to create
  13866. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13867. * @param scene Define the scene the texture belongs to
  13868. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13869. * @param generateMipMaps Define if the texture should creates mip maps or not
  13870. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13871. */
  13872. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13873. /**
  13874. * The effect that is created when initializing the post process.
  13875. * @returns The created effect corrisponding the the postprocess.
  13876. */
  13877. getEffect(): Effect;
  13878. /**
  13879. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13880. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13881. */
  13882. getContent(): Nullable<ArrayBufferView>;
  13883. private _createIndexBuffer;
  13884. /** @hidden */ rebuild(): void;
  13885. /**
  13886. * Resets the texture in order to recreate its associated resources.
  13887. * This can be called in case of context loss
  13888. */
  13889. reset(): void;
  13890. protected _getDefines(): string;
  13891. /**
  13892. * Is the texture ready to be used ? (rendered at least once)
  13893. * @returns true if ready, otherwise, false.
  13894. */
  13895. isReady(): boolean;
  13896. /**
  13897. * Resets the refresh counter of the texture and start bak from scratch.
  13898. * Could be useful to regenerate the texture if it is setup to render only once.
  13899. */
  13900. resetRefreshCounter(): void;
  13901. /**
  13902. * Set the fragment shader to use in order to render the texture.
  13903. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  13904. */
  13905. setFragment(fragment: any): void;
  13906. /**
  13907. * Define the refresh rate of the texture or the rendering frequency.
  13908. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  13909. */
  13910. refreshRate: number;
  13911. /** @hidden */ shouldRender(): boolean;
  13912. /**
  13913. * Get the size the texture is rendering at.
  13914. * @returns the size (texture is always squared)
  13915. */
  13916. getRenderSize(): number;
  13917. /**
  13918. * Resize the texture to new value.
  13919. * @param size Define the new size the texture should have
  13920. * @param generateMipMaps Define whether the new texture should create mip maps
  13921. */
  13922. resize(size: number, generateMipMaps: boolean): void;
  13923. private _checkUniform;
  13924. /**
  13925. * Set a texture in the shader program used to render.
  13926. * @param name Define the name of the uniform samplers as defined in the shader
  13927. * @param texture Define the texture to bind to this sampler
  13928. * @return the texture itself allowing "fluent" like uniform updates
  13929. */
  13930. setTexture(name: string, texture: Texture): ProceduralTexture;
  13931. /**
  13932. * Set a float in the shader.
  13933. * @param name Define the name of the uniform as defined in the shader
  13934. * @param value Define the value to give to the uniform
  13935. * @return the texture itself allowing "fluent" like uniform updates
  13936. */
  13937. setFloat(name: string, value: number): ProceduralTexture;
  13938. /**
  13939. * Set a int in the shader.
  13940. * @param name Define the name of the uniform as defined in the shader
  13941. * @param value Define the value to give to the uniform
  13942. * @return the texture itself allowing "fluent" like uniform updates
  13943. */
  13944. setInt(name: string, value: number): ProceduralTexture;
  13945. /**
  13946. * Set an array of floats in the shader.
  13947. * @param name Define the name of the uniform as defined in the shader
  13948. * @param value Define the value to give to the uniform
  13949. * @return the texture itself allowing "fluent" like uniform updates
  13950. */
  13951. setFloats(name: string, value: number[]): ProceduralTexture;
  13952. /**
  13953. * Set a vec3 in the shader from a Color3.
  13954. * @param name Define the name of the uniform as defined in the shader
  13955. * @param value Define the value to give to the uniform
  13956. * @return the texture itself allowing "fluent" like uniform updates
  13957. */
  13958. setColor3(name: string, value: Color3): ProceduralTexture;
  13959. /**
  13960. * Set a vec4 in the shader from a Color4.
  13961. * @param name Define the name of the uniform as defined in the shader
  13962. * @param value Define the value to give to the uniform
  13963. * @return the texture itself allowing "fluent" like uniform updates
  13964. */
  13965. setColor4(name: string, value: Color4): ProceduralTexture;
  13966. /**
  13967. * Set a vec2 in the shader from a Vector2.
  13968. * @param name Define the name of the uniform as defined in the shader
  13969. * @param value Define the value to give to the uniform
  13970. * @return the texture itself allowing "fluent" like uniform updates
  13971. */
  13972. setVector2(name: string, value: Vector2): ProceduralTexture;
  13973. /**
  13974. * Set a vec3 in the shader from a Vector3.
  13975. * @param name Define the name of the uniform as defined in the shader
  13976. * @param value Define the value to give to the uniform
  13977. * @return the texture itself allowing "fluent" like uniform updates
  13978. */
  13979. setVector3(name: string, value: Vector3): ProceduralTexture;
  13980. /**
  13981. * Set a mat4 in the shader from a MAtrix.
  13982. * @param name Define the name of the uniform as defined in the shader
  13983. * @param value Define the value to give to the uniform
  13984. * @return the texture itself allowing "fluent" like uniform updates
  13985. */
  13986. setMatrix(name: string, value: Matrix): ProceduralTexture;
  13987. /**
  13988. * Render the texture to its associated render target.
  13989. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  13990. */
  13991. render(useCameraPostProcess?: boolean): void;
  13992. /**
  13993. * Clone the texture.
  13994. * @returns the cloned texture
  13995. */
  13996. clone(): ProceduralTexture;
  13997. /**
  13998. * Dispose the texture and release its asoociated resources.
  13999. */
  14000. dispose(): void;
  14001. }
  14002. }
  14003. declare module BABYLON {
  14004. /**
  14005. * This represents the base class for particle system in Babylon.
  14006. * 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.
  14007. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14008. * @example https://doc.babylonjs.com/babylon101/particles
  14009. */
  14010. export class BaseParticleSystem {
  14011. /**
  14012. * Source color is added to the destination color without alpha affecting the result
  14013. */
  14014. static BLENDMODE_ONEONE: number;
  14015. /**
  14016. * Blend current color and particle color using particle’s alpha
  14017. */
  14018. static BLENDMODE_STANDARD: number;
  14019. /**
  14020. * Add current color and particle color multiplied by particle’s alpha
  14021. */
  14022. static BLENDMODE_ADD: number;
  14023. /**
  14024. * Multiply current color with particle color
  14025. */
  14026. static BLENDMODE_MULTIPLY: number;
  14027. /**
  14028. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14029. */
  14030. static BLENDMODE_MULTIPLYADD: number;
  14031. /**
  14032. * List of animations used by the particle system.
  14033. */
  14034. animations: Animation[];
  14035. /**
  14036. * The id of the Particle system.
  14037. */
  14038. id: string;
  14039. /**
  14040. * The friendly name of the Particle system.
  14041. */
  14042. name: string;
  14043. /**
  14044. * The rendering group used by the Particle system to chose when to render.
  14045. */
  14046. renderingGroupId: number;
  14047. /**
  14048. * The emitter represents the Mesh or position we are attaching the particle system to.
  14049. */
  14050. emitter: Nullable<AbstractMesh | Vector3>;
  14051. /**
  14052. * The maximum number of particles to emit per frame
  14053. */
  14054. emitRate: number;
  14055. /**
  14056. * If you want to launch only a few particles at once, that can be done, as well.
  14057. */
  14058. manualEmitCount: number;
  14059. /**
  14060. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14061. */
  14062. updateSpeed: number;
  14063. /**
  14064. * The amount of time the particle system is running (depends of the overall update speed).
  14065. */
  14066. targetStopDuration: number;
  14067. /**
  14068. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14069. */
  14070. disposeOnStop: boolean;
  14071. /**
  14072. * Minimum power of emitting particles.
  14073. */
  14074. minEmitPower: number;
  14075. /**
  14076. * Maximum power of emitting particles.
  14077. */
  14078. maxEmitPower: number;
  14079. /**
  14080. * Minimum life time of emitting particles.
  14081. */
  14082. minLifeTime: number;
  14083. /**
  14084. * Maximum life time of emitting particles.
  14085. */
  14086. maxLifeTime: number;
  14087. /**
  14088. * Minimum Size of emitting particles.
  14089. */
  14090. minSize: number;
  14091. /**
  14092. * Maximum Size of emitting particles.
  14093. */
  14094. maxSize: number;
  14095. /**
  14096. * Minimum scale of emitting particles on X axis.
  14097. */
  14098. minScaleX: number;
  14099. /**
  14100. * Maximum scale of emitting particles on X axis.
  14101. */
  14102. maxScaleX: number;
  14103. /**
  14104. * Minimum scale of emitting particles on Y axis.
  14105. */
  14106. minScaleY: number;
  14107. /**
  14108. * Maximum scale of emitting particles on Y axis.
  14109. */
  14110. maxScaleY: number;
  14111. /**
  14112. * Gets or sets the minimal initial rotation in radians.
  14113. */
  14114. minInitialRotation: number;
  14115. /**
  14116. * Gets or sets the maximal initial rotation in radians.
  14117. */
  14118. maxInitialRotation: number;
  14119. /**
  14120. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14121. */
  14122. minAngularSpeed: number;
  14123. /**
  14124. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14125. */
  14126. maxAngularSpeed: number;
  14127. /**
  14128. * The texture used to render each particle. (this can be a spritesheet)
  14129. */
  14130. particleTexture: Nullable<Texture>;
  14131. /**
  14132. * The layer mask we are rendering the particles through.
  14133. */
  14134. layerMask: number;
  14135. /**
  14136. * This can help using your own shader to render the particle system.
  14137. * The according effect will be created
  14138. */
  14139. customShader: any;
  14140. /**
  14141. * By default particle system starts as soon as they are created. This prevents the
  14142. * automatic start to happen and let you decide when to start emitting particles.
  14143. */
  14144. preventAutoStart: boolean;
  14145. private _noiseTexture;
  14146. /**
  14147. * Gets or sets a texture used to add random noise to particle positions
  14148. */
  14149. noiseTexture: Nullable<ProceduralTexture>;
  14150. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14151. noiseStrength: Vector3;
  14152. /**
  14153. * Callback triggered when the particle animation is ending.
  14154. */
  14155. onAnimationEnd: Nullable<() => void>;
  14156. /**
  14157. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14158. */
  14159. blendMode: number;
  14160. /**
  14161. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14162. * to override the particles.
  14163. */
  14164. forceDepthWrite: boolean;
  14165. /** 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 */
  14166. preWarmCycles: number;
  14167. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14168. preWarmStepOffset: number;
  14169. /**
  14170. * 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)
  14171. */
  14172. spriteCellChangeSpeed: number;
  14173. /**
  14174. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14175. */
  14176. startSpriteCellID: number;
  14177. /**
  14178. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14179. */
  14180. endSpriteCellID: number;
  14181. /**
  14182. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14183. */
  14184. spriteCellWidth: number;
  14185. /**
  14186. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14187. */
  14188. spriteCellHeight: number;
  14189. /**
  14190. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14191. */
  14192. spriteRandomStartCell: boolean;
  14193. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14194. translationPivot: Vector2;
  14195. /** @hidden */
  14196. protected _isAnimationSheetEnabled: boolean;
  14197. /**
  14198. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14199. */
  14200. beginAnimationOnStart: boolean;
  14201. /**
  14202. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14203. */
  14204. beginAnimationFrom: number;
  14205. /**
  14206. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14207. */
  14208. beginAnimationTo: number;
  14209. /**
  14210. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14211. */
  14212. beginAnimationLoop: boolean;
  14213. /**
  14214. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14215. */
  14216. isAnimationSheetEnabled: boolean;
  14217. /**
  14218. * Get hosting scene
  14219. * @returns the scene
  14220. */
  14221. getScene(): Scene;
  14222. /**
  14223. * You can use gravity if you want to give an orientation to your particles.
  14224. */
  14225. gravity: Vector3;
  14226. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14227. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14228. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14229. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14230. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14231. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14232. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14233. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14234. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14235. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14236. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14237. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14238. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14239. /**
  14240. * Defines the delay in milliseconds before starting the system (0 by default)
  14241. */
  14242. startDelay: number;
  14243. /**
  14244. * Gets the current list of drag gradients.
  14245. * You must use addDragGradient and removeDragGradient to udpate this list
  14246. * @returns the list of drag gradients
  14247. */
  14248. getDragGradients(): Nullable<Array<FactorGradient>>;
  14249. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14250. limitVelocityDamping: number;
  14251. /**
  14252. * Gets the current list of limit velocity gradients.
  14253. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14254. * @returns the list of limit velocity gradients
  14255. */
  14256. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14257. /**
  14258. * Gets the current list of color gradients.
  14259. * You must use addColorGradient and removeColorGradient to udpate this list
  14260. * @returns the list of color gradients
  14261. */
  14262. getColorGradients(): Nullable<Array<ColorGradient>>;
  14263. /**
  14264. * Gets the current list of size gradients.
  14265. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14266. * @returns the list of size gradients
  14267. */
  14268. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14269. /**
  14270. * Gets the current list of color remap gradients.
  14271. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14272. * @returns the list of color remap gradients
  14273. */
  14274. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14275. /**
  14276. * Gets the current list of alpha remap gradients.
  14277. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14278. * @returns the list of alpha remap gradients
  14279. */
  14280. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14281. /**
  14282. * Gets the current list of life time gradients.
  14283. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14284. * @returns the list of life time gradients
  14285. */
  14286. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14287. /**
  14288. * Gets the current list of angular speed gradients.
  14289. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14290. * @returns the list of angular speed gradients
  14291. */
  14292. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14293. /**
  14294. * Gets the current list of velocity gradients.
  14295. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14296. * @returns the list of velocity gradients
  14297. */
  14298. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14299. /**
  14300. * Gets the current list of start size gradients.
  14301. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14302. * @returns the list of start size gradients
  14303. */
  14304. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14305. /**
  14306. * Gets the current list of emit rate gradients.
  14307. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14308. * @returns the list of emit rate gradients
  14309. */
  14310. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14311. /**
  14312. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14313. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14314. */
  14315. direction1: Vector3;
  14316. /**
  14317. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14318. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14319. */
  14320. direction2: Vector3;
  14321. /**
  14322. * 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.
  14323. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14324. */
  14325. minEmitBox: Vector3;
  14326. /**
  14327. * 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.
  14328. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14329. */
  14330. maxEmitBox: Vector3;
  14331. /**
  14332. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14333. */
  14334. color1: Color4;
  14335. /**
  14336. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14337. */
  14338. color2: Color4;
  14339. /**
  14340. * Color the particle will have at the end of its lifetime
  14341. */
  14342. colorDead: Color4;
  14343. /**
  14344. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14345. */
  14346. textureMask: Color4;
  14347. /**
  14348. * The particle emitter type defines the emitter used by the particle system.
  14349. * It can be for example box, sphere, or cone...
  14350. */
  14351. particleEmitterType: IParticleEmitterType;
  14352. /** @hidden */ isSubEmitter: boolean;
  14353. /**
  14354. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14355. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14356. */
  14357. billboardMode: number;
  14358. protected _isBillboardBased: boolean;
  14359. /**
  14360. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14361. */
  14362. isBillboardBased: boolean;
  14363. /**
  14364. * The scene the particle system belongs to.
  14365. */
  14366. protected _scene: Scene;
  14367. /**
  14368. * Local cache of defines for image processing.
  14369. */
  14370. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14371. /**
  14372. * Default configuration related to image processing available in the standard Material.
  14373. */
  14374. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14375. /**
  14376. * Gets the image processing configuration used either in this material.
  14377. */
  14378. /**
  14379. * Sets the Default image processing configuration used either in the this material.
  14380. *
  14381. * If sets to null, the scene one is in use.
  14382. */
  14383. imageProcessingConfiguration: ImageProcessingConfiguration;
  14384. /**
  14385. * Attaches a new image processing configuration to the Standard Material.
  14386. * @param configuration
  14387. */
  14388. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14389. /** @hidden */
  14390. protected _reset(): void;
  14391. /** @hidden */
  14392. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14393. /**
  14394. * Instantiates a particle system.
  14395. * 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.
  14396. * @param name The name of the particle system
  14397. */
  14398. constructor(name: string);
  14399. /**
  14400. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14401. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14402. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14403. * @returns the emitter
  14404. */
  14405. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14406. /**
  14407. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14408. * @param radius The radius of the hemisphere to emit from
  14409. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14410. * @returns the emitter
  14411. */
  14412. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14413. /**
  14414. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14415. * @param radius The radius of the sphere to emit from
  14416. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14417. * @returns the emitter
  14418. */
  14419. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14420. /**
  14421. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14422. * @param radius The radius of the sphere to emit from
  14423. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14424. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14425. * @returns the emitter
  14426. */
  14427. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14428. /**
  14429. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14430. * @param radius The radius of the emission cylinder
  14431. * @param height The height of the emission cylinder
  14432. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14433. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14434. * @returns the emitter
  14435. */
  14436. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14437. /**
  14438. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14439. * @param radius The radius of the cylinder to emit from
  14440. * @param height The height of the emission cylinder
  14441. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14442. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14443. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14444. * @returns the emitter
  14445. */
  14446. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14447. /**
  14448. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14449. * @param radius The radius of the cone to emit from
  14450. * @param angle The base angle of the cone
  14451. * @returns the emitter
  14452. */
  14453. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14454. /**
  14455. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14456. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14457. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14458. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14459. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14460. * @returns the emitter
  14461. */
  14462. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14463. }
  14464. }
  14465. declare module BABYLON {
  14466. /**
  14467. * Type of sub emitter
  14468. */
  14469. export enum SubEmitterType {
  14470. /**
  14471. * Attached to the particle over it's lifetime
  14472. */
  14473. ATTACHED = 0,
  14474. /**
  14475. * Created when the particle dies
  14476. */
  14477. END = 1
  14478. }
  14479. /**
  14480. * Sub emitter class used to emit particles from an existing particle
  14481. */
  14482. export class SubEmitter {
  14483. /**
  14484. * the particle system to be used by the sub emitter
  14485. */
  14486. particleSystem: ParticleSystem;
  14487. /**
  14488. * Type of the submitter (Default: END)
  14489. */
  14490. type: SubEmitterType;
  14491. /**
  14492. * 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)
  14493. * Note: This only is supported when using an emitter of type Mesh
  14494. */
  14495. inheritDirection: boolean;
  14496. /**
  14497. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14498. */
  14499. inheritedVelocityAmount: number;
  14500. /**
  14501. * Creates a sub emitter
  14502. * @param particleSystem the particle system to be used by the sub emitter
  14503. */
  14504. constructor(
  14505. /**
  14506. * the particle system to be used by the sub emitter
  14507. */
  14508. particleSystem: ParticleSystem);
  14509. /**
  14510. * Clones the sub emitter
  14511. * @returns the cloned sub emitter
  14512. */
  14513. clone(): SubEmitter;
  14514. /**
  14515. * Serialize current object to a JSON object
  14516. * @returns the serialized object
  14517. */
  14518. serialize(): any;
  14519. /** @hidden */ private static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14520. /**
  14521. * Creates a new SubEmitter from a serialized JSON version
  14522. * @param serializationObject defines the JSON object to read from
  14523. * @param scene defines the hosting scene
  14524. * @param rootUrl defines the rootUrl for data loading
  14525. * @returns a new SubEmitter
  14526. */
  14527. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14528. /** Release associated resources */
  14529. dispose(): void;
  14530. }
  14531. }
  14532. declare module BABYLON {
  14533. /** @hidden */
  14534. export var clipPlaneFragmentDeclaration: {
  14535. name: string;
  14536. shader: string;
  14537. };
  14538. }
  14539. declare module BABYLON {
  14540. /** @hidden */
  14541. export var imageProcessingDeclaration: {
  14542. name: string;
  14543. shader: string;
  14544. };
  14545. }
  14546. declare module BABYLON {
  14547. /** @hidden */
  14548. export var imageProcessingFunctions: {
  14549. name: string;
  14550. shader: string;
  14551. };
  14552. }
  14553. declare module BABYLON {
  14554. /** @hidden */
  14555. export var clipPlaneFragment: {
  14556. name: string;
  14557. shader: string;
  14558. };
  14559. }
  14560. declare module BABYLON {
  14561. /** @hidden */
  14562. export var particlesPixelShader: {
  14563. name: string;
  14564. shader: string;
  14565. };
  14566. }
  14567. declare module BABYLON {
  14568. /** @hidden */
  14569. export var clipPlaneVertexDeclaration: {
  14570. name: string;
  14571. shader: string;
  14572. };
  14573. }
  14574. declare module BABYLON {
  14575. /** @hidden */
  14576. export var clipPlaneVertex: {
  14577. name: string;
  14578. shader: string;
  14579. };
  14580. }
  14581. declare module BABYLON {
  14582. /** @hidden */
  14583. export var particlesVertexShader: {
  14584. name: string;
  14585. shader: string;
  14586. };
  14587. }
  14588. declare module BABYLON {
  14589. /**
  14590. * This represents a particle system in Babylon.
  14591. * 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.
  14592. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14593. * @example https://doc.babylonjs.com/babylon101/particles
  14594. */
  14595. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14596. /**
  14597. * Billboard mode will only apply to Y axis
  14598. */
  14599. static readonly BILLBOARDMODE_Y: number;
  14600. /**
  14601. * Billboard mode will apply to all axes
  14602. */
  14603. static readonly BILLBOARDMODE_ALL: number;
  14604. /**
  14605. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14606. */
  14607. static readonly BILLBOARDMODE_STRETCHED: number;
  14608. /**
  14609. * This function can be defined to provide custom update for active particles.
  14610. * This function will be called instead of regular update (age, position, color, etc.).
  14611. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14612. */
  14613. updateFunction: (particles: Particle[]) => void;
  14614. private _emitterWorldMatrix;
  14615. /**
  14616. * This function can be defined to specify initial direction for every new particle.
  14617. * It by default use the emitterType defined function
  14618. */
  14619. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14620. /**
  14621. * This function can be defined to specify initial position for every new particle.
  14622. * It by default use the emitterType defined function
  14623. */
  14624. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14625. /**
  14626. * @hidden
  14627. */ inheritedVelocityOffset: Vector3;
  14628. /**
  14629. * An event triggered when the system is disposed
  14630. */
  14631. onDisposeObservable: Observable<ParticleSystem>;
  14632. private _onDisposeObserver;
  14633. /**
  14634. * Sets a callback that will be triggered when the system is disposed
  14635. */
  14636. onDispose: () => void;
  14637. private _particles;
  14638. private _epsilon;
  14639. private _capacity;
  14640. private _stockParticles;
  14641. private _newPartsExcess;
  14642. private _vertexData;
  14643. private _vertexBuffer;
  14644. private _vertexBuffers;
  14645. private _spriteBuffer;
  14646. private _indexBuffer;
  14647. private _effect;
  14648. private _customEffect;
  14649. private _cachedDefines;
  14650. private _scaledColorStep;
  14651. private _colorDiff;
  14652. private _scaledDirection;
  14653. private _scaledGravity;
  14654. private _currentRenderId;
  14655. private _alive;
  14656. private _useInstancing;
  14657. private _started;
  14658. private _stopped;
  14659. private _actualFrame;
  14660. private _scaledUpdateSpeed;
  14661. private _vertexBufferSize;
  14662. /** @hidden */ currentEmitRateGradient: Nullable<FactorGradient>;
  14663. /** @hidden */ currentEmitRate1: number;
  14664. /** @hidden */ currentEmitRate2: number;
  14665. /** @hidden */ currentStartSizeGradient: Nullable<FactorGradient>;
  14666. /** @hidden */ currentStartSize1: number;
  14667. /** @hidden */ currentStartSize2: number;
  14668. private readonly _rawTextureWidth;
  14669. private _rampGradientsTexture;
  14670. private _useRampGradients;
  14671. /** Gets or sets a boolean indicating that ramp gradients must be used
  14672. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14673. */
  14674. useRampGradients: boolean;
  14675. /**
  14676. * 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.
  14677. * 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: [])
  14678. */
  14679. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14680. private _subEmitters;
  14681. /**
  14682. * @hidden
  14683. * If the particle systems emitter should be disposed when the particle system is disposed
  14684. */ disposeEmitterOnDispose: boolean;
  14685. /**
  14686. * The current active Sub-systems, this property is used by the root particle system only.
  14687. */
  14688. activeSubSystems: Array<ParticleSystem>;
  14689. private _rootParticleSystem;
  14690. /**
  14691. * Gets the current list of active particles
  14692. */
  14693. readonly particles: Particle[];
  14694. /**
  14695. * Returns the string "ParticleSystem"
  14696. * @returns a string containing the class name
  14697. */
  14698. getClassName(): string;
  14699. /**
  14700. * Instantiates a particle system.
  14701. * 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.
  14702. * @param name The name of the particle system
  14703. * @param capacity The max number of particles alive at the same time
  14704. * @param scene The scene the particle system belongs to
  14705. * @param customEffect a custom effect used to change the way particles are rendered by default
  14706. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14707. * @param epsilon Offset used to render the particles
  14708. */
  14709. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14710. private _addFactorGradient;
  14711. private _removeFactorGradient;
  14712. /**
  14713. * Adds a new life time gradient
  14714. * @param gradient defines the gradient to use (between 0 and 1)
  14715. * @param factor defines the life time factor to affect to the specified gradient
  14716. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14717. * @returns the current particle system
  14718. */
  14719. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14720. /**
  14721. * Remove a specific life time gradient
  14722. * @param gradient defines the gradient to remove
  14723. * @returns the current particle system
  14724. */
  14725. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14726. /**
  14727. * Adds a new size gradient
  14728. * @param gradient defines the gradient to use (between 0 and 1)
  14729. * @param factor defines the size factor to affect to the specified gradient
  14730. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14731. * @returns the current particle system
  14732. */
  14733. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14734. /**
  14735. * Remove a specific size gradient
  14736. * @param gradient defines the gradient to remove
  14737. * @returns the current particle system
  14738. */
  14739. removeSizeGradient(gradient: number): IParticleSystem;
  14740. /**
  14741. * Adds a new color remap gradient
  14742. * @param gradient defines the gradient to use (between 0 and 1)
  14743. * @param min defines the color remap minimal range
  14744. * @param max defines the color remap maximal range
  14745. * @returns the current particle system
  14746. */
  14747. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14748. /**
  14749. * Remove a specific color remap gradient
  14750. * @param gradient defines the gradient to remove
  14751. * @returns the current particle system
  14752. */
  14753. removeColorRemapGradient(gradient: number): IParticleSystem;
  14754. /**
  14755. * Adds a new alpha remap gradient
  14756. * @param gradient defines the gradient to use (between 0 and 1)
  14757. * @param min defines the alpha remap minimal range
  14758. * @param max defines the alpha remap maximal range
  14759. * @returns the current particle system
  14760. */
  14761. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14762. /**
  14763. * Remove a specific alpha remap gradient
  14764. * @param gradient defines the gradient to remove
  14765. * @returns the current particle system
  14766. */
  14767. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14768. /**
  14769. * Adds a new angular speed gradient
  14770. * @param gradient defines the gradient to use (between 0 and 1)
  14771. * @param factor defines the angular speed to affect to the specified gradient
  14772. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14773. * @returns the current particle system
  14774. */
  14775. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14776. /**
  14777. * Remove a specific angular speed gradient
  14778. * @param gradient defines the gradient to remove
  14779. * @returns the current particle system
  14780. */
  14781. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14782. /**
  14783. * Adds a new velocity gradient
  14784. * @param gradient defines the gradient to use (between 0 and 1)
  14785. * @param factor defines the velocity to affect to the specified gradient
  14786. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14787. * @returns the current particle system
  14788. */
  14789. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14790. /**
  14791. * Remove a specific velocity gradient
  14792. * @param gradient defines the gradient to remove
  14793. * @returns the current particle system
  14794. */
  14795. removeVelocityGradient(gradient: number): IParticleSystem;
  14796. /**
  14797. * Adds a new limit velocity gradient
  14798. * @param gradient defines the gradient to use (between 0 and 1)
  14799. * @param factor defines the limit velocity value to affect to the specified gradient
  14800. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14801. * @returns the current particle system
  14802. */
  14803. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14804. /**
  14805. * Remove a specific limit velocity gradient
  14806. * @param gradient defines the gradient to remove
  14807. * @returns the current particle system
  14808. */
  14809. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14810. /**
  14811. * Adds a new drag gradient
  14812. * @param gradient defines the gradient to use (between 0 and 1)
  14813. * @param factor defines the drag value to affect to the specified gradient
  14814. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14815. * @returns the current particle system
  14816. */
  14817. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14818. /**
  14819. * Remove a specific drag gradient
  14820. * @param gradient defines the gradient to remove
  14821. * @returns the current particle system
  14822. */
  14823. removeDragGradient(gradient: number): IParticleSystem;
  14824. /**
  14825. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14826. * @param gradient defines the gradient to use (between 0 and 1)
  14827. * @param factor defines the emit rate value to affect to the specified gradient
  14828. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14829. * @returns the current particle system
  14830. */
  14831. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14832. /**
  14833. * Remove a specific emit rate gradient
  14834. * @param gradient defines the gradient to remove
  14835. * @returns the current particle system
  14836. */
  14837. removeEmitRateGradient(gradient: number): IParticleSystem;
  14838. /**
  14839. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14840. * @param gradient defines the gradient to use (between 0 and 1)
  14841. * @param factor defines the start size value to affect to the specified gradient
  14842. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14843. * @returns the current particle system
  14844. */
  14845. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14846. /**
  14847. * Remove a specific start size gradient
  14848. * @param gradient defines the gradient to remove
  14849. * @returns the current particle system
  14850. */
  14851. removeStartSizeGradient(gradient: number): IParticleSystem;
  14852. private _createRampGradientTexture;
  14853. /**
  14854. * Gets the current list of ramp gradients.
  14855. * You must use addRampGradient and removeRampGradient to udpate this list
  14856. * @returns the list of ramp gradients
  14857. */
  14858. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14859. /**
  14860. * Adds a new ramp gradient used to remap particle colors
  14861. * @param gradient defines the gradient to use (between 0 and 1)
  14862. * @param color defines the color to affect to the specified gradient
  14863. * @returns the current particle system
  14864. */
  14865. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14866. /**
  14867. * Remove a specific ramp gradient
  14868. * @param gradient defines the gradient to remove
  14869. * @returns the current particle system
  14870. */
  14871. removeRampGradient(gradient: number): ParticleSystem;
  14872. /**
  14873. * Adds a new color gradient
  14874. * @param gradient defines the gradient to use (between 0 and 1)
  14875. * @param color1 defines the color to affect to the specified gradient
  14876. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14877. * @returns this particle system
  14878. */
  14879. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14880. /**
  14881. * Remove a specific color gradient
  14882. * @param gradient defines the gradient to remove
  14883. * @returns this particle system
  14884. */
  14885. removeColorGradient(gradient: number): IParticleSystem;
  14886. private _fetchR;
  14887. protected _reset(): void;
  14888. private _resetEffect;
  14889. private _createVertexBuffers;
  14890. private _createIndexBuffer;
  14891. /**
  14892. * Gets the maximum number of particles active at the same time.
  14893. * @returns The max number of active particles.
  14894. */
  14895. getCapacity(): number;
  14896. /**
  14897. * Gets whether there are still active particles in the system.
  14898. * @returns True if it is alive, otherwise false.
  14899. */
  14900. isAlive(): boolean;
  14901. /**
  14902. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14903. * @returns True if it has been started, otherwise false.
  14904. */
  14905. isStarted(): boolean;
  14906. private _prepareSubEmitterInternalArray;
  14907. /**
  14908. * Starts the particle system and begins to emit
  14909. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  14910. */
  14911. start(delay?: number): void;
  14912. /**
  14913. * Stops the particle system.
  14914. * @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.
  14915. */
  14916. stop(stopSubEmitters?: boolean): void;
  14917. /**
  14918. * Remove all active particles
  14919. */
  14920. reset(): void;
  14921. /**
  14922. * @hidden (for internal use only)
  14923. */ appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  14924. /**
  14925. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  14926. * Its lifetime will start back at 0.
  14927. */
  14928. recycleParticle: (particle: Particle) => void;
  14929. private _stopSubEmitters;
  14930. private _createParticle;
  14931. private _removeFromRoot;
  14932. private _emitFromParticle;
  14933. private _update;
  14934. /** @hidden */ private static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  14935. /** @hidden */ private static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  14936. /** @hidden */
  14937. private _getEffect;
  14938. /**
  14939. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  14940. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  14941. */
  14942. animate(preWarmOnly?: boolean): void;
  14943. private _appendParticleVertices;
  14944. /**
  14945. * Rebuilds the particle system.
  14946. */
  14947. rebuild(): void;
  14948. /**
  14949. * Is this system ready to be used/rendered
  14950. * @return true if the system is ready
  14951. */
  14952. isReady(): boolean;
  14953. private _render;
  14954. /**
  14955. * Renders the particle system in its current state.
  14956. * @returns the current number of particles
  14957. */
  14958. render(): number;
  14959. /**
  14960. * Disposes the particle system and free the associated resources
  14961. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14962. */
  14963. dispose(disposeTexture?: boolean): void;
  14964. /**
  14965. * Clones the particle system.
  14966. * @param name The name of the cloned object
  14967. * @param newEmitter The new emitter to use
  14968. * @returns the cloned particle system
  14969. */
  14970. clone(name: string, newEmitter: any): ParticleSystem;
  14971. /**
  14972. * Serializes the particle system to a JSON object.
  14973. * @returns the JSON object
  14974. */
  14975. serialize(): any;
  14976. /** @hidden */ private static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  14977. /** @hidden */ private static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  14978. /**
  14979. * Parses a JSON object to create a particle system.
  14980. * @param parsedParticleSystem The JSON object to parse
  14981. * @param scene The scene to create the particle system in
  14982. * @param rootUrl The root url to use to load external dependencies like texture
  14983. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  14984. * @returns the Parsed particle system
  14985. */
  14986. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  14987. }
  14988. }
  14989. declare module BABYLON {
  14990. /**
  14991. * A particle represents one of the element emitted by a particle system.
  14992. * This is mainly define by its coordinates, direction, velocity and age.
  14993. */
  14994. export class Particle {
  14995. /**
  14996. * The particle system the particle belongs to.
  14997. */
  14998. particleSystem: ParticleSystem;
  14999. private static _Count;
  15000. /**
  15001. * Unique ID of the particle
  15002. */
  15003. id: number;
  15004. /**
  15005. * The world position of the particle in the scene.
  15006. */
  15007. position: Vector3;
  15008. /**
  15009. * The world direction of the particle in the scene.
  15010. */
  15011. direction: Vector3;
  15012. /**
  15013. * The color of the particle.
  15014. */
  15015. color: Color4;
  15016. /**
  15017. * The color change of the particle per step.
  15018. */
  15019. colorStep: Color4;
  15020. /**
  15021. * Defines how long will the life of the particle be.
  15022. */
  15023. lifeTime: number;
  15024. /**
  15025. * The current age of the particle.
  15026. */
  15027. age: number;
  15028. /**
  15029. * The current size of the particle.
  15030. */
  15031. size: number;
  15032. /**
  15033. * The current scale of the particle.
  15034. */
  15035. scale: Vector2;
  15036. /**
  15037. * The current angle of the particle.
  15038. */
  15039. angle: number;
  15040. /**
  15041. * Defines how fast is the angle changing.
  15042. */
  15043. angularSpeed: number;
  15044. /**
  15045. * Defines the cell index used by the particle to be rendered from a sprite.
  15046. */
  15047. cellIndex: number;
  15048. /**
  15049. * The information required to support color remapping
  15050. */
  15051. remapData: Vector4;
  15052. /** @hidden */ randomCellOffset?: number;
  15053. /** @hidden */ initialDirection: Nullable<Vector3>;
  15054. /** @hidden */ attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15055. /** @hidden */ initialStartSpriteCellID: number;
  15056. /** @hidden */ initialEndSpriteCellID: number;
  15057. /** @hidden */ currentColorGradient: Nullable<ColorGradient>;
  15058. /** @hidden */ currentColor1: Color4;
  15059. /** @hidden */ currentColor2: Color4;
  15060. /** @hidden */ currentSizeGradient: Nullable<FactorGradient>;
  15061. /** @hidden */ currentSize1: number;
  15062. /** @hidden */ currentSize2: number;
  15063. /** @hidden */ currentAngularSpeedGradient: Nullable<FactorGradient>;
  15064. /** @hidden */ currentAngularSpeed1: number;
  15065. /** @hidden */ currentAngularSpeed2: number;
  15066. /** @hidden */ currentVelocityGradient: Nullable<FactorGradient>;
  15067. /** @hidden */ currentVelocity1: number;
  15068. /** @hidden */ currentVelocity2: number;
  15069. /** @hidden */ currentLimitVelocityGradient: Nullable<FactorGradient>;
  15070. /** @hidden */ currentLimitVelocity1: number;
  15071. /** @hidden */ currentLimitVelocity2: number;
  15072. /** @hidden */ currentDragGradient: Nullable<FactorGradient>;
  15073. /** @hidden */ currentDrag1: number;
  15074. /** @hidden */ currentDrag2: number;
  15075. /** @hidden */ randomNoiseCoordinates1: Vector3;
  15076. /** @hidden */ randomNoiseCoordinates2: Vector3;
  15077. /**
  15078. * Creates a new instance Particle
  15079. * @param particleSystem the particle system the particle belongs to
  15080. */
  15081. constructor(
  15082. /**
  15083. * The particle system the particle belongs to.
  15084. */
  15085. particleSystem: ParticleSystem);
  15086. private updateCellInfoFromSystem;
  15087. /**
  15088. * Defines how the sprite cell index is updated for the particle
  15089. */
  15090. updateCellIndex(): void;
  15091. /** @hidden */ inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15092. /** @hidden */ inheritParticleInfoToSubEmitters(): void;
  15093. /** @hidden */ reset(): void;
  15094. /**
  15095. * Copy the properties of particle to another one.
  15096. * @param other the particle to copy the information to.
  15097. */
  15098. copyTo(other: Particle): void;
  15099. }
  15100. }
  15101. declare module BABYLON {
  15102. /**
  15103. * Particle emitter represents a volume emitting particles.
  15104. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15105. */
  15106. export interface IParticleEmitterType {
  15107. /**
  15108. * Called by the particle System when the direction is computed for the created particle.
  15109. * @param worldMatrix is the world matrix of the particle system
  15110. * @param directionToUpdate is the direction vector to update with the result
  15111. * @param particle is the particle we are computed the direction for
  15112. */
  15113. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15114. /**
  15115. * Called by the particle System when the position is computed for the created particle.
  15116. * @param worldMatrix is the world matrix of the particle system
  15117. * @param positionToUpdate is the position vector to update with the result
  15118. * @param particle is the particle we are computed the position for
  15119. */
  15120. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15121. /**
  15122. * Clones the current emitter and returns a copy of it
  15123. * @returns the new emitter
  15124. */
  15125. clone(): IParticleEmitterType;
  15126. /**
  15127. * Called by the GPUParticleSystem to setup the update shader
  15128. * @param effect defines the update shader
  15129. */
  15130. applyToShader(effect: Effect): void;
  15131. /**
  15132. * Returns a string to use to update the GPU particles update shader
  15133. * @returns the effect defines string
  15134. */
  15135. getEffectDefines(): string;
  15136. /**
  15137. * Returns a string representing the class name
  15138. * @returns a string containing the class name
  15139. */
  15140. getClassName(): string;
  15141. /**
  15142. * Serializes the particle system to a JSON object.
  15143. * @returns the JSON object
  15144. */
  15145. serialize(): any;
  15146. /**
  15147. * Parse properties from a JSON object
  15148. * @param serializationObject defines the JSON object
  15149. */
  15150. parse(serializationObject: any): void;
  15151. }
  15152. }
  15153. declare module BABYLON {
  15154. /**
  15155. * Particle emitter emitting particles from the inside of a box.
  15156. * It emits the particles randomly between 2 given directions.
  15157. */
  15158. export class BoxParticleEmitter implements IParticleEmitterType {
  15159. /**
  15160. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15161. */
  15162. direction1: Vector3;
  15163. /**
  15164. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15165. */
  15166. direction2: Vector3;
  15167. /**
  15168. * 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.
  15169. */
  15170. minEmitBox: Vector3;
  15171. /**
  15172. * 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.
  15173. */
  15174. maxEmitBox: Vector3;
  15175. /**
  15176. * Creates a new instance BoxParticleEmitter
  15177. */
  15178. constructor();
  15179. /**
  15180. * Called by the particle System when the direction is computed for the created particle.
  15181. * @param worldMatrix is the world matrix of the particle system
  15182. * @param directionToUpdate is the direction vector to update with the result
  15183. * @param particle is the particle we are computed the direction for
  15184. */
  15185. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15186. /**
  15187. * Called by the particle System when the position is computed for the created particle.
  15188. * @param worldMatrix is the world matrix of the particle system
  15189. * @param positionToUpdate is the position vector to update with the result
  15190. * @param particle is the particle we are computed the position for
  15191. */
  15192. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15193. /**
  15194. * Clones the current emitter and returns a copy of it
  15195. * @returns the new emitter
  15196. */
  15197. clone(): BoxParticleEmitter;
  15198. /**
  15199. * Called by the GPUParticleSystem to setup the update shader
  15200. * @param effect defines the update shader
  15201. */
  15202. applyToShader(effect: Effect): void;
  15203. /**
  15204. * Returns a string to use to update the GPU particles update shader
  15205. * @returns a string containng the defines string
  15206. */
  15207. getEffectDefines(): string;
  15208. /**
  15209. * Returns the string "BoxParticleEmitter"
  15210. * @returns a string containing the class name
  15211. */
  15212. getClassName(): string;
  15213. /**
  15214. * Serializes the particle system to a JSON object.
  15215. * @returns the JSON object
  15216. */
  15217. serialize(): any;
  15218. /**
  15219. * Parse properties from a JSON object
  15220. * @param serializationObject defines the JSON object
  15221. */
  15222. parse(serializationObject: any): void;
  15223. }
  15224. }
  15225. declare module BABYLON {
  15226. /**
  15227. * Particle emitter emitting particles from the inside of a cone.
  15228. * It emits the particles alongside the cone volume from the base to the particle.
  15229. * The emission direction might be randomized.
  15230. */
  15231. export class ConeParticleEmitter implements IParticleEmitterType {
  15232. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15233. directionRandomizer: number;
  15234. private _radius;
  15235. private _angle;
  15236. private _height;
  15237. /**
  15238. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15239. */
  15240. radiusRange: number;
  15241. /**
  15242. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15243. */
  15244. heightRange: number;
  15245. /**
  15246. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15247. */
  15248. emitFromSpawnPointOnly: boolean;
  15249. /**
  15250. * Gets or sets the radius of the emission cone
  15251. */
  15252. radius: number;
  15253. /**
  15254. * Gets or sets the angle of the emission cone
  15255. */
  15256. angle: number;
  15257. private _buildHeight;
  15258. /**
  15259. * Creates a new instance ConeParticleEmitter
  15260. * @param radius the radius of the emission cone (1 by default)
  15261. * @param angle the cone base angle (PI by default)
  15262. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15263. */
  15264. constructor(radius?: number, angle?: number,
  15265. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15266. directionRandomizer?: number);
  15267. /**
  15268. * Called by the particle System when the direction is computed for the created particle.
  15269. * @param worldMatrix is the world matrix of the particle system
  15270. * @param directionToUpdate is the direction vector to update with the result
  15271. * @param particle is the particle we are computed the direction for
  15272. */
  15273. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15274. /**
  15275. * Called by the particle System when the position is computed for the created particle.
  15276. * @param worldMatrix is the world matrix of the particle system
  15277. * @param positionToUpdate is the position vector to update with the result
  15278. * @param particle is the particle we are computed the position for
  15279. */
  15280. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15281. /**
  15282. * Clones the current emitter and returns a copy of it
  15283. * @returns the new emitter
  15284. */
  15285. clone(): ConeParticleEmitter;
  15286. /**
  15287. * Called by the GPUParticleSystem to setup the update shader
  15288. * @param effect defines the update shader
  15289. */
  15290. applyToShader(effect: Effect): void;
  15291. /**
  15292. * Returns a string to use to update the GPU particles update shader
  15293. * @returns a string containng the defines string
  15294. */
  15295. getEffectDefines(): string;
  15296. /**
  15297. * Returns the string "ConeParticleEmitter"
  15298. * @returns a string containing the class name
  15299. */
  15300. getClassName(): string;
  15301. /**
  15302. * Serializes the particle system to a JSON object.
  15303. * @returns the JSON object
  15304. */
  15305. serialize(): any;
  15306. /**
  15307. * Parse properties from a JSON object
  15308. * @param serializationObject defines the JSON object
  15309. */
  15310. parse(serializationObject: any): void;
  15311. }
  15312. }
  15313. declare module BABYLON {
  15314. /**
  15315. * Particle emitter emitting particles from the inside of a cylinder.
  15316. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15317. */
  15318. export class CylinderParticleEmitter implements IParticleEmitterType {
  15319. /**
  15320. * The radius of the emission cylinder.
  15321. */
  15322. radius: number;
  15323. /**
  15324. * The height of the emission cylinder.
  15325. */
  15326. height: number;
  15327. /**
  15328. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15329. */
  15330. radiusRange: number;
  15331. /**
  15332. * How much to randomize the particle direction [0-1].
  15333. */
  15334. directionRandomizer: number;
  15335. /**
  15336. * Creates a new instance CylinderParticleEmitter
  15337. * @param radius the radius of the emission cylinder (1 by default)
  15338. * @param height the height of the emission cylinder (1 by default)
  15339. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15340. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15341. */
  15342. constructor(
  15343. /**
  15344. * The radius of the emission cylinder.
  15345. */
  15346. radius?: number,
  15347. /**
  15348. * The height of the emission cylinder.
  15349. */
  15350. height?: number,
  15351. /**
  15352. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15353. */
  15354. radiusRange?: number,
  15355. /**
  15356. * How much to randomize the particle direction [0-1].
  15357. */
  15358. directionRandomizer?: number);
  15359. /**
  15360. * Called by the particle System when the direction is computed for the created particle.
  15361. * @param worldMatrix is the world matrix of the particle system
  15362. * @param directionToUpdate is the direction vector to update with the result
  15363. * @param particle is the particle we are computed the direction for
  15364. */
  15365. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15366. /**
  15367. * Called by the particle System when the position is computed for the created particle.
  15368. * @param worldMatrix is the world matrix of the particle system
  15369. * @param positionToUpdate is the position vector to update with the result
  15370. * @param particle is the particle we are computed the position for
  15371. */
  15372. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15373. /**
  15374. * Clones the current emitter and returns a copy of it
  15375. * @returns the new emitter
  15376. */
  15377. clone(): CylinderParticleEmitter;
  15378. /**
  15379. * Called by the GPUParticleSystem to setup the update shader
  15380. * @param effect defines the update shader
  15381. */
  15382. applyToShader(effect: Effect): void;
  15383. /**
  15384. * Returns a string to use to update the GPU particles update shader
  15385. * @returns a string containng the defines string
  15386. */
  15387. getEffectDefines(): string;
  15388. /**
  15389. * Returns the string "CylinderParticleEmitter"
  15390. * @returns a string containing the class name
  15391. */
  15392. getClassName(): string;
  15393. /**
  15394. * Serializes the particle system to a JSON object.
  15395. * @returns the JSON object
  15396. */
  15397. serialize(): any;
  15398. /**
  15399. * Parse properties from a JSON object
  15400. * @param serializationObject defines the JSON object
  15401. */
  15402. parse(serializationObject: any): void;
  15403. }
  15404. /**
  15405. * Particle emitter emitting particles from the inside of a cylinder.
  15406. * It emits the particles randomly between two vectors.
  15407. */
  15408. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15409. /**
  15410. * The min limit of the emission direction.
  15411. */
  15412. direction1: Vector3;
  15413. /**
  15414. * The max limit of the emission direction.
  15415. */
  15416. direction2: Vector3;
  15417. /**
  15418. * Creates a new instance CylinderDirectedParticleEmitter
  15419. * @param radius the radius of the emission cylinder (1 by default)
  15420. * @param height the height of the emission cylinder (1 by default)
  15421. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15422. * @param direction1 the min limit of the emission direction (up vector by default)
  15423. * @param direction2 the max limit of the emission direction (up vector by default)
  15424. */
  15425. constructor(radius?: number, height?: number, radiusRange?: number,
  15426. /**
  15427. * The min limit of the emission direction.
  15428. */
  15429. direction1?: Vector3,
  15430. /**
  15431. * The max limit of the emission direction.
  15432. */
  15433. direction2?: Vector3);
  15434. /**
  15435. * Called by the particle System when the direction is computed for the created particle.
  15436. * @param worldMatrix is the world matrix of the particle system
  15437. * @param directionToUpdate is the direction vector to update with the result
  15438. * @param particle is the particle we are computed the direction for
  15439. */
  15440. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15441. /**
  15442. * Clones the current emitter and returns a copy of it
  15443. * @returns the new emitter
  15444. */
  15445. clone(): CylinderDirectedParticleEmitter;
  15446. /**
  15447. * Called by the GPUParticleSystem to setup the update shader
  15448. * @param effect defines the update shader
  15449. */
  15450. applyToShader(effect: Effect): void;
  15451. /**
  15452. * Returns a string to use to update the GPU particles update shader
  15453. * @returns a string containng the defines string
  15454. */
  15455. getEffectDefines(): string;
  15456. /**
  15457. * Returns the string "CylinderDirectedParticleEmitter"
  15458. * @returns a string containing the class name
  15459. */
  15460. getClassName(): string;
  15461. /**
  15462. * Serializes the particle system to a JSON object.
  15463. * @returns the JSON object
  15464. */
  15465. serialize(): any;
  15466. /**
  15467. * Parse properties from a JSON object
  15468. * @param serializationObject defines the JSON object
  15469. */
  15470. parse(serializationObject: any): void;
  15471. }
  15472. }
  15473. declare module BABYLON {
  15474. /**
  15475. * Particle emitter emitting particles from the inside of a hemisphere.
  15476. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15477. */
  15478. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15479. /**
  15480. * The radius of the emission hemisphere.
  15481. */
  15482. radius: number;
  15483. /**
  15484. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15485. */
  15486. radiusRange: number;
  15487. /**
  15488. * How much to randomize the particle direction [0-1].
  15489. */
  15490. directionRandomizer: number;
  15491. /**
  15492. * Creates a new instance HemisphericParticleEmitter
  15493. * @param radius the radius of the emission hemisphere (1 by default)
  15494. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15495. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15496. */
  15497. constructor(
  15498. /**
  15499. * The radius of the emission hemisphere.
  15500. */
  15501. radius?: number,
  15502. /**
  15503. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15504. */
  15505. radiusRange?: number,
  15506. /**
  15507. * How much to randomize the particle direction [0-1].
  15508. */
  15509. directionRandomizer?: number);
  15510. /**
  15511. * Called by the particle System when the direction is computed for the created particle.
  15512. * @param worldMatrix is the world matrix of the particle system
  15513. * @param directionToUpdate is the direction vector to update with the result
  15514. * @param particle is the particle we are computed the direction for
  15515. */
  15516. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15517. /**
  15518. * Called by the particle System when the position is computed for the created particle.
  15519. * @param worldMatrix is the world matrix of the particle system
  15520. * @param positionToUpdate is the position vector to update with the result
  15521. * @param particle is the particle we are computed the position for
  15522. */
  15523. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15524. /**
  15525. * Clones the current emitter and returns a copy of it
  15526. * @returns the new emitter
  15527. */
  15528. clone(): HemisphericParticleEmitter;
  15529. /**
  15530. * Called by the GPUParticleSystem to setup the update shader
  15531. * @param effect defines the update shader
  15532. */
  15533. applyToShader(effect: Effect): void;
  15534. /**
  15535. * Returns a string to use to update the GPU particles update shader
  15536. * @returns a string containng the defines string
  15537. */
  15538. getEffectDefines(): string;
  15539. /**
  15540. * Returns the string "HemisphericParticleEmitter"
  15541. * @returns a string containing the class name
  15542. */
  15543. getClassName(): string;
  15544. /**
  15545. * Serializes the particle system to a JSON object.
  15546. * @returns the JSON object
  15547. */
  15548. serialize(): any;
  15549. /**
  15550. * Parse properties from a JSON object
  15551. * @param serializationObject defines the JSON object
  15552. */
  15553. parse(serializationObject: any): void;
  15554. }
  15555. }
  15556. declare module BABYLON {
  15557. /**
  15558. * Particle emitter emitting particles from a point.
  15559. * It emits the particles randomly between 2 given directions.
  15560. */
  15561. export class PointParticleEmitter implements IParticleEmitterType {
  15562. /**
  15563. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15564. */
  15565. direction1: Vector3;
  15566. /**
  15567. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15568. */
  15569. direction2: Vector3;
  15570. /**
  15571. * Creates a new instance PointParticleEmitter
  15572. */
  15573. constructor();
  15574. /**
  15575. * Called by the particle System when the direction is computed for the created particle.
  15576. * @param worldMatrix is the world matrix of the particle system
  15577. * @param directionToUpdate is the direction vector to update with the result
  15578. * @param particle is the particle we are computed the direction for
  15579. */
  15580. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15581. /**
  15582. * Called by the particle System when the position is computed for the created particle.
  15583. * @param worldMatrix is the world matrix of the particle system
  15584. * @param positionToUpdate is the position vector to update with the result
  15585. * @param particle is the particle we are computed the position for
  15586. */
  15587. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15588. /**
  15589. * Clones the current emitter and returns a copy of it
  15590. * @returns the new emitter
  15591. */
  15592. clone(): PointParticleEmitter;
  15593. /**
  15594. * Called by the GPUParticleSystem to setup the update shader
  15595. * @param effect defines the update shader
  15596. */
  15597. applyToShader(effect: Effect): void;
  15598. /**
  15599. * Returns a string to use to update the GPU particles update shader
  15600. * @returns a string containng the defines string
  15601. */
  15602. getEffectDefines(): string;
  15603. /**
  15604. * Returns the string "PointParticleEmitter"
  15605. * @returns a string containing the class name
  15606. */
  15607. getClassName(): string;
  15608. /**
  15609. * Serializes the particle system to a JSON object.
  15610. * @returns the JSON object
  15611. */
  15612. serialize(): any;
  15613. /**
  15614. * Parse properties from a JSON object
  15615. * @param serializationObject defines the JSON object
  15616. */
  15617. parse(serializationObject: any): void;
  15618. }
  15619. }
  15620. declare module BABYLON {
  15621. /**
  15622. * Particle emitter emitting particles from the inside of a sphere.
  15623. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15624. */
  15625. export class SphereParticleEmitter implements IParticleEmitterType {
  15626. /**
  15627. * The radius of the emission sphere.
  15628. */
  15629. radius: number;
  15630. /**
  15631. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15632. */
  15633. radiusRange: number;
  15634. /**
  15635. * How much to randomize the particle direction [0-1].
  15636. */
  15637. directionRandomizer: number;
  15638. /**
  15639. * Creates a new instance SphereParticleEmitter
  15640. * @param radius the radius of the emission sphere (1 by default)
  15641. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15642. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15643. */
  15644. constructor(
  15645. /**
  15646. * The radius of the emission sphere.
  15647. */
  15648. radius?: number,
  15649. /**
  15650. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15651. */
  15652. radiusRange?: number,
  15653. /**
  15654. * How much to randomize the particle direction [0-1].
  15655. */
  15656. directionRandomizer?: number);
  15657. /**
  15658. * Called by the particle System when the direction is computed for the created particle.
  15659. * @param worldMatrix is the world matrix of the particle system
  15660. * @param directionToUpdate is the direction vector to update with the result
  15661. * @param particle is the particle we are computed the direction for
  15662. */
  15663. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15664. /**
  15665. * Called by the particle System when the position is computed for the created particle.
  15666. * @param worldMatrix is the world matrix of the particle system
  15667. * @param positionToUpdate is the position vector to update with the result
  15668. * @param particle is the particle we are computed the position for
  15669. */
  15670. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15671. /**
  15672. * Clones the current emitter and returns a copy of it
  15673. * @returns the new emitter
  15674. */
  15675. clone(): SphereParticleEmitter;
  15676. /**
  15677. * Called by the GPUParticleSystem to setup the update shader
  15678. * @param effect defines the update shader
  15679. */
  15680. applyToShader(effect: Effect): void;
  15681. /**
  15682. * Returns a string to use to update the GPU particles update shader
  15683. * @returns a string containng the defines string
  15684. */
  15685. getEffectDefines(): string;
  15686. /**
  15687. * Returns the string "SphereParticleEmitter"
  15688. * @returns a string containing the class name
  15689. */
  15690. getClassName(): string;
  15691. /**
  15692. * Serializes the particle system to a JSON object.
  15693. * @returns the JSON object
  15694. */
  15695. serialize(): any;
  15696. /**
  15697. * Parse properties from a JSON object
  15698. * @param serializationObject defines the JSON object
  15699. */
  15700. parse(serializationObject: any): void;
  15701. }
  15702. /**
  15703. * Particle emitter emitting particles from the inside of a sphere.
  15704. * It emits the particles randomly between two vectors.
  15705. */
  15706. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15707. /**
  15708. * The min limit of the emission direction.
  15709. */
  15710. direction1: Vector3;
  15711. /**
  15712. * The max limit of the emission direction.
  15713. */
  15714. direction2: Vector3;
  15715. /**
  15716. * Creates a new instance SphereDirectedParticleEmitter
  15717. * @param radius the radius of the emission sphere (1 by default)
  15718. * @param direction1 the min limit of the emission direction (up vector by default)
  15719. * @param direction2 the max limit of the emission direction (up vector by default)
  15720. */
  15721. constructor(radius?: number,
  15722. /**
  15723. * The min limit of the emission direction.
  15724. */
  15725. direction1?: Vector3,
  15726. /**
  15727. * The max limit of the emission direction.
  15728. */
  15729. direction2?: Vector3);
  15730. /**
  15731. * Called by the particle System when the direction is computed for the created particle.
  15732. * @param worldMatrix is the world matrix of the particle system
  15733. * @param directionToUpdate is the direction vector to update with the result
  15734. * @param particle is the particle we are computed the direction for
  15735. */
  15736. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15737. /**
  15738. * Clones the current emitter and returns a copy of it
  15739. * @returns the new emitter
  15740. */
  15741. clone(): SphereDirectedParticleEmitter;
  15742. /**
  15743. * Called by the GPUParticleSystem to setup the update shader
  15744. * @param effect defines the update shader
  15745. */
  15746. applyToShader(effect: Effect): void;
  15747. /**
  15748. * Returns a string to use to update the GPU particles update shader
  15749. * @returns a string containng the defines string
  15750. */
  15751. getEffectDefines(): string;
  15752. /**
  15753. * Returns the string "SphereDirectedParticleEmitter"
  15754. * @returns a string containing the class name
  15755. */
  15756. getClassName(): string;
  15757. /**
  15758. * Serializes the particle system to a JSON object.
  15759. * @returns the JSON object
  15760. */
  15761. serialize(): any;
  15762. /**
  15763. * Parse properties from a JSON object
  15764. * @param serializationObject defines the JSON object
  15765. */
  15766. parse(serializationObject: any): void;
  15767. }
  15768. }
  15769. declare module BABYLON {
  15770. /**
  15771. * Interface representing a particle system in Babylon.js.
  15772. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15773. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15774. */
  15775. export interface IParticleSystem {
  15776. /**
  15777. * List of animations used by the particle system.
  15778. */
  15779. animations: Animation[];
  15780. /**
  15781. * The id of the Particle system.
  15782. */
  15783. id: string;
  15784. /**
  15785. * The name of the Particle system.
  15786. */
  15787. name: string;
  15788. /**
  15789. * The emitter represents the Mesh or position we are attaching the particle system to.
  15790. */
  15791. emitter: Nullable<AbstractMesh | Vector3>;
  15792. /**
  15793. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15794. */
  15795. isBillboardBased: boolean;
  15796. /**
  15797. * The rendering group used by the Particle system to chose when to render.
  15798. */
  15799. renderingGroupId: number;
  15800. /**
  15801. * The layer mask we are rendering the particles through.
  15802. */
  15803. layerMask: number;
  15804. /**
  15805. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15806. */
  15807. updateSpeed: number;
  15808. /**
  15809. * The amount of time the particle system is running (depends of the overall update speed).
  15810. */
  15811. targetStopDuration: number;
  15812. /**
  15813. * The texture used to render each particle. (this can be a spritesheet)
  15814. */
  15815. particleTexture: Nullable<Texture>;
  15816. /**
  15817. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  15818. */
  15819. blendMode: number;
  15820. /**
  15821. * Minimum life time of emitting particles.
  15822. */
  15823. minLifeTime: number;
  15824. /**
  15825. * Maximum life time of emitting particles.
  15826. */
  15827. maxLifeTime: number;
  15828. /**
  15829. * Minimum Size of emitting particles.
  15830. */
  15831. minSize: number;
  15832. /**
  15833. * Maximum Size of emitting particles.
  15834. */
  15835. maxSize: number;
  15836. /**
  15837. * Minimum scale of emitting particles on X axis.
  15838. */
  15839. minScaleX: number;
  15840. /**
  15841. * Maximum scale of emitting particles on X axis.
  15842. */
  15843. maxScaleX: number;
  15844. /**
  15845. * Minimum scale of emitting particles on Y axis.
  15846. */
  15847. minScaleY: number;
  15848. /**
  15849. * Maximum scale of emitting particles on Y axis.
  15850. */
  15851. maxScaleY: number;
  15852. /**
  15853. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15854. */
  15855. color1: Color4;
  15856. /**
  15857. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15858. */
  15859. color2: Color4;
  15860. /**
  15861. * Color the particle will have at the end of its lifetime.
  15862. */
  15863. colorDead: Color4;
  15864. /**
  15865. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  15866. */
  15867. emitRate: number;
  15868. /**
  15869. * You can use gravity if you want to give an orientation to your particles.
  15870. */
  15871. gravity: Vector3;
  15872. /**
  15873. * Minimum power of emitting particles.
  15874. */
  15875. minEmitPower: number;
  15876. /**
  15877. * Maximum power of emitting particles.
  15878. */
  15879. maxEmitPower: number;
  15880. /**
  15881. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15882. */
  15883. minAngularSpeed: number;
  15884. /**
  15885. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15886. */
  15887. maxAngularSpeed: number;
  15888. /**
  15889. * Gets or sets the minimal initial rotation in radians.
  15890. */
  15891. minInitialRotation: number;
  15892. /**
  15893. * Gets or sets the maximal initial rotation in radians.
  15894. */
  15895. maxInitialRotation: number;
  15896. /**
  15897. * The particle emitter type defines the emitter used by the particle system.
  15898. * It can be for example box, sphere, or cone...
  15899. */
  15900. particleEmitterType: Nullable<IParticleEmitterType>;
  15901. /**
  15902. * Defines the delay in milliseconds before starting the system (0 by default)
  15903. */
  15904. startDelay: number;
  15905. /**
  15906. * 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
  15907. */
  15908. preWarmCycles: number;
  15909. /**
  15910. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  15911. */
  15912. preWarmStepOffset: number;
  15913. /**
  15914. * 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)
  15915. */
  15916. spriteCellChangeSpeed: number;
  15917. /**
  15918. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15919. */
  15920. startSpriteCellID: number;
  15921. /**
  15922. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15923. */
  15924. endSpriteCellID: number;
  15925. /**
  15926. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15927. */
  15928. spriteCellWidth: number;
  15929. /**
  15930. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15931. */
  15932. spriteCellHeight: number;
  15933. /**
  15934. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15935. */
  15936. spriteRandomStartCell: boolean;
  15937. /**
  15938. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  15939. */
  15940. isAnimationSheetEnabled: boolean;
  15941. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15942. translationPivot: Vector2;
  15943. /**
  15944. * Gets or sets a texture used to add random noise to particle positions
  15945. */
  15946. noiseTexture: Nullable<BaseTexture>;
  15947. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15948. noiseStrength: Vector3;
  15949. /**
  15950. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15951. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15952. */
  15953. billboardMode: number;
  15954. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15955. limitVelocityDamping: number;
  15956. /**
  15957. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15958. */
  15959. beginAnimationOnStart: boolean;
  15960. /**
  15961. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15962. */
  15963. beginAnimationFrom: number;
  15964. /**
  15965. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15966. */
  15967. beginAnimationTo: number;
  15968. /**
  15969. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15970. */
  15971. beginAnimationLoop: boolean;
  15972. /**
  15973. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  15974. */
  15975. disposeOnStop: boolean;
  15976. /**
  15977. * Gets the maximum number of particles active at the same time.
  15978. * @returns The max number of active particles.
  15979. */
  15980. getCapacity(): number;
  15981. /**
  15982. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15983. * @returns True if it has been started, otherwise false.
  15984. */
  15985. isStarted(): boolean;
  15986. /**
  15987. * Animates the particle system for this frame.
  15988. */
  15989. animate(): void;
  15990. /**
  15991. * Renders the particle system in its current state.
  15992. * @returns the current number of particles
  15993. */
  15994. render(): number;
  15995. /**
  15996. * Dispose the particle system and frees its associated resources.
  15997. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15998. */
  15999. dispose(disposeTexture?: boolean): void;
  16000. /**
  16001. * Clones the particle system.
  16002. * @param name The name of the cloned object
  16003. * @param newEmitter The new emitter to use
  16004. * @returns the cloned particle system
  16005. */
  16006. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16007. /**
  16008. * Serializes the particle system to a JSON object.
  16009. * @returns the JSON object
  16010. */
  16011. serialize(): any;
  16012. /**
  16013. * Rebuild the particle system
  16014. */
  16015. rebuild(): void;
  16016. /**
  16017. * Starts the particle system and begins to emit
  16018. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16019. */
  16020. start(delay?: number): void;
  16021. /**
  16022. * Stops the particle system.
  16023. */
  16024. stop(): void;
  16025. /**
  16026. * Remove all active particles
  16027. */
  16028. reset(): void;
  16029. /**
  16030. * Is this system ready to be used/rendered
  16031. * @return true if the system is ready
  16032. */
  16033. isReady(): boolean;
  16034. /**
  16035. * Adds a new color gradient
  16036. * @param gradient defines the gradient to use (between 0 and 1)
  16037. * @param color1 defines the color to affect to the specified gradient
  16038. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16039. * @returns the current particle system
  16040. */
  16041. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16042. /**
  16043. * Remove a specific color gradient
  16044. * @param gradient defines the gradient to remove
  16045. * @returns the current particle system
  16046. */
  16047. removeColorGradient(gradient: number): IParticleSystem;
  16048. /**
  16049. * Adds a new size gradient
  16050. * @param gradient defines the gradient to use (between 0 and 1)
  16051. * @param factor defines the size factor to affect to the specified gradient
  16052. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16053. * @returns the current particle system
  16054. */
  16055. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16056. /**
  16057. * Remove a specific size gradient
  16058. * @param gradient defines the gradient to remove
  16059. * @returns the current particle system
  16060. */
  16061. removeSizeGradient(gradient: number): IParticleSystem;
  16062. /**
  16063. * Gets the current list of color gradients.
  16064. * You must use addColorGradient and removeColorGradient to udpate this list
  16065. * @returns the list of color gradients
  16066. */
  16067. getColorGradients(): Nullable<Array<ColorGradient>>;
  16068. /**
  16069. * Gets the current list of size gradients.
  16070. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16071. * @returns the list of size gradients
  16072. */
  16073. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16074. /**
  16075. * Gets the current list of angular speed gradients.
  16076. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16077. * @returns the list of angular speed gradients
  16078. */
  16079. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16080. /**
  16081. * Adds a new angular speed gradient
  16082. * @param gradient defines the gradient to use (between 0 and 1)
  16083. * @param factor defines the angular speed to affect to the specified gradient
  16084. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16085. * @returns the current particle system
  16086. */
  16087. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16088. /**
  16089. * Remove a specific angular speed gradient
  16090. * @param gradient defines the gradient to remove
  16091. * @returns the current particle system
  16092. */
  16093. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16094. /**
  16095. * Gets the current list of velocity gradients.
  16096. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16097. * @returns the list of velocity gradients
  16098. */
  16099. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16100. /**
  16101. * Adds a new velocity gradient
  16102. * @param gradient defines the gradient to use (between 0 and 1)
  16103. * @param factor defines the velocity to affect to the specified gradient
  16104. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16105. * @returns the current particle system
  16106. */
  16107. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16108. /**
  16109. * Remove a specific velocity gradient
  16110. * @param gradient defines the gradient to remove
  16111. * @returns the current particle system
  16112. */
  16113. removeVelocityGradient(gradient: number): IParticleSystem;
  16114. /**
  16115. * Gets the current list of limit velocity gradients.
  16116. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16117. * @returns the list of limit velocity gradients
  16118. */
  16119. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16120. /**
  16121. * Adds a new limit velocity gradient
  16122. * @param gradient defines the gradient to use (between 0 and 1)
  16123. * @param factor defines the limit velocity to affect to the specified gradient
  16124. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16125. * @returns the current particle system
  16126. */
  16127. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16128. /**
  16129. * Remove a specific limit velocity gradient
  16130. * @param gradient defines the gradient to remove
  16131. * @returns the current particle system
  16132. */
  16133. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16134. /**
  16135. * Adds a new drag gradient
  16136. * @param gradient defines the gradient to use (between 0 and 1)
  16137. * @param factor defines the drag to affect to the specified gradient
  16138. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16139. * @returns the current particle system
  16140. */
  16141. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16142. /**
  16143. * Remove a specific drag gradient
  16144. * @param gradient defines the gradient to remove
  16145. * @returns the current particle system
  16146. */
  16147. removeDragGradient(gradient: number): IParticleSystem;
  16148. /**
  16149. * Gets the current list of drag gradients.
  16150. * You must use addDragGradient and removeDragGradient to udpate this list
  16151. * @returns the list of drag gradients
  16152. */
  16153. getDragGradients(): Nullable<Array<FactorGradient>>;
  16154. /**
  16155. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16156. * @param gradient defines the gradient to use (between 0 and 1)
  16157. * @param factor defines the emit rate to affect to the specified gradient
  16158. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16159. * @returns the current particle system
  16160. */
  16161. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16162. /**
  16163. * Remove a specific emit rate gradient
  16164. * @param gradient defines the gradient to remove
  16165. * @returns the current particle system
  16166. */
  16167. removeEmitRateGradient(gradient: number): IParticleSystem;
  16168. /**
  16169. * Gets the current list of emit rate gradients.
  16170. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16171. * @returns the list of emit rate gradients
  16172. */
  16173. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16174. /**
  16175. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16176. * @param gradient defines the gradient to use (between 0 and 1)
  16177. * @param factor defines the start size to affect to the specified gradient
  16178. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16179. * @returns the current particle system
  16180. */
  16181. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16182. /**
  16183. * Remove a specific start size gradient
  16184. * @param gradient defines the gradient to remove
  16185. * @returns the current particle system
  16186. */
  16187. removeStartSizeGradient(gradient: number): IParticleSystem;
  16188. /**
  16189. * Gets the current list of start size gradients.
  16190. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16191. * @returns the list of start size gradients
  16192. */
  16193. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16194. /**
  16195. * Adds a new life time gradient
  16196. * @param gradient defines the gradient to use (between 0 and 1)
  16197. * @param factor defines the life time factor to affect to the specified gradient
  16198. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16199. * @returns the current particle system
  16200. */
  16201. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16202. /**
  16203. * Remove a specific life time gradient
  16204. * @param gradient defines the gradient to remove
  16205. * @returns the current particle system
  16206. */
  16207. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16208. /**
  16209. * Gets the current list of life time gradients.
  16210. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16211. * @returns the list of life time gradients
  16212. */
  16213. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16214. /**
  16215. * Gets the current list of color gradients.
  16216. * You must use addColorGradient and removeColorGradient to udpate this list
  16217. * @returns the list of color gradients
  16218. */
  16219. getColorGradients(): Nullable<Array<ColorGradient>>;
  16220. /**
  16221. * Adds a new ramp gradient used to remap particle colors
  16222. * @param gradient defines the gradient to use (between 0 and 1)
  16223. * @param color defines the color to affect to the specified gradient
  16224. * @returns the current particle system
  16225. */
  16226. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16227. /**
  16228. * Gets the current list of ramp gradients.
  16229. * You must use addRampGradient and removeRampGradient to udpate this list
  16230. * @returns the list of ramp gradients
  16231. */
  16232. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16233. /** Gets or sets a boolean indicating that ramp gradients must be used
  16234. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16235. */
  16236. useRampGradients: boolean;
  16237. /**
  16238. * Adds a new color remap gradient
  16239. * @param gradient defines the gradient to use (between 0 and 1)
  16240. * @param min defines the color remap minimal range
  16241. * @param max defines the color remap maximal range
  16242. * @returns the current particle system
  16243. */
  16244. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16245. /**
  16246. * Gets the current list of color remap gradients.
  16247. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16248. * @returns the list of color remap gradients
  16249. */
  16250. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16251. /**
  16252. * Adds a new alpha remap gradient
  16253. * @param gradient defines the gradient to use (between 0 and 1)
  16254. * @param min defines the alpha remap minimal range
  16255. * @param max defines the alpha remap maximal range
  16256. * @returns the current particle system
  16257. */
  16258. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16259. /**
  16260. * Gets the current list of alpha remap gradients.
  16261. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16262. * @returns the list of alpha remap gradients
  16263. */
  16264. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16265. /**
  16266. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16267. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16268. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16269. * @returns the emitter
  16270. */
  16271. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16272. /**
  16273. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16274. * @param radius The radius of the hemisphere to emit from
  16275. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16276. * @returns the emitter
  16277. */
  16278. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16279. /**
  16280. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16281. * @param radius The radius of the sphere to emit from
  16282. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16283. * @returns the emitter
  16284. */
  16285. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16286. /**
  16287. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16288. * @param radius The radius of the sphere to emit from
  16289. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16290. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16291. * @returns the emitter
  16292. */
  16293. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16294. /**
  16295. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16296. * @param radius The radius of the emission cylinder
  16297. * @param height The height of the emission cylinder
  16298. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16299. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16300. * @returns the emitter
  16301. */
  16302. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16303. /**
  16304. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16305. * @param radius The radius of the cylinder to emit from
  16306. * @param height The height of the emission cylinder
  16307. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16308. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16309. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16310. * @returns the emitter
  16311. */
  16312. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16313. /**
  16314. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16315. * @param radius The radius of the cone to emit from
  16316. * @param angle The base angle of the cone
  16317. * @returns the emitter
  16318. */
  16319. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16320. /**
  16321. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16322. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16323. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16324. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16325. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16326. * @returns the emitter
  16327. */
  16328. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16329. /**
  16330. * Get hosting scene
  16331. * @returns the scene
  16332. */
  16333. getScene(): Scene;
  16334. }
  16335. }
  16336. declare module BABYLON {
  16337. /** @hidden */
  16338. export var linePixelShader: {
  16339. name: string;
  16340. shader: string;
  16341. };
  16342. }
  16343. declare module BABYLON {
  16344. /** @hidden */
  16345. export var lineVertexShader: {
  16346. name: string;
  16347. shader: string;
  16348. };
  16349. }
  16350. declare module BABYLON {
  16351. interface AbstractMesh {
  16352. /**
  16353. * Disables the mesh edge rendering mode
  16354. * @returns the currentAbstractMesh
  16355. */
  16356. disableEdgesRendering(): AbstractMesh;
  16357. /**
  16358. * Enables the edge rendering mode on the mesh.
  16359. * This mode makes the mesh edges visible
  16360. * @param epsilon defines the maximal distance between two angles to detect a face
  16361. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16362. * @returns the currentAbstractMesh
  16363. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16364. */
  16365. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16366. /**
  16367. * Gets the edgesRenderer associated with the mesh
  16368. */
  16369. edgesRenderer: Nullable<EdgesRenderer>;
  16370. }
  16371. interface LinesMesh {
  16372. /**
  16373. * Enables the edge rendering mode on the mesh.
  16374. * This mode makes the mesh edges visible
  16375. * @param epsilon defines the maximal distance between two angles to detect a face
  16376. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16377. * @returns the currentAbstractMesh
  16378. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16379. */
  16380. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16381. }
  16382. interface InstancedLinesMesh {
  16383. /**
  16384. * Enables the edge rendering mode on the mesh.
  16385. * This mode makes the mesh edges visible
  16386. * @param epsilon defines the maximal distance between two angles to detect a face
  16387. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16388. * @returns the current InstancedLinesMesh
  16389. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16390. */
  16391. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16392. }
  16393. /**
  16394. * Defines the minimum contract an Edges renderer should follow.
  16395. */
  16396. export interface IEdgesRenderer extends IDisposable {
  16397. /**
  16398. * Gets or sets a boolean indicating if the edgesRenderer is active
  16399. */
  16400. isEnabled: boolean;
  16401. /**
  16402. * Renders the edges of the attached mesh,
  16403. */
  16404. render(): void;
  16405. /**
  16406. * Checks wether or not the edges renderer is ready to render.
  16407. * @return true if ready, otherwise false.
  16408. */
  16409. isReady(): boolean;
  16410. }
  16411. /**
  16412. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16413. */
  16414. export class EdgesRenderer implements IEdgesRenderer {
  16415. /**
  16416. * Define the size of the edges with an orthographic camera
  16417. */
  16418. edgesWidthScalerForOrthographic: number;
  16419. /**
  16420. * Define the size of the edges with a perspective camera
  16421. */
  16422. edgesWidthScalerForPerspective: number;
  16423. protected _source: AbstractMesh;
  16424. protected _linesPositions: number[];
  16425. protected _linesNormals: number[];
  16426. protected _linesIndices: number[];
  16427. protected _epsilon: number;
  16428. protected _indicesCount: number;
  16429. protected _lineShader: ShaderMaterial;
  16430. protected _ib: WebGLBuffer;
  16431. protected _buffers: {
  16432. [key: string]: Nullable<VertexBuffer>;
  16433. };
  16434. protected _checkVerticesInsteadOfIndices: boolean;
  16435. private _meshRebuildObserver;
  16436. private _meshDisposeObserver;
  16437. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16438. isEnabled: boolean;
  16439. /**
  16440. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16441. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16442. * @param source Mesh used to create edges
  16443. * @param epsilon sum of angles in adjacency to check for edge
  16444. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16445. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16446. */
  16447. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16448. protected _prepareRessources(): void;
  16449. /** @hidden */ rebuild(): void;
  16450. /**
  16451. * Releases the required resources for the edges renderer
  16452. */
  16453. dispose(): void;
  16454. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16455. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16456. /**
  16457. * Checks if the pair of p0 and p1 is en edge
  16458. * @param faceIndex
  16459. * @param edge
  16460. * @param faceNormals
  16461. * @param p0
  16462. * @param p1
  16463. * @private
  16464. */
  16465. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16466. /**
  16467. * push line into the position, normal and index buffer
  16468. * @protected
  16469. */
  16470. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16471. /**
  16472. * Generates lines edges from adjacencjes
  16473. * @private
  16474. */ generateEdgesLines(): void;
  16475. /**
  16476. * Checks wether or not the edges renderer is ready to render.
  16477. * @return true if ready, otherwise false.
  16478. */
  16479. isReady(): boolean;
  16480. /**
  16481. * Renders the edges of the attached mesh,
  16482. */
  16483. render(): void;
  16484. }
  16485. /**
  16486. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16487. */
  16488. export class LineEdgesRenderer extends EdgesRenderer {
  16489. /**
  16490. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16491. * @param source LineMesh used to generate edges
  16492. * @param epsilon not important (specified angle for edge detection)
  16493. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16494. */
  16495. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16496. /**
  16497. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16498. */ generateEdgesLines(): void;
  16499. }
  16500. }
  16501. declare module BABYLON {
  16502. /**
  16503. * This represents the object necessary to create a rendering group.
  16504. * This is exclusively used and created by the rendering manager.
  16505. * To modify the behavior, you use the available helpers in your scene or meshes.
  16506. * @hidden
  16507. */
  16508. export class RenderingGroup {
  16509. index: number;
  16510. private _scene;
  16511. private _opaqueSubMeshes;
  16512. private _transparentSubMeshes;
  16513. private _alphaTestSubMeshes;
  16514. private _depthOnlySubMeshes;
  16515. private _particleSystems;
  16516. private _spriteManagers;
  16517. private _opaqueSortCompareFn;
  16518. private _alphaTestSortCompareFn;
  16519. private _transparentSortCompareFn;
  16520. private _renderOpaque;
  16521. private _renderAlphaTest;
  16522. private _renderTransparent;
  16523. private _edgesRenderers;
  16524. onBeforeTransparentRendering: () => void;
  16525. /**
  16526. * Set the opaque sort comparison function.
  16527. * If null the sub meshes will be render in the order they were created
  16528. */
  16529. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16530. /**
  16531. * Set the alpha test sort comparison function.
  16532. * If null the sub meshes will be render in the order they were created
  16533. */
  16534. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16535. /**
  16536. * Set the transparent sort comparison function.
  16537. * If null the sub meshes will be render in the order they were created
  16538. */
  16539. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16540. /**
  16541. * Creates a new rendering group.
  16542. * @param index The rendering group index
  16543. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16544. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16545. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16546. */
  16547. 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>);
  16548. /**
  16549. * Render all the sub meshes contained in the group.
  16550. * @param customRenderFunction Used to override the default render behaviour of the group.
  16551. * @returns true if rendered some submeshes.
  16552. */
  16553. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16554. /**
  16555. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16556. * @param subMeshes The submeshes to render
  16557. */
  16558. private renderOpaqueSorted;
  16559. /**
  16560. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16561. * @param subMeshes The submeshes to render
  16562. */
  16563. private renderAlphaTestSorted;
  16564. /**
  16565. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16566. * @param subMeshes The submeshes to render
  16567. */
  16568. private renderTransparentSorted;
  16569. /**
  16570. * Renders the submeshes in a specified order.
  16571. * @param subMeshes The submeshes to sort before render
  16572. * @param sortCompareFn The comparison function use to sort
  16573. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16574. * @param transparent Specifies to activate blending if true
  16575. */
  16576. private static renderSorted;
  16577. /**
  16578. * Renders the submeshes in the order they were dispatched (no sort applied).
  16579. * @param subMeshes The submeshes to render
  16580. */
  16581. private static renderUnsorted;
  16582. /**
  16583. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16584. * are rendered back to front if in the same alpha index.
  16585. *
  16586. * @param a The first submesh
  16587. * @param b The second submesh
  16588. * @returns The result of the comparison
  16589. */
  16590. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16591. /**
  16592. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16593. * are rendered back to front.
  16594. *
  16595. * @param a The first submesh
  16596. * @param b The second submesh
  16597. * @returns The result of the comparison
  16598. */
  16599. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16600. /**
  16601. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16602. * are rendered front to back (prevent overdraw).
  16603. *
  16604. * @param a The first submesh
  16605. * @param b The second submesh
  16606. * @returns The result of the comparison
  16607. */
  16608. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16609. /**
  16610. * Resets the different lists of submeshes to prepare a new frame.
  16611. */
  16612. prepare(): void;
  16613. dispose(): void;
  16614. /**
  16615. * Inserts the submesh in its correct queue depending on its material.
  16616. * @param subMesh The submesh to dispatch
  16617. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16618. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16619. */
  16620. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16621. dispatchSprites(spriteManager: ISpriteManager): void;
  16622. dispatchParticles(particleSystem: IParticleSystem): void;
  16623. private _renderParticles;
  16624. private _renderSprites;
  16625. }
  16626. }
  16627. declare module BABYLON {
  16628. /**
  16629. * Interface describing the different options available in the rendering manager
  16630. * regarding Auto Clear between groups.
  16631. */
  16632. export interface IRenderingManagerAutoClearSetup {
  16633. /**
  16634. * Defines whether or not autoclear is enable.
  16635. */
  16636. autoClear: boolean;
  16637. /**
  16638. * Defines whether or not to autoclear the depth buffer.
  16639. */
  16640. depth: boolean;
  16641. /**
  16642. * Defines whether or not to autoclear the stencil buffer.
  16643. */
  16644. stencil: boolean;
  16645. }
  16646. /**
  16647. * This class is used by the onRenderingGroupObservable
  16648. */
  16649. export class RenderingGroupInfo {
  16650. /**
  16651. * The Scene that being rendered
  16652. */
  16653. scene: Scene;
  16654. /**
  16655. * The camera currently used for the rendering pass
  16656. */
  16657. camera: Nullable<Camera>;
  16658. /**
  16659. * The ID of the renderingGroup being processed
  16660. */
  16661. renderingGroupId: number;
  16662. }
  16663. /**
  16664. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16665. * It is enable to manage the different groups as well as the different necessary sort functions.
  16666. * This should not be used directly aside of the few static configurations
  16667. */
  16668. export class RenderingManager {
  16669. /**
  16670. * The max id used for rendering groups (not included)
  16671. */
  16672. static MAX_RENDERINGGROUPS: number;
  16673. /**
  16674. * The min id used for rendering groups (included)
  16675. */
  16676. static MIN_RENDERINGGROUPS: number;
  16677. /**
  16678. * Used to globally prevent autoclearing scenes.
  16679. */
  16680. static AUTOCLEAR: boolean;
  16681. /**
  16682. * @hidden
  16683. */ useSceneAutoClearSetup: boolean;
  16684. private _scene;
  16685. private _renderingGroups;
  16686. private _depthStencilBufferAlreadyCleaned;
  16687. private _autoClearDepthStencil;
  16688. private _customOpaqueSortCompareFn;
  16689. private _customAlphaTestSortCompareFn;
  16690. private _customTransparentSortCompareFn;
  16691. private _renderingGroupInfo;
  16692. /**
  16693. * Instantiates a new rendering group for a particular scene
  16694. * @param scene Defines the scene the groups belongs to
  16695. */
  16696. constructor(scene: Scene);
  16697. private _clearDepthStencilBuffer;
  16698. /**
  16699. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16700. * @hidden
  16701. */
  16702. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16703. /**
  16704. * Resets the different information of the group to prepare a new frame
  16705. * @hidden
  16706. */
  16707. reset(): void;
  16708. /**
  16709. * Dispose and release the group and its associated resources.
  16710. * @hidden
  16711. */
  16712. dispose(): void;
  16713. /**
  16714. * Clear the info related to rendering groups preventing retention points during dispose.
  16715. */
  16716. freeRenderingGroups(): void;
  16717. private _prepareRenderingGroup;
  16718. /**
  16719. * Add a sprite manager to the rendering manager in order to render it this frame.
  16720. * @param spriteManager Define the sprite manager to render
  16721. */
  16722. dispatchSprites(spriteManager: ISpriteManager): void;
  16723. /**
  16724. * Add a particle system to the rendering manager in order to render it this frame.
  16725. * @param particleSystem Define the particle system to render
  16726. */
  16727. dispatchParticles(particleSystem: IParticleSystem): void;
  16728. /**
  16729. * Add a submesh to the manager in order to render it this frame
  16730. * @param subMesh The submesh to dispatch
  16731. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16732. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16733. */
  16734. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16735. /**
  16736. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16737. * This allowed control for front to back rendering or reversly depending of the special needs.
  16738. *
  16739. * @param renderingGroupId The rendering group id corresponding to its index
  16740. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16741. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16742. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16743. */
  16744. 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;
  16745. /**
  16746. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16747. *
  16748. * @param renderingGroupId The rendering group id corresponding to its index
  16749. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16750. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16751. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16752. */
  16753. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16754. /**
  16755. * Gets the current auto clear configuration for one rendering group of the rendering
  16756. * manager.
  16757. * @param index the rendering group index to get the information for
  16758. * @returns The auto clear setup for the requested rendering group
  16759. */
  16760. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16761. }
  16762. }
  16763. declare module BABYLON {
  16764. /**
  16765. * This Helps creating a texture that will be created from a camera in your scene.
  16766. * It is basically a dynamic texture that could be used to create special effects for instance.
  16767. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  16768. */
  16769. export class RenderTargetTexture extends Texture {
  16770. isCube: boolean;
  16771. /**
  16772. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  16773. */
  16774. static readonly REFRESHRATE_RENDER_ONCE: number;
  16775. /**
  16776. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  16777. */
  16778. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  16779. /**
  16780. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  16781. * the central point of your effect and can save a lot of performances.
  16782. */
  16783. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  16784. /**
  16785. * Use this predicate to dynamically define the list of mesh you want to render.
  16786. * If set, the renderList property will be overwritten.
  16787. */
  16788. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  16789. private _renderList;
  16790. /**
  16791. * Use this list to define the list of mesh you want to render.
  16792. */
  16793. renderList: Nullable<Array<AbstractMesh>>;
  16794. private _hookArray;
  16795. /**
  16796. * Define if particles should be rendered in your texture.
  16797. */
  16798. renderParticles: boolean;
  16799. /**
  16800. * Define if sprites should be rendered in your texture.
  16801. */
  16802. renderSprites: boolean;
  16803. /**
  16804. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  16805. */
  16806. coordinatesMode: number;
  16807. /**
  16808. * Define the camera used to render the texture.
  16809. */
  16810. activeCamera: Nullable<Camera>;
  16811. /**
  16812. * Override the render function of the texture with your own one.
  16813. */
  16814. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  16815. /**
  16816. * Define if camera post processes should be use while rendering the texture.
  16817. */
  16818. useCameraPostProcesses: boolean;
  16819. /**
  16820. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  16821. */
  16822. ignoreCameraViewport: boolean;
  16823. private _postProcessManager;
  16824. private _postProcesses;
  16825. private _resizeObserver;
  16826. /**
  16827. * An event triggered when the texture is unbind.
  16828. */
  16829. onBeforeBindObservable: Observable<RenderTargetTexture>;
  16830. /**
  16831. * An event triggered when the texture is unbind.
  16832. */
  16833. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  16834. private _onAfterUnbindObserver;
  16835. /**
  16836. * Set a after unbind callback in the texture.
  16837. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  16838. */
  16839. onAfterUnbind: () => void;
  16840. /**
  16841. * An event triggered before rendering the texture
  16842. */
  16843. onBeforeRenderObservable: Observable<number>;
  16844. private _onBeforeRenderObserver;
  16845. /**
  16846. * Set a before render callback in the texture.
  16847. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  16848. */
  16849. onBeforeRender: (faceIndex: number) => void;
  16850. /**
  16851. * An event triggered after rendering the texture
  16852. */
  16853. onAfterRenderObservable: Observable<number>;
  16854. private _onAfterRenderObserver;
  16855. /**
  16856. * Set a after render callback in the texture.
  16857. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  16858. */
  16859. onAfterRender: (faceIndex: number) => void;
  16860. /**
  16861. * An event triggered after the texture clear
  16862. */
  16863. onClearObservable: Observable<Engine>;
  16864. private _onClearObserver;
  16865. /**
  16866. * Set a clear callback in the texture.
  16867. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  16868. */
  16869. onClear: (Engine: Engine) => void;
  16870. /**
  16871. * Define the clear color of the Render Target if it should be different from the scene.
  16872. */
  16873. clearColor: Color4;
  16874. protected _size: number | {
  16875. width: number;
  16876. height: number;
  16877. };
  16878. protected _initialSizeParameter: number | {
  16879. width: number;
  16880. height: number;
  16881. } | {
  16882. ratio: number;
  16883. };
  16884. protected _sizeRatio: Nullable<number>;
  16885. /** @hidden */ generateMipMaps: boolean;
  16886. protected _renderingManager: RenderingManager;
  16887. /** @hidden */ waitingRenderList: string[];
  16888. protected _doNotChangeAspectRatio: boolean;
  16889. protected _currentRefreshId: number;
  16890. protected _refreshRate: number;
  16891. protected _textureMatrix: Matrix;
  16892. protected _samples: number;
  16893. protected _renderTargetOptions: RenderTargetCreationOptions;
  16894. /**
  16895. * Gets render target creation options that were used.
  16896. */
  16897. readonly renderTargetOptions: RenderTargetCreationOptions;
  16898. protected _engine: Engine;
  16899. protected _onRatioRescale(): void;
  16900. /**
  16901. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  16902. * It must define where the camera used to render the texture is set
  16903. */
  16904. boundingBoxPosition: Vector3;
  16905. private _boundingBoxSize;
  16906. /**
  16907. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  16908. * When defined, the cubemap will switch to local mode
  16909. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  16910. * @example https://www.babylonjs-playground.com/#RNASML
  16911. */
  16912. boundingBoxSize: Vector3;
  16913. /**
  16914. * In case the RTT has been created with a depth texture, get the associated
  16915. * depth texture.
  16916. * Otherwise, return null.
  16917. */
  16918. depthStencilTexture: Nullable<InternalTexture>;
  16919. /**
  16920. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  16921. * or used a shadow, depth texture...
  16922. * @param name The friendly name of the texture
  16923. * @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)
  16924. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  16925. * @param generateMipMaps True if mip maps need to be generated after render.
  16926. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  16927. * @param type The type of the buffer in the RTT (int, half float, float...)
  16928. * @param isCube True if a cube texture needs to be created
  16929. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  16930. * @param generateDepthBuffer True to generate a depth buffer
  16931. * @param generateStencilBuffer True to generate a stencil buffer
  16932. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  16933. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  16934. * @param delayAllocation if the texture allocation should be delayed (default: false)
  16935. */
  16936. constructor(name: string, size: number | {
  16937. width: number;
  16938. height: number;
  16939. } | {
  16940. ratio: number;
  16941. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  16942. /**
  16943. * Creates a depth stencil texture.
  16944. * This is only available in WebGL 2 or with the depth texture extension available.
  16945. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  16946. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  16947. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  16948. */
  16949. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  16950. private _processSizeParameter;
  16951. /**
  16952. * Define the number of samples to use in case of MSAA.
  16953. * It defaults to one meaning no MSAA has been enabled.
  16954. */
  16955. samples: number;
  16956. /**
  16957. * Resets the refresh counter of the texture and start bak from scratch.
  16958. * Could be useful to regenerate the texture if it is setup to render only once.
  16959. */
  16960. resetRefreshCounter(): void;
  16961. /**
  16962. * Define the refresh rate of the texture or the rendering frequency.
  16963. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16964. */
  16965. refreshRate: number;
  16966. /**
  16967. * Adds a post process to the render target rendering passes.
  16968. * @param postProcess define the post process to add
  16969. */
  16970. addPostProcess(postProcess: PostProcess): void;
  16971. /**
  16972. * Clear all the post processes attached to the render target
  16973. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  16974. */
  16975. clearPostProcesses(dispose?: boolean): void;
  16976. /**
  16977. * Remove one of the post process from the list of attached post processes to the texture
  16978. * @param postProcess define the post process to remove from the list
  16979. */
  16980. removePostProcess(postProcess: PostProcess): void;
  16981. /** @hidden */ shouldRender(): boolean;
  16982. /**
  16983. * Gets the actual render size of the texture.
  16984. * @returns the width of the render size
  16985. */
  16986. getRenderSize(): number;
  16987. /**
  16988. * Gets the actual render width of the texture.
  16989. * @returns the width of the render size
  16990. */
  16991. getRenderWidth(): number;
  16992. /**
  16993. * Gets the actual render height of the texture.
  16994. * @returns the height of the render size
  16995. */
  16996. getRenderHeight(): number;
  16997. /**
  16998. * Get if the texture can be rescaled or not.
  16999. */
  17000. readonly canRescale: boolean;
  17001. /**
  17002. * Resize the texture using a ratio.
  17003. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17004. */
  17005. scale(ratio: number): void;
  17006. /**
  17007. * Get the texture reflection matrix used to rotate/transform the reflection.
  17008. * @returns the reflection matrix
  17009. */
  17010. getReflectionTextureMatrix(): Matrix;
  17011. /**
  17012. * Resize the texture to a new desired size.
  17013. * Be carrefull as it will recreate all the data in the new texture.
  17014. * @param size Define the new size. It can be:
  17015. * - a number for squared texture,
  17016. * - an object containing { width: number, height: number }
  17017. * - or an object containing a ratio { ratio: number }
  17018. */
  17019. resize(size: number | {
  17020. width: number;
  17021. height: number;
  17022. } | {
  17023. ratio: number;
  17024. }): void;
  17025. /**
  17026. * Renders all the objects from the render list into the texture.
  17027. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17028. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17029. */
  17030. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17031. private _bestReflectionRenderTargetDimension;
  17032. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17033. private renderToTarget;
  17034. /**
  17035. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17036. * This allowed control for front to back rendering or reversly depending of the special needs.
  17037. *
  17038. * @param renderingGroupId The rendering group id corresponding to its index
  17039. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17040. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17041. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17042. */
  17043. 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;
  17044. /**
  17045. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17046. *
  17047. * @param renderingGroupId The rendering group id corresponding to its index
  17048. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17049. */
  17050. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17051. /**
  17052. * Clones the texture.
  17053. * @returns the cloned texture
  17054. */
  17055. clone(): RenderTargetTexture;
  17056. /**
  17057. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17058. * @returns The JSON representation of the texture
  17059. */
  17060. serialize(): any;
  17061. /**
  17062. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17063. */
  17064. disposeFramebufferObjects(): void;
  17065. /**
  17066. * Dispose the texture and release its associated resources.
  17067. */
  17068. dispose(): void;
  17069. /** @hidden */ rebuild(): void;
  17070. /**
  17071. * Clear the info related to rendering groups preventing retention point in material dispose.
  17072. */
  17073. freeRenderingGroups(): void;
  17074. }
  17075. }
  17076. declare module BABYLON {
  17077. /**
  17078. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17079. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17080. * You can then easily use it as a reflectionTexture on a flat surface.
  17081. * In case the surface is not a plane, please consider relying on reflection probes.
  17082. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17083. */
  17084. export class MirrorTexture extends RenderTargetTexture {
  17085. private scene;
  17086. /**
  17087. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17088. * 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.
  17089. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17090. */
  17091. mirrorPlane: Plane;
  17092. /**
  17093. * Define the blur ratio used to blur the reflection if needed.
  17094. */
  17095. blurRatio: number;
  17096. /**
  17097. * Define the adaptive blur kernel used to blur the reflection if needed.
  17098. * This will autocompute the closest best match for the `blurKernel`
  17099. */
  17100. adaptiveBlurKernel: number;
  17101. /**
  17102. * Define the blur kernel used to blur the reflection if needed.
  17103. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17104. */
  17105. blurKernel: number;
  17106. /**
  17107. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17108. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17109. */
  17110. blurKernelX: number;
  17111. /**
  17112. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17113. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17114. */
  17115. blurKernelY: number;
  17116. private _autoComputeBlurKernel;
  17117. protected _onRatioRescale(): void;
  17118. private _updateGammaSpace;
  17119. private _imageProcessingConfigChangeObserver;
  17120. private _transformMatrix;
  17121. private _mirrorMatrix;
  17122. private _savedViewMatrix;
  17123. private _blurX;
  17124. private _blurY;
  17125. private _adaptiveBlurKernel;
  17126. private _blurKernelX;
  17127. private _blurKernelY;
  17128. private _blurRatio;
  17129. /**
  17130. * Instantiates a Mirror Texture.
  17131. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17132. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17133. * You can then easily use it as a reflectionTexture on a flat surface.
  17134. * In case the surface is not a plane, please consider relying on reflection probes.
  17135. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17136. * @param name
  17137. * @param size
  17138. * @param scene
  17139. * @param generateMipMaps
  17140. * @param type
  17141. * @param samplingMode
  17142. * @param generateDepthBuffer
  17143. */
  17144. constructor(name: string, size: number | {
  17145. width: number;
  17146. height: number;
  17147. } | {
  17148. ratio: number;
  17149. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17150. private _preparePostProcesses;
  17151. /**
  17152. * Clone the mirror texture.
  17153. * @returns the cloned texture
  17154. */
  17155. clone(): MirrorTexture;
  17156. /**
  17157. * Serialize the texture to a JSON representation you could use in Parse later on
  17158. * @returns the serialized JSON representation
  17159. */
  17160. serialize(): any;
  17161. /**
  17162. * Dispose the texture and release its associated resources.
  17163. */
  17164. dispose(): void;
  17165. }
  17166. }
  17167. declare module BABYLON {
  17168. /**
  17169. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17170. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17171. */
  17172. export class Texture extends BaseTexture {
  17173. /** @hidden */ private static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  17174. /** @hidden */ private static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  17175. /** @hidden */ private static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  17176. /** nearest is mag = nearest and min = nearest and mip = linear */
  17177. static readonly NEAREST_SAMPLINGMODE: number;
  17178. /** nearest is mag = nearest and min = nearest and mip = linear */
  17179. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  17180. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17181. static readonly BILINEAR_SAMPLINGMODE: number;
  17182. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17183. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  17184. /** Trilinear is mag = linear and min = linear and mip = linear */
  17185. static readonly TRILINEAR_SAMPLINGMODE: number;
  17186. /** Trilinear is mag = linear and min = linear and mip = linear */
  17187. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  17188. /** mag = nearest and min = nearest and mip = nearest */
  17189. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  17190. /** mag = nearest and min = linear and mip = nearest */
  17191. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  17192. /** mag = nearest and min = linear and mip = linear */
  17193. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  17194. /** mag = nearest and min = linear and mip = none */
  17195. static readonly NEAREST_LINEAR: number;
  17196. /** mag = nearest and min = nearest and mip = none */
  17197. static readonly NEAREST_NEAREST: number;
  17198. /** mag = linear and min = nearest and mip = nearest */
  17199. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  17200. /** mag = linear and min = nearest and mip = linear */
  17201. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  17202. /** mag = linear and min = linear and mip = none */
  17203. static readonly LINEAR_LINEAR: number;
  17204. /** mag = linear and min = nearest and mip = none */
  17205. static readonly LINEAR_NEAREST: number;
  17206. /** Explicit coordinates mode */
  17207. static readonly EXPLICIT_MODE: number;
  17208. /** Spherical coordinates mode */
  17209. static readonly SPHERICAL_MODE: number;
  17210. /** Planar coordinates mode */
  17211. static readonly PLANAR_MODE: number;
  17212. /** Cubic coordinates mode */
  17213. static readonly CUBIC_MODE: number;
  17214. /** Projection coordinates mode */
  17215. static readonly PROJECTION_MODE: number;
  17216. /** Inverse Cubic coordinates mode */
  17217. static readonly SKYBOX_MODE: number;
  17218. /** Inverse Cubic coordinates mode */
  17219. static readonly INVCUBIC_MODE: number;
  17220. /** Equirectangular coordinates mode */
  17221. static readonly EQUIRECTANGULAR_MODE: number;
  17222. /** Equirectangular Fixed coordinates mode */
  17223. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  17224. /** Equirectangular Fixed Mirrored coordinates mode */
  17225. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  17226. /** Texture is not repeating outside of 0..1 UVs */
  17227. static readonly CLAMP_ADDRESSMODE: number;
  17228. /** Texture is repeating outside of 0..1 UVs */
  17229. static readonly WRAP_ADDRESSMODE: number;
  17230. /** Texture is repeating and mirrored */
  17231. static readonly MIRROR_ADDRESSMODE: number;
  17232. /**
  17233. * 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
  17234. */
  17235. static UseSerializedUrlIfAny: boolean;
  17236. /**
  17237. * Define the url of the texture.
  17238. */
  17239. url: Nullable<string>;
  17240. /**
  17241. * Define an offset on the texture to offset the u coordinates of the UVs
  17242. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17243. */
  17244. uOffset: number;
  17245. /**
  17246. * Define an offset on the texture to offset the v coordinates of the UVs
  17247. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17248. */
  17249. vOffset: number;
  17250. /**
  17251. * Define an offset on the texture to scale the u coordinates of the UVs
  17252. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17253. */
  17254. uScale: number;
  17255. /**
  17256. * Define an offset on the texture to scale the v coordinates of the UVs
  17257. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17258. */
  17259. vScale: number;
  17260. /**
  17261. * Define an offset on the texture to rotate around the u coordinates of the UVs
  17262. * @see http://doc.babylonjs.com/how_to/more_materials
  17263. */
  17264. uAng: number;
  17265. /**
  17266. * Define an offset on the texture to rotate around the v coordinates of the UVs
  17267. * @see http://doc.babylonjs.com/how_to/more_materials
  17268. */
  17269. vAng: number;
  17270. /**
  17271. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  17272. * @see http://doc.babylonjs.com/how_to/more_materials
  17273. */
  17274. wAng: number;
  17275. /**
  17276. * Defines the center of rotation (U)
  17277. */
  17278. uRotationCenter: number;
  17279. /**
  17280. * Defines the center of rotation (V)
  17281. */
  17282. vRotationCenter: number;
  17283. /**
  17284. * Defines the center of rotation (W)
  17285. */
  17286. wRotationCenter: number;
  17287. /**
  17288. * Are mip maps generated for this texture or not.
  17289. */
  17290. readonly noMipmap: boolean;
  17291. private _noMipmap;
  17292. /** @hidden */ invertY: boolean;
  17293. private _rowGenerationMatrix;
  17294. private _cachedTextureMatrix;
  17295. private _projectionModeMatrix;
  17296. private _t0;
  17297. private _t1;
  17298. private _t2;
  17299. private _cachedUOffset;
  17300. private _cachedVOffset;
  17301. private _cachedUScale;
  17302. private _cachedVScale;
  17303. private _cachedUAng;
  17304. private _cachedVAng;
  17305. private _cachedWAng;
  17306. private _cachedProjectionMatrixId;
  17307. private _cachedCoordinatesMode;
  17308. /** @hidden */
  17309. protected _initialSamplingMode: number;
  17310. /** @hidden */ buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  17311. private _deleteBuffer;
  17312. protected _format: Nullable<number>;
  17313. private _delayedOnLoad;
  17314. private _delayedOnError;
  17315. /**
  17316. * Observable triggered once the texture has been loaded.
  17317. */
  17318. onLoadObservable: Observable<Texture>;
  17319. protected _isBlocking: boolean;
  17320. /**
  17321. * Is the texture preventing material to render while loading.
  17322. * If false, a default texture will be used instead of the loading one during the preparation step.
  17323. */
  17324. isBlocking: boolean;
  17325. /**
  17326. * Get the current sampling mode associated with the texture.
  17327. */
  17328. readonly samplingMode: number;
  17329. /**
  17330. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  17331. */
  17332. readonly invertY: boolean;
  17333. /**
  17334. * Instantiates a new texture.
  17335. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17336. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17337. * @param url define the url of the picture to load as a texture
  17338. * @param scene define the scene the texture will belong to
  17339. * @param noMipmap define if the texture will require mip maps or not
  17340. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17341. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17342. * @param onLoad define a callback triggered when the texture has been loaded
  17343. * @param onError define a callback triggered when an error occurred during the loading session
  17344. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  17345. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  17346. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17347. */
  17348. 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);
  17349. /**
  17350. * Update the url (and optional buffer) of this texture if url was null during construction.
  17351. * @param url the url of the texture
  17352. * @param buffer the buffer of the texture (defaults to null)
  17353. * @param onLoad callback called when the texture is loaded (defaults to null)
  17354. */
  17355. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  17356. /**
  17357. * Finish the loading sequence of a texture flagged as delayed load.
  17358. * @hidden
  17359. */
  17360. delayLoad(): void;
  17361. private _prepareRowForTextureGeneration;
  17362. /**
  17363. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  17364. * @returns the transform matrix of the texture.
  17365. */
  17366. getTextureMatrix(): Matrix;
  17367. /**
  17368. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  17369. * @returns The reflection texture transform
  17370. */
  17371. getReflectionTextureMatrix(): Matrix;
  17372. /**
  17373. * Clones the texture.
  17374. * @returns the cloned texture
  17375. */
  17376. clone(): Texture;
  17377. /**
  17378. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17379. * @returns The JSON representation of the texture
  17380. */
  17381. serialize(): any;
  17382. /**
  17383. * Get the current class name of the texture useful for serialization or dynamic coding.
  17384. * @returns "Texture"
  17385. */
  17386. getClassName(): string;
  17387. /**
  17388. * Dispose the texture and release its associated resources.
  17389. */
  17390. dispose(): void;
  17391. /**
  17392. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  17393. * @param parsedTexture Define the JSON representation of the texture
  17394. * @param scene Define the scene the parsed texture should be instantiated in
  17395. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  17396. * @returns The parsed texture if successful
  17397. */
  17398. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  17399. /**
  17400. * Creates a texture from its base 64 representation.
  17401. * @param data Define the base64 payload without the data: prefix
  17402. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  17403. * @param scene Define the scene the texture should belong to
  17404. * @param noMipmap Forces the texture to not create mip map information if true
  17405. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17406. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17407. * @param onLoad define a callback triggered when the texture has been loaded
  17408. * @param onError define a callback triggered when an error occurred during the loading session
  17409. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17410. * @returns the created texture
  17411. */
  17412. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  17413. /**
  17414. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  17415. * @param data Define the base64 payload without the data: prefix
  17416. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  17417. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  17418. * @param scene Define the scene the texture should belong to
  17419. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  17420. * @param noMipmap Forces the texture to not create mip map information if true
  17421. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17422. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17423. * @param onLoad define a callback triggered when the texture has been loaded
  17424. * @param onError define a callback triggered when an error occurred during the loading session
  17425. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17426. * @returns the created texture
  17427. */
  17428. 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;
  17429. }
  17430. }
  17431. declare module BABYLON {
  17432. /**
  17433. * Defines the options associated with the creation of a shader material.
  17434. */
  17435. export interface IShaderMaterialOptions {
  17436. /**
  17437. * Does the material work in alpha blend mode
  17438. */
  17439. needAlphaBlending: boolean;
  17440. /**
  17441. * Does the material work in alpha test mode
  17442. */
  17443. needAlphaTesting: boolean;
  17444. /**
  17445. * The list of attribute names used in the shader
  17446. */
  17447. attributes: string[];
  17448. /**
  17449. * The list of unifrom names used in the shader
  17450. */
  17451. uniforms: string[];
  17452. /**
  17453. * The list of UBO names used in the shader
  17454. */
  17455. uniformBuffers: string[];
  17456. /**
  17457. * The list of sampler names used in the shader
  17458. */
  17459. samplers: string[];
  17460. /**
  17461. * The list of defines used in the shader
  17462. */
  17463. defines: string[];
  17464. }
  17465. /**
  17466. * 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.
  17467. *
  17468. * This returned material effects how the mesh will look based on the code in the shaders.
  17469. *
  17470. * @see http://doc.babylonjs.com/how_to/shader_material
  17471. */
  17472. export class ShaderMaterial extends Material {
  17473. private _shaderPath;
  17474. private _options;
  17475. private _textures;
  17476. private _textureArrays;
  17477. private _floats;
  17478. private _ints;
  17479. private _floatsArrays;
  17480. private _colors3;
  17481. private _colors3Arrays;
  17482. private _colors4;
  17483. private _vectors2;
  17484. private _vectors3;
  17485. private _vectors4;
  17486. private _matrices;
  17487. private _matrices3x3;
  17488. private _matrices2x2;
  17489. private _vectors2Arrays;
  17490. private _vectors3Arrays;
  17491. private _cachedWorldViewMatrix;
  17492. private _renderId;
  17493. /**
  17494. * Instantiate a new shader material.
  17495. * 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.
  17496. * This returned material effects how the mesh will look based on the code in the shaders.
  17497. * @see http://doc.babylonjs.com/how_to/shader_material
  17498. * @param name Define the name of the material in the scene
  17499. * @param scene Define the scene the material belongs to
  17500. * @param shaderPath Defines the route to the shader code in one of three ways:
  17501. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17502. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17503. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17504. * @param options Define the options used to create the shader
  17505. */
  17506. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17507. /**
  17508. * Gets the current class name of the material e.g. "ShaderMaterial"
  17509. * Mainly use in serialization.
  17510. * @returns the class name
  17511. */
  17512. getClassName(): string;
  17513. /**
  17514. * Specifies if the material will require alpha blending
  17515. * @returns a boolean specifying if alpha blending is needed
  17516. */
  17517. needAlphaBlending(): boolean;
  17518. /**
  17519. * Specifies if this material should be rendered in alpha test mode
  17520. * @returns a boolean specifying if an alpha test is needed.
  17521. */
  17522. needAlphaTesting(): boolean;
  17523. private _checkUniform;
  17524. /**
  17525. * Set a texture in the shader.
  17526. * @param name Define the name of the uniform samplers as defined in the shader
  17527. * @param texture Define the texture to bind to this sampler
  17528. * @return the material itself allowing "fluent" like uniform updates
  17529. */
  17530. setTexture(name: string, texture: Texture): ShaderMaterial;
  17531. /**
  17532. * Set a texture array in the shader.
  17533. * @param name Define the name of the uniform sampler array as defined in the shader
  17534. * @param textures Define the list of textures to bind to this sampler
  17535. * @return the material itself allowing "fluent" like uniform updates
  17536. */
  17537. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17538. /**
  17539. * Set a float in the shader.
  17540. * @param name Define the name of the uniform as defined in the shader
  17541. * @param value Define the value to give to the uniform
  17542. * @return the material itself allowing "fluent" like uniform updates
  17543. */
  17544. setFloat(name: string, value: number): ShaderMaterial;
  17545. /**
  17546. * Set a int in the shader.
  17547. * @param name Define the name of the uniform as defined in the shader
  17548. * @param value Define the value to give to the uniform
  17549. * @return the material itself allowing "fluent" like uniform updates
  17550. */
  17551. setInt(name: string, value: number): ShaderMaterial;
  17552. /**
  17553. * Set an array of floats in the shader.
  17554. * @param name Define the name of the uniform as defined in the shader
  17555. * @param value Define the value to give to the uniform
  17556. * @return the material itself allowing "fluent" like uniform updates
  17557. */
  17558. setFloats(name: string, value: number[]): ShaderMaterial;
  17559. /**
  17560. * Set a vec3 in the shader from a Color3.
  17561. * @param name Define the name of the uniform as defined in the shader
  17562. * @param value Define the value to give to the uniform
  17563. * @return the material itself allowing "fluent" like uniform updates
  17564. */
  17565. setColor3(name: string, value: Color3): ShaderMaterial;
  17566. /**
  17567. * Set a vec3 array in the shader from a Color3 array.
  17568. * @param name Define the name of the uniform as defined in the shader
  17569. * @param value Define the value to give to the uniform
  17570. * @return the material itself allowing "fluent" like uniform updates
  17571. */
  17572. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17573. /**
  17574. * Set a vec4 in the shader from a Color4.
  17575. * @param name Define the name of the uniform as defined in the shader
  17576. * @param value Define the value to give to the uniform
  17577. * @return the material itself allowing "fluent" like uniform updates
  17578. */
  17579. setColor4(name: string, value: Color4): ShaderMaterial;
  17580. /**
  17581. * Set a vec2 in the shader from a Vector2.
  17582. * @param name Define the name of the uniform as defined in the shader
  17583. * @param value Define the value to give to the uniform
  17584. * @return the material itself allowing "fluent" like uniform updates
  17585. */
  17586. setVector2(name: string, value: Vector2): ShaderMaterial;
  17587. /**
  17588. * Set a vec3 in the shader from a Vector3.
  17589. * @param name Define the name of the uniform as defined in the shader
  17590. * @param value Define the value to give to the uniform
  17591. * @return the material itself allowing "fluent" like uniform updates
  17592. */
  17593. setVector3(name: string, value: Vector3): ShaderMaterial;
  17594. /**
  17595. * Set a vec4 in the shader from a Vector4.
  17596. * @param name Define the name of the uniform as defined in the shader
  17597. * @param value Define the value to give to the uniform
  17598. * @return the material itself allowing "fluent" like uniform updates
  17599. */
  17600. setVector4(name: string, value: Vector4): ShaderMaterial;
  17601. /**
  17602. * Set a mat4 in the shader from a Matrix.
  17603. * @param name Define the name of the uniform as defined in the shader
  17604. * @param value Define the value to give to the uniform
  17605. * @return the material itself allowing "fluent" like uniform updates
  17606. */
  17607. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17608. /**
  17609. * Set a mat3 in the shader from a Float32Array.
  17610. * @param name Define the name of the uniform as defined in the shader
  17611. * @param value Define the value to give to the uniform
  17612. * @return the material itself allowing "fluent" like uniform updates
  17613. */
  17614. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17615. /**
  17616. * Set a mat2 in the shader from a Float32Array.
  17617. * @param name Define the name of the uniform as defined in the shader
  17618. * @param value Define the value to give to the uniform
  17619. * @return the material itself allowing "fluent" like uniform updates
  17620. */
  17621. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17622. /**
  17623. * Set a vec2 array in the shader from a number array.
  17624. * @param name Define the name of the uniform as defined in the shader
  17625. * @param value Define the value to give to the uniform
  17626. * @return the material itself allowing "fluent" like uniform updates
  17627. */
  17628. setArray2(name: string, value: number[]): ShaderMaterial;
  17629. /**
  17630. * Set a vec3 array in the shader from a number array.
  17631. * @param name Define the name of the uniform as defined in the shader
  17632. * @param value Define the value to give to the uniform
  17633. * @return the material itself allowing "fluent" like uniform updates
  17634. */
  17635. setArray3(name: string, value: number[]): ShaderMaterial;
  17636. private _checkCache;
  17637. /**
  17638. * Checks if the material is ready to render the requested mesh
  17639. * @param mesh Define the mesh to render
  17640. * @param useInstances Define whether or not the material is used with instances
  17641. * @returns true if ready, otherwise false
  17642. */
  17643. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17644. /**
  17645. * Binds the world matrix to the material
  17646. * @param world defines the world transformation matrix
  17647. */
  17648. bindOnlyWorldMatrix(world: Matrix): void;
  17649. /**
  17650. * Binds the material to the mesh
  17651. * @param world defines the world transformation matrix
  17652. * @param mesh defines the mesh to bind the material to
  17653. */
  17654. bind(world: Matrix, mesh?: Mesh): void;
  17655. /**
  17656. * Gets the active textures from the material
  17657. * @returns an array of textures
  17658. */
  17659. getActiveTextures(): BaseTexture[];
  17660. /**
  17661. * Specifies if the material uses a texture
  17662. * @param texture defines the texture to check against the material
  17663. * @returns a boolean specifying if the material uses the texture
  17664. */
  17665. hasTexture(texture: BaseTexture): boolean;
  17666. /**
  17667. * Makes a duplicate of the material, and gives it a new name
  17668. * @param name defines the new name for the duplicated material
  17669. * @returns the cloned material
  17670. */
  17671. clone(name: string): ShaderMaterial;
  17672. /**
  17673. * Disposes the material
  17674. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17675. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17676. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17677. */
  17678. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17679. /**
  17680. * Serializes this material in a JSON representation
  17681. * @returns the serialized material object
  17682. */
  17683. serialize(): any;
  17684. /**
  17685. * Creates a shader material from parsed shader material data
  17686. * @param source defines the JSON represnetation of the material
  17687. * @param scene defines the hosting scene
  17688. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17689. * @returns a new material
  17690. */
  17691. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17692. }
  17693. }
  17694. declare module BABYLON {
  17695. /** @hidden */
  17696. export var colorPixelShader: {
  17697. name: string;
  17698. shader: string;
  17699. };
  17700. }
  17701. declare module BABYLON {
  17702. /** @hidden */
  17703. export var colorVertexShader: {
  17704. name: string;
  17705. shader: string;
  17706. };
  17707. }
  17708. declare module BABYLON {
  17709. /**
  17710. * Line mesh
  17711. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17712. */
  17713. export class LinesMesh extends Mesh {
  17714. /**
  17715. * If vertex color should be applied to the mesh
  17716. */
  17717. useVertexColor?: boolean | undefined;
  17718. /**
  17719. * If vertex alpha should be applied to the mesh
  17720. */
  17721. useVertexAlpha?: boolean | undefined;
  17722. /**
  17723. * Color of the line (Default: White)
  17724. */
  17725. color: Color3;
  17726. /**
  17727. * Alpha of the line (Default: 1)
  17728. */
  17729. alpha: number;
  17730. /**
  17731. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17732. * This margin is expressed in world space coordinates, so its value may vary.
  17733. * Default value is 0.1
  17734. */
  17735. intersectionThreshold: number;
  17736. private _colorShader;
  17737. /**
  17738. * Creates a new LinesMesh
  17739. * @param name defines the name
  17740. * @param scene defines the hosting scene
  17741. * @param parent defines the parent mesh if any
  17742. * @param source defines the optional source LinesMesh used to clone data from
  17743. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17744. * When false, achieved by calling a clone(), also passing False.
  17745. * This will make creation of children, recursive.
  17746. * @param useVertexColor defines if this LinesMesh supports vertex color
  17747. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17748. */
  17749. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17750. /**
  17751. * If vertex color should be applied to the mesh
  17752. */
  17753. useVertexColor?: boolean | undefined,
  17754. /**
  17755. * If vertex alpha should be applied to the mesh
  17756. */
  17757. useVertexAlpha?: boolean | undefined);
  17758. /**
  17759. * Returns the string "LineMesh"
  17760. */
  17761. getClassName(): string;
  17762. /**
  17763. * @hidden
  17764. */
  17765. /**
  17766. * @hidden
  17767. */
  17768. material: Material;
  17769. /**
  17770. * @hidden
  17771. */
  17772. readonly checkCollisions: boolean;
  17773. /** @hidden */ bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17774. /** @hidden */ draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17775. /**
  17776. * Disposes of the line mesh
  17777. * @param doNotRecurse If children should be disposed
  17778. */
  17779. dispose(doNotRecurse?: boolean): void;
  17780. /**
  17781. * Returns a new LineMesh object cloned from the current one.
  17782. */
  17783. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17784. /**
  17785. * Creates a new InstancedLinesMesh object from the mesh model.
  17786. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17787. * @param name defines the name of the new instance
  17788. * @returns a new InstancedLinesMesh
  17789. */
  17790. createInstance(name: string): InstancedLinesMesh;
  17791. }
  17792. /**
  17793. * Creates an instance based on a source LinesMesh
  17794. */
  17795. export class InstancedLinesMesh extends InstancedMesh {
  17796. /**
  17797. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17798. * This margin is expressed in world space coordinates, so its value may vary.
  17799. * Initilized with the intersectionThreshold value of the source LinesMesh
  17800. */
  17801. intersectionThreshold: number;
  17802. constructor(name: string, source: LinesMesh);
  17803. /**
  17804. * Returns the string "InstancedLinesMesh".
  17805. */
  17806. getClassName(): string;
  17807. }
  17808. }
  17809. declare module BABYLON {
  17810. /**
  17811. * Mesh representing the gorund
  17812. */
  17813. export class GroundMesh extends Mesh {
  17814. /** If octree should be generated */
  17815. generateOctree: boolean;
  17816. private _heightQuads;
  17817. /** @hidden */ subdivisionsX: number;
  17818. /** @hidden */ subdivisionsY: number;
  17819. /** @hidden */ width: number;
  17820. /** @hidden */ height: number;
  17821. /** @hidden */ minX: number;
  17822. /** @hidden */ maxX: number;
  17823. /** @hidden */ minZ: number;
  17824. /** @hidden */ maxZ: number;
  17825. constructor(name: string, scene: Scene);
  17826. /**
  17827. * "GroundMesh"
  17828. * @returns "GroundMesh"
  17829. */
  17830. getClassName(): string;
  17831. /**
  17832. * The minimum of x and y subdivisions
  17833. */
  17834. readonly subdivisions: number;
  17835. /**
  17836. * X subdivisions
  17837. */
  17838. readonly subdivisionsX: number;
  17839. /**
  17840. * Y subdivisions
  17841. */
  17842. readonly subdivisionsY: number;
  17843. /**
  17844. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  17845. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  17846. * @param chunksCount the number of subdivisions for x and y
  17847. * @param octreeBlocksSize (Default: 32)
  17848. */
  17849. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  17850. /**
  17851. * Returns a height (y) value in the Worl system :
  17852. * the ground altitude at the coordinates (x, z) expressed in the World system.
  17853. * @param x x coordinate
  17854. * @param z z coordinate
  17855. * @returns the ground y position if (x, z) are outside the ground surface.
  17856. */
  17857. getHeightAtCoordinates(x: number, z: number): number;
  17858. /**
  17859. * Returns a normalized vector (Vector3) orthogonal to the ground
  17860. * at the ground coordinates (x, z) expressed in the World system.
  17861. * @param x x coordinate
  17862. * @param z z coordinate
  17863. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  17864. */
  17865. getNormalAtCoordinates(x: number, z: number): Vector3;
  17866. /**
  17867. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  17868. * at the ground coordinates (x, z) expressed in the World system.
  17869. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  17870. * @param x x coordinate
  17871. * @param z z coordinate
  17872. * @param ref vector to store the result
  17873. * @returns the GroundMesh.
  17874. */
  17875. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  17876. /**
  17877. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  17878. * if the ground has been updated.
  17879. * This can be used in the render loop.
  17880. * @returns the GroundMesh.
  17881. */
  17882. updateCoordinateHeights(): GroundMesh;
  17883. private _getFacetAt;
  17884. private _initHeightQuads;
  17885. private _computeHeightQuads;
  17886. /**
  17887. * Serializes this ground mesh
  17888. * @param serializationObject object to write serialization to
  17889. */
  17890. serialize(serializationObject: any): void;
  17891. /**
  17892. * Parses a serialized ground mesh
  17893. * @param parsedMesh the serialized mesh
  17894. * @param scene the scene to create the ground mesh in
  17895. * @returns the created ground mesh
  17896. */
  17897. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  17898. }
  17899. }
  17900. declare module BABYLON {
  17901. /**
  17902. * Interface for Physics-Joint data
  17903. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  17904. */
  17905. export interface PhysicsJointData {
  17906. /**
  17907. * The main pivot of the joint
  17908. */
  17909. mainPivot?: Vector3;
  17910. /**
  17911. * The connected pivot of the joint
  17912. */
  17913. connectedPivot?: Vector3;
  17914. /**
  17915. * The main axis of the joint
  17916. */
  17917. mainAxis?: Vector3;
  17918. /**
  17919. * The connected axis of the joint
  17920. */
  17921. connectedAxis?: Vector3;
  17922. /**
  17923. * The collision of the joint
  17924. */
  17925. collision?: boolean;
  17926. /**
  17927. * Native Oimo/Cannon/Energy data
  17928. */
  17929. nativeParams?: any;
  17930. }
  17931. /**
  17932. * This is a holder class for the physics joint created by the physics plugin
  17933. * It holds a set of functions to control the underlying joint
  17934. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  17935. */
  17936. export class PhysicsJoint {
  17937. /**
  17938. * The type of the physics joint
  17939. */
  17940. type: number;
  17941. /**
  17942. * The data for the physics joint
  17943. */
  17944. jointData: PhysicsJointData;
  17945. private _physicsJoint;
  17946. protected _physicsPlugin: IPhysicsEnginePlugin;
  17947. /**
  17948. * Initializes the physics joint
  17949. * @param type The type of the physics joint
  17950. * @param jointData The data for the physics joint
  17951. */
  17952. constructor(
  17953. /**
  17954. * The type of the physics joint
  17955. */
  17956. type: number,
  17957. /**
  17958. * The data for the physics joint
  17959. */
  17960. jointData: PhysicsJointData);
  17961. /**
  17962. * Gets the physics joint
  17963. */
  17964. /**
  17965. * Sets the physics joint
  17966. */
  17967. physicsJoint: any;
  17968. /**
  17969. * Sets the physics plugin
  17970. */
  17971. physicsPlugin: IPhysicsEnginePlugin;
  17972. /**
  17973. * Execute a function that is physics-plugin specific.
  17974. * @param {Function} func the function that will be executed.
  17975. * It accepts two parameters: the physics world and the physics joint
  17976. */
  17977. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  17978. /**
  17979. * Distance-Joint type
  17980. */
  17981. static DistanceJoint: number;
  17982. /**
  17983. * Hinge-Joint type
  17984. */
  17985. static HingeJoint: number;
  17986. /**
  17987. * Ball-and-Socket joint type
  17988. */
  17989. static BallAndSocketJoint: number;
  17990. /**
  17991. * Wheel-Joint type
  17992. */
  17993. static WheelJoint: number;
  17994. /**
  17995. * Slider-Joint type
  17996. */
  17997. static SliderJoint: number;
  17998. /**
  17999. * Prismatic-Joint type
  18000. */
  18001. static PrismaticJoint: number;
  18002. /**
  18003. * Universal-Joint type
  18004. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  18005. */
  18006. static UniversalJoint: number;
  18007. /**
  18008. * Hinge-Joint 2 type
  18009. */
  18010. static Hinge2Joint: number;
  18011. /**
  18012. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  18013. */
  18014. static PointToPointJoint: number;
  18015. /**
  18016. * Spring-Joint type
  18017. */
  18018. static SpringJoint: number;
  18019. /**
  18020. * Lock-Joint type
  18021. */
  18022. static LockJoint: number;
  18023. }
  18024. /**
  18025. * A class representing a physics distance joint
  18026. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18027. */
  18028. export class DistanceJoint extends PhysicsJoint {
  18029. /**
  18030. *
  18031. * @param jointData The data for the Distance-Joint
  18032. */
  18033. constructor(jointData: DistanceJointData);
  18034. /**
  18035. * Update the predefined distance.
  18036. * @param maxDistance The maximum preferred distance
  18037. * @param minDistance The minimum preferred distance
  18038. */
  18039. updateDistance(maxDistance: number, minDistance?: number): void;
  18040. }
  18041. /**
  18042. * Represents a Motor-Enabled Joint
  18043. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18044. */
  18045. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  18046. /**
  18047. * Initializes the Motor-Enabled Joint
  18048. * @param type The type of the joint
  18049. * @param jointData The physica joint data for the joint
  18050. */
  18051. constructor(type: number, jointData: PhysicsJointData);
  18052. /**
  18053. * Set the motor values.
  18054. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18055. * @param force the force to apply
  18056. * @param maxForce max force for this motor.
  18057. */
  18058. setMotor(force?: number, maxForce?: number): void;
  18059. /**
  18060. * Set the motor's limits.
  18061. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18062. * @param upperLimit The upper limit of the motor
  18063. * @param lowerLimit The lower limit of the motor
  18064. */
  18065. setLimit(upperLimit: number, lowerLimit?: number): void;
  18066. }
  18067. /**
  18068. * This class represents a single physics Hinge-Joint
  18069. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18070. */
  18071. export class HingeJoint extends MotorEnabledJoint {
  18072. /**
  18073. * Initializes the Hinge-Joint
  18074. * @param jointData The joint data for the Hinge-Joint
  18075. */
  18076. constructor(jointData: PhysicsJointData);
  18077. /**
  18078. * Set the motor values.
  18079. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18080. * @param {number} force the force to apply
  18081. * @param {number} maxForce max force for this motor.
  18082. */
  18083. setMotor(force?: number, maxForce?: number): void;
  18084. /**
  18085. * Set the motor's limits.
  18086. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18087. * @param upperLimit The upper limit of the motor
  18088. * @param lowerLimit The lower limit of the motor
  18089. */
  18090. setLimit(upperLimit: number, lowerLimit?: number): void;
  18091. }
  18092. /**
  18093. * This class represents a dual hinge physics joint (same as wheel joint)
  18094. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18095. */
  18096. export class Hinge2Joint extends MotorEnabledJoint {
  18097. /**
  18098. * Initializes the Hinge2-Joint
  18099. * @param jointData The joint data for the Hinge2-Joint
  18100. */
  18101. constructor(jointData: PhysicsJointData);
  18102. /**
  18103. * Set the motor values.
  18104. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18105. * @param {number} force the force to apply
  18106. * @param {number} maxForce max force for this motor.
  18107. * @param {motorIndex} the motor's index, 0 or 1.
  18108. */
  18109. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  18110. /**
  18111. * Set the motor limits.
  18112. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18113. * @param {number} upperLimit the upper limit
  18114. * @param {number} lowerLimit lower limit
  18115. * @param {motorIndex} the motor's index, 0 or 1.
  18116. */
  18117. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18118. }
  18119. /**
  18120. * Interface for a motor enabled joint
  18121. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18122. */
  18123. export interface IMotorEnabledJoint {
  18124. /**
  18125. * Physics joint
  18126. */
  18127. physicsJoint: any;
  18128. /**
  18129. * Sets the motor of the motor-enabled joint
  18130. * @param force The force of the motor
  18131. * @param maxForce The maximum force of the motor
  18132. * @param motorIndex The index of the motor
  18133. */
  18134. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  18135. /**
  18136. * Sets the limit of the motor
  18137. * @param upperLimit The upper limit of the motor
  18138. * @param lowerLimit The lower limit of the motor
  18139. * @param motorIndex The index of the motor
  18140. */
  18141. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18142. }
  18143. /**
  18144. * Joint data for a Distance-Joint
  18145. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18146. */
  18147. export interface DistanceJointData extends PhysicsJointData {
  18148. /**
  18149. * Max distance the 2 joint objects can be apart
  18150. */
  18151. maxDistance: number;
  18152. }
  18153. /**
  18154. * Joint data from a spring joint
  18155. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18156. */
  18157. export interface SpringJointData extends PhysicsJointData {
  18158. /**
  18159. * Length of the spring
  18160. */
  18161. length: number;
  18162. /**
  18163. * Stiffness of the spring
  18164. */
  18165. stiffness: number;
  18166. /**
  18167. * Damping of the spring
  18168. */
  18169. damping: number;
  18170. /** this callback will be called when applying the force to the impostors. */
  18171. forceApplicationCallback: () => void;
  18172. }
  18173. }
  18174. declare module BABYLON {
  18175. /**
  18176. * Interface used to describe a physics joint
  18177. */
  18178. export interface PhysicsImpostorJoint {
  18179. /** Defines the main impostor to which the joint is linked */
  18180. mainImpostor: PhysicsImpostor;
  18181. /** Defines the impostor that is connected to the main impostor using this joint */
  18182. connectedImpostor: PhysicsImpostor;
  18183. /** Defines the joint itself */
  18184. joint: PhysicsJoint;
  18185. }
  18186. /** @hidden */
  18187. export interface IPhysicsEnginePlugin {
  18188. world: any;
  18189. name: string;
  18190. setGravity(gravity: Vector3): void;
  18191. setTimeStep(timeStep: number): void;
  18192. getTimeStep(): number;
  18193. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  18194. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18195. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18196. generatePhysicsBody(impostor: PhysicsImpostor): void;
  18197. removePhysicsBody(impostor: PhysicsImpostor): void;
  18198. generateJoint(joint: PhysicsImpostorJoint): void;
  18199. removeJoint(joint: PhysicsImpostorJoint): void;
  18200. isSupported(): boolean;
  18201. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  18202. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  18203. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18204. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18205. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18206. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18207. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  18208. getBodyMass(impostor: PhysicsImpostor): number;
  18209. getBodyFriction(impostor: PhysicsImpostor): number;
  18210. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  18211. getBodyRestitution(impostor: PhysicsImpostor): number;
  18212. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  18213. sleepBody(impostor: PhysicsImpostor): void;
  18214. wakeUpBody(impostor: PhysicsImpostor): void;
  18215. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  18216. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  18217. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18218. getRadius(impostor: PhysicsImpostor): number;
  18219. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  18220. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  18221. dispose(): void;
  18222. }
  18223. /**
  18224. * Interface used to define a physics engine
  18225. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  18226. */
  18227. export interface IPhysicsEngine {
  18228. /**
  18229. * Gets the gravity vector used by the simulation
  18230. */
  18231. gravity: Vector3;
  18232. /**
  18233. * Sets the gravity vector used by the simulation
  18234. * @param gravity defines the gravity vector to use
  18235. */
  18236. setGravity(gravity: Vector3): void;
  18237. /**
  18238. * Set the time step of the physics engine.
  18239. * Default is 1/60.
  18240. * To slow it down, enter 1/600 for example.
  18241. * To speed it up, 1/30
  18242. * @param newTimeStep the new timestep to apply to this world.
  18243. */
  18244. setTimeStep(newTimeStep: number): void;
  18245. /**
  18246. * Get the time step of the physics engine.
  18247. * @returns the current time step
  18248. */
  18249. getTimeStep(): number;
  18250. /**
  18251. * Release all resources
  18252. */
  18253. dispose(): void;
  18254. /**
  18255. * Gets the name of the current physics plugin
  18256. * @returns the name of the plugin
  18257. */
  18258. getPhysicsPluginName(): string;
  18259. /**
  18260. * Adding a new impostor for the impostor tracking.
  18261. * This will be done by the impostor itself.
  18262. * @param impostor the impostor to add
  18263. */
  18264. addImpostor(impostor: PhysicsImpostor): void;
  18265. /**
  18266. * Remove an impostor from the engine.
  18267. * This impostor and its mesh will not longer be updated by the physics engine.
  18268. * @param impostor the impostor to remove
  18269. */
  18270. removeImpostor(impostor: PhysicsImpostor): void;
  18271. /**
  18272. * Add a joint to the physics engine
  18273. * @param mainImpostor defines the main impostor to which the joint is added.
  18274. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  18275. * @param joint defines the joint that will connect both impostors.
  18276. */
  18277. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  18278. /**
  18279. * Removes a joint from the simulation
  18280. * @param mainImpostor defines the impostor used with the joint
  18281. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  18282. * @param joint defines the joint to remove
  18283. */
  18284. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  18285. /**
  18286. * Gets the current plugin used to run the simulation
  18287. * @returns current plugin
  18288. */
  18289. getPhysicsPlugin(): IPhysicsEnginePlugin;
  18290. /**
  18291. * Gets the list of physic impostors
  18292. * @returns an array of PhysicsImpostor
  18293. */
  18294. getImpostors(): Array<PhysicsImpostor>;
  18295. /**
  18296. * Gets the impostor for a physics enabled object
  18297. * @param object defines the object impersonated by the impostor
  18298. * @returns the PhysicsImpostor or null if not found
  18299. */
  18300. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  18301. /**
  18302. * Gets the impostor for a physics body object
  18303. * @param body defines physics body used by the impostor
  18304. * @returns the PhysicsImpostor or null if not found
  18305. */
  18306. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  18307. /**
  18308. * Called by the scene. No need to call it.
  18309. * @param delta defines the timespam between frames
  18310. */ step(delta: number): void;
  18311. }
  18312. }
  18313. declare module BABYLON {
  18314. /**
  18315. * The interface for the physics imposter parameters
  18316. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18317. */
  18318. export interface PhysicsImpostorParameters {
  18319. /**
  18320. * The mass of the physics imposter
  18321. */
  18322. mass: number;
  18323. /**
  18324. * The friction of the physics imposter
  18325. */
  18326. friction?: number;
  18327. /**
  18328. * The coefficient of restitution of the physics imposter
  18329. */
  18330. restitution?: number;
  18331. /**
  18332. * The native options of the physics imposter
  18333. */
  18334. nativeOptions?: any;
  18335. /**
  18336. * Specifies if the parent should be ignored
  18337. */
  18338. ignoreParent?: boolean;
  18339. /**
  18340. * Specifies if bi-directional transformations should be disabled
  18341. */
  18342. disableBidirectionalTransformation?: boolean;
  18343. }
  18344. /**
  18345. * Interface for a physics-enabled object
  18346. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18347. */
  18348. export interface IPhysicsEnabledObject {
  18349. /**
  18350. * The position of the physics-enabled object
  18351. */
  18352. position: Vector3;
  18353. /**
  18354. * The rotation of the physics-enabled object
  18355. */
  18356. rotationQuaternion: Nullable<Quaternion>;
  18357. /**
  18358. * The scale of the physics-enabled object
  18359. */
  18360. scaling: Vector3;
  18361. /**
  18362. * The rotation of the physics-enabled object
  18363. */
  18364. rotation?: Vector3;
  18365. /**
  18366. * The parent of the physics-enabled object
  18367. */
  18368. parent?: any;
  18369. /**
  18370. * The bounding info of the physics-enabled object
  18371. * @returns The bounding info of the physics-enabled object
  18372. */
  18373. getBoundingInfo(): BoundingInfo;
  18374. /**
  18375. * Computes the world matrix
  18376. * @param force Specifies if the world matrix should be computed by force
  18377. * @returns A world matrix
  18378. */
  18379. computeWorldMatrix(force: boolean): Matrix;
  18380. /**
  18381. * Gets the world matrix
  18382. * @returns A world matrix
  18383. */
  18384. getWorldMatrix?(): Matrix;
  18385. /**
  18386. * Gets the child meshes
  18387. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  18388. * @returns An array of abstract meshes
  18389. */
  18390. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  18391. /**
  18392. * Gets the vertex data
  18393. * @param kind The type of vertex data
  18394. * @returns A nullable array of numbers, or a float32 array
  18395. */
  18396. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  18397. /**
  18398. * Gets the indices from the mesh
  18399. * @returns A nullable array of index arrays
  18400. */
  18401. getIndices?(): Nullable<IndicesArray>;
  18402. /**
  18403. * Gets the scene from the mesh
  18404. * @returns the indices array or null
  18405. */
  18406. getScene?(): Scene;
  18407. /**
  18408. * Gets the absolute position from the mesh
  18409. * @returns the absolute position
  18410. */
  18411. getAbsolutePosition(): Vector3;
  18412. /**
  18413. * Gets the absolute pivot point from the mesh
  18414. * @returns the absolute pivot point
  18415. */
  18416. getAbsolutePivotPoint(): Vector3;
  18417. /**
  18418. * Rotates the mesh
  18419. * @param axis The axis of rotation
  18420. * @param amount The amount of rotation
  18421. * @param space The space of the rotation
  18422. * @returns The rotation transform node
  18423. */
  18424. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  18425. /**
  18426. * Translates the mesh
  18427. * @param axis The axis of translation
  18428. * @param distance The distance of translation
  18429. * @param space The space of the translation
  18430. * @returns The transform node
  18431. */
  18432. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  18433. /**
  18434. * Sets the absolute position of the mesh
  18435. * @param absolutePosition The absolute position of the mesh
  18436. * @returns The transform node
  18437. */
  18438. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  18439. /**
  18440. * Gets the class name of the mesh
  18441. * @returns The class name
  18442. */
  18443. getClassName(): string;
  18444. }
  18445. /**
  18446. * Represents a physics imposter
  18447. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18448. */
  18449. export class PhysicsImpostor {
  18450. /**
  18451. * The physics-enabled object used as the physics imposter
  18452. */
  18453. object: IPhysicsEnabledObject;
  18454. /**
  18455. * The type of the physics imposter
  18456. */
  18457. type: number;
  18458. private _options;
  18459. private _scene?;
  18460. /**
  18461. * The default object size of the imposter
  18462. */
  18463. static DEFAULT_OBJECT_SIZE: Vector3;
  18464. /**
  18465. * The identity quaternion of the imposter
  18466. */
  18467. static IDENTITY_QUATERNION: Quaternion;
  18468. /** @hidden */ pluginData: any;
  18469. private _physicsEngine;
  18470. private _physicsBody;
  18471. private _bodyUpdateRequired;
  18472. private _onBeforePhysicsStepCallbacks;
  18473. private _onAfterPhysicsStepCallbacks;
  18474. /** @hidden */ onPhysicsCollideCallbacks: Array<{
  18475. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  18476. otherImpostors: Array<PhysicsImpostor>;
  18477. }>;
  18478. private _deltaPosition;
  18479. private _deltaRotation;
  18480. private _deltaRotationConjugated;
  18481. private _parent;
  18482. private _isDisposed;
  18483. private static _tmpVecs;
  18484. private static _tmpQuat;
  18485. /**
  18486. * Specifies if the physics imposter is disposed
  18487. */
  18488. readonly isDisposed: boolean;
  18489. /**
  18490. * Gets the mass of the physics imposter
  18491. */
  18492. mass: number;
  18493. /**
  18494. * Gets the coefficient of friction
  18495. */
  18496. /**
  18497. * Sets the coefficient of friction
  18498. */
  18499. friction: number;
  18500. /**
  18501. * Gets the coefficient of restitution
  18502. */
  18503. /**
  18504. * Sets the coefficient of restitution
  18505. */
  18506. restitution: number;
  18507. /**
  18508. * The unique id of the physics imposter
  18509. * set by the physics engine when adding this impostor to the array
  18510. */
  18511. uniqueId: number;
  18512. private _joints;
  18513. /**
  18514. * Initializes the physics imposter
  18515. * @param object The physics-enabled object used as the physics imposter
  18516. * @param type The type of the physics imposter
  18517. * @param _options The options for the physics imposter
  18518. * @param _scene The Babylon scene
  18519. */
  18520. constructor(
  18521. /**
  18522. * The physics-enabled object used as the physics imposter
  18523. */
  18524. object: IPhysicsEnabledObject,
  18525. /**
  18526. * The type of the physics imposter
  18527. */
  18528. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  18529. /**
  18530. * This function will completly initialize this impostor.
  18531. * It will create a new body - but only if this mesh has no parent.
  18532. * If it has, this impostor will not be used other than to define the impostor
  18533. * of the child mesh.
  18534. * @hidden
  18535. */ init(): void;
  18536. private _getPhysicsParent;
  18537. /**
  18538. * Should a new body be generated.
  18539. * @returns boolean specifying if body initialization is required
  18540. */
  18541. isBodyInitRequired(): boolean;
  18542. /**
  18543. * Sets the updated scaling
  18544. * @param updated Specifies if the scaling is updated
  18545. */
  18546. setScalingUpdated(): void;
  18547. /**
  18548. * Force a regeneration of this or the parent's impostor's body.
  18549. * Use under cautious - This will remove all joints already implemented.
  18550. */
  18551. forceUpdate(): void;
  18552. /**
  18553. * Gets the body that holds this impostor. Either its own, or its parent.
  18554. */
  18555. /**
  18556. * Set the physics body. Used mainly by the physics engine/plugin
  18557. */
  18558. physicsBody: any;
  18559. /**
  18560. * Get the parent of the physics imposter
  18561. * @returns Physics imposter or null
  18562. */
  18563. /**
  18564. * Sets the parent of the physics imposter
  18565. */
  18566. parent: Nullable<PhysicsImpostor>;
  18567. /**
  18568. * Resets the update flags
  18569. */
  18570. resetUpdateFlags(): void;
  18571. /**
  18572. * Gets the object extend size
  18573. * @returns the object extend size
  18574. */
  18575. getObjectExtendSize(): Vector3;
  18576. /**
  18577. * Gets the object center
  18578. * @returns The object center
  18579. */
  18580. getObjectCenter(): Vector3;
  18581. /**
  18582. * Get a specific parametes from the options parameter
  18583. * @param paramName The object parameter name
  18584. * @returns The object parameter
  18585. */
  18586. getParam(paramName: string): any;
  18587. /**
  18588. * Sets a specific parameter in the options given to the physics plugin
  18589. * @param paramName The parameter name
  18590. * @param value The value of the parameter
  18591. */
  18592. setParam(paramName: string, value: number): void;
  18593. /**
  18594. * Specifically change the body's mass option. Won't recreate the physics body object
  18595. * @param mass The mass of the physics imposter
  18596. */
  18597. setMass(mass: number): void;
  18598. /**
  18599. * Gets the linear velocity
  18600. * @returns linear velocity or null
  18601. */
  18602. getLinearVelocity(): Nullable<Vector3>;
  18603. /**
  18604. * Sets the linear velocity
  18605. * @param velocity linear velocity or null
  18606. */
  18607. setLinearVelocity(velocity: Nullable<Vector3>): void;
  18608. /**
  18609. * Gets the angular velocity
  18610. * @returns angular velocity or null
  18611. */
  18612. getAngularVelocity(): Nullable<Vector3>;
  18613. /**
  18614. * Sets the angular velocity
  18615. * @param velocity The velocity or null
  18616. */
  18617. setAngularVelocity(velocity: Nullable<Vector3>): void;
  18618. /**
  18619. * Execute a function with the physics plugin native code
  18620. * Provide a function the will have two variables - the world object and the physics body object
  18621. * @param func The function to execute with the physics plugin native code
  18622. */
  18623. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  18624. /**
  18625. * Register a function that will be executed before the physics world is stepping forward
  18626. * @param func The function to execute before the physics world is stepped forward
  18627. */
  18628. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18629. /**
  18630. * Unregister a function that will be executed before the physics world is stepping forward
  18631. * @param func The function to execute before the physics world is stepped forward
  18632. */
  18633. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18634. /**
  18635. * Register a function that will be executed after the physics step
  18636. * @param func The function to execute after physics step
  18637. */
  18638. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18639. /**
  18640. * Unregisters a function that will be executed after the physics step
  18641. * @param func The function to execute after physics step
  18642. */
  18643. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18644. /**
  18645. * register a function that will be executed when this impostor collides against a different body
  18646. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  18647. * @param func Callback that is executed on collision
  18648. */
  18649. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  18650. /**
  18651. * Unregisters the physics imposter on contact
  18652. * @param collideAgainst The physics object to collide against
  18653. * @param func Callback to execute on collision
  18654. */
  18655. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  18656. private _tmpQuat;
  18657. private _tmpQuat2;
  18658. /**
  18659. * Get the parent rotation
  18660. * @returns The parent rotation
  18661. */
  18662. getParentsRotation(): Quaternion;
  18663. /**
  18664. * this function is executed by the physics engine.
  18665. */
  18666. beforeStep: () => void;
  18667. /**
  18668. * this function is executed by the physics engine
  18669. */
  18670. afterStep: () => void;
  18671. /**
  18672. * Legacy collision detection event support
  18673. */
  18674. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  18675. /**
  18676. * event and body object due to cannon's event-based architecture.
  18677. */
  18678. onCollide: (e: {
  18679. body: any;
  18680. }) => void;
  18681. /**
  18682. * Apply a force
  18683. * @param force The force to apply
  18684. * @param contactPoint The contact point for the force
  18685. * @returns The physics imposter
  18686. */
  18687. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  18688. /**
  18689. * Apply an impulse
  18690. * @param force The impulse force
  18691. * @param contactPoint The contact point for the impulse force
  18692. * @returns The physics imposter
  18693. */
  18694. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  18695. /**
  18696. * A help function to create a joint
  18697. * @param otherImpostor A physics imposter used to create a joint
  18698. * @param jointType The type of joint
  18699. * @param jointData The data for the joint
  18700. * @returns The physics imposter
  18701. */
  18702. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  18703. /**
  18704. * Add a joint to this impostor with a different impostor
  18705. * @param otherImpostor A physics imposter used to add a joint
  18706. * @param joint The joint to add
  18707. * @returns The physics imposter
  18708. */
  18709. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  18710. /**
  18711. * Will keep this body still, in a sleep mode.
  18712. * @returns the physics imposter
  18713. */
  18714. sleep(): PhysicsImpostor;
  18715. /**
  18716. * Wake the body up.
  18717. * @returns The physics imposter
  18718. */
  18719. wakeUp(): PhysicsImpostor;
  18720. /**
  18721. * Clones the physics imposter
  18722. * @param newObject The physics imposter clones to this physics-enabled object
  18723. * @returns A nullable physics imposter
  18724. */
  18725. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  18726. /**
  18727. * Disposes the physics imposter
  18728. */
  18729. dispose(): void;
  18730. /**
  18731. * Sets the delta position
  18732. * @param position The delta position amount
  18733. */
  18734. setDeltaPosition(position: Vector3): void;
  18735. /**
  18736. * Sets the delta rotation
  18737. * @param rotation The delta rotation amount
  18738. */
  18739. setDeltaRotation(rotation: Quaternion): void;
  18740. /**
  18741. * Gets the box size of the physics imposter and stores the result in the input parameter
  18742. * @param result Stores the box size
  18743. * @returns The physics imposter
  18744. */
  18745. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  18746. /**
  18747. * Gets the radius of the physics imposter
  18748. * @returns Radius of the physics imposter
  18749. */
  18750. getRadius(): number;
  18751. /**
  18752. * Sync a bone with this impostor
  18753. * @param bone The bone to sync to the impostor.
  18754. * @param boneMesh The mesh that the bone is influencing.
  18755. * @param jointPivot The pivot of the joint / bone in local space.
  18756. * @param distToJoint Optional distance from the impostor to the joint.
  18757. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  18758. */
  18759. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  18760. /**
  18761. * Sync impostor to a bone
  18762. * @param bone The bone that the impostor will be synced to.
  18763. * @param boneMesh The mesh that the bone is influencing.
  18764. * @param jointPivot The pivot of the joint / bone in local space.
  18765. * @param distToJoint Optional distance from the impostor to the joint.
  18766. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  18767. * @param boneAxis Optional vector3 axis the bone is aligned with
  18768. */
  18769. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  18770. /**
  18771. * No-Imposter type
  18772. */
  18773. static NoImpostor: number;
  18774. /**
  18775. * Sphere-Imposter type
  18776. */
  18777. static SphereImpostor: number;
  18778. /**
  18779. * Box-Imposter type
  18780. */
  18781. static BoxImpostor: number;
  18782. /**
  18783. * Plane-Imposter type
  18784. */
  18785. static PlaneImpostor: number;
  18786. /**
  18787. * Mesh-imposter type
  18788. */
  18789. static MeshImpostor: number;
  18790. /**
  18791. * Cylinder-Imposter type
  18792. */
  18793. static CylinderImpostor: number;
  18794. /**
  18795. * Particle-Imposter type
  18796. */
  18797. static ParticleImpostor: number;
  18798. /**
  18799. * Heightmap-Imposter type
  18800. */
  18801. static HeightmapImpostor: number;
  18802. }
  18803. }
  18804. declare module BABYLON {
  18805. /**
  18806. * Class used to represent a specific level of detail of a mesh
  18807. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  18808. */
  18809. export class MeshLODLevel {
  18810. /** Defines the distance where this level should star being displayed */
  18811. distance: number;
  18812. /** Defines the mesh to use to render this level */
  18813. mesh: Nullable<Mesh>;
  18814. /**
  18815. * Creates a new LOD level
  18816. * @param distance defines the distance where this level should star being displayed
  18817. * @param mesh defines the mesh to use to render this level
  18818. */
  18819. constructor(
  18820. /** Defines the distance where this level should star being displayed */
  18821. distance: number,
  18822. /** Defines the mesh to use to render this level */
  18823. mesh: Nullable<Mesh>);
  18824. }
  18825. /**
  18826. * @hidden
  18827. **/
  18828. export class _CreationDataStorage {
  18829. closePath?: boolean;
  18830. closeArray?: boolean;
  18831. idx: number[];
  18832. dashSize: number;
  18833. gapSize: number;
  18834. path3D: Path3D;
  18835. pathArray: Vector3[][];
  18836. arc: number;
  18837. radius: number;
  18838. cap: number;
  18839. tessellation: number;
  18840. }
  18841. /**
  18842. * @hidden
  18843. **/ private class _InstanceDataStorage {
  18844. visibleInstances: any;
  18845. renderIdForInstances: number[];
  18846. batchCache: _InstancesBatch;
  18847. instancesBufferSize: number;
  18848. instancesBuffer: Nullable<Buffer>;
  18849. instancesData: Float32Array;
  18850. overridenInstanceCount: number;
  18851. }
  18852. /**
  18853. * @hidden
  18854. **/
  18855. export class _InstancesBatch {
  18856. mustReturn: boolean;
  18857. visibleInstances: Nullable<InstancedMesh[]>[];
  18858. renderSelf: boolean[];
  18859. }
  18860. /**
  18861. * Class used to represent renderable models
  18862. */
  18863. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  18864. /**
  18865. * Mesh side orientation : usually the external or front surface
  18866. */
  18867. static readonly FRONTSIDE: number;
  18868. /**
  18869. * Mesh side orientation : usually the internal or back surface
  18870. */
  18871. static readonly BACKSIDE: number;
  18872. /**
  18873. * Mesh side orientation : both internal and external or front and back surfaces
  18874. */
  18875. static readonly DOUBLESIDE: number;
  18876. /**
  18877. * Mesh side orientation : by default, `FRONTSIDE`
  18878. */
  18879. static readonly DEFAULTSIDE: number;
  18880. /**
  18881. * Mesh cap setting : no cap
  18882. */
  18883. static readonly NO_CAP: number;
  18884. /**
  18885. * Mesh cap setting : one cap at the beginning of the mesh
  18886. */
  18887. static readonly CAP_START: number;
  18888. /**
  18889. * Mesh cap setting : one cap at the end of the mesh
  18890. */
  18891. static readonly CAP_END: number;
  18892. /**
  18893. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  18894. */
  18895. static readonly CAP_ALL: number;
  18896. /**
  18897. * Gets the default side orientation.
  18898. * @param orientation the orientation to value to attempt to get
  18899. * @returns the default orientation
  18900. * @hidden
  18901. */ private static _GetDefaultSideOrientation(orientation?: number): number;
  18902. private _onBeforeRenderObservable;
  18903. private _onBeforeBindObservable;
  18904. private _onAfterRenderObservable;
  18905. private _onBeforeDrawObservable;
  18906. /**
  18907. * An event triggered before rendering the mesh
  18908. */
  18909. readonly onBeforeRenderObservable: Observable<Mesh>;
  18910. /**
  18911. * An event triggered before binding the mesh
  18912. */
  18913. readonly onBeforeBindObservable: Observable<Mesh>;
  18914. /**
  18915. * An event triggered after rendering the mesh
  18916. */
  18917. readonly onAfterRenderObservable: Observable<Mesh>;
  18918. /**
  18919. * An event triggered before drawing the mesh
  18920. */
  18921. readonly onBeforeDrawObservable: Observable<Mesh>;
  18922. private _onBeforeDrawObserver;
  18923. /**
  18924. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  18925. */
  18926. onBeforeDraw: () => void;
  18927. /**
  18928. * Gets the delay loading state of the mesh (when delay loading is turned on)
  18929. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  18930. */
  18931. delayLoadState: number;
  18932. /**
  18933. * Gets the list of instances created from this mesh
  18934. * it is not supposed to be modified manually.
  18935. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  18936. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  18937. */
  18938. instances: InstancedMesh[];
  18939. /**
  18940. * Gets the file containing delay loading data for this mesh
  18941. */
  18942. delayLoadingFile: string;
  18943. /** @hidden */ binaryInfo: any;
  18944. private _LODLevels;
  18945. /**
  18946. * User defined function used to change how LOD level selection is done
  18947. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  18948. */
  18949. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  18950. private _morphTargetManager;
  18951. /**
  18952. * Gets or sets the morph target manager
  18953. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18954. */
  18955. morphTargetManager: Nullable<MorphTargetManager>;
  18956. /** @hidden */ creationDataStorage: Nullable<_CreationDataStorage>;
  18957. /** @hidden */ geometry: Nullable<Geometry>;
  18958. /** @hidden */ delayInfo: Array<string>;
  18959. /** @hidden */ delayLoadingFunction: (any: any, mesh: Mesh) => void;
  18960. /** @hidden */ instanceDataStorage: _InstanceDataStorage;
  18961. private _effectiveMaterial;
  18962. /** @hidden */ shouldGenerateFlatShading: boolean;
  18963. private _preActivateId;
  18964. /** @hidden */ originalBuilderSideOrientation: number;
  18965. /**
  18966. * Use this property to change the original side orientation defined at construction time
  18967. */
  18968. overrideMaterialSideOrientation: Nullable<number>;
  18969. private _areNormalsFrozen;
  18970. private _sourcePositions;
  18971. private _sourceNormals;
  18972. private _source;
  18973. private meshMap;
  18974. /**
  18975. * Gets the source mesh (the one used to clone this one from)
  18976. */
  18977. readonly source: Nullable<Mesh>;
  18978. /**
  18979. * Gets or sets a boolean indicating that this mesh does not use index buffer
  18980. */
  18981. isUnIndexed: boolean;
  18982. /**
  18983. * @constructor
  18984. * @param name The value used by scene.getMeshByName() to do a lookup.
  18985. * @param scene The scene to add this mesh to.
  18986. * @param parent The parent of this mesh, if it has one
  18987. * @param source An optional Mesh from which geometry is shared, cloned.
  18988. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  18989. * When false, achieved by calling a clone(), also passing False.
  18990. * This will make creation of children, recursive.
  18991. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  18992. */
  18993. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  18994. /**
  18995. * Gets the class name
  18996. * @returns the string "Mesh".
  18997. */
  18998. getClassName(): string;
  18999. /** @hidden */ protected readonly _isMesh: boolean;
  19000. /**
  19001. * Returns a description of this mesh
  19002. * @param fullDetails define if full details about this mesh must be used
  19003. * @returns a descriptive string representing this mesh
  19004. */
  19005. toString(fullDetails?: boolean): string;
  19006. /** @hidden */ unBindEffect(): void;
  19007. /**
  19008. * Gets a boolean indicating if this mesh has LOD
  19009. */
  19010. readonly hasLODLevels: boolean;
  19011. /**
  19012. * Gets the list of MeshLODLevel associated with the current mesh
  19013. * @returns an array of MeshLODLevel
  19014. */
  19015. getLODLevels(): MeshLODLevel[];
  19016. private _sortLODLevels;
  19017. /**
  19018. * Add a mesh as LOD level triggered at the given distance.
  19019. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19020. * @param distance The distance from the center of the object to show this level
  19021. * @param mesh The mesh to be added as LOD level (can be null)
  19022. * @return This mesh (for chaining)
  19023. */
  19024. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  19025. /**
  19026. * Returns the LOD level mesh at the passed distance or null if not found.
  19027. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19028. * @param distance The distance from the center of the object to show this level
  19029. * @returns a Mesh or `null`
  19030. */
  19031. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  19032. /**
  19033. * Remove a mesh from the LOD array
  19034. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19035. * @param mesh defines the mesh to be removed
  19036. * @return This mesh (for chaining)
  19037. */
  19038. removeLODLevel(mesh: Mesh): Mesh;
  19039. /**
  19040. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  19041. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19042. * @param camera defines the camera to use to compute distance
  19043. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  19044. * @return This mesh (for chaining)
  19045. */
  19046. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  19047. /**
  19048. * Gets the mesh internal Geometry object
  19049. */
  19050. readonly geometry: Nullable<Geometry>;
  19051. /**
  19052. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  19053. * @returns the total number of vertices
  19054. */
  19055. getTotalVertices(): number;
  19056. /**
  19057. * Returns the content of an associated vertex buffer
  19058. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19059. * - VertexBuffer.PositionKind
  19060. * - VertexBuffer.UVKind
  19061. * - VertexBuffer.UV2Kind
  19062. * - VertexBuffer.UV3Kind
  19063. * - VertexBuffer.UV4Kind
  19064. * - VertexBuffer.UV5Kind
  19065. * - VertexBuffer.UV6Kind
  19066. * - VertexBuffer.ColorKind
  19067. * - VertexBuffer.MatricesIndicesKind
  19068. * - VertexBuffer.MatricesIndicesExtraKind
  19069. * - VertexBuffer.MatricesWeightsKind
  19070. * - VertexBuffer.MatricesWeightsExtraKind
  19071. * @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
  19072. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  19073. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  19074. */
  19075. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  19076. /**
  19077. * Returns the mesh VertexBuffer object from the requested `kind`
  19078. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19079. * - VertexBuffer.PositionKind
  19080. * - VertexBuffer.UVKind
  19081. * - VertexBuffer.UV2Kind
  19082. * - VertexBuffer.UV3Kind
  19083. * - VertexBuffer.UV4Kind
  19084. * - VertexBuffer.UV5Kind
  19085. * - VertexBuffer.UV6Kind
  19086. * - VertexBuffer.ColorKind
  19087. * - VertexBuffer.MatricesIndicesKind
  19088. * - VertexBuffer.MatricesIndicesExtraKind
  19089. * - VertexBuffer.MatricesWeightsKind
  19090. * - VertexBuffer.MatricesWeightsExtraKind
  19091. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  19092. */
  19093. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  19094. /**
  19095. * Tests if a specific vertex buffer is associated with this mesh
  19096. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  19097. * - VertexBuffer.PositionKind
  19098. * - VertexBuffer.UVKind
  19099. * - VertexBuffer.UV2Kind
  19100. * - VertexBuffer.UV3Kind
  19101. * - VertexBuffer.UV4Kind
  19102. * - VertexBuffer.UV5Kind
  19103. * - VertexBuffer.UV6Kind
  19104. * - VertexBuffer.ColorKind
  19105. * - VertexBuffer.MatricesIndicesKind
  19106. * - VertexBuffer.MatricesIndicesExtraKind
  19107. * - VertexBuffer.MatricesWeightsKind
  19108. * - VertexBuffer.MatricesWeightsExtraKind
  19109. * @returns a boolean
  19110. */
  19111. isVerticesDataPresent(kind: string): boolean;
  19112. /**
  19113. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  19114. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  19115. * - VertexBuffer.PositionKind
  19116. * - VertexBuffer.UVKind
  19117. * - VertexBuffer.UV2Kind
  19118. * - VertexBuffer.UV3Kind
  19119. * - VertexBuffer.UV4Kind
  19120. * - VertexBuffer.UV5Kind
  19121. * - VertexBuffer.UV6Kind
  19122. * - VertexBuffer.ColorKind
  19123. * - VertexBuffer.MatricesIndicesKind
  19124. * - VertexBuffer.MatricesIndicesExtraKind
  19125. * - VertexBuffer.MatricesWeightsKind
  19126. * - VertexBuffer.MatricesWeightsExtraKind
  19127. * @returns a boolean
  19128. */
  19129. isVertexBufferUpdatable(kind: string): boolean;
  19130. /**
  19131. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  19132. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19133. * - VertexBuffer.PositionKind
  19134. * - VertexBuffer.UVKind
  19135. * - VertexBuffer.UV2Kind
  19136. * - VertexBuffer.UV3Kind
  19137. * - VertexBuffer.UV4Kind
  19138. * - VertexBuffer.UV5Kind
  19139. * - VertexBuffer.UV6Kind
  19140. * - VertexBuffer.ColorKind
  19141. * - VertexBuffer.MatricesIndicesKind
  19142. * - VertexBuffer.MatricesIndicesExtraKind
  19143. * - VertexBuffer.MatricesWeightsKind
  19144. * - VertexBuffer.MatricesWeightsExtraKind
  19145. * @returns an array of strings
  19146. */
  19147. getVerticesDataKinds(): string[];
  19148. /**
  19149. * Returns a positive integer : the total number of indices in this mesh geometry.
  19150. * @returns the numner of indices or zero if the mesh has no geometry.
  19151. */
  19152. getTotalIndices(): number;
  19153. /**
  19154. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19155. * @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.
  19156. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  19157. * @returns the indices array or an empty array if the mesh has no geometry
  19158. */
  19159. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  19160. readonly isBlocked: boolean;
  19161. /**
  19162. * Determine if the current mesh is ready to be rendered
  19163. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19164. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  19165. * @returns true if all associated assets are ready (material, textures, shaders)
  19166. */
  19167. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  19168. /**
  19169. * 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.
  19170. */
  19171. readonly areNormalsFrozen: boolean;
  19172. /**
  19173. * 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.
  19174. * @returns the current mesh
  19175. */
  19176. freezeNormals(): Mesh;
  19177. /**
  19178. * 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
  19179. * @returns the current mesh
  19180. */
  19181. unfreezeNormals(): Mesh;
  19182. /**
  19183. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  19184. */
  19185. overridenInstanceCount: number;
  19186. /** @hidden */ preActivate(): Mesh;
  19187. /** @hidden */ preActivateForIntermediateRendering(renderId: number): Mesh;
  19188. /** @hidden */ registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  19189. /**
  19190. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19191. * This means the mesh underlying bounding box and sphere are recomputed.
  19192. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19193. * @returns the current mesh
  19194. */
  19195. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  19196. /** @hidden */ createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  19197. /**
  19198. * This function will subdivide the mesh into multiple submeshes
  19199. * @param count defines the expected number of submeshes
  19200. */
  19201. subdivide(count: number): void;
  19202. /**
  19203. * Copy a FloatArray into a specific associated vertex buffer
  19204. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  19205. * - VertexBuffer.PositionKind
  19206. * - VertexBuffer.UVKind
  19207. * - VertexBuffer.UV2Kind
  19208. * - VertexBuffer.UV3Kind
  19209. * - VertexBuffer.UV4Kind
  19210. * - VertexBuffer.UV5Kind
  19211. * - VertexBuffer.UV6Kind
  19212. * - VertexBuffer.ColorKind
  19213. * - VertexBuffer.MatricesIndicesKind
  19214. * - VertexBuffer.MatricesIndicesExtraKind
  19215. * - VertexBuffer.MatricesWeightsKind
  19216. * - VertexBuffer.MatricesWeightsExtraKind
  19217. * @param data defines the data source
  19218. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  19219. * @param stride defines the data stride size (can be null)
  19220. * @returns the current mesh
  19221. */
  19222. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  19223. /**
  19224. * Flags an associated vertex buffer as updatable
  19225. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  19226. * - VertexBuffer.PositionKind
  19227. * - VertexBuffer.UVKind
  19228. * - VertexBuffer.UV2Kind
  19229. * - VertexBuffer.UV3Kind
  19230. * - VertexBuffer.UV4Kind
  19231. * - VertexBuffer.UV5Kind
  19232. * - VertexBuffer.UV6Kind
  19233. * - VertexBuffer.ColorKind
  19234. * - VertexBuffer.MatricesIndicesKind
  19235. * - VertexBuffer.MatricesIndicesExtraKind
  19236. * - VertexBuffer.MatricesWeightsKind
  19237. * - VertexBuffer.MatricesWeightsExtraKind
  19238. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  19239. */
  19240. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  19241. /**
  19242. * Sets the mesh global Vertex Buffer
  19243. * @param buffer defines the buffer to use
  19244. * @returns the current mesh
  19245. */
  19246. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  19247. /**
  19248. * Update a specific associated vertex buffer
  19249. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  19250. * - VertexBuffer.PositionKind
  19251. * - VertexBuffer.UVKind
  19252. * - VertexBuffer.UV2Kind
  19253. * - VertexBuffer.UV3Kind
  19254. * - VertexBuffer.UV4Kind
  19255. * - VertexBuffer.UV5Kind
  19256. * - VertexBuffer.UV6Kind
  19257. * - VertexBuffer.ColorKind
  19258. * - VertexBuffer.MatricesIndicesKind
  19259. * - VertexBuffer.MatricesIndicesExtraKind
  19260. * - VertexBuffer.MatricesWeightsKind
  19261. * - VertexBuffer.MatricesWeightsExtraKind
  19262. * @param data defines the data source
  19263. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  19264. * @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)
  19265. * @returns the current mesh
  19266. */
  19267. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19268. /**
  19269. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  19270. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  19271. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  19272. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  19273. * @returns the current mesh
  19274. */
  19275. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  19276. /**
  19277. * Creates a un-shared specific occurence of the geometry for the mesh.
  19278. * @returns the current mesh
  19279. */
  19280. makeGeometryUnique(): Mesh;
  19281. /**
  19282. * Set the index buffer of this mesh
  19283. * @param indices defines the source data
  19284. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  19285. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  19286. * @returns the current mesh
  19287. */
  19288. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  19289. /**
  19290. * Update the current index buffer
  19291. * @param indices defines the source data
  19292. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  19293. * @returns the current mesh
  19294. */
  19295. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  19296. /**
  19297. * Invert the geometry to move from a right handed system to a left handed one.
  19298. * @returns the current mesh
  19299. */
  19300. toLeftHanded(): Mesh;
  19301. /** @hidden */ bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19302. /** @hidden */ draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  19303. /**
  19304. * Registers for this mesh a javascript function called just before the rendering process
  19305. * @param func defines the function to call before rendering this mesh
  19306. * @returns the current mesh
  19307. */
  19308. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  19309. /**
  19310. * Disposes a previously registered javascript function called before the rendering
  19311. * @param func defines the function to remove
  19312. * @returns the current mesh
  19313. */
  19314. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  19315. /**
  19316. * Registers for this mesh a javascript function called just after the rendering is complete
  19317. * @param func defines the function to call after rendering this mesh
  19318. * @returns the current mesh
  19319. */
  19320. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  19321. /**
  19322. * Disposes a previously registered javascript function called after the rendering.
  19323. * @param func defines the function to remove
  19324. * @returns the current mesh
  19325. */
  19326. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  19327. /** @hidden */ getInstancesRenderList(subMeshId: number): _InstancesBatch;
  19328. /** @hidden */ renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  19329. /** @hidden */ processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  19330. /**
  19331. * 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
  19332. * @param subMesh defines the subMesh to render
  19333. * @param enableAlphaMode defines if alpha mode can be changed
  19334. * @returns the current mesh
  19335. */
  19336. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  19337. private _onBeforeDraw;
  19338. /**
  19339. * Renormalize the mesh and patch it up if there are no weights
  19340. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  19341. * However in the case of zero weights then we set just a single influence to 1.
  19342. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  19343. */
  19344. cleanMatrixWeights(): void;
  19345. private normalizeSkinFourWeights;
  19346. private normalizeSkinWeightsAndExtra;
  19347. /**
  19348. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  19349. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  19350. * the user know there was an issue with importing the mesh
  19351. * @returns a validation object with skinned, valid and report string
  19352. */
  19353. validateSkinning(): {
  19354. skinned: boolean;
  19355. valid: boolean;
  19356. report: string;
  19357. };
  19358. /** @hidden */ checkDelayState(): Mesh;
  19359. private _queueLoad;
  19360. /**
  19361. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  19362. * A mesh is in the frustum if its bounding box intersects the frustum
  19363. * @param frustumPlanes defines the frustum to test
  19364. * @returns true if the mesh is in the frustum planes
  19365. */
  19366. isInFrustum(frustumPlanes: Plane[]): boolean;
  19367. /**
  19368. * Sets the mesh material by the material or multiMaterial `id` property
  19369. * @param id is a string identifying the material or the multiMaterial
  19370. * @returns the current mesh
  19371. */
  19372. setMaterialByID(id: string): Mesh;
  19373. /**
  19374. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  19375. * @returns an array of IAnimatable
  19376. */
  19377. getAnimatables(): IAnimatable[];
  19378. /**
  19379. * Modifies the mesh geometry according to the passed transformation matrix.
  19380. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  19381. * The mesh normals are modified using the same transformation.
  19382. * Note that, under the hood, this method sets a new VertexBuffer each call.
  19383. * @param transform defines the transform matrix to use
  19384. * @see http://doc.babylonjs.com/resources/baking_transformations
  19385. * @returns the current mesh
  19386. */
  19387. bakeTransformIntoVertices(transform: Matrix): Mesh;
  19388. /**
  19389. * Modifies the mesh geometry according to its own current World Matrix.
  19390. * The mesh World Matrix is then reset.
  19391. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  19392. * Note that, under the hood, this method sets a new VertexBuffer each call.
  19393. * @see http://doc.babylonjs.com/resources/baking_transformations
  19394. * @returns the current mesh
  19395. */
  19396. bakeCurrentTransformIntoVertices(): Mesh;
  19397. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  19398. /** @hidden */ resetPointsArrayCache(): Mesh;
  19399. /** @hidden */ generatePointsArray(): boolean;
  19400. /**
  19401. * Returns a new Mesh object generated from the current mesh properties.
  19402. * This method must not get confused with createInstance()
  19403. * @param name is a string, the name given to the new mesh
  19404. * @param newParent can be any Node object (default `null`)
  19405. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  19406. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  19407. * @returns a new mesh
  19408. */
  19409. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  19410. /**
  19411. * Releases resources associated with this mesh.
  19412. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  19413. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  19414. */
  19415. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19416. /**
  19417. * Modifies the mesh geometry according to a displacement map.
  19418. * 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.
  19419. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  19420. * @param url is a string, the URL from the image file is to be downloaded.
  19421. * @param minHeight is the lower limit of the displacement.
  19422. * @param maxHeight is the upper limit of the displacement.
  19423. * @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.
  19424. * @param uvOffset is an optional vector2 used to offset UV.
  19425. * @param uvScale is an optional vector2 used to scale UV.
  19426. * @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.
  19427. * @returns the Mesh.
  19428. */
  19429. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  19430. /**
  19431. * Modifies the mesh geometry according to a displacementMap buffer.
  19432. * 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.
  19433. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  19434. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  19435. * @param heightMapWidth is the width of the buffer image.
  19436. * @param heightMapHeight is the height of the buffer image.
  19437. * @param minHeight is the lower limit of the displacement.
  19438. * @param maxHeight is the upper limit of the displacement.
  19439. * @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.
  19440. * @param uvOffset is an optional vector2 used to offset UV.
  19441. * @param uvScale is an optional vector2 used to scale UV.
  19442. * @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.
  19443. * @returns the Mesh.
  19444. */
  19445. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  19446. /**
  19447. * Modify the mesh to get a flat shading rendering.
  19448. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  19449. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  19450. * @returns current mesh
  19451. */
  19452. convertToFlatShadedMesh(): Mesh;
  19453. /**
  19454. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  19455. * In other words, more vertices, no more indices and a single bigger VBO.
  19456. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  19457. * @returns current mesh
  19458. */
  19459. convertToUnIndexedMesh(): Mesh;
  19460. /**
  19461. * Inverses facet orientations.
  19462. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  19463. * @param flipNormals will also inverts the normals
  19464. * @returns current mesh
  19465. */
  19466. flipFaces(flipNormals?: boolean): Mesh;
  19467. /** @hidden */ private static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  19468. /** @hidden */ private static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  19469. /**
  19470. * Creates a new InstancedMesh object from the mesh model.
  19471. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19472. * @param name defines the name of the new instance
  19473. * @returns a new InstancedMesh
  19474. */
  19475. createInstance(name: string): InstancedMesh;
  19476. /**
  19477. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  19478. * After this call, all the mesh instances have the same submeshes than the current mesh.
  19479. * @returns the current mesh
  19480. */
  19481. synchronizeInstances(): Mesh;
  19482. /**
  19483. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  19484. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  19485. * This should be used together with the simplification to avoid disappearing triangles.
  19486. * @param successCallback an optional success callback to be called after the optimization finished.
  19487. * @returns the current mesh
  19488. */
  19489. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  19490. /**
  19491. * Serialize current mesh
  19492. * @param serializationObject defines the object which will receive the serialization data
  19493. */
  19494. serialize(serializationObject: any): void;
  19495. /** @hidden */ syncGeometryWithMorphTargetManager(): void;
  19496. /** @hidden */ private static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  19497. /**
  19498. * Returns a new Mesh object parsed from the source provided.
  19499. * @param parsedMesh is the source
  19500. * @param scene defines the hosting scene
  19501. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  19502. * @returns a new Mesh
  19503. */
  19504. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  19505. /**
  19506. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  19507. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  19508. * @param name defines the name of the mesh to create
  19509. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  19510. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  19511. * @param closePath creates a seam between the first and the last points of each path of the path array
  19512. * @param offset is taken in account only if the `pathArray` is containing a single path
  19513. * @param scene defines the hosting scene
  19514. * @param updatable defines if the mesh must be flagged as updatable
  19515. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19516. * @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)
  19517. * @returns a new Mesh
  19518. */
  19519. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  19520. /**
  19521. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  19522. * @param name defines the name of the mesh to create
  19523. * @param radius sets the radius size (float) of the polygon (default 0.5)
  19524. * @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
  19525. * @param scene defines the hosting scene
  19526. * @param updatable defines if the mesh must be flagged as updatable
  19527. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19528. * @returns a new Mesh
  19529. */
  19530. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  19531. /**
  19532. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  19533. * @param name defines the name of the mesh to create
  19534. * @param size sets the size (float) of each box side (default 1)
  19535. * @param scene defines the hosting scene
  19536. * @param updatable defines if the mesh must be flagged as updatable
  19537. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19538. * @returns a new Mesh
  19539. */
  19540. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  19541. /**
  19542. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  19543. * @param name defines the name of the mesh to create
  19544. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  19545. * @param diameter sets the diameter size (float) of the sphere (default 1)
  19546. * @param scene defines the hosting scene
  19547. * @param updatable defines if the mesh must be flagged as updatable
  19548. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19549. * @returns a new Mesh
  19550. */
  19551. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19552. /**
  19553. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  19554. * @param name defines the name of the mesh to create
  19555. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  19556. * @param diameterTop set the top cap diameter (floats, default 1)
  19557. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  19558. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  19559. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  19560. * @param scene defines the hosting scene
  19561. * @param updatable defines if the mesh must be flagged as updatable
  19562. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19563. * @returns a new Mesh
  19564. */
  19565. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  19566. /**
  19567. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  19568. * @param name defines the name of the mesh to create
  19569. * @param diameter sets the diameter size (float) of the torus (default 1)
  19570. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  19571. * @param tessellation sets the number of torus sides (postive integer, default 16)
  19572. * @param scene defines the hosting scene
  19573. * @param updatable defines if the mesh must be flagged as updatable
  19574. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19575. * @returns a new Mesh
  19576. */
  19577. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19578. /**
  19579. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  19580. * @param name defines the name of the mesh to create
  19581. * @param radius sets the global radius size (float) of the torus knot (default 2)
  19582. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  19583. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  19584. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  19585. * @param p the number of windings on X axis (positive integers, default 2)
  19586. * @param q the number of windings on Y axis (positive integers, default 3)
  19587. * @param scene defines the hosting scene
  19588. * @param updatable defines if the mesh must be flagged as updatable
  19589. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19590. * @returns a new Mesh
  19591. */
  19592. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19593. /**
  19594. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  19595. * @param name defines the name of the mesh to create
  19596. * @param points is an array successive Vector3
  19597. * @param scene defines the hosting scene
  19598. * @param updatable defines if the mesh must be flagged as updatable
  19599. * @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).
  19600. * @returns a new Mesh
  19601. */
  19602. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  19603. /**
  19604. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  19605. * @param name defines the name of the mesh to create
  19606. * @param points is an array successive Vector3
  19607. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  19608. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  19609. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  19610. * @param scene defines the hosting scene
  19611. * @param updatable defines if the mesh must be flagged as updatable
  19612. * @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)
  19613. * @returns a new Mesh
  19614. */
  19615. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  19616. /**
  19617. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  19618. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  19619. * 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.
  19620. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  19621. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  19622. * Remember you can only change the shape positions, not their number when updating a polygon.
  19623. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  19624. * @param name defines the name of the mesh to create
  19625. * @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
  19626. * @param scene defines the hosting scene
  19627. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  19628. * @param updatable defines if the mesh must be flagged as updatable
  19629. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19630. * @param earcutInjection can be used to inject your own earcut reference
  19631. * @returns a new Mesh
  19632. */
  19633. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  19634. /**
  19635. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  19636. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  19637. * @param name defines the name of the mesh to create
  19638. * @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
  19639. * @param depth defines the height of extrusion
  19640. * @param scene defines the hosting scene
  19641. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  19642. * @param updatable defines if the mesh must be flagged as updatable
  19643. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19644. * @param earcutInjection can be used to inject your own earcut reference
  19645. * @returns a new Mesh
  19646. */
  19647. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  19648. /**
  19649. * Creates an extruded shape mesh.
  19650. * 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
  19651. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  19652. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  19653. * @param name defines the name of the mesh to create
  19654. * @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
  19655. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  19656. * @param scale is the value to scale the shape
  19657. * @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
  19658. * @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
  19659. * @param scene defines the hosting scene
  19660. * @param updatable defines if the mesh must be flagged as updatable
  19661. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19662. * @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)
  19663. * @returns a new Mesh
  19664. */
  19665. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  19666. /**
  19667. * Creates an custom extruded shape mesh.
  19668. * The custom extrusion is a parametric shape.
  19669. * It has no predefined shape. Its final shape will depend on the input parameters.
  19670. * Please consider using the same method from the MeshBuilder class instead
  19671. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  19672. * @param name defines the name of the mesh to create
  19673. * @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
  19674. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  19675. * @param scaleFunction is a custom Javascript function called on each path point
  19676. * @param rotationFunction is a custom Javascript function called on each path point
  19677. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  19678. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  19679. * @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
  19680. * @param scene defines the hosting scene
  19681. * @param updatable defines if the mesh must be flagged as updatable
  19682. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19683. * @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)
  19684. * @returns a new Mesh
  19685. */
  19686. 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;
  19687. /**
  19688. * Creates lathe mesh.
  19689. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  19690. * Please consider using the same method from the MeshBuilder class instead
  19691. * @param name defines the name of the mesh to create
  19692. * @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
  19693. * @param radius is the radius value of the lathe
  19694. * @param tessellation is the side number of the lathe.
  19695. * @param scene defines the hosting scene
  19696. * @param updatable defines if the mesh must be flagged as updatable
  19697. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19698. * @returns a new Mesh
  19699. */
  19700. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19701. /**
  19702. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  19703. * @param name defines the name of the mesh to create
  19704. * @param size sets the size (float) of both sides of the plane at once (default 1)
  19705. * @param scene defines the hosting scene
  19706. * @param updatable defines if the mesh must be flagged as updatable
  19707. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19708. * @returns a new Mesh
  19709. */
  19710. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19711. /**
  19712. * Creates a ground mesh.
  19713. * Please consider using the same method from the MeshBuilder class instead
  19714. * @param name defines the name of the mesh to create
  19715. * @param width set the width of the ground
  19716. * @param height set the height of the ground
  19717. * @param subdivisions sets the number of subdivisions per side
  19718. * @param scene defines the hosting scene
  19719. * @param updatable defines if the mesh must be flagged as updatable
  19720. * @returns a new Mesh
  19721. */
  19722. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  19723. /**
  19724. * Creates a tiled ground mesh.
  19725. * Please consider using the same method from the MeshBuilder class instead
  19726. * @param name defines the name of the mesh to create
  19727. * @param xmin set the ground minimum X coordinate
  19728. * @param zmin set the ground minimum Y coordinate
  19729. * @param xmax set the ground maximum X coordinate
  19730. * @param zmax set the ground maximum Z coordinate
  19731. * @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
  19732. * @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
  19733. * @param scene defines the hosting scene
  19734. * @param updatable defines if the mesh must be flagged as updatable
  19735. * @returns a new Mesh
  19736. */
  19737. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  19738. w: number;
  19739. h: number;
  19740. }, precision: {
  19741. w: number;
  19742. h: number;
  19743. }, scene: Scene, updatable?: boolean): Mesh;
  19744. /**
  19745. * Creates a ground mesh from a height map.
  19746. * Please consider using the same method from the MeshBuilder class instead
  19747. * @see http://doc.babylonjs.com/babylon101/height_map
  19748. * @param name defines the name of the mesh to create
  19749. * @param url sets the URL of the height map image resource
  19750. * @param width set the ground width size
  19751. * @param height set the ground height size
  19752. * @param subdivisions sets the number of subdivision per side
  19753. * @param minHeight is the minimum altitude on the ground
  19754. * @param maxHeight is the maximum altitude on the ground
  19755. * @param scene defines the hosting scene
  19756. * @param updatable defines if the mesh must be flagged as updatable
  19757. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  19758. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  19759. * @returns a new Mesh
  19760. */
  19761. 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;
  19762. /**
  19763. * Creates a tube mesh.
  19764. * The tube is a parametric shape.
  19765. * It has no predefined shape. Its final shape will depend on the input parameters.
  19766. * Please consider using the same method from the MeshBuilder class instead
  19767. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  19768. * @param name defines the name of the mesh to create
  19769. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  19770. * @param radius sets the tube radius size
  19771. * @param tessellation is the number of sides on the tubular surface
  19772. * @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
  19773. * @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
  19774. * @param scene defines the hosting scene
  19775. * @param updatable defines if the mesh must be flagged as updatable
  19776. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19777. * @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)
  19778. * @returns a new Mesh
  19779. */
  19780. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  19781. (i: number, distance: number): number;
  19782. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  19783. /**
  19784. * Creates a polyhedron mesh.
  19785. * Please consider using the same method from the MeshBuilder class instead.
  19786. * * 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
  19787. * * The parameter `size` (positive float, default 1) sets the polygon size
  19788. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  19789. * * 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`
  19790. * * 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
  19791. * * 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)`)
  19792. * * 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
  19793. * * 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
  19794. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  19795. * * 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
  19796. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  19797. * @param name defines the name of the mesh to create
  19798. * @param options defines the options used to create the mesh
  19799. * @param scene defines the hosting scene
  19800. * @returns a new Mesh
  19801. */
  19802. static CreatePolyhedron(name: string, options: {
  19803. type?: number;
  19804. size?: number;
  19805. sizeX?: number;
  19806. sizeY?: number;
  19807. sizeZ?: number;
  19808. custom?: any;
  19809. faceUV?: Vector4[];
  19810. faceColors?: Color4[];
  19811. updatable?: boolean;
  19812. sideOrientation?: number;
  19813. }, scene: Scene): Mesh;
  19814. /**
  19815. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  19816. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  19817. * * 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`)
  19818. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  19819. * * 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
  19820. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  19821. * * 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
  19822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  19823. * @param name defines the name of the mesh
  19824. * @param options defines the options used to create the mesh
  19825. * @param scene defines the hosting scene
  19826. * @returns a new Mesh
  19827. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  19828. */
  19829. static CreateIcoSphere(name: string, options: {
  19830. radius?: number;
  19831. flat?: boolean;
  19832. subdivisions?: number;
  19833. sideOrientation?: number;
  19834. updatable?: boolean;
  19835. }, scene: Scene): Mesh;
  19836. /**
  19837. * Creates a decal mesh.
  19838. * Please consider using the same method from the MeshBuilder class instead.
  19839. * A decal is a mesh usually applied as a model onto the surface of another mesh
  19840. * @param name defines the name of the mesh
  19841. * @param sourceMesh defines the mesh receiving the decal
  19842. * @param position sets the position of the decal in world coordinates
  19843. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  19844. * @param size sets the decal scaling
  19845. * @param angle sets the angle to rotate the decal
  19846. * @returns a new Mesh
  19847. */
  19848. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  19849. /**
  19850. * Prepare internal position array for software CPU skinning
  19851. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  19852. */
  19853. setPositionsForCPUSkinning(): Float32Array;
  19854. /**
  19855. * Prepare internal normal array for software CPU skinning
  19856. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  19857. */
  19858. setNormalsForCPUSkinning(): Float32Array;
  19859. /**
  19860. * Updates the vertex buffer by applying transformation from the bones
  19861. * @param skeleton defines the skeleton to apply to current mesh
  19862. * @returns the current mesh
  19863. */
  19864. applySkeleton(skeleton: Skeleton): Mesh;
  19865. /**
  19866. * 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
  19867. * @param meshes defines the list of meshes to scan
  19868. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  19869. */
  19870. static MinMax(meshes: AbstractMesh[]): {
  19871. min: Vector3;
  19872. max: Vector3;
  19873. };
  19874. /**
  19875. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  19876. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  19877. * @returns a vector3
  19878. */
  19879. static Center(meshesOrMinMaxVector: {
  19880. min: Vector3;
  19881. max: Vector3;
  19882. } | AbstractMesh[]): Vector3;
  19883. /**
  19884. * Merge the array of meshes into a single mesh for performance reasons.
  19885. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  19886. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  19887. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  19888. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  19889. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  19890. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  19891. * @returns a new mesh
  19892. */
  19893. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  19894. /** @hidden */
  19895. addInstance(instance: InstancedMesh): void;
  19896. /** @hidden */
  19897. removeInstance(instance: InstancedMesh): void;
  19898. }
  19899. }
  19900. declare module BABYLON {
  19901. /**
  19902. * Base class for the main features of a material in Babylon.js
  19903. */
  19904. export class Material implements IAnimatable {
  19905. /**
  19906. * Returns the triangle fill mode
  19907. */
  19908. static readonly TriangleFillMode: number;
  19909. /**
  19910. * Returns the wireframe mode
  19911. */
  19912. static readonly WireFrameFillMode: number;
  19913. /**
  19914. * Returns the point fill mode
  19915. */
  19916. static readonly PointFillMode: number;
  19917. /**
  19918. * Returns the point list draw mode
  19919. */
  19920. static readonly PointListDrawMode: number;
  19921. /**
  19922. * Returns the line list draw mode
  19923. */
  19924. static readonly LineListDrawMode: number;
  19925. /**
  19926. * Returns the line loop draw mode
  19927. */
  19928. static readonly LineLoopDrawMode: number;
  19929. /**
  19930. * Returns the line strip draw mode
  19931. */
  19932. static readonly LineStripDrawMode: number;
  19933. /**
  19934. * Returns the triangle strip draw mode
  19935. */
  19936. static readonly TriangleStripDrawMode: number;
  19937. /**
  19938. * Returns the triangle fan draw mode
  19939. */
  19940. static readonly TriangleFanDrawMode: number;
  19941. /**
  19942. * Stores the clock-wise side orientation
  19943. */
  19944. static readonly ClockWiseSideOrientation: number;
  19945. /**
  19946. * Stores the counter clock-wise side orientation
  19947. */
  19948. static readonly CounterClockWiseSideOrientation: number;
  19949. /**
  19950. * The dirty texture flag value
  19951. */
  19952. static readonly TextureDirtyFlag: number;
  19953. /**
  19954. * The dirty light flag value
  19955. */
  19956. static readonly LightDirtyFlag: number;
  19957. /**
  19958. * The dirty fresnel flag value
  19959. */
  19960. static readonly FresnelDirtyFlag: number;
  19961. /**
  19962. * The dirty attribute flag value
  19963. */
  19964. static readonly AttributesDirtyFlag: number;
  19965. /**
  19966. * The dirty misc flag value
  19967. */
  19968. static readonly MiscDirtyFlag: number;
  19969. /**
  19970. * The all dirty flag value
  19971. */
  19972. static readonly AllDirtyFlag: number;
  19973. /**
  19974. * The ID of the material
  19975. */
  19976. id: string;
  19977. /**
  19978. * Gets or sets the unique id of the material
  19979. */
  19980. uniqueId: number;
  19981. /**
  19982. * The name of the material
  19983. */
  19984. name: string;
  19985. /**
  19986. * Gets or sets user defined metadata
  19987. */
  19988. metadata: any;
  19989. /**
  19990. * For internal use only. Please do not use.
  19991. */
  19992. reservedDataStore: any;
  19993. /**
  19994. * Specifies if the ready state should be checked on each call
  19995. */
  19996. checkReadyOnEveryCall: boolean;
  19997. /**
  19998. * Specifies if the ready state should be checked once
  19999. */
  20000. checkReadyOnlyOnce: boolean;
  20001. /**
  20002. * The state of the material
  20003. */
  20004. state: string;
  20005. /**
  20006. * The alpha value of the material
  20007. */
  20008. protected _alpha: number;
  20009. /**
  20010. * Sets the alpha value of the material
  20011. */
  20012. /**
  20013. * Gets the alpha value of the material
  20014. */
  20015. alpha: number;
  20016. /**
  20017. * Specifies if back face culling is enabled
  20018. */
  20019. protected _backFaceCulling: boolean;
  20020. /**
  20021. * Sets the back-face culling state
  20022. */
  20023. /**
  20024. * Gets the back-face culling state
  20025. */
  20026. backFaceCulling: boolean;
  20027. /**
  20028. * Stores the value for side orientation
  20029. */
  20030. sideOrientation: number;
  20031. /**
  20032. * Callback triggered when the material is compiled
  20033. */
  20034. onCompiled: (effect: Effect) => void;
  20035. /**
  20036. * Callback triggered when an error occurs
  20037. */
  20038. onError: (effect: Effect, errors: string) => void;
  20039. /**
  20040. * Callback triggered to get the render target textures
  20041. */
  20042. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  20043. /**
  20044. * Gets a boolean indicating that current material needs to register RTT
  20045. */
  20046. readonly hasRenderTargetTextures: boolean;
  20047. /**
  20048. * Specifies if the material should be serialized
  20049. */
  20050. doNotSerialize: boolean;
  20051. /**
  20052. * @hidden
  20053. */ storeEffectOnSubMeshes: boolean;
  20054. /**
  20055. * Stores the animations for the material
  20056. */
  20057. animations: Array<Animation>;
  20058. /**
  20059. * An event triggered when the material is disposed
  20060. */
  20061. onDisposeObservable: Observable<Material>;
  20062. /**
  20063. * An observer which watches for dispose events
  20064. */
  20065. private _onDisposeObserver;
  20066. private _onUnBindObservable;
  20067. /**
  20068. * Called during a dispose event
  20069. */
  20070. onDispose: () => void;
  20071. private _onBindObservable;
  20072. /**
  20073. * An event triggered when the material is bound
  20074. */
  20075. readonly onBindObservable: Observable<AbstractMesh>;
  20076. /**
  20077. * An observer which watches for bind events
  20078. */
  20079. private _onBindObserver;
  20080. /**
  20081. * Called during a bind event
  20082. */
  20083. onBind: (Mesh: AbstractMesh) => void;
  20084. /**
  20085. * An event triggered when the material is unbound
  20086. */
  20087. readonly onUnBindObservable: Observable<Material>;
  20088. /**
  20089. * Stores the value of the alpha mode
  20090. */
  20091. private _alphaMode;
  20092. /**
  20093. * Sets the value of the alpha mode.
  20094. *
  20095. * | Value | Type | Description |
  20096. * | --- | --- | --- |
  20097. * | 0 | ALPHA_DISABLE | |
  20098. * | 1 | ALPHA_ADD | |
  20099. * | 2 | ALPHA_COMBINE | |
  20100. * | 3 | ALPHA_SUBTRACT | |
  20101. * | 4 | ALPHA_MULTIPLY | |
  20102. * | 5 | ALPHA_MAXIMIZED | |
  20103. * | 6 | ALPHA_ONEONE | |
  20104. * | 7 | ALPHA_PREMULTIPLIED | |
  20105. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20106. * | 9 | ALPHA_INTERPOLATE | |
  20107. * | 10 | ALPHA_SCREENMODE | |
  20108. *
  20109. */
  20110. /**
  20111. * Gets the value of the alpha mode
  20112. */
  20113. alphaMode: number;
  20114. /**
  20115. * Stores the state of the need depth pre-pass value
  20116. */
  20117. private _needDepthPrePass;
  20118. /**
  20119. * Sets the need depth pre-pass value
  20120. */
  20121. /**
  20122. * Gets the depth pre-pass value
  20123. */
  20124. needDepthPrePass: boolean;
  20125. /**
  20126. * Specifies if depth writing should be disabled
  20127. */
  20128. disableDepthWrite: boolean;
  20129. /**
  20130. * Specifies if depth writing should be forced
  20131. */
  20132. forceDepthWrite: boolean;
  20133. /**
  20134. * Specifies if there should be a separate pass for culling
  20135. */
  20136. separateCullingPass: boolean;
  20137. /**
  20138. * Stores the state specifing if fog should be enabled
  20139. */
  20140. private _fogEnabled;
  20141. /**
  20142. * Sets the state for enabling fog
  20143. */
  20144. /**
  20145. * Gets the value of the fog enabled state
  20146. */
  20147. fogEnabled: boolean;
  20148. /**
  20149. * Stores the size of points
  20150. */
  20151. pointSize: number;
  20152. /**
  20153. * Stores the z offset value
  20154. */
  20155. zOffset: number;
  20156. /**
  20157. * Gets a value specifying if wireframe mode is enabled
  20158. */
  20159. /**
  20160. * Sets the state of wireframe mode
  20161. */
  20162. wireframe: boolean;
  20163. /**
  20164. * Gets the value specifying if point clouds are enabled
  20165. */
  20166. /**
  20167. * Sets the state of point cloud mode
  20168. */
  20169. pointsCloud: boolean;
  20170. /**
  20171. * Gets the material fill mode
  20172. */
  20173. /**
  20174. * Sets the material fill mode
  20175. */
  20176. fillMode: number;
  20177. /**
  20178. * @hidden
  20179. * Stores the effects for the material
  20180. */ effect: Nullable<Effect>;
  20181. /**
  20182. * @hidden
  20183. * Specifies if the material was previously ready
  20184. */ wasPreviouslyReady: boolean;
  20185. /**
  20186. * Specifies if uniform buffers should be used
  20187. */
  20188. private _useUBO;
  20189. /**
  20190. * Stores a reference to the scene
  20191. */
  20192. private _scene;
  20193. /**
  20194. * Stores the fill mode state
  20195. */
  20196. private _fillMode;
  20197. /**
  20198. * Specifies if the depth write state should be cached
  20199. */
  20200. private _cachedDepthWriteState;
  20201. /**
  20202. * Stores the uniform buffer
  20203. */
  20204. protected _uniformBuffer: UniformBuffer;
  20205. /** @hidden */ indexInSceneMaterialArray: number;
  20206. /** @hidden */
  20207. meshMap: Nullable<{
  20208. [id: string]: AbstractMesh | undefined;
  20209. }>;
  20210. /**
  20211. * Creates a material instance
  20212. * @param name defines the name of the material
  20213. * @param scene defines the scene to reference
  20214. * @param doNotAdd specifies if the material should be added to the scene
  20215. */
  20216. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20217. /**
  20218. * Returns a string representation of the current material
  20219. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20220. * @returns a string with material information
  20221. */
  20222. toString(fullDetails?: boolean): string;
  20223. /**
  20224. * Gets the class name of the material
  20225. * @returns a string with the class name of the material
  20226. */
  20227. getClassName(): string;
  20228. /**
  20229. * Specifies if updates for the material been locked
  20230. */
  20231. readonly isFrozen: boolean;
  20232. /**
  20233. * Locks updates for the material
  20234. */
  20235. freeze(): void;
  20236. /**
  20237. * Unlocks updates for the material
  20238. */
  20239. unfreeze(): void;
  20240. /**
  20241. * Specifies if the material is ready to be used
  20242. * @param mesh defines the mesh to check
  20243. * @param useInstances specifies if instances should be used
  20244. * @returns a boolean indicating if the material is ready to be used
  20245. */
  20246. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20247. /**
  20248. * Specifies that the submesh is ready to be used
  20249. * @param mesh defines the mesh to check
  20250. * @param subMesh defines which submesh to check
  20251. * @param useInstances specifies that instances should be used
  20252. * @returns a boolean indicating that the submesh is ready or not
  20253. */
  20254. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20255. /**
  20256. * Returns the material effect
  20257. * @returns the effect associated with the material
  20258. */
  20259. getEffect(): Nullable<Effect>;
  20260. /**
  20261. * Returns the current scene
  20262. * @returns a Scene
  20263. */
  20264. getScene(): Scene;
  20265. /**
  20266. * Specifies if the material will require alpha blending
  20267. * @returns a boolean specifying if alpha blending is needed
  20268. */
  20269. needAlphaBlending(): boolean;
  20270. /**
  20271. * Specifies if the mesh will require alpha blending
  20272. * @param mesh defines the mesh to check
  20273. * @returns a boolean specifying if alpha blending is needed for the mesh
  20274. */
  20275. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20276. /**
  20277. * Specifies if this material should be rendered in alpha test mode
  20278. * @returns a boolean specifying if an alpha test is needed.
  20279. */
  20280. needAlphaTesting(): boolean;
  20281. /**
  20282. * Gets the texture used for the alpha test
  20283. * @returns the texture to use for alpha testing
  20284. */
  20285. getAlphaTestTexture(): Nullable<BaseTexture>;
  20286. /**
  20287. * Marks the material to indicate that it needs to be re-calculated
  20288. */
  20289. markDirty(): void;
  20290. /** @hidden */ preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20291. /**
  20292. * Binds the material to the mesh
  20293. * @param world defines the world transformation matrix
  20294. * @param mesh defines the mesh to bind the material to
  20295. */
  20296. bind(world: Matrix, mesh?: Mesh): void;
  20297. /**
  20298. * Binds the submesh to the material
  20299. * @param world defines the world transformation matrix
  20300. * @param mesh defines the mesh containing the submesh
  20301. * @param subMesh defines the submesh to bind the material to
  20302. */
  20303. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20304. /**
  20305. * Binds the world matrix to the material
  20306. * @param world defines the world transformation matrix
  20307. */
  20308. bindOnlyWorldMatrix(world: Matrix): void;
  20309. /**
  20310. * Binds the scene's uniform buffer to the effect.
  20311. * @param effect defines the effect to bind to the scene uniform buffer
  20312. * @param sceneUbo defines the uniform buffer storing scene data
  20313. */
  20314. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20315. /**
  20316. * Binds the view matrix to the effect
  20317. * @param effect defines the effect to bind the view matrix to
  20318. */
  20319. bindView(effect: Effect): void;
  20320. /**
  20321. * Binds the view projection matrix to the effect
  20322. * @param effect defines the effect to bind the view projection matrix to
  20323. */
  20324. bindViewProjection(effect: Effect): void;
  20325. /**
  20326. * Specifies if material alpha testing should be turned on for the mesh
  20327. * @param mesh defines the mesh to check
  20328. */
  20329. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20330. /**
  20331. * Processes to execute after binding the material to a mesh
  20332. * @param mesh defines the rendered mesh
  20333. */
  20334. protected _afterBind(mesh?: Mesh): void;
  20335. /**
  20336. * Unbinds the material from the mesh
  20337. */
  20338. unbind(): void;
  20339. /**
  20340. * Gets the active textures from the material
  20341. * @returns an array of textures
  20342. */
  20343. getActiveTextures(): BaseTexture[];
  20344. /**
  20345. * Specifies if the material uses a texture
  20346. * @param texture defines the texture to check against the material
  20347. * @returns a boolean specifying if the material uses the texture
  20348. */
  20349. hasTexture(texture: BaseTexture): boolean;
  20350. /**
  20351. * Makes a duplicate of the material, and gives it a new name
  20352. * @param name defines the new name for the duplicated material
  20353. * @returns the cloned material
  20354. */
  20355. clone(name: string): Nullable<Material>;
  20356. /**
  20357. * Gets the meshes bound to the material
  20358. * @returns an array of meshes bound to the material
  20359. */
  20360. getBindedMeshes(): AbstractMesh[];
  20361. /**
  20362. * Force shader compilation
  20363. * @param mesh defines the mesh associated with this material
  20364. * @param onCompiled defines a function to execute once the material is compiled
  20365. * @param options defines the options to configure the compilation
  20366. */
  20367. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20368. clipPlane: boolean;
  20369. }>): void;
  20370. /**
  20371. * Force shader compilation
  20372. * @param mesh defines the mesh that will use this material
  20373. * @param options defines additional options for compiling the shaders
  20374. * @returns a promise that resolves when the compilation completes
  20375. */
  20376. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20377. clipPlane: boolean;
  20378. }>): Promise<void>;
  20379. private static readonly _ImageProcessingDirtyCallBack;
  20380. private static readonly _TextureDirtyCallBack;
  20381. private static readonly _FresnelDirtyCallBack;
  20382. private static readonly _MiscDirtyCallBack;
  20383. private static readonly _LightsDirtyCallBack;
  20384. private static readonly _AttributeDirtyCallBack;
  20385. private static _FresnelAndMiscDirtyCallBack;
  20386. private static _TextureAndMiscDirtyCallBack;
  20387. private static readonly _DirtyCallbackArray;
  20388. private static readonly _RunDirtyCallBacks;
  20389. /**
  20390. * Marks a define in the material to indicate that it needs to be re-computed
  20391. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20392. */
  20393. markAsDirty(flag: number): void;
  20394. /**
  20395. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20396. * @param func defines a function which checks material defines against the submeshes
  20397. */
  20398. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20399. /**
  20400. * Indicates that image processing needs to be re-calculated for all submeshes
  20401. */
  20402. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20403. /**
  20404. * Indicates that textures need to be re-calculated for all submeshes
  20405. */
  20406. protected _markAllSubMeshesAsTexturesDirty(): void;
  20407. /**
  20408. * Indicates that fresnel needs to be re-calculated for all submeshes
  20409. */
  20410. protected _markAllSubMeshesAsFresnelDirty(): void;
  20411. /**
  20412. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20413. */
  20414. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20415. /**
  20416. * Indicates that lights need to be re-calculated for all submeshes
  20417. */
  20418. protected _markAllSubMeshesAsLightsDirty(): void;
  20419. /**
  20420. * Indicates that attributes need to be re-calculated for all submeshes
  20421. */
  20422. protected _markAllSubMeshesAsAttributesDirty(): void;
  20423. /**
  20424. * Indicates that misc needs to be re-calculated for all submeshes
  20425. */
  20426. protected _markAllSubMeshesAsMiscDirty(): void;
  20427. /**
  20428. * Indicates that textures and misc need to be re-calculated for all submeshes
  20429. */
  20430. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20431. /**
  20432. * Disposes the material
  20433. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20434. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20435. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20436. */
  20437. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20438. /** @hidden */
  20439. private releaseVertexArrayObject;
  20440. /**
  20441. * Serializes this material
  20442. * @returns the serialized material object
  20443. */
  20444. serialize(): any;
  20445. /**
  20446. * Creates a material from parsed material data
  20447. * @param parsedMaterial defines parsed material data
  20448. * @param scene defines the hosting scene
  20449. * @param rootUrl defines the root URL to use to load textures
  20450. * @returns a new material
  20451. */
  20452. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  20453. }
  20454. }
  20455. declare module BABYLON {
  20456. /**
  20457. * Base class for submeshes
  20458. */
  20459. export class BaseSubMesh {
  20460. /** @hidden */ materialDefines: Nullable<MaterialDefines>;
  20461. /** @hidden */ materialEffect: Nullable<Effect>;
  20462. /**
  20463. * Gets associated effect
  20464. */
  20465. readonly effect: Nullable<Effect>;
  20466. /**
  20467. * Sets associated effect (effect used to render this submesh)
  20468. * @param effect defines the effect to associate with
  20469. * @param defines defines the set of defines used to compile this effect
  20470. */
  20471. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20472. }
  20473. /**
  20474. * Defines a subdivision inside a mesh
  20475. */
  20476. export class SubMesh extends BaseSubMesh implements ICullable {
  20477. /** the material index to use */
  20478. materialIndex: number;
  20479. /** vertex index start */
  20480. verticesStart: number;
  20481. /** vertices count */
  20482. verticesCount: number;
  20483. /** index start */
  20484. indexStart: number;
  20485. /** indices count */
  20486. indexCount: number;
  20487. /** @hidden */ linesIndexCount: number;
  20488. private _mesh;
  20489. private _renderingMesh;
  20490. private _boundingInfo;
  20491. private _linesIndexBuffer;
  20492. /** @hidden */ lastColliderWorldVertices: Nullable<Vector3[]>;
  20493. /** @hidden */ trianglePlanes: Plane[];
  20494. /** @hidden */ lastColliderTransformMatrix: Matrix;
  20495. /** @hidden */ renderId: number;
  20496. /** @hidden */ alphaIndex: number;
  20497. /** @hidden */ distanceToCamera: number;
  20498. /** @hidden */ id: number;
  20499. private _currentMaterial;
  20500. /**
  20501. * Add a new submesh to a mesh
  20502. * @param materialIndex defines the material index to use
  20503. * @param verticesStart defines vertex index start
  20504. * @param verticesCount defines vertices count
  20505. * @param indexStart defines index start
  20506. * @param indexCount defines indices count
  20507. * @param mesh defines the parent mesh
  20508. * @param renderingMesh defines an optional rendering mesh
  20509. * @param createBoundingBox defines if bounding box should be created for this submesh
  20510. * @returns the new submesh
  20511. */
  20512. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20513. /**
  20514. * Creates a new submesh
  20515. * @param materialIndex defines the material index to use
  20516. * @param verticesStart defines vertex index start
  20517. * @param verticesCount defines vertices count
  20518. * @param indexStart defines index start
  20519. * @param indexCount defines indices count
  20520. * @param mesh defines the parent mesh
  20521. * @param renderingMesh defines an optional rendering mesh
  20522. * @param createBoundingBox defines if bounding box should be created for this submesh
  20523. */
  20524. constructor(
  20525. /** the material index to use */
  20526. materialIndex: number,
  20527. /** vertex index start */
  20528. verticesStart: number,
  20529. /** vertices count */
  20530. verticesCount: number,
  20531. /** index start */
  20532. indexStart: number,
  20533. /** indices count */
  20534. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20535. /**
  20536. * Returns true if this submesh covers the entire parent mesh
  20537. * @ignorenaming
  20538. */
  20539. readonly IsGlobal: boolean;
  20540. /**
  20541. * Returns the submesh BoudingInfo object
  20542. * @returns current bounding info (or mesh's one if the submesh is global)
  20543. */
  20544. getBoundingInfo(): BoundingInfo;
  20545. /**
  20546. * Sets the submesh BoundingInfo
  20547. * @param boundingInfo defines the new bounding info to use
  20548. * @returns the SubMesh
  20549. */
  20550. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20551. /**
  20552. * Returns the mesh of the current submesh
  20553. * @return the parent mesh
  20554. */
  20555. getMesh(): AbstractMesh;
  20556. /**
  20557. * Returns the rendering mesh of the submesh
  20558. * @returns the rendering mesh (could be different from parent mesh)
  20559. */
  20560. getRenderingMesh(): Mesh;
  20561. /**
  20562. * Returns the submesh material
  20563. * @returns null or the current material
  20564. */
  20565. getMaterial(): Nullable<Material>;
  20566. /**
  20567. * Sets a new updated BoundingInfo object to the submesh
  20568. * @returns the SubMesh
  20569. */
  20570. refreshBoundingInfo(): SubMesh;
  20571. /** @hidden */ checkCollision(collider: Collider): boolean;
  20572. /**
  20573. * Updates the submesh BoundingInfo
  20574. * @param world defines the world matrix to use to update the bounding info
  20575. * @returns the submesh
  20576. */
  20577. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20578. /**
  20579. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20580. * @param frustumPlanes defines the frustum planes
  20581. * @returns true if the submesh is intersecting with the frustum
  20582. */
  20583. isInFrustum(frustumPlanes: Plane[]): boolean;
  20584. /**
  20585. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20586. * @param frustumPlanes defines the frustum planes
  20587. * @returns true if the submesh is inside the frustum
  20588. */
  20589. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20590. /**
  20591. * Renders the submesh
  20592. * @param enableAlphaMode defines if alpha needs to be used
  20593. * @returns the submesh
  20594. */
  20595. render(enableAlphaMode: boolean): SubMesh;
  20596. /**
  20597. * @hidden
  20598. */ getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  20599. /**
  20600. * Checks if the submesh intersects with a ray
  20601. * @param ray defines the ray to test
  20602. * @returns true is the passed ray intersects the submesh bounding box
  20603. */
  20604. canIntersects(ray: Ray): boolean;
  20605. /**
  20606. * Intersects current submesh with a ray
  20607. * @param ray defines the ray to test
  20608. * @param positions defines mesh's positions array
  20609. * @param indices defines mesh's indices array
  20610. * @param fastCheck defines if only bounding info should be used
  20611. * @returns intersection info or null if no intersection
  20612. */
  20613. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  20614. /** @hidden */
  20615. private _intersectLines;
  20616. /** @hidden */
  20617. private _intersectTriangles;
  20618. /** @hidden */ rebuild(): void;
  20619. /**
  20620. * Creates a new submesh from the passed mesh
  20621. * @param newMesh defines the new hosting mesh
  20622. * @param newRenderingMesh defines an optional rendering mesh
  20623. * @returns the new submesh
  20624. */
  20625. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20626. /**
  20627. * Release associated resources
  20628. */
  20629. dispose(): void;
  20630. /**
  20631. * Gets the class name
  20632. * @returns the string "SubMesh".
  20633. */
  20634. getClassName(): string;
  20635. /**
  20636. * Creates a new submesh from indices data
  20637. * @param materialIndex the index of the main mesh material
  20638. * @param startIndex the index where to start the copy in the mesh indices array
  20639. * @param indexCount the number of indices to copy then from the startIndex
  20640. * @param mesh the main mesh to create the submesh from
  20641. * @param renderingMesh the optional rendering mesh
  20642. * @returns a new submesh
  20643. */
  20644. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20645. }
  20646. }
  20647. declare module BABYLON {
  20648. /**
  20649. * Class used to store geometry data (vertex buffers + index buffer)
  20650. */
  20651. export class Geometry implements IGetSetVerticesData {
  20652. /**
  20653. * Gets or sets the ID of the geometry
  20654. */
  20655. id: string;
  20656. /**
  20657. * Gets or sets the unique ID of the geometry
  20658. */
  20659. uniqueId: number;
  20660. /**
  20661. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20662. */
  20663. delayLoadState: number;
  20664. /**
  20665. * Gets the file containing the data to load when running in delay load state
  20666. */
  20667. delayLoadingFile: Nullable<string>;
  20668. /**
  20669. * Callback called when the geometry is updated
  20670. */
  20671. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20672. private _scene;
  20673. private _engine;
  20674. private _meshes;
  20675. private _totalVertices;
  20676. /** @hidden */ indices: IndicesArray;
  20677. /** @hidden */ vertexBuffers: {
  20678. [key: string]: VertexBuffer;
  20679. };
  20680. private _isDisposed;
  20681. private _extend;
  20682. private _boundingBias;
  20683. /** @hidden */ delayInfo: Array<string>;
  20684. private _indexBuffer;
  20685. private _indexBufferIsUpdatable;
  20686. /** @hidden */ boundingInfo: Nullable<BoundingInfo>;
  20687. /** @hidden */ delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20688. /** @hidden */ softwareSkinningFrameId: number;
  20689. private _vertexArrayObjects;
  20690. private _updatable;
  20691. /** @hidden */ positions: Nullable<Vector3[]>;
  20692. /**
  20693. * 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
  20694. */
  20695. /**
  20696. * 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
  20697. */
  20698. boundingBias: Vector2;
  20699. /**
  20700. * Static function used to attach a new empty geometry to a mesh
  20701. * @param mesh defines the mesh to attach the geometry to
  20702. * @returns the new Geometry
  20703. */
  20704. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20705. /**
  20706. * Creates a new geometry
  20707. * @param id defines the unique ID
  20708. * @param scene defines the hosting scene
  20709. * @param vertexData defines the VertexData used to get geometry data
  20710. * @param updatable defines if geometry must be updatable (false by default)
  20711. * @param mesh defines the mesh that will be associated with the geometry
  20712. */
  20713. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20714. /**
  20715. * Gets the current extend of the geometry
  20716. */
  20717. readonly extend: {
  20718. minimum: Vector3;
  20719. maximum: Vector3;
  20720. };
  20721. /**
  20722. * Gets the hosting scene
  20723. * @returns the hosting Scene
  20724. */
  20725. getScene(): Scene;
  20726. /**
  20727. * Gets the hosting engine
  20728. * @returns the hosting Engine
  20729. */
  20730. getEngine(): Engine;
  20731. /**
  20732. * Defines if the geometry is ready to use
  20733. * @returns true if the geometry is ready to be used
  20734. */
  20735. isReady(): boolean;
  20736. /**
  20737. * Gets a value indicating that the geometry should not be serialized
  20738. */
  20739. readonly doNotSerialize: boolean;
  20740. /** @hidden */ rebuild(): void;
  20741. /**
  20742. * Affects all geometry data in one call
  20743. * @param vertexData defines the geometry data
  20744. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20745. */
  20746. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20747. /**
  20748. * Set specific vertex data
  20749. * @param kind defines the data kind (Position, normal, etc...)
  20750. * @param data defines the vertex data to use
  20751. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20752. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20753. */
  20754. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20755. /**
  20756. * Removes a specific vertex data
  20757. * @param kind defines the data kind (Position, normal, etc...)
  20758. */
  20759. removeVerticesData(kind: string): void;
  20760. /**
  20761. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20762. * @param buffer defines the vertex buffer to use
  20763. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20764. */
  20765. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20766. /**
  20767. * Update a specific vertex buffer
  20768. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  20769. * It will do nothing if the buffer is not updatable
  20770. * @param kind defines the data kind (Position, normal, etc...)
  20771. * @param data defines the data to use
  20772. * @param offset defines the offset in the target buffer where to store the data
  20773. * @param useBytes set to true if the offset is in bytes
  20774. */
  20775. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20776. /**
  20777. * Update a specific vertex buffer
  20778. * This function will create a new buffer if the current one is not updatable
  20779. * @param kind defines the data kind (Position, normal, etc...)
  20780. * @param data defines the data to use
  20781. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20782. */
  20783. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20784. private _updateBoundingInfo;
  20785. /** @hidden */ bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  20786. /**
  20787. * Gets total number of vertices
  20788. * @returns the total number of vertices
  20789. */
  20790. getTotalVertices(): number;
  20791. /**
  20792. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20793. * @param kind defines the data kind (Position, normal, etc...)
  20794. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20795. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20796. * @returns a float array containing vertex data
  20797. */
  20798. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20799. /**
  20800. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20801. * @param kind defines the data kind (Position, normal, etc...)
  20802. * @returns true if the vertex buffer with the specified kind is updatable
  20803. */
  20804. isVertexBufferUpdatable(kind: string): boolean;
  20805. /**
  20806. * Gets a specific vertex buffer
  20807. * @param kind defines the data kind (Position, normal, etc...)
  20808. * @returns a VertexBuffer
  20809. */
  20810. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20811. /**
  20812. * Returns all vertex buffers
  20813. * @return an object holding all vertex buffers indexed by kind
  20814. */
  20815. getVertexBuffers(): Nullable<{
  20816. [key: string]: VertexBuffer;
  20817. }>;
  20818. /**
  20819. * Gets a boolean indicating if specific vertex buffer is present
  20820. * @param kind defines the data kind (Position, normal, etc...)
  20821. * @returns true if data is present
  20822. */
  20823. isVerticesDataPresent(kind: string): boolean;
  20824. /**
  20825. * Gets a list of all attached data kinds (Position, normal, etc...)
  20826. * @returns a list of string containing all kinds
  20827. */
  20828. getVerticesDataKinds(): string[];
  20829. /**
  20830. * Update index buffer
  20831. * @param indices defines the indices to store in the index buffer
  20832. * @param offset defines the offset in the target buffer where to store the data
  20833. */
  20834. updateIndices(indices: IndicesArray, offset?: number): void;
  20835. /**
  20836. * Creates a new index buffer
  20837. * @param indices defines the indices to store in the index buffer
  20838. * @param totalVertices defines the total number of vertices (could be null)
  20839. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20840. */
  20841. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  20842. /**
  20843. * Return the total number of indices
  20844. * @returns the total number of indices
  20845. */
  20846. getTotalIndices(): number;
  20847. /**
  20848. * Gets the index buffer array
  20849. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20850. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20851. * @returns the index buffer array
  20852. */
  20853. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20854. /**
  20855. * Gets the index buffer
  20856. * @return the index buffer
  20857. */
  20858. getIndexBuffer(): Nullable<WebGLBuffer>;
  20859. /** @hidden */ releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  20860. /**
  20861. * Release the associated resources for a specific mesh
  20862. * @param mesh defines the source mesh
  20863. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  20864. */
  20865. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  20866. /**
  20867. * Apply current geometry to a given mesh
  20868. * @param mesh defines the mesh to apply geometry to
  20869. */
  20870. applyToMesh(mesh: Mesh): void;
  20871. private _updateExtend;
  20872. private _applyToMesh;
  20873. private notifyUpdate;
  20874. /**
  20875. * Load the geometry if it was flagged as delay loaded
  20876. * @param scene defines the hosting scene
  20877. * @param onLoaded defines a callback called when the geometry is loaded
  20878. */
  20879. load(scene: Scene, onLoaded?: () => void): void;
  20880. private _queueLoad;
  20881. /**
  20882. * Invert the geometry to move from a right handed system to a left handed one.
  20883. */
  20884. toLeftHanded(): void;
  20885. /** @hidden */ resetPointsArrayCache(): void;
  20886. /** @hidden */ generatePointsArray(): boolean;
  20887. /**
  20888. * Gets a value indicating if the geometry is disposed
  20889. * @returns true if the geometry was disposed
  20890. */
  20891. isDisposed(): boolean;
  20892. private _disposeVertexArrayObjects;
  20893. /**
  20894. * Free all associated resources
  20895. */
  20896. dispose(): void;
  20897. /**
  20898. * Clone the current geometry into a new geometry
  20899. * @param id defines the unique ID of the new geometry
  20900. * @returns a new geometry object
  20901. */
  20902. copy(id: string): Geometry;
  20903. /**
  20904. * Serialize the current geometry info (and not the vertices data) into a JSON object
  20905. * @return a JSON representation of the current geometry data (without the vertices data)
  20906. */
  20907. serialize(): any;
  20908. private toNumberArray;
  20909. /**
  20910. * Serialize all vertices data into a JSON oject
  20911. * @returns a JSON representation of the current geometry data
  20912. */
  20913. serializeVerticeData(): any;
  20914. /**
  20915. * Extracts a clone of a mesh geometry
  20916. * @param mesh defines the source mesh
  20917. * @param id defines the unique ID of the new geometry object
  20918. * @returns the new geometry object
  20919. */
  20920. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  20921. /**
  20922. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  20923. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  20924. * Be aware Math.random() could cause collisions, but:
  20925. * "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"
  20926. * @returns a string containing a new GUID
  20927. */
  20928. static RandomId(): string;
  20929. /** @hidden */ private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  20930. private static _CleanMatricesWeights;
  20931. /**
  20932. * Create a new geometry from persisted data (Using .babylon file format)
  20933. * @param parsedVertexData defines the persisted data
  20934. * @param scene defines the hosting scene
  20935. * @param rootUrl defines the root url to use to load assets (like delayed data)
  20936. * @returns the new geometry object
  20937. */
  20938. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  20939. }
  20940. }
  20941. declare module BABYLON {
  20942. /**
  20943. * Define an interface for all classes that will get and set the data on vertices
  20944. */
  20945. export interface IGetSetVerticesData {
  20946. /**
  20947. * Gets a boolean indicating if specific vertex data is present
  20948. * @param kind defines the vertex data kind to use
  20949. * @returns true is data kind is present
  20950. */
  20951. isVerticesDataPresent(kind: string): boolean;
  20952. /**
  20953. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20954. * @param kind defines the data kind (Position, normal, etc...)
  20955. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20956. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20957. * @returns a float array containing vertex data
  20958. */
  20959. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20960. /**
  20961. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20962. * @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.
  20963. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20964. * @returns the indices array or an empty array if the mesh has no geometry
  20965. */
  20966. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20967. /**
  20968. * Set specific vertex data
  20969. * @param kind defines the data kind (Position, normal, etc...)
  20970. * @param data defines the vertex data to use
  20971. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20972. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20973. */
  20974. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  20975. /**
  20976. * Update a specific associated vertex buffer
  20977. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20978. * - VertexBuffer.PositionKind
  20979. * - VertexBuffer.UVKind
  20980. * - VertexBuffer.UV2Kind
  20981. * - VertexBuffer.UV3Kind
  20982. * - VertexBuffer.UV4Kind
  20983. * - VertexBuffer.UV5Kind
  20984. * - VertexBuffer.UV6Kind
  20985. * - VertexBuffer.ColorKind
  20986. * - VertexBuffer.MatricesIndicesKind
  20987. * - VertexBuffer.MatricesIndicesExtraKind
  20988. * - VertexBuffer.MatricesWeightsKind
  20989. * - VertexBuffer.MatricesWeightsExtraKind
  20990. * @param data defines the data source
  20991. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20992. * @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)
  20993. */
  20994. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  20995. /**
  20996. * Creates a new index buffer
  20997. * @param indices defines the indices to store in the index buffer
  20998. * @param totalVertices defines the total number of vertices (could be null)
  20999. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21000. */
  21001. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21002. }
  21003. /**
  21004. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21005. */
  21006. export class VertexData {
  21007. /**
  21008. * Mesh side orientation : usually the external or front surface
  21009. */
  21010. static readonly FRONTSIDE: number;
  21011. /**
  21012. * Mesh side orientation : usually the internal or back surface
  21013. */
  21014. static readonly BACKSIDE: number;
  21015. /**
  21016. * Mesh side orientation : both internal and external or front and back surfaces
  21017. */
  21018. static readonly DOUBLESIDE: number;
  21019. /**
  21020. * Mesh side orientation : by default, `FRONTSIDE`
  21021. */
  21022. static readonly DEFAULTSIDE: number;
  21023. /**
  21024. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21025. */
  21026. positions: Nullable<FloatArray>;
  21027. /**
  21028. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21029. */
  21030. normals: Nullable<FloatArray>;
  21031. /**
  21032. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21033. */
  21034. tangents: Nullable<FloatArray>;
  21035. /**
  21036. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21037. */
  21038. uvs: Nullable<FloatArray>;
  21039. /**
  21040. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21041. */
  21042. uvs2: Nullable<FloatArray>;
  21043. /**
  21044. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21045. */
  21046. uvs3: Nullable<FloatArray>;
  21047. /**
  21048. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21049. */
  21050. uvs4: Nullable<FloatArray>;
  21051. /**
  21052. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21053. */
  21054. uvs5: Nullable<FloatArray>;
  21055. /**
  21056. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21057. */
  21058. uvs6: Nullable<FloatArray>;
  21059. /**
  21060. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21061. */
  21062. colors: Nullable<FloatArray>;
  21063. /**
  21064. * 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).
  21065. */
  21066. matricesIndices: Nullable<FloatArray>;
  21067. /**
  21068. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21069. */
  21070. matricesWeights: Nullable<FloatArray>;
  21071. /**
  21072. * An array extending the number of possible indices
  21073. */
  21074. matricesIndicesExtra: Nullable<FloatArray>;
  21075. /**
  21076. * An array extending the number of possible weights when the number of indices is extended
  21077. */
  21078. matricesWeightsExtra: Nullable<FloatArray>;
  21079. /**
  21080. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21081. */
  21082. indices: Nullable<IndicesArray>;
  21083. /**
  21084. * Uses the passed data array to set the set the values for the specified kind of data
  21085. * @param data a linear array of floating numbers
  21086. * @param kind the type of data that is being set, eg positions, colors etc
  21087. */
  21088. set(data: FloatArray, kind: string): void;
  21089. /**
  21090. * Associates the vertexData to the passed Mesh.
  21091. * Sets it as updatable or not (default `false`)
  21092. * @param mesh the mesh the vertexData is applied to
  21093. * @param updatable when used and having the value true allows new data to update the vertexData
  21094. * @returns the VertexData
  21095. */
  21096. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21097. /**
  21098. * Associates the vertexData to the passed Geometry.
  21099. * Sets it as updatable or not (default `false`)
  21100. * @param geometry the geometry the vertexData is applied to
  21101. * @param updatable when used and having the value true allows new data to update the vertexData
  21102. * @returns VertexData
  21103. */
  21104. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21105. /**
  21106. * Updates the associated mesh
  21107. * @param mesh the mesh to be updated
  21108. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21109. * @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
  21110. * @returns VertexData
  21111. */
  21112. updateMesh(mesh: Mesh): VertexData;
  21113. /**
  21114. * Updates the associated geometry
  21115. * @param geometry the geometry to be updated
  21116. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21117. * @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
  21118. * @returns VertexData.
  21119. */
  21120. updateGeometry(geometry: Geometry): VertexData;
  21121. private _applyTo;
  21122. private _update;
  21123. /**
  21124. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21125. * @param matrix the transforming matrix
  21126. * @returns the VertexData
  21127. */
  21128. transform(matrix: Matrix): VertexData;
  21129. /**
  21130. * Merges the passed VertexData into the current one
  21131. * @param other the VertexData to be merged into the current one
  21132. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21133. * @returns the modified VertexData
  21134. */
  21135. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21136. private _mergeElement;
  21137. private _validate;
  21138. /**
  21139. * Serializes the VertexData
  21140. * @returns a serialized object
  21141. */
  21142. serialize(): any;
  21143. /**
  21144. * Extracts the vertexData from a mesh
  21145. * @param mesh the mesh from which to extract the VertexData
  21146. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21147. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21148. * @returns the object VertexData associated to the passed mesh
  21149. */
  21150. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21151. /**
  21152. * Extracts the vertexData from the geometry
  21153. * @param geometry the geometry from which to extract the VertexData
  21154. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21155. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21156. * @returns the object VertexData associated to the passed mesh
  21157. */
  21158. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21159. private static _ExtractFrom;
  21160. /**
  21161. * Creates the VertexData for a Ribbon
  21162. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21163. * * pathArray array of paths, each of which an array of successive Vector3
  21164. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21165. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21166. * * 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
  21167. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21168. * * 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)
  21169. * * 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)
  21170. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21171. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21172. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21173. * @returns the VertexData of the ribbon
  21174. */
  21175. static CreateRibbon(options: {
  21176. pathArray: Vector3[][];
  21177. closeArray?: boolean;
  21178. closePath?: boolean;
  21179. offset?: number;
  21180. sideOrientation?: number;
  21181. frontUVs?: Vector4;
  21182. backUVs?: Vector4;
  21183. invertUV?: boolean;
  21184. uvs?: Vector2[];
  21185. colors?: Color4[];
  21186. }): VertexData;
  21187. /**
  21188. * Creates the VertexData for a box
  21189. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21190. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21191. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21192. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21193. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21194. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21195. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21196. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21197. * * 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)
  21198. * * 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)
  21199. * @returns the VertexData of the box
  21200. */
  21201. static CreateBox(options: {
  21202. size?: number;
  21203. width?: number;
  21204. height?: number;
  21205. depth?: number;
  21206. faceUV?: Vector4[];
  21207. faceColors?: Color4[];
  21208. sideOrientation?: number;
  21209. frontUVs?: Vector4;
  21210. backUVs?: Vector4;
  21211. }): VertexData;
  21212. /**
  21213. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21214. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21215. * * segments sets the number of horizontal strips optional, default 32
  21216. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21217. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21218. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21219. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21220. * * 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
  21221. * * 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
  21222. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21223. * * 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)
  21224. * * 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)
  21225. * @returns the VertexData of the ellipsoid
  21226. */
  21227. static CreateSphere(options: {
  21228. segments?: number;
  21229. diameter?: number;
  21230. diameterX?: number;
  21231. diameterY?: number;
  21232. diameterZ?: number;
  21233. arc?: number;
  21234. slice?: number;
  21235. sideOrientation?: number;
  21236. frontUVs?: Vector4;
  21237. backUVs?: Vector4;
  21238. }): VertexData;
  21239. /**
  21240. * Creates the VertexData for a cylinder, cone or prism
  21241. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21242. * * height sets the height (y direction) of the cylinder, optional, default 2
  21243. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21244. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21245. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21246. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21247. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21248. * * 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
  21249. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21250. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21251. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21252. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21253. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21254. * * 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)
  21255. * * 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)
  21256. * @returns the VertexData of the cylinder, cone or prism
  21257. */
  21258. static CreateCylinder(options: {
  21259. height?: number;
  21260. diameterTop?: number;
  21261. diameterBottom?: number;
  21262. diameter?: number;
  21263. tessellation?: number;
  21264. subdivisions?: number;
  21265. arc?: number;
  21266. faceColors?: Color4[];
  21267. faceUV?: Vector4[];
  21268. hasRings?: boolean;
  21269. enclose?: boolean;
  21270. sideOrientation?: number;
  21271. frontUVs?: Vector4;
  21272. backUVs?: Vector4;
  21273. }): VertexData;
  21274. /**
  21275. * Creates the VertexData for a torus
  21276. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21277. * * diameter the diameter of the torus, optional default 1
  21278. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21279. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21280. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21281. * * 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)
  21282. * * 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)
  21283. * @returns the VertexData of the torus
  21284. */
  21285. static CreateTorus(options: {
  21286. diameter?: number;
  21287. thickness?: number;
  21288. tessellation?: number;
  21289. sideOrientation?: number;
  21290. frontUVs?: Vector4;
  21291. backUVs?: Vector4;
  21292. }): VertexData;
  21293. /**
  21294. * Creates the VertexData of the LineSystem
  21295. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21296. * - lines an array of lines, each line being an array of successive Vector3
  21297. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21298. * @returns the VertexData of the LineSystem
  21299. */
  21300. static CreateLineSystem(options: {
  21301. lines: Vector3[][];
  21302. colors?: Nullable<Color4[][]>;
  21303. }): VertexData;
  21304. /**
  21305. * Create the VertexData for a DashedLines
  21306. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21307. * - points an array successive Vector3
  21308. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21309. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21310. * - dashNb the intended total number of dashes, optional, default 200
  21311. * @returns the VertexData for the DashedLines
  21312. */
  21313. static CreateDashedLines(options: {
  21314. points: Vector3[];
  21315. dashSize?: number;
  21316. gapSize?: number;
  21317. dashNb?: number;
  21318. }): VertexData;
  21319. /**
  21320. * Creates the VertexData for a Ground
  21321. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21322. * - width the width (x direction) of the ground, optional, default 1
  21323. * - height the height (z direction) of the ground, optional, default 1
  21324. * - subdivisions the number of subdivisions per side, optional, default 1
  21325. * @returns the VertexData of the Ground
  21326. */
  21327. static CreateGround(options: {
  21328. width?: number;
  21329. height?: number;
  21330. subdivisions?: number;
  21331. subdivisionsX?: number;
  21332. subdivisionsY?: number;
  21333. }): VertexData;
  21334. /**
  21335. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21336. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21337. * * xmin the ground minimum X coordinate, optional, default -1
  21338. * * zmin the ground minimum Z coordinate, optional, default -1
  21339. * * xmax the ground maximum X coordinate, optional, default 1
  21340. * * zmax the ground maximum Z coordinate, optional, default 1
  21341. * * 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}
  21342. * * 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}
  21343. * @returns the VertexData of the TiledGround
  21344. */
  21345. static CreateTiledGround(options: {
  21346. xmin: number;
  21347. zmin: number;
  21348. xmax: number;
  21349. zmax: number;
  21350. subdivisions?: {
  21351. w: number;
  21352. h: number;
  21353. };
  21354. precision?: {
  21355. w: number;
  21356. h: number;
  21357. };
  21358. }): VertexData;
  21359. /**
  21360. * Creates the VertexData of the Ground designed from a heightmap
  21361. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21362. * * width the width (x direction) of the ground
  21363. * * height the height (z direction) of the ground
  21364. * * subdivisions the number of subdivisions per side
  21365. * * minHeight the minimum altitude on the ground, optional, default 0
  21366. * * maxHeight the maximum altitude on the ground, optional default 1
  21367. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21368. * * buffer the array holding the image color data
  21369. * * bufferWidth the width of image
  21370. * * bufferHeight the height of image
  21371. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21372. * @returns the VertexData of the Ground designed from a heightmap
  21373. */
  21374. static CreateGroundFromHeightMap(options: {
  21375. width: number;
  21376. height: number;
  21377. subdivisions: number;
  21378. minHeight: number;
  21379. maxHeight: number;
  21380. colorFilter: Color3;
  21381. buffer: Uint8Array;
  21382. bufferWidth: number;
  21383. bufferHeight: number;
  21384. alphaFilter: number;
  21385. }): VertexData;
  21386. /**
  21387. * Creates the VertexData for a Plane
  21388. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21389. * * size sets the width and height of the plane to the value of size, optional default 1
  21390. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21391. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21392. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21393. * * 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)
  21394. * * 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)
  21395. * @returns the VertexData of the box
  21396. */
  21397. static CreatePlane(options: {
  21398. size?: number;
  21399. width?: number;
  21400. height?: number;
  21401. sideOrientation?: number;
  21402. frontUVs?: Vector4;
  21403. backUVs?: Vector4;
  21404. }): VertexData;
  21405. /**
  21406. * Creates the VertexData of the Disc or regular Polygon
  21407. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21408. * * radius the radius of the disc, optional default 0.5
  21409. * * tessellation the number of polygon sides, optional, default 64
  21410. * * 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
  21411. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21412. * * 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)
  21413. * * 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)
  21414. * @returns the VertexData of the box
  21415. */
  21416. static CreateDisc(options: {
  21417. radius?: number;
  21418. tessellation?: number;
  21419. arc?: number;
  21420. sideOrientation?: number;
  21421. frontUVs?: Vector4;
  21422. backUVs?: Vector4;
  21423. }): VertexData;
  21424. /**
  21425. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21426. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21427. * @param polygon a mesh built from polygonTriangulation.build()
  21428. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21429. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21430. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21431. * @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)
  21432. * @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)
  21433. * @returns the VertexData of the Polygon
  21434. */
  21435. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21436. /**
  21437. * Creates the VertexData of the IcoSphere
  21438. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21439. * * radius the radius of the IcoSphere, optional default 1
  21440. * * radiusX allows stretching in the x direction, optional, default radius
  21441. * * radiusY allows stretching in the y direction, optional, default radius
  21442. * * radiusZ allows stretching in the z direction, optional, default radius
  21443. * * flat when true creates a flat shaded mesh, optional, default true
  21444. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21445. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21446. * * 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)
  21447. * * 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)
  21448. * @returns the VertexData of the IcoSphere
  21449. */
  21450. static CreateIcoSphere(options: {
  21451. radius?: number;
  21452. radiusX?: number;
  21453. radiusY?: number;
  21454. radiusZ?: number;
  21455. flat?: boolean;
  21456. subdivisions?: number;
  21457. sideOrientation?: number;
  21458. frontUVs?: Vector4;
  21459. backUVs?: Vector4;
  21460. }): VertexData;
  21461. /**
  21462. * Creates the VertexData for a Polyhedron
  21463. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21464. * * type provided types are:
  21465. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21466. * * 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)
  21467. * * size the size of the IcoSphere, optional default 1
  21468. * * sizeX allows stretching in the x direction, optional, default size
  21469. * * sizeY allows stretching in the y direction, optional, default size
  21470. * * sizeZ allows stretching in the z direction, optional, default size
  21471. * * 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
  21472. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21473. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21474. * * flat when true creates a flat shaded mesh, optional, default true
  21475. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21476. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21477. * * 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)
  21478. * * 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)
  21479. * @returns the VertexData of the Polyhedron
  21480. */
  21481. static CreatePolyhedron(options: {
  21482. type?: number;
  21483. size?: number;
  21484. sizeX?: number;
  21485. sizeY?: number;
  21486. sizeZ?: number;
  21487. custom?: any;
  21488. faceUV?: Vector4[];
  21489. faceColors?: Color4[];
  21490. flat?: boolean;
  21491. sideOrientation?: number;
  21492. frontUVs?: Vector4;
  21493. backUVs?: Vector4;
  21494. }): VertexData;
  21495. /**
  21496. * Creates the VertexData for a TorusKnot
  21497. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21498. * * radius the radius of the torus knot, optional, default 2
  21499. * * tube the thickness of the tube, optional, default 0.5
  21500. * * radialSegments the number of sides on each tube segments, optional, default 32
  21501. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21502. * * p the number of windings around the z axis, optional, default 2
  21503. * * q the number of windings around the x axis, optional, default 3
  21504. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21505. * * 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)
  21506. * * 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)
  21507. * @returns the VertexData of the Torus Knot
  21508. */
  21509. static CreateTorusKnot(options: {
  21510. radius?: number;
  21511. tube?: number;
  21512. radialSegments?: number;
  21513. tubularSegments?: number;
  21514. p?: number;
  21515. q?: number;
  21516. sideOrientation?: number;
  21517. frontUVs?: Vector4;
  21518. backUVs?: Vector4;
  21519. }): VertexData;
  21520. /**
  21521. * Compute normals for given positions and indices
  21522. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21523. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21524. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21525. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21526. * * facetNormals : optional array of facet normals (vector3)
  21527. * * facetPositions : optional array of facet positions (vector3)
  21528. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21529. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21530. * * bInfo : optional bounding info, required for facetPartitioning computation
  21531. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21532. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21533. * * useRightHandedSystem: optional boolean to for right handed system computation
  21534. * * depthSort : optional boolean to enable the facet depth sort computation
  21535. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21536. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21537. */
  21538. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21539. facetNormals?: any;
  21540. facetPositions?: any;
  21541. facetPartitioning?: any;
  21542. ratio?: number;
  21543. bInfo?: any;
  21544. bbSize?: Vector3;
  21545. subDiv?: any;
  21546. useRightHandedSystem?: boolean;
  21547. depthSort?: boolean;
  21548. distanceTo?: Vector3;
  21549. depthSortedFacets?: any;
  21550. }): void;
  21551. /** @hidden */ private static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21552. /**
  21553. * Applies VertexData created from the imported parameters to the geometry
  21554. * @param parsedVertexData the parsed data from an imported file
  21555. * @param geometry the geometry to apply the VertexData to
  21556. */
  21557. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21558. }
  21559. }
  21560. declare module BABYLON {
  21561. /**
  21562. * Class containing static functions to help procedurally build meshes
  21563. */
  21564. export class DiscBuilder {
  21565. /**
  21566. * Creates a plane polygonal mesh. By default, this is a disc
  21567. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  21568. * * 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
  21569. * * 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
  21570. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21571. * * 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
  21572. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21573. * @param name defines the name of the mesh
  21574. * @param options defines the options used to create the mesh
  21575. * @param scene defines the hosting scene
  21576. * @returns the plane polygonal mesh
  21577. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  21578. */
  21579. static CreateDisc(name: string, options: {
  21580. radius?: number;
  21581. tessellation?: number;
  21582. arc?: number;
  21583. updatable?: boolean;
  21584. sideOrientation?: number;
  21585. frontUVs?: Vector4;
  21586. backUVs?: Vector4;
  21587. }, scene?: Nullable<Scene>): Mesh;
  21588. }
  21589. }
  21590. declare module BABYLON {
  21591. /**
  21592. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  21593. *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.
  21594. * The SPS is also a particle system. It provides some methods to manage the particles.
  21595. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  21596. *
  21597. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  21598. */
  21599. export class SolidParticleSystem implements IDisposable {
  21600. /**
  21601. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  21602. * Example : var p = SPS.particles[i];
  21603. */
  21604. particles: SolidParticle[];
  21605. /**
  21606. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  21607. */
  21608. nbParticles: number;
  21609. /**
  21610. * If the particles must ever face the camera (default false). Useful for planar particles.
  21611. */
  21612. billboard: boolean;
  21613. /**
  21614. * Recompute normals when adding a shape
  21615. */
  21616. recomputeNormals: boolean;
  21617. /**
  21618. * This a counter ofr your own usage. It's not set by any SPS functions.
  21619. */
  21620. counter: number;
  21621. /**
  21622. * The SPS name. This name is also given to the underlying mesh.
  21623. */
  21624. name: string;
  21625. /**
  21626. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  21627. */
  21628. mesh: Mesh;
  21629. /**
  21630. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  21631. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  21632. */
  21633. vars: any;
  21634. /**
  21635. * This array is populated when the SPS is set as 'pickable'.
  21636. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  21637. * Each element of this array is an object `{idx: int, faceId: int}`.
  21638. * `idx` is the picked particle index in the `SPS.particles` array
  21639. * `faceId` is the picked face index counted within this particle.
  21640. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  21641. */
  21642. pickedParticles: {
  21643. idx: number;
  21644. faceId: number;
  21645. }[];
  21646. /**
  21647. * This array is populated when `enableDepthSort` is set to true.
  21648. * Each element of this array is an instance of the class DepthSortedParticle.
  21649. */
  21650. depthSortedParticles: DepthSortedParticle[];
  21651. /**
  21652. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  21653. * @hidden
  21654. */ bSphereOnly: boolean;
  21655. /**
  21656. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  21657. * @hidden
  21658. */ bSphereRadiusFactor: number;
  21659. private _scene;
  21660. private _positions;
  21661. private _indices;
  21662. private _normals;
  21663. private _colors;
  21664. private _uvs;
  21665. private _indices32;
  21666. private _positions32;
  21667. private _normals32;
  21668. private _fixedNormal32;
  21669. private _colors32;
  21670. private _uvs32;
  21671. private _index;
  21672. private _updatable;
  21673. private _pickable;
  21674. private _isVisibilityBoxLocked;
  21675. private _alwaysVisible;
  21676. private _depthSort;
  21677. private _shapeCounter;
  21678. private _copy;
  21679. private _color;
  21680. private _computeParticleColor;
  21681. private _computeParticleTexture;
  21682. private _computeParticleRotation;
  21683. private _computeParticleVertex;
  21684. private _computeBoundingBox;
  21685. private _depthSortParticles;
  21686. private _camera;
  21687. private _mustUnrotateFixedNormals;
  21688. private _particlesIntersect;
  21689. private _needs32Bits;
  21690. /**
  21691. * Creates a SPS (Solid Particle System) object.
  21692. * @param name (String) is the SPS name, this will be the underlying mesh name.
  21693. * @param scene (Scene) is the scene in which the SPS is added.
  21694. * @param options defines the options of the sps e.g.
  21695. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  21696. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  21697. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  21698. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  21699. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  21700. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  21701. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  21702. */
  21703. constructor(name: string, scene: Scene, options?: {
  21704. updatable?: boolean;
  21705. isPickable?: boolean;
  21706. enableDepthSort?: boolean;
  21707. particleIntersection?: boolean;
  21708. boundingSphereOnly?: boolean;
  21709. bSphereRadiusFactor?: number;
  21710. });
  21711. /**
  21712. * Builds the SPS underlying mesh. Returns a standard Mesh.
  21713. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  21714. * @returns the created mesh
  21715. */
  21716. buildMesh(): Mesh;
  21717. /**
  21718. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  21719. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  21720. * Thus the particles generated from `digest()` have their property `position` set yet.
  21721. * @param mesh ( Mesh ) is the mesh to be digested
  21722. * @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
  21723. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  21724. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  21725. * @returns the current SPS
  21726. */
  21727. digest(mesh: Mesh, options?: {
  21728. facetNb?: number;
  21729. number?: number;
  21730. delta?: number;
  21731. }): SolidParticleSystem;
  21732. private _unrotateFixedNormals;
  21733. private _resetCopy;
  21734. private _meshBuilder;
  21735. private _posToShape;
  21736. private _uvsToShapeUV;
  21737. private _addParticle;
  21738. /**
  21739. * Adds some particles to the SPS from the model shape. Returns the shape id.
  21740. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  21741. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  21742. * @param nb (positive integer) the number of particles to be created from this model
  21743. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  21744. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  21745. * @returns the number of shapes in the system
  21746. */
  21747. addShape(mesh: Mesh, nb: number, options?: {
  21748. positionFunction?: any;
  21749. vertexFunction?: any;
  21750. }): number;
  21751. private _rebuildParticle;
  21752. /**
  21753. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  21754. * @returns the SPS.
  21755. */
  21756. rebuildMesh(): SolidParticleSystem;
  21757. /**
  21758. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  21759. * This method calls `updateParticle()` for each particle of the SPS.
  21760. * For an animated SPS, it is usually called within the render loop.
  21761. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  21762. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  21763. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  21764. * @returns the SPS.
  21765. */
  21766. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  21767. /**
  21768. * Disposes the SPS.
  21769. */
  21770. dispose(): void;
  21771. /**
  21772. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  21773. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  21774. * @returns the SPS.
  21775. */
  21776. refreshVisibleSize(): SolidParticleSystem;
  21777. /**
  21778. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  21779. * @param size the size (float) of the visibility box
  21780. * note : this doesn't lock the SPS mesh bounding box.
  21781. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  21782. */
  21783. setVisibilityBox(size: number): void;
  21784. /**
  21785. * Gets whether the SPS as always visible or not
  21786. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  21787. */
  21788. /**
  21789. * Sets the SPS as always visible or not
  21790. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  21791. */
  21792. isAlwaysVisible: boolean;
  21793. /**
  21794. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  21795. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  21796. */
  21797. /**
  21798. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  21799. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  21800. */
  21801. isVisibilityBoxLocked: boolean;
  21802. /**
  21803. * Tells to `setParticles()` to compute the particle rotations or not.
  21804. * Default value : true. The SPS is faster when it's set to false.
  21805. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  21806. */
  21807. /**
  21808. * Gets if `setParticles()` computes the particle rotations or not.
  21809. * Default value : true. The SPS is faster when it's set to false.
  21810. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  21811. */
  21812. computeParticleRotation: boolean;
  21813. /**
  21814. * Tells to `setParticles()` to compute the particle colors or not.
  21815. * Default value : true. The SPS is faster when it's set to false.
  21816. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  21817. */
  21818. /**
  21819. * Gets if `setParticles()` computes the particle colors or not.
  21820. * Default value : true. The SPS is faster when it's set to false.
  21821. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  21822. */
  21823. computeParticleColor: boolean;
  21824. /**
  21825. * Gets if `setParticles()` computes the particle textures or not.
  21826. * Default value : true. The SPS is faster when it's set to false.
  21827. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  21828. */
  21829. computeParticleTexture: boolean;
  21830. /**
  21831. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  21832. * Default value : false. The SPS is faster when it's set to false.
  21833. * Note : the particle custom vertex positions aren't stored values.
  21834. */
  21835. /**
  21836. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  21837. * Default value : false. The SPS is faster when it's set to false.
  21838. * Note : the particle custom vertex positions aren't stored values.
  21839. */
  21840. computeParticleVertex: boolean;
  21841. /**
  21842. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  21843. */
  21844. /**
  21845. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  21846. */
  21847. computeBoundingBox: boolean;
  21848. /**
  21849. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  21850. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  21851. * Default : `true`
  21852. */
  21853. /**
  21854. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  21855. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  21856. * Default : `true`
  21857. */
  21858. depthSortParticles: boolean;
  21859. /**
  21860. * This function does nothing. It may be overwritten to set all the particle first values.
  21861. * The SPS doesn't call this function, you may have to call it by your own.
  21862. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  21863. */
  21864. initParticles(): void;
  21865. /**
  21866. * This function does nothing. It may be overwritten to recycle a particle.
  21867. * The SPS doesn't call this function, you may have to call it by your own.
  21868. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  21869. * @param particle The particle to recycle
  21870. * @returns the recycled particle
  21871. */
  21872. recycleParticle(particle: SolidParticle): SolidParticle;
  21873. /**
  21874. * Updates a particle : this function should be overwritten by the user.
  21875. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  21876. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  21877. * @example : just set a particle position or velocity and recycle conditions
  21878. * @param particle The particle to update
  21879. * @returns the updated particle
  21880. */
  21881. updateParticle(particle: SolidParticle): SolidParticle;
  21882. /**
  21883. * Updates a vertex of a particle : it can be overwritten by the user.
  21884. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  21885. * @param particle the current particle
  21886. * @param vertex the current index of the current particle
  21887. * @param pt the index of the current vertex in the particle shape
  21888. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  21889. * @example : just set a vertex particle position
  21890. * @returns the updated vertex
  21891. */
  21892. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  21893. /**
  21894. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  21895. * This does nothing and may be overwritten by the user.
  21896. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  21897. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  21898. * @param update the boolean update value actually passed to setParticles()
  21899. */
  21900. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  21901. /**
  21902. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  21903. * This will be passed three parameters.
  21904. * This does nothing and may be overwritten by the user.
  21905. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  21906. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  21907. * @param update the boolean update value actually passed to setParticles()
  21908. */
  21909. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  21910. }
  21911. }
  21912. declare module BABYLON {
  21913. /**
  21914. * Represents one particle of a solid particle system.
  21915. */
  21916. export class SolidParticle {
  21917. /**
  21918. * particle global index
  21919. */
  21920. idx: number;
  21921. /**
  21922. * The color of the particle
  21923. */
  21924. color: Nullable<Color4>;
  21925. /**
  21926. * The world space position of the particle.
  21927. */
  21928. position: Vector3;
  21929. /**
  21930. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  21931. */
  21932. rotation: Vector3;
  21933. /**
  21934. * The world space rotation quaternion of the particle.
  21935. */
  21936. rotationQuaternion: Nullable<Quaternion>;
  21937. /**
  21938. * The scaling of the particle.
  21939. */
  21940. scaling: Vector3;
  21941. /**
  21942. * The uvs of the particle.
  21943. */
  21944. uvs: Vector4;
  21945. /**
  21946. * The current speed of the particle.
  21947. */
  21948. velocity: Vector3;
  21949. /**
  21950. * The pivot point in the particle local space.
  21951. */
  21952. pivot: Vector3;
  21953. /**
  21954. * Must the particle be translated from its pivot point in its local space ?
  21955. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  21956. * Default : false
  21957. */
  21958. translateFromPivot: boolean;
  21959. /**
  21960. * Is the particle active or not ?
  21961. */
  21962. alive: boolean;
  21963. /**
  21964. * Is the particle visible or not ?
  21965. */
  21966. isVisible: boolean;
  21967. /**
  21968. * Index of this particle in the global "positions" array (Internal use)
  21969. * @hidden
  21970. */ pos: number;
  21971. /**
  21972. * @hidden Index of this particle in the global "indices" array (Internal use)
  21973. */ ind: number;
  21974. /**
  21975. * @hidden ModelShape of this particle (Internal use)
  21976. */ model: ModelShape;
  21977. /**
  21978. * ModelShape id of this particle
  21979. */
  21980. shapeId: number;
  21981. /**
  21982. * Index of the particle in its shape id (Internal use)
  21983. */
  21984. idxInShape: number;
  21985. /**
  21986. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  21987. */ modelBoundingInfo: BoundingInfo;
  21988. /**
  21989. * @hidden Particle BoundingInfo object (Internal use)
  21990. */ boundingInfo: BoundingInfo;
  21991. /**
  21992. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  21993. */ sps: SolidParticleSystem;
  21994. /**
  21995. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  21996. */ stillInvisible: boolean;
  21997. /**
  21998. * @hidden Last computed particle rotation matrix
  21999. */ rotationMatrix: number[];
  22000. /**
  22001. * Parent particle Id, if any.
  22002. * Default null.
  22003. */
  22004. parentId: Nullable<number>;
  22005. /**
  22006. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  22007. * The possible values are :
  22008. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  22009. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  22010. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  22011. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  22012. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  22013. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  22014. * */
  22015. cullingStrategy: number;
  22016. /**
  22017. * @hidden Internal global position in the SPS.
  22018. */ globalPosition: Vector3;
  22019. /**
  22020. * Creates a Solid Particle object.
  22021. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  22022. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  22023. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  22024. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  22025. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  22026. * @param shapeId (integer) is the model shape identifier in the SPS.
  22027. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  22028. * @param sps defines the sps it is associated to
  22029. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  22030. */
  22031. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  22032. /**
  22033. * Legacy support, changed scale to scaling
  22034. */
  22035. /**
  22036. * Legacy support, changed scale to scaling
  22037. */
  22038. scale: Vector3;
  22039. /**
  22040. * Legacy support, changed quaternion to rotationQuaternion
  22041. */
  22042. /**
  22043. * Legacy support, changed quaternion to rotationQuaternion
  22044. */
  22045. quaternion: Nullable<Quaternion>;
  22046. /**
  22047. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  22048. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  22049. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  22050. * @returns true if it intersects
  22051. */
  22052. intersectsMesh(target: Mesh | SolidParticle): boolean;
  22053. /**
  22054. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  22055. * A particle is in the frustum if its bounding box intersects the frustum
  22056. * @param frustumPlanes defines the frustum to test
  22057. * @returns true if the particle is in the frustum planes
  22058. */
  22059. isInFrustum(frustumPlanes: Plane[]): boolean;
  22060. /**
  22061. * get the rotation matrix of the particle
  22062. * @hidden
  22063. */
  22064. getRotationMatrix(m: Matrix): void;
  22065. }
  22066. /**
  22067. * Represents the shape of the model used by one particle of a solid particle system.
  22068. * SPS internal tool, don't use it manually.
  22069. */
  22070. export class ModelShape {
  22071. /**
  22072. * The shape id
  22073. * @hidden
  22074. */
  22075. shapeID: number;
  22076. /**
  22077. * flat array of model positions (internal use)
  22078. * @hidden
  22079. */ shape: Vector3[];
  22080. /**
  22081. * flat array of model UVs (internal use)
  22082. * @hidden
  22083. */ shapeUV: number[];
  22084. /**
  22085. * length of the shape in the model indices array (internal use)
  22086. * @hidden
  22087. */ indicesLength: number;
  22088. /**
  22089. * Custom position function (internal use)
  22090. * @hidden
  22091. */ positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  22092. /**
  22093. * Custom vertex function (internal use)
  22094. * @hidden
  22095. */ vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  22096. /**
  22097. * 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.
  22098. * SPS internal tool, don't use it manually.
  22099. * @hidden
  22100. */
  22101. 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>);
  22102. }
  22103. /**
  22104. * Represents a Depth Sorted Particle in the solid particle system.
  22105. */
  22106. export class DepthSortedParticle {
  22107. /**
  22108. * Index of the particle in the "indices" array
  22109. */
  22110. ind: number;
  22111. /**
  22112. * Length of the particle shape in the "indices" array
  22113. */
  22114. indicesLength: number;
  22115. /**
  22116. * Squared distance from the particle to the camera
  22117. */
  22118. sqDistance: number;
  22119. }
  22120. }
  22121. declare module BABYLON {
  22122. /**
  22123. * Class used to store all common mesh properties
  22124. */
  22125. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  22126. /** No occlusion */
  22127. static OCCLUSION_TYPE_NONE: number;
  22128. /** Occlusion set to optimisitic */
  22129. static OCCLUSION_TYPE_OPTIMISTIC: number;
  22130. /** Occlusion set to strict */
  22131. static OCCLUSION_TYPE_STRICT: number;
  22132. /** Use an accurante occlusion algorithm */
  22133. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  22134. /** Use a conservative occlusion algorithm */
  22135. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  22136. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  22137. * Test order :
  22138. * Is the bounding sphere outside the frustum ?
  22139. * If not, are the bounding box vertices outside the frustum ?
  22140. * It not, then the cullable object is in the frustum.
  22141. */
  22142. static readonly CULLINGSTRATEGY_STANDARD: number;
  22143. /** Culling strategy : Bounding Sphere Only.
  22144. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  22145. * It's also less accurate than the standard because some not visible objects can still be selected.
  22146. * Test : is the bounding sphere outside the frustum ?
  22147. * If not, then the cullable object is in the frustum.
  22148. */
  22149. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  22150. /** Culling strategy : Optimistic Inclusion.
  22151. * This in an inclusion test first, then the standard exclusion test.
  22152. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  22153. * 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.
  22154. * Anyway, it's as accurate as the standard strategy.
  22155. * Test :
  22156. * Is the cullable object bounding sphere center in the frustum ?
  22157. * If not, apply the default culling strategy.
  22158. */
  22159. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  22160. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  22161. * This in an inclusion test first, then the bounding sphere only exclusion test.
  22162. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  22163. * 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.
  22164. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  22165. * Test :
  22166. * Is the cullable object bounding sphere center in the frustum ?
  22167. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  22168. */
  22169. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  22170. /**
  22171. * No billboard
  22172. */
  22173. static readonly BILLBOARDMODE_NONE: number;
  22174. /** Billboard on X axis */
  22175. static readonly BILLBOARDMODE_X: number;
  22176. /** Billboard on Y axis */
  22177. static readonly BILLBOARDMODE_Y: number;
  22178. /** Billboard on Z axis */
  22179. static readonly BILLBOARDMODE_Z: number;
  22180. /** Billboard on all axes */
  22181. static readonly BILLBOARDMODE_ALL: number;
  22182. private _facetData;
  22183. /**
  22184. * The culling strategy to use to check whether the mesh must be rendered or not.
  22185. * This value can be changed at any time and will be used on the next render mesh selection.
  22186. * The possible values are :
  22187. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  22188. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  22189. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  22190. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  22191. * Please read each static variable documentation to get details about the culling process.
  22192. * */
  22193. cullingStrategy: number;
  22194. /**
  22195. * Gets the number of facets in the mesh
  22196. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  22197. */
  22198. readonly facetNb: number;
  22199. /**
  22200. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  22201. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  22202. */
  22203. partitioningSubdivisions: number;
  22204. /**
  22205. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  22206. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  22207. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  22208. */
  22209. partitioningBBoxRatio: number;
  22210. /**
  22211. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  22212. * Works only for updatable meshes.
  22213. * Doesn't work with multi-materials
  22214. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  22215. */
  22216. mustDepthSortFacets: boolean;
  22217. /**
  22218. * The location (Vector3) where the facet depth sort must be computed from.
  22219. * By default, the active camera position.
  22220. * Used only when facet depth sort is enabled
  22221. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  22222. */
  22223. facetDepthSortFrom: Vector3;
  22224. /**
  22225. * gets a boolean indicating if facetData is enabled
  22226. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  22227. */
  22228. readonly isFacetDataEnabled: boolean;
  22229. /** @hidden */ updateNonUniformScalingState(value: boolean): boolean;
  22230. /**
  22231. * An event triggered when this mesh collides with another one
  22232. */
  22233. onCollideObservable: Observable<AbstractMesh>;
  22234. private _onCollideObserver;
  22235. /** Set a function to call when this mesh collides with another one */
  22236. onCollide: () => void;
  22237. /**
  22238. * An event triggered when the collision's position changes
  22239. */
  22240. onCollisionPositionChangeObservable: Observable<Vector3>;
  22241. private _onCollisionPositionChangeObserver;
  22242. /** Set a function to call when the collision's position changes */
  22243. onCollisionPositionChange: () => void;
  22244. /**
  22245. * An event triggered when material is changed
  22246. */
  22247. onMaterialChangedObservable: Observable<AbstractMesh>;
  22248. /**
  22249. * Gets or sets the orientation for POV movement & rotation
  22250. */
  22251. definedFacingForward: boolean;
  22252. /** @hidden */ occlusionQuery: Nullable<WebGLQuery>;
  22253. private _visibility;
  22254. /**
  22255. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  22256. */
  22257. /**
  22258. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  22259. */
  22260. visibility: number;
  22261. /** Gets or sets the alpha index used to sort transparent meshes
  22262. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  22263. */
  22264. alphaIndex: number;
  22265. /**
  22266. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  22267. */
  22268. isVisible: boolean;
  22269. /**
  22270. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  22271. */
  22272. isPickable: boolean;
  22273. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  22274. showSubMeshesBoundingBox: boolean;
  22275. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  22276. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  22277. */
  22278. isBlocker: boolean;
  22279. /**
  22280. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  22281. */
  22282. enablePointerMoveEvents: boolean;
  22283. /**
  22284. * Specifies the rendering group id for this mesh (0 by default)
  22285. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  22286. */
  22287. renderingGroupId: number;
  22288. private _material;
  22289. /** Gets or sets current material */
  22290. material: Nullable<Material>;
  22291. private _receiveShadows;
  22292. /**
  22293. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  22294. * @see http://doc.babylonjs.com/babylon101/shadows
  22295. */
  22296. receiveShadows: boolean;
  22297. /** Defines color to use when rendering outline */
  22298. outlineColor: Color3;
  22299. /** Define width to use when rendering outline */
  22300. outlineWidth: number;
  22301. /** Defines color to use when rendering overlay */
  22302. overlayColor: Color3;
  22303. /** Defines alpha to use when rendering overlay */
  22304. overlayAlpha: number;
  22305. private _hasVertexAlpha;
  22306. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  22307. hasVertexAlpha: boolean;
  22308. private _useVertexColors;
  22309. /** 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) */
  22310. useVertexColors: boolean;
  22311. private _computeBonesUsingShaders;
  22312. /**
  22313. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  22314. */
  22315. computeBonesUsingShaders: boolean;
  22316. private _numBoneInfluencers;
  22317. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  22318. numBoneInfluencers: number;
  22319. private _applyFog;
  22320. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  22321. applyFog: boolean;
  22322. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  22323. useOctreeForRenderingSelection: boolean;
  22324. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  22325. useOctreeForPicking: boolean;
  22326. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  22327. useOctreeForCollisions: boolean;
  22328. private _layerMask;
  22329. /**
  22330. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  22331. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  22332. */
  22333. layerMask: number;
  22334. /**
  22335. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  22336. */
  22337. alwaysSelectAsActiveMesh: boolean;
  22338. /**
  22339. * Gets or sets the current action manager
  22340. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  22341. */
  22342. actionManager: Nullable<AbstractActionManager>;
  22343. private _checkCollisions;
  22344. private _collisionMask;
  22345. private _collisionGroup;
  22346. /**
  22347. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  22348. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  22349. */
  22350. ellipsoid: Vector3;
  22351. /**
  22352. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  22353. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  22354. */
  22355. ellipsoidOffset: Vector3;
  22356. private _collider;
  22357. private _oldPositionForCollisions;
  22358. private _diffPositionForCollisions;
  22359. /**
  22360. * Gets or sets a collision mask used to mask collisions (default is -1).
  22361. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  22362. */
  22363. collisionMask: number;
  22364. /**
  22365. * Gets or sets the current collision group mask (-1 by default).
  22366. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  22367. */
  22368. collisionGroup: number;
  22369. /**
  22370. * Defines edge width used when edgesRenderer is enabled
  22371. * @see https://www.babylonjs-playground.com/#10OJSG#13
  22372. */
  22373. edgesWidth: number;
  22374. /**
  22375. * Defines edge color used when edgesRenderer is enabled
  22376. * @see https://www.babylonjs-playground.com/#10OJSG#13
  22377. */
  22378. edgesColor: Color4;
  22379. /** @hidden */ edgesRenderer: Nullable<IEdgesRenderer>;
  22380. /** @hidden */ masterMesh: Nullable<AbstractMesh>;
  22381. /** @hidden */ boundingInfo: Nullable<BoundingInfo>;
  22382. /** @hidden */ renderId: number;
  22383. /**
  22384. * Gets or sets the list of subMeshes
  22385. * @see http://doc.babylonjs.com/how_to/multi_materials
  22386. */
  22387. subMeshes: SubMesh[];
  22388. /** @hidden */ intersectionsInProgress: AbstractMesh[];
  22389. /** @hidden */ unIndexed: boolean;
  22390. /** @hidden */ lightSources: Light[];
  22391. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  22392. /** @hidden */ waitingActions: any;
  22393. /** @hidden */ waitingFreezeWorldMatrix: Nullable<boolean>;
  22394. private _skeleton;
  22395. /** @hidden */ bonesTransformMatrices: Nullable<Float32Array>;
  22396. /**
  22397. * Gets or sets a skeleton to apply skining transformations
  22398. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  22399. */
  22400. skeleton: Nullable<Skeleton>;
  22401. /**
  22402. * An event triggered when the mesh is rebuilt.
  22403. */
  22404. onRebuildObservable: Observable<AbstractMesh>;
  22405. /**
  22406. * Creates a new AbstractMesh
  22407. * @param name defines the name of the mesh
  22408. * @param scene defines the hosting scene
  22409. */
  22410. constructor(name: string, scene?: Nullable<Scene>);
  22411. /**
  22412. * Returns the string "AbstractMesh"
  22413. * @returns "AbstractMesh"
  22414. */
  22415. getClassName(): string;
  22416. /**
  22417. * Gets a string representation of the current mesh
  22418. * @param fullDetails defines a boolean indicating if full details must be included
  22419. * @returns a string representation of the current mesh
  22420. */
  22421. toString(fullDetails?: boolean): string;
  22422. /** @hidden */ rebuild(): void;
  22423. /** @hidden */ resyncLightSources(): void;
  22424. /** @hidden */ resyncLighSource(light: Light): void;
  22425. /** @hidden */ unBindEffect(): void;
  22426. /** @hidden */ removeLightSource(light: Light): void;
  22427. private _markSubMeshesAsDirty;
  22428. /** @hidden */ markSubMeshesAsLightDirty(): void;
  22429. /** @hidden */ markSubMeshesAsAttributesDirty(): void;
  22430. /** @hidden */ markSubMeshesAsMiscDirty(): void;
  22431. /**
  22432. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  22433. */
  22434. scaling: Vector3;
  22435. /**
  22436. * Returns true if the mesh is blocked. Implemented by child classes
  22437. */
  22438. readonly isBlocked: boolean;
  22439. /**
  22440. * Returns the mesh itself by default. Implemented by child classes
  22441. * @param camera defines the camera to use to pick the right LOD level
  22442. * @returns the currentAbstractMesh
  22443. */
  22444. getLOD(camera: Camera): Nullable<AbstractMesh>;
  22445. /**
  22446. * Returns 0 by default. Implemented by child classes
  22447. * @returns an integer
  22448. */
  22449. getTotalVertices(): number;
  22450. /**
  22451. * Returns a positive integer : the total number of indices in this mesh geometry.
  22452. * @returns the numner of indices or zero if the mesh has no geometry.
  22453. */
  22454. getTotalIndices(): number;
  22455. /**
  22456. * Returns null by default. Implemented by child classes
  22457. * @returns null
  22458. */
  22459. getIndices(): Nullable<IndicesArray>;
  22460. /**
  22461. * Returns the array of the requested vertex data kind. Implemented by child classes
  22462. * @param kind defines the vertex data kind to use
  22463. * @returns null
  22464. */
  22465. getVerticesData(kind: string): Nullable<FloatArray>;
  22466. /**
  22467. * Sets the vertex data of the mesh geometry for the requested `kind`.
  22468. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  22469. * Note that a new underlying VertexBuffer object is created each call.
  22470. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  22471. * @param kind defines vertex data kind:
  22472. * * VertexBuffer.PositionKind
  22473. * * VertexBuffer.UVKind
  22474. * * VertexBuffer.UV2Kind
  22475. * * VertexBuffer.UV3Kind
  22476. * * VertexBuffer.UV4Kind
  22477. * * VertexBuffer.UV5Kind
  22478. * * VertexBuffer.UV6Kind
  22479. * * VertexBuffer.ColorKind
  22480. * * VertexBuffer.MatricesIndicesKind
  22481. * * VertexBuffer.MatricesIndicesExtraKind
  22482. * * VertexBuffer.MatricesWeightsKind
  22483. * * VertexBuffer.MatricesWeightsExtraKind
  22484. * @param data defines the data source
  22485. * @param updatable defines if the data must be flagged as updatable (or static)
  22486. * @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
  22487. * @returns the current mesh
  22488. */
  22489. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  22490. /**
  22491. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  22492. * If the mesh has no geometry, it is simply returned as it is.
  22493. * @param kind defines vertex data kind:
  22494. * * VertexBuffer.PositionKind
  22495. * * VertexBuffer.UVKind
  22496. * * VertexBuffer.UV2Kind
  22497. * * VertexBuffer.UV3Kind
  22498. * * VertexBuffer.UV4Kind
  22499. * * VertexBuffer.UV5Kind
  22500. * * VertexBuffer.UV6Kind
  22501. * * VertexBuffer.ColorKind
  22502. * * VertexBuffer.MatricesIndicesKind
  22503. * * VertexBuffer.MatricesIndicesExtraKind
  22504. * * VertexBuffer.MatricesWeightsKind
  22505. * * VertexBuffer.MatricesWeightsExtraKind
  22506. * @param data defines the data source
  22507. * @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
  22508. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  22509. * @returns the current mesh
  22510. */
  22511. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  22512. /**
  22513. * Sets the mesh indices,
  22514. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  22515. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  22516. * @param totalVertices Defines the total number of vertices
  22517. * @returns the current mesh
  22518. */
  22519. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  22520. /**
  22521. * Gets a boolean indicating if specific vertex data is present
  22522. * @param kind defines the vertex data kind to use
  22523. * @returns true is data kind is present
  22524. */
  22525. isVerticesDataPresent(kind: string): boolean;
  22526. /**
  22527. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  22528. * @returns a BoundingInfo
  22529. */
  22530. getBoundingInfo(): BoundingInfo;
  22531. /**
  22532. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  22533. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  22534. * @returns the current mesh
  22535. */
  22536. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  22537. /**
  22538. * Overwrite the current bounding info
  22539. * @param boundingInfo defines the new bounding info
  22540. * @returns the current mesh
  22541. */
  22542. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  22543. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  22544. readonly useBones: boolean;
  22545. /** @hidden */ preActivate(): void;
  22546. /** @hidden */ preActivateForIntermediateRendering(renderId: number): void;
  22547. /** @hidden */ activate(renderId: number): void;
  22548. /**
  22549. * Gets the current world matrix
  22550. * @returns a Matrix
  22551. */
  22552. getWorldMatrix(): Matrix;
  22553. /** @hidden */ getWorldMatrixDeterminant(): number;
  22554. /**
  22555. * Perform relative position change from the point of view of behind the front of the mesh.
  22556. * This is performed taking into account the meshes current rotation, so you do not have to care.
  22557. * Supports definition of mesh facing forward or backward
  22558. * @param amountRight defines the distance on the right axis
  22559. * @param amountUp defines the distance on the up axis
  22560. * @param amountForward defines the distance on the forward axis
  22561. * @returns the current mesh
  22562. */
  22563. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  22564. /**
  22565. * Calculate relative position change from the point of view of behind the front of the mesh.
  22566. * This is performed taking into account the meshes current rotation, so you do not have to care.
  22567. * Supports definition of mesh facing forward or backward
  22568. * @param amountRight defines the distance on the right axis
  22569. * @param amountUp defines the distance on the up axis
  22570. * @param amountForward defines the distance on the forward axis
  22571. * @returns the new displacement vector
  22572. */
  22573. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  22574. /**
  22575. * Perform relative rotation change from the point of view of behind the front of the mesh.
  22576. * Supports definition of mesh facing forward or backward
  22577. * @param flipBack defines the flip
  22578. * @param twirlClockwise defines the twirl
  22579. * @param tiltRight defines the tilt
  22580. * @returns the current mesh
  22581. */
  22582. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  22583. /**
  22584. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  22585. * Supports definition of mesh facing forward or backward.
  22586. * @param flipBack defines the flip
  22587. * @param twirlClockwise defines the twirl
  22588. * @param tiltRight defines the tilt
  22589. * @returns the new rotation vector
  22590. */
  22591. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  22592. /**
  22593. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  22594. * @param includeDescendants Include bounding info from descendants as well (true by default)
  22595. * @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
  22596. * @returns the new bounding vectors
  22597. */
  22598. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  22599. min: Vector3;
  22600. max: Vector3;
  22601. };
  22602. /**
  22603. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  22604. * This means the mesh underlying bounding box and sphere are recomputed.
  22605. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  22606. * @returns the current mesh
  22607. */
  22608. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  22609. /** @hidden */ refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  22610. /** @hidden */ getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  22611. /** @hidden */ updateBoundingInfo(): AbstractMesh;
  22612. /** @hidden */ updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  22613. /** @hidden */
  22614. protected _afterComputeWorldMatrix(): void;
  22615. /**
  22616. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  22617. * A mesh is in the frustum if its bounding box intersects the frustum
  22618. * @param frustumPlanes defines the frustum to test
  22619. * @returns true if the mesh is in the frustum planes
  22620. */
  22621. isInFrustum(frustumPlanes: Plane[]): boolean;
  22622. /**
  22623. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  22624. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  22625. * @param frustumPlanes defines the frustum to test
  22626. * @returns true if the mesh is completely in the frustum planes
  22627. */
  22628. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22629. /**
  22630. * True if the mesh intersects another mesh or a SolidParticle object
  22631. * @param mesh defines a target mesh or SolidParticle to test
  22632. * @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)
  22633. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  22634. * @returns true if there is an intersection
  22635. */
  22636. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  22637. /**
  22638. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  22639. * @param point defines the point to test
  22640. * @returns true if there is an intersection
  22641. */
  22642. intersectsPoint(point: Vector3): boolean;
  22643. /**
  22644. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  22645. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  22646. */
  22647. checkCollisions: boolean;
  22648. /**
  22649. * Gets Collider object used to compute collisions (not physics)
  22650. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  22651. */
  22652. readonly collider: Collider;
  22653. /**
  22654. * Move the mesh using collision engine
  22655. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  22656. * @param displacement defines the requested displacement vector
  22657. * @returns the current mesh
  22658. */
  22659. moveWithCollisions(displacement: Vector3): AbstractMesh;
  22660. private _onCollisionPositionChange;
  22661. /** @hidden */ collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  22662. /** @hidden */ processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  22663. /** @hidden */ checkCollision(collider: Collider): AbstractMesh;
  22664. /** @hidden */ generatePointsArray(): boolean;
  22665. /**
  22666. * Checks if the passed Ray intersects with the mesh
  22667. * @param ray defines the ray to use
  22668. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  22669. * @returns the picking info
  22670. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  22671. */
  22672. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  22673. /**
  22674. * Clones the current mesh
  22675. * @param name defines the mesh name
  22676. * @param newParent defines the new mesh parent
  22677. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  22678. * @returns the new mesh
  22679. */
  22680. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  22681. /**
  22682. * Disposes all the submeshes of the current meshnp
  22683. * @returns the current mesh
  22684. */
  22685. releaseSubMeshes(): AbstractMesh;
  22686. /**
  22687. * Releases resources associated with this abstract mesh.
  22688. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  22689. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  22690. */
  22691. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  22692. /**
  22693. * Adds the passed mesh as a child to the current mesh
  22694. * @param mesh defines the child mesh
  22695. * @returns the current mesh
  22696. */
  22697. addChild(mesh: AbstractMesh): AbstractMesh;
  22698. /**
  22699. * Removes the passed mesh from the current mesh children list
  22700. * @param mesh defines the child mesh
  22701. * @returns the current mesh
  22702. */
  22703. removeChild(mesh: AbstractMesh): AbstractMesh;
  22704. /** @hidden */
  22705. private _initFacetData;
  22706. /**
  22707. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  22708. * This method can be called within the render loop.
  22709. * 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
  22710. * @returns the current mesh
  22711. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22712. */
  22713. updateFacetData(): AbstractMesh;
  22714. /**
  22715. * Returns the facetLocalNormals array.
  22716. * The normals are expressed in the mesh local spac
  22717. * @returns an array of Vector3
  22718. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22719. */
  22720. getFacetLocalNormals(): Vector3[];
  22721. /**
  22722. * Returns the facetLocalPositions array.
  22723. * The facet positions are expressed in the mesh local space
  22724. * @returns an array of Vector3
  22725. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22726. */
  22727. getFacetLocalPositions(): Vector3[];
  22728. /**
  22729. * Returns the facetLocalPartioning array
  22730. * @returns an array of array of numbers
  22731. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22732. */
  22733. getFacetLocalPartitioning(): number[][];
  22734. /**
  22735. * Returns the i-th facet position in the world system.
  22736. * This method allocates a new Vector3 per call
  22737. * @param i defines the facet index
  22738. * @returns a new Vector3
  22739. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22740. */
  22741. getFacetPosition(i: number): Vector3;
  22742. /**
  22743. * Sets the reference Vector3 with the i-th facet position in the world system
  22744. * @param i defines the facet index
  22745. * @param ref defines the target vector
  22746. * @returns the current mesh
  22747. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22748. */
  22749. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  22750. /**
  22751. * Returns the i-th facet normal in the world system.
  22752. * This method allocates a new Vector3 per call
  22753. * @param i defines the facet index
  22754. * @returns a new Vector3
  22755. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22756. */
  22757. getFacetNormal(i: number): Vector3;
  22758. /**
  22759. * Sets the reference Vector3 with the i-th facet normal in the world system
  22760. * @param i defines the facet index
  22761. * @param ref defines the target vector
  22762. * @returns the current mesh
  22763. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22764. */
  22765. getFacetNormalToRef(i: number, ref: Vector3): this;
  22766. /**
  22767. * 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)
  22768. * @param x defines x coordinate
  22769. * @param y defines y coordinate
  22770. * @param z defines z coordinate
  22771. * @returns the array of facet indexes
  22772. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22773. */
  22774. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  22775. /**
  22776. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  22777. * @param projected sets as the (x,y,z) world projection on the facet
  22778. * @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
  22779. * @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
  22780. * @param x defines x coordinate
  22781. * @param y defines y coordinate
  22782. * @param z defines z coordinate
  22783. * @returns the face index if found (or null instead)
  22784. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22785. */
  22786. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  22787. /**
  22788. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  22789. * @param projected sets as the (x,y,z) local projection on the facet
  22790. * @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
  22791. * @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
  22792. * @param x defines x coordinate
  22793. * @param y defines y coordinate
  22794. * @param z defines z coordinate
  22795. * @returns the face index if found (or null instead)
  22796. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22797. */
  22798. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  22799. /**
  22800. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  22801. * @returns the parameters
  22802. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22803. */
  22804. getFacetDataParameters(): any;
  22805. /**
  22806. * Disables the feature FacetData and frees the related memory
  22807. * @returns the current mesh
  22808. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  22809. */
  22810. disableFacetData(): AbstractMesh;
  22811. /**
  22812. * Updates the AbstractMesh indices array
  22813. * @param indices defines the data source
  22814. * @returns the current mesh
  22815. */
  22816. updateIndices(indices: IndicesArray): AbstractMesh;
  22817. /**
  22818. * Creates new normals data for the mesh
  22819. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  22820. * @returns the current mesh
  22821. */
  22822. createNormals(updatable: boolean): AbstractMesh;
  22823. /**
  22824. * Align the mesh with a normal
  22825. * @param normal defines the normal to use
  22826. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  22827. * @returns the current mesh
  22828. */
  22829. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  22830. /** @hidden */ checkOcclusionQuery(): boolean;
  22831. }
  22832. }
  22833. declare module BABYLON {
  22834. /**
  22835. * Class used to handle skinning animations
  22836. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  22837. */
  22838. export class Skeleton implements IAnimatable {
  22839. /** defines the skeleton name */
  22840. name: string;
  22841. /** defines the skeleton Id */
  22842. id: string;
  22843. /**
  22844. * Defines the list of child bones
  22845. */
  22846. bones: Bone[];
  22847. /**
  22848. * Defines an estimate of the dimension of the skeleton at rest
  22849. */
  22850. dimensionsAtRest: Vector3;
  22851. /**
  22852. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  22853. */
  22854. needInitialSkinMatrix: boolean;
  22855. /**
  22856. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  22857. */
  22858. overrideMesh: Nullable<AbstractMesh>;
  22859. /**
  22860. * Gets the list of animations attached to this skeleton
  22861. */
  22862. animations: Array<Animation>;
  22863. private _scene;
  22864. private _isDirty;
  22865. private _transformMatrices;
  22866. private _transformMatrixTexture;
  22867. private _meshesWithPoseMatrix;
  22868. private _animatables;
  22869. private _identity;
  22870. private _synchronizedWithMesh;
  22871. private _ranges;
  22872. private _lastAbsoluteTransformsUpdateId;
  22873. private _canUseTextureForBones;
  22874. /** @hidden */ numBonesWithLinkedTransformNode: number;
  22875. /**
  22876. * Specifies if the skeleton should be serialized
  22877. */
  22878. doNotSerialize: boolean;
  22879. /**
  22880. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  22881. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  22882. */
  22883. useTextureToStoreBoneMatrices: boolean;
  22884. private _animationPropertiesOverride;
  22885. /**
  22886. * Gets or sets the animation properties override
  22887. */
  22888. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22889. /**
  22890. * An observable triggered before computing the skeleton's matrices
  22891. */
  22892. onBeforeComputeObservable: Observable<Skeleton>;
  22893. /**
  22894. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  22895. */
  22896. readonly isUsingTextureForMatrices: boolean;
  22897. /**
  22898. * Creates a new skeleton
  22899. * @param name defines the skeleton name
  22900. * @param id defines the skeleton Id
  22901. * @param scene defines the hosting scene
  22902. */
  22903. constructor(
  22904. /** defines the skeleton name */
  22905. name: string,
  22906. /** defines the skeleton Id */
  22907. id: string, scene: Scene);
  22908. /**
  22909. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  22910. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  22911. * @returns a Float32Array containing matrices data
  22912. */
  22913. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  22914. /**
  22915. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  22916. * @returns a raw texture containing the data
  22917. */
  22918. getTransformMatrixTexture(): Nullable<RawTexture>;
  22919. /**
  22920. * Gets the current hosting scene
  22921. * @returns a scene object
  22922. */
  22923. getScene(): Scene;
  22924. /**
  22925. * Gets a string representing the current skeleton data
  22926. * @param fullDetails defines a boolean indicating if we want a verbose version
  22927. * @returns a string representing the current skeleton data
  22928. */
  22929. toString(fullDetails?: boolean): string;
  22930. /**
  22931. * Get bone's index searching by name
  22932. * @param name defines bone's name to search for
  22933. * @return the indice of the bone. Returns -1 if not found
  22934. */
  22935. getBoneIndexByName(name: string): number;
  22936. /**
  22937. * Creater a new animation range
  22938. * @param name defines the name of the range
  22939. * @param from defines the start key
  22940. * @param to defines the end key
  22941. */
  22942. createAnimationRange(name: string, from: number, to: number): void;
  22943. /**
  22944. * Delete a specific animation range
  22945. * @param name defines the name of the range
  22946. * @param deleteFrames defines if frames must be removed as well
  22947. */
  22948. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  22949. /**
  22950. * Gets a specific animation range
  22951. * @param name defines the name of the range to look for
  22952. * @returns the requested animation range or null if not found
  22953. */
  22954. getAnimationRange(name: string): Nullable<AnimationRange>;
  22955. /**
  22956. * Gets the list of all animation ranges defined on this skeleton
  22957. * @returns an array
  22958. */
  22959. getAnimationRanges(): Nullable<AnimationRange>[];
  22960. /**
  22961. * Copy animation range from a source skeleton.
  22962. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  22963. * @param source defines the source skeleton
  22964. * @param name defines the name of the range to copy
  22965. * @param rescaleAsRequired defines if rescaling must be applied if required
  22966. * @returns true if operation was successful
  22967. */
  22968. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  22969. /**
  22970. * Forces the skeleton to go to rest pose
  22971. */
  22972. returnToRest(): void;
  22973. private _getHighestAnimationFrame;
  22974. /**
  22975. * Begin a specific animation range
  22976. * @param name defines the name of the range to start
  22977. * @param loop defines if looping must be turned on (false by default)
  22978. * @param speedRatio defines the speed ratio to apply (1 by default)
  22979. * @param onAnimationEnd defines a callback which will be called when animation will end
  22980. * @returns a new animatable
  22981. */
  22982. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  22983. /** @hidden */ markAsDirty(): void;
  22984. /** @hidden */ registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  22985. /** @hidden */ unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  22986. private _computeTransformMatrices;
  22987. /**
  22988. * Build all resources required to render a skeleton
  22989. */
  22990. prepare(): void;
  22991. /**
  22992. * Gets the list of animatables currently running for this skeleton
  22993. * @returns an array of animatables
  22994. */
  22995. getAnimatables(): IAnimatable[];
  22996. /**
  22997. * Clone the current skeleton
  22998. * @param name defines the name of the new skeleton
  22999. * @param id defines the id of the enw skeleton
  23000. * @returns the new skeleton
  23001. */
  23002. clone(name: string, id: string): Skeleton;
  23003. /**
  23004. * Enable animation blending for this skeleton
  23005. * @param blendingSpeed defines the blending speed to apply
  23006. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  23007. */
  23008. enableBlending(blendingSpeed?: number): void;
  23009. /**
  23010. * Releases all resources associated with the current skeleton
  23011. */
  23012. dispose(): void;
  23013. /**
  23014. * Serialize the skeleton in a JSON object
  23015. * @returns a JSON object
  23016. */
  23017. serialize(): any;
  23018. /**
  23019. * Creates a new skeleton from serialized data
  23020. * @param parsedSkeleton defines the serialized data
  23021. * @param scene defines the hosting scene
  23022. * @returns a new skeleton
  23023. */
  23024. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  23025. /**
  23026. * Compute all node absolute transforms
  23027. * @param forceUpdate defines if computation must be done even if cache is up to date
  23028. */
  23029. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  23030. /**
  23031. * Gets the root pose matrix
  23032. * @returns a matrix
  23033. */
  23034. getPoseMatrix(): Nullable<Matrix>;
  23035. /**
  23036. * Sorts bones per internal index
  23037. */
  23038. sortBones(): void;
  23039. private _sortBones;
  23040. }
  23041. }
  23042. declare module BABYLON {
  23043. /**
  23044. * Class used to store bone information
  23045. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  23046. */
  23047. export class Bone extends Node {
  23048. /**
  23049. * defines the bone name
  23050. */
  23051. name: string;
  23052. private static _tmpVecs;
  23053. private static _tmpQuat;
  23054. private static _tmpMats;
  23055. /**
  23056. * Gets the list of child bones
  23057. */
  23058. children: Bone[];
  23059. /** Gets the animations associated with this bone */
  23060. animations: Animation[];
  23061. /**
  23062. * Gets or sets bone length
  23063. */
  23064. length: number;
  23065. /**
  23066. * @hidden Internal only
  23067. * Set this value to map this bone to a different index in the transform matrices
  23068. * Set this value to -1 to exclude the bone from the transform matrices
  23069. */ index: Nullable<number>;
  23070. private _skeleton;
  23071. private _localMatrix;
  23072. private _restPose;
  23073. private _baseMatrix;
  23074. private _absoluteTransform;
  23075. private _invertedAbsoluteTransform;
  23076. private _parent;
  23077. private _scalingDeterminant;
  23078. private _worldTransform;
  23079. private _localScaling;
  23080. private _localRotation;
  23081. private _localPosition;
  23082. private _needToDecompose;
  23083. private _needToCompose;
  23084. /** @hidden */ linkedTransformNode: Nullable<TransformNode>;
  23085. /** @hidden */
  23086. /** @hidden */ matrix: Matrix;
  23087. /**
  23088. * Create a new bone
  23089. * @param name defines the bone name
  23090. * @param skeleton defines the parent skeleton
  23091. * @param parentBone defines the parent (can be null if the bone is the root)
  23092. * @param localMatrix defines the local matrix
  23093. * @param restPose defines the rest pose matrix
  23094. * @param baseMatrix defines the base matrix
  23095. * @param index defines index of the bone in the hiearchy
  23096. */
  23097. constructor(
  23098. /**
  23099. * defines the bone name
  23100. */
  23101. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  23102. /**
  23103. * Gets the parent skeleton
  23104. * @returns a skeleton
  23105. */
  23106. getSkeleton(): Skeleton;
  23107. /**
  23108. * Gets parent bone
  23109. * @returns a bone or null if the bone is the root of the bone hierarchy
  23110. */
  23111. getParent(): Nullable<Bone>;
  23112. /**
  23113. * Sets the parent bone
  23114. * @param parent defines the parent (can be null if the bone is the root)
  23115. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  23116. */
  23117. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  23118. /**
  23119. * Gets the local matrix
  23120. * @returns a matrix
  23121. */
  23122. getLocalMatrix(): Matrix;
  23123. /**
  23124. * Gets the base matrix (initial matrix which remains unchanged)
  23125. * @returns a matrix
  23126. */
  23127. getBaseMatrix(): Matrix;
  23128. /**
  23129. * Gets the rest pose matrix
  23130. * @returns a matrix
  23131. */
  23132. getRestPose(): Matrix;
  23133. /**
  23134. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  23135. */
  23136. getWorldMatrix(): Matrix;
  23137. /**
  23138. * Sets the local matrix to rest pose matrix
  23139. */
  23140. returnToRest(): void;
  23141. /**
  23142. * Gets the inverse of the absolute transform matrix.
  23143. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  23144. * @returns a matrix
  23145. */
  23146. getInvertedAbsoluteTransform(): Matrix;
  23147. /**
  23148. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  23149. * @returns a matrix
  23150. */
  23151. getAbsoluteTransform(): Matrix;
  23152. /**
  23153. * Links with the given transform node.
  23154. * The local matrix of this bone is copied from the transform node every frame.
  23155. * @param transformNode defines the transform node to link to
  23156. */
  23157. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  23158. /** Gets or sets current position (in local space) */
  23159. position: Vector3;
  23160. /** Gets or sets current rotation (in local space) */
  23161. rotation: Vector3;
  23162. /** Gets or sets current rotation quaternion (in local space) */
  23163. rotationQuaternion: Quaternion;
  23164. /** Gets or sets current scaling (in local space) */
  23165. scaling: Vector3;
  23166. /**
  23167. * Gets the animation properties override
  23168. */
  23169. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  23170. private _decompose;
  23171. private _compose;
  23172. /**
  23173. * Update the base and local matrices
  23174. * @param matrix defines the new base or local matrix
  23175. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  23176. * @param updateLocalMatrix defines if the local matrix should be updated
  23177. */
  23178. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  23179. /** @hidden */ updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  23180. /**
  23181. * Flag the bone as dirty (Forcing it to update everything)
  23182. */
  23183. markAsDirty(): void;
  23184. private _markAsDirtyAndCompose;
  23185. private _markAsDirtyAndDecompose;
  23186. /**
  23187. * Translate the bone in local or world space
  23188. * @param vec The amount to translate the bone
  23189. * @param space The space that the translation is in
  23190. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23191. */
  23192. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  23193. /**
  23194. * Set the postion of the bone in local or world space
  23195. * @param position The position to set the bone
  23196. * @param space The space that the position is in
  23197. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23198. */
  23199. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  23200. /**
  23201. * Set the absolute position of the bone (world space)
  23202. * @param position The position to set the bone
  23203. * @param mesh The mesh that this bone is attached to
  23204. */
  23205. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  23206. /**
  23207. * Scale the bone on the x, y and z axes (in local space)
  23208. * @param x The amount to scale the bone on the x axis
  23209. * @param y The amount to scale the bone on the y axis
  23210. * @param z The amount to scale the bone on the z axis
  23211. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  23212. */
  23213. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  23214. /**
  23215. * Set the bone scaling in local space
  23216. * @param scale defines the scaling vector
  23217. */
  23218. setScale(scale: Vector3): void;
  23219. /**
  23220. * Gets the current scaling in local space
  23221. * @returns the current scaling vector
  23222. */
  23223. getScale(): Vector3;
  23224. /**
  23225. * Gets the current scaling in local space and stores it in a target vector
  23226. * @param result defines the target vector
  23227. */
  23228. getScaleToRef(result: Vector3): void;
  23229. /**
  23230. * Set the yaw, pitch, and roll of the bone in local or world space
  23231. * @param yaw The rotation of the bone on the y axis
  23232. * @param pitch The rotation of the bone on the x axis
  23233. * @param roll The rotation of the bone on the z axis
  23234. * @param space The space that the axes of rotation are in
  23235. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23236. */
  23237. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  23238. /**
  23239. * Add a rotation to the bone on an axis in local or world space
  23240. * @param axis The axis to rotate the bone on
  23241. * @param amount The amount to rotate the bone
  23242. * @param space The space that the axis is in
  23243. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23244. */
  23245. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  23246. /**
  23247. * Set the rotation of the bone to a particular axis angle in local or world space
  23248. * @param axis The axis to rotate the bone on
  23249. * @param angle The angle that the bone should be rotated to
  23250. * @param space The space that the axis is in
  23251. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23252. */
  23253. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  23254. /**
  23255. * Set the euler rotation of the bone in local of world space
  23256. * @param rotation The euler rotation that the bone should be set to
  23257. * @param space The space that the rotation is in
  23258. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23259. */
  23260. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  23261. /**
  23262. * Set the quaternion rotation of the bone in local of world space
  23263. * @param quat The quaternion rotation that the bone should be set to
  23264. * @param space The space that the rotation is in
  23265. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23266. */
  23267. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  23268. /**
  23269. * Set the rotation matrix of the bone in local of world space
  23270. * @param rotMat The rotation matrix that the bone should be set to
  23271. * @param space The space that the rotation is in
  23272. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23273. */
  23274. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  23275. private _rotateWithMatrix;
  23276. private _getNegativeRotationToRef;
  23277. /**
  23278. * Get the position of the bone in local or world space
  23279. * @param space The space that the returned position is in
  23280. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23281. * @returns The position of the bone
  23282. */
  23283. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  23284. /**
  23285. * Copy the position of the bone to a vector3 in local or world space
  23286. * @param space The space that the returned position is in
  23287. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23288. * @param result The vector3 to copy the position to
  23289. */
  23290. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  23291. /**
  23292. * Get the absolute position of the bone (world space)
  23293. * @param mesh The mesh that this bone is attached to
  23294. * @returns The absolute position of the bone
  23295. */
  23296. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  23297. /**
  23298. * Copy the absolute position of the bone (world space) to the result param
  23299. * @param mesh The mesh that this bone is attached to
  23300. * @param result The vector3 to copy the absolute position to
  23301. */
  23302. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  23303. /**
  23304. * Compute the absolute transforms of this bone and its children
  23305. */
  23306. computeAbsoluteTransforms(): void;
  23307. /**
  23308. * Get the world direction from an axis that is in the local space of the bone
  23309. * @param localAxis The local direction that is used to compute the world direction
  23310. * @param mesh The mesh that this bone is attached to
  23311. * @returns The world direction
  23312. */
  23313. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  23314. /**
  23315. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  23316. * @param localAxis The local direction that is used to compute the world direction
  23317. * @param mesh The mesh that this bone is attached to
  23318. * @param result The vector3 that the world direction will be copied to
  23319. */
  23320. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  23321. /**
  23322. * Get the euler rotation of the bone in local or world space
  23323. * @param space The space that the rotation should be in
  23324. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23325. * @returns The euler rotation
  23326. */
  23327. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  23328. /**
  23329. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  23330. * @param space The space that the rotation should be in
  23331. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23332. * @param result The vector3 that the rotation should be copied to
  23333. */
  23334. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  23335. /**
  23336. * Get the quaternion rotation of the bone in either local or world space
  23337. * @param space The space that the rotation should be in
  23338. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23339. * @returns The quaternion rotation
  23340. */
  23341. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  23342. /**
  23343. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  23344. * @param space The space that the rotation should be in
  23345. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23346. * @param result The quaternion that the rotation should be copied to
  23347. */
  23348. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  23349. /**
  23350. * Get the rotation matrix of the bone in local or world space
  23351. * @param space The space that the rotation should be in
  23352. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23353. * @returns The rotation matrix
  23354. */
  23355. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  23356. /**
  23357. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  23358. * @param space The space that the rotation should be in
  23359. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23360. * @param result The quaternion that the rotation should be copied to
  23361. */
  23362. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  23363. /**
  23364. * Get the world position of a point that is in the local space of the bone
  23365. * @param position The local position
  23366. * @param mesh The mesh that this bone is attached to
  23367. * @returns The world position
  23368. */
  23369. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  23370. /**
  23371. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  23372. * @param position The local position
  23373. * @param mesh The mesh that this bone is attached to
  23374. * @param result The vector3 that the world position should be copied to
  23375. */
  23376. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  23377. /**
  23378. * Get the local position of a point that is in world space
  23379. * @param position The world position
  23380. * @param mesh The mesh that this bone is attached to
  23381. * @returns The local position
  23382. */
  23383. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  23384. /**
  23385. * Get the local position of a point that is in world space and copy it to the result param
  23386. * @param position The world position
  23387. * @param mesh The mesh that this bone is attached to
  23388. * @param result The vector3 that the local position should be copied to
  23389. */
  23390. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  23391. }
  23392. }
  23393. declare module BABYLON {
  23394. /**
  23395. * Class used to store an actual running animation
  23396. */
  23397. export class Animatable {
  23398. /** defines the target object */
  23399. target: any;
  23400. /** defines the starting frame number (default is 0) */
  23401. fromFrame: number;
  23402. /** defines the ending frame number (default is 100) */
  23403. toFrame: number;
  23404. /** defines if the animation must loop (default is false) */
  23405. loopAnimation: boolean;
  23406. /** defines a callback to call when animation ends if it is not looping */
  23407. onAnimationEnd?: (() => void) | null | undefined;
  23408. /** defines a callback to call when animation loops */
  23409. onAnimationLoop?: (() => void) | null | undefined;
  23410. private _localDelayOffset;
  23411. private _pausedDelay;
  23412. private _runtimeAnimations;
  23413. private _paused;
  23414. private _scene;
  23415. private _speedRatio;
  23416. private _weight;
  23417. private _syncRoot;
  23418. /**
  23419. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  23420. * This will only apply for non looping animation (default is true)
  23421. */
  23422. disposeOnEnd: boolean;
  23423. /**
  23424. * Gets a boolean indicating if the animation has started
  23425. */
  23426. animationStarted: boolean;
  23427. /**
  23428. * Observer raised when the animation ends
  23429. */
  23430. onAnimationEndObservable: Observable<Animatable>;
  23431. /**
  23432. * Observer raised when the animation loops
  23433. */
  23434. onAnimationLoopObservable: Observable<Animatable>;
  23435. /**
  23436. * Gets the root Animatable used to synchronize and normalize animations
  23437. */
  23438. readonly syncRoot: Animatable;
  23439. /**
  23440. * Gets the current frame of the first RuntimeAnimation
  23441. * Used to synchronize Animatables
  23442. */
  23443. readonly masterFrame: number;
  23444. /**
  23445. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  23446. */
  23447. weight: number;
  23448. /**
  23449. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  23450. */
  23451. speedRatio: number;
  23452. /**
  23453. * Creates a new Animatable
  23454. * @param scene defines the hosting scene
  23455. * @param target defines the target object
  23456. * @param fromFrame defines the starting frame number (default is 0)
  23457. * @param toFrame defines the ending frame number (default is 100)
  23458. * @param loopAnimation defines if the animation must loop (default is false)
  23459. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  23460. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  23461. * @param animations defines a group of animation to add to the new Animatable
  23462. * @param onAnimationLoop defines a callback to call when animation loops
  23463. */
  23464. constructor(scene: Scene,
  23465. /** defines the target object */
  23466. target: any,
  23467. /** defines the starting frame number (default is 0) */
  23468. fromFrame?: number,
  23469. /** defines the ending frame number (default is 100) */
  23470. toFrame?: number,
  23471. /** defines if the animation must loop (default is false) */
  23472. loopAnimation?: boolean, speedRatio?: number,
  23473. /** defines a callback to call when animation ends if it is not looping */
  23474. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  23475. /** defines a callback to call when animation loops */
  23476. onAnimationLoop?: (() => void) | null | undefined);
  23477. /**
  23478. * Synchronize and normalize current Animatable with a source Animatable
  23479. * This is useful when using animation weights and when animations are not of the same length
  23480. * @param root defines the root Animatable to synchronize with
  23481. * @returns the current Animatable
  23482. */
  23483. syncWith(root: Animatable): Animatable;
  23484. /**
  23485. * Gets the list of runtime animations
  23486. * @returns an array of RuntimeAnimation
  23487. */
  23488. getAnimations(): RuntimeAnimation[];
  23489. /**
  23490. * Adds more animations to the current animatable
  23491. * @param target defines the target of the animations
  23492. * @param animations defines the new animations to add
  23493. */
  23494. appendAnimations(target: any, animations: Animation[]): void;
  23495. /**
  23496. * Gets the source animation for a specific property
  23497. * @param property defines the propertyu to look for
  23498. * @returns null or the source animation for the given property
  23499. */
  23500. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  23501. /**
  23502. * Gets the runtime animation for a specific property
  23503. * @param property defines the propertyu to look for
  23504. * @returns null or the runtime animation for the given property
  23505. */
  23506. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  23507. /**
  23508. * Resets the animatable to its original state
  23509. */
  23510. reset(): void;
  23511. /**
  23512. * Allows the animatable to blend with current running animations
  23513. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  23514. * @param blendingSpeed defines the blending speed to use
  23515. */
  23516. enableBlending(blendingSpeed: number): void;
  23517. /**
  23518. * Disable animation blending
  23519. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  23520. */
  23521. disableBlending(): void;
  23522. /**
  23523. * Jump directly to a given frame
  23524. * @param frame defines the frame to jump to
  23525. */
  23526. goToFrame(frame: number): void;
  23527. /**
  23528. * Pause the animation
  23529. */
  23530. pause(): void;
  23531. /**
  23532. * Restart the animation
  23533. */
  23534. restart(): void;
  23535. private _raiseOnAnimationEnd;
  23536. /**
  23537. * Stop and delete the current animation
  23538. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  23539. * @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)
  23540. */
  23541. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  23542. /**
  23543. * Wait asynchronously for the animation to end
  23544. * @returns a promise which will be fullfilled when the animation ends
  23545. */
  23546. waitAsync(): Promise<Animatable>;
  23547. /** @hidden */ animate(delay: number): boolean;
  23548. }
  23549. interface Scene {
  23550. /** @hidden */ registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  23551. /** @hidden */ processLateAnimationBindingsForMatrices(holder: {
  23552. totalWeight: number;
  23553. animations: RuntimeAnimation[];
  23554. originalValue: Matrix;
  23555. }): any;
  23556. /** @hidden */ processLateAnimationBindingsForQuaternions(holder: {
  23557. totalWeight: number;
  23558. animations: RuntimeAnimation[];
  23559. originalValue: Quaternion;
  23560. }, refQuaternion: Quaternion): Quaternion;
  23561. /** @hidden */ processLateAnimationBindings(): void;
  23562. /**
  23563. * Will start the animation sequence of a given target
  23564. * @param target defines the target
  23565. * @param from defines from which frame should animation start
  23566. * @param to defines until which frame should animation run.
  23567. * @param weight defines the weight to apply to the animation (1.0 by default)
  23568. * @param loop defines if the animation loops
  23569. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  23570. * @param onAnimationEnd defines the function to be executed when the animation ends
  23571. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  23572. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  23573. * @param onAnimationLoop defines the callback to call when an animation loops
  23574. * @returns the animatable object created for this animation
  23575. */
  23576. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  23577. /**
  23578. * Will start the animation sequence of a given target
  23579. * @param target defines the target
  23580. * @param from defines from which frame should animation start
  23581. * @param to defines until which frame should animation run.
  23582. * @param loop defines if the animation loops
  23583. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  23584. * @param onAnimationEnd defines the function to be executed when the animation ends
  23585. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  23586. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  23587. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  23588. * @param onAnimationLoop defines the callback to call when an animation loops
  23589. * @returns the animatable object created for this animation
  23590. */
  23591. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  23592. /**
  23593. * Will start the animation sequence of a given target and its hierarchy
  23594. * @param target defines the target
  23595. * @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.
  23596. * @param from defines from which frame should animation start
  23597. * @param to defines until which frame should animation run.
  23598. * @param loop defines if the animation loops
  23599. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  23600. * @param onAnimationEnd defines the function to be executed when the animation ends
  23601. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  23602. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  23603. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  23604. * @param onAnimationLoop defines the callback to call when an animation loops
  23605. * @returns the list of created animatables
  23606. */
  23607. 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[];
  23608. /**
  23609. * Begin a new animation on a given node
  23610. * @param target defines the target where the animation will take place
  23611. * @param animations defines the list of animations to start
  23612. * @param from defines the initial value
  23613. * @param to defines the final value
  23614. * @param loop defines if you want animation to loop (off by default)
  23615. * @param speedRatio defines the speed ratio to apply to all animations
  23616. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  23617. * @param onAnimationLoop defines the callback to call when an animation loops
  23618. * @returns the list of created animatables
  23619. */
  23620. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  23621. /**
  23622. * Begin a new animation on a given node and its hierarchy
  23623. * @param target defines the root node where the animation will take place
  23624. * @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.
  23625. * @param animations defines the list of animations to start
  23626. * @param from defines the initial value
  23627. * @param to defines the final value
  23628. * @param loop defines if you want animation to loop (off by default)
  23629. * @param speedRatio defines the speed ratio to apply to all animations
  23630. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  23631. * @param onAnimationLoop defines the callback to call when an animation loops
  23632. * @returns the list of animatables created for all nodes
  23633. */
  23634. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  23635. /**
  23636. * Gets the animatable associated with a specific target
  23637. * @param target defines the target of the animatable
  23638. * @returns the required animatable if found
  23639. */
  23640. getAnimatableByTarget(target: any): Nullable<Animatable>;
  23641. /**
  23642. * Gets all animatables associated with a given target
  23643. * @param target defines the target to look animatables for
  23644. * @returns an array of Animatables
  23645. */
  23646. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  23647. /**
  23648. * Will stop the animation of the given target
  23649. * @param target - the target
  23650. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  23651. * @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)
  23652. */
  23653. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  23654. /**
  23655. * Stops and removes all animations that have been applied to the scene
  23656. */
  23657. stopAllAnimations(): void;
  23658. }
  23659. interface Bone {
  23660. /**
  23661. * Copy an animation range from another bone
  23662. * @param source defines the source bone
  23663. * @param rangeName defines the range name to copy
  23664. * @param frameOffset defines the frame offset
  23665. * @param rescaleAsRequired defines if rescaling must be applied if required
  23666. * @param skelDimensionsRatio defines the scaling ratio
  23667. * @returns true if operation was successful
  23668. */
  23669. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  23670. }
  23671. }
  23672. declare module BABYLON {
  23673. /**
  23674. * Defines how a node can be built from a string name.
  23675. */
  23676. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  23677. /**
  23678. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  23679. */
  23680. export class Node implements IBehaviorAware<Node> {
  23681. /** @hidden */ private static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  23682. private static _NodeConstructors;
  23683. /**
  23684. * Add a new node constructor
  23685. * @param type defines the type name of the node to construct
  23686. * @param constructorFunc defines the constructor function
  23687. */
  23688. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  23689. /**
  23690. * Returns a node constructor based on type name
  23691. * @param type defines the type name
  23692. * @param name defines the new node name
  23693. * @param scene defines the hosting scene
  23694. * @param options defines optional options to transmit to constructors
  23695. * @returns the new constructor or null
  23696. */
  23697. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  23698. /**
  23699. * Gets or sets the name of the node
  23700. */
  23701. name: string;
  23702. /**
  23703. * Gets or sets the id of the node
  23704. */
  23705. id: string;
  23706. /**
  23707. * Gets or sets the unique id of the node
  23708. */
  23709. uniqueId: number;
  23710. /**
  23711. * Gets or sets a string used to store user defined state for the node
  23712. */
  23713. state: string;
  23714. /**
  23715. * Gets or sets an object used to store user defined information for the node
  23716. */
  23717. metadata: any;
  23718. /**
  23719. * For internal use only. Please do not use.
  23720. */
  23721. reservedDataStore: any;
  23722. /**
  23723. * Gets or sets a boolean used to define if the node must be serialized
  23724. */
  23725. doNotSerialize: boolean;
  23726. /** @hidden */ isDisposed: boolean;
  23727. /**
  23728. * Gets a list of Animations associated with the node
  23729. */
  23730. animations: Animation[];
  23731. protected _ranges: {
  23732. [name: string]: Nullable<AnimationRange>;
  23733. };
  23734. /**
  23735. * Callback raised when the node is ready to be used
  23736. */
  23737. onReady: (node: Node) => void;
  23738. private _isEnabled;
  23739. private _isParentEnabled;
  23740. private _isReady;
  23741. /** @hidden */ currentRenderId: number;
  23742. private _parentRenderId;
  23743. protected _childRenderId: number;
  23744. /** @hidden */ waitingParentId: Nullable<string>;
  23745. /** @hidden */ scene: Scene;
  23746. /** @hidden */ cache: any;
  23747. private _parentNode;
  23748. private _children;
  23749. /** @hidden */ worldMatrix: Matrix;
  23750. /** @hidden */ worldMatrixDeterminant: number;
  23751. /** @hidden */
  23752. private _sceneRootNodesIndex;
  23753. /**
  23754. * Gets a boolean indicating if the node has been disposed
  23755. * @returns true if the node was disposed
  23756. */
  23757. isDisposed(): boolean;
  23758. /**
  23759. * Gets or sets the parent of the node
  23760. */
  23761. parent: Nullable<Node>;
  23762. private addToSceneRootNodes;
  23763. private removeFromSceneRootNodes;
  23764. private _animationPropertiesOverride;
  23765. /**
  23766. * Gets or sets the animation properties override
  23767. */
  23768. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  23769. /**
  23770. * Gets a string idenfifying the name of the class
  23771. * @returns "Node" string
  23772. */
  23773. getClassName(): string;
  23774. /** @hidden */ protected readonly _isNode: boolean;
  23775. /**
  23776. * An event triggered when the mesh is disposed
  23777. */
  23778. onDisposeObservable: Observable<Node>;
  23779. private _onDisposeObserver;
  23780. /**
  23781. * Sets a callback that will be raised when the node will be disposed
  23782. */
  23783. onDispose: () => void;
  23784. /**
  23785. * Creates a new Node
  23786. * @param name the name and id to be given to this node
  23787. * @param scene the scene this node will be added to
  23788. * @param addToRootNodes the node will be added to scene.rootNodes
  23789. */
  23790. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  23791. /**
  23792. * Gets the scene of the node
  23793. * @returns a scene
  23794. */
  23795. getScene(): Scene;
  23796. /**
  23797. * Gets the engine of the node
  23798. * @returns a Engine
  23799. */
  23800. getEngine(): Engine;
  23801. private _behaviors;
  23802. /**
  23803. * Attach a behavior to the node
  23804. * @see http://doc.babylonjs.com/features/behaviour
  23805. * @param behavior defines the behavior to attach
  23806. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  23807. * @returns the current Node
  23808. */
  23809. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  23810. /**
  23811. * Remove an attached behavior
  23812. * @see http://doc.babylonjs.com/features/behaviour
  23813. * @param behavior defines the behavior to attach
  23814. * @returns the current Node
  23815. */
  23816. removeBehavior(behavior: Behavior<Node>): Node;
  23817. /**
  23818. * Gets the list of attached behaviors
  23819. * @see http://doc.babylonjs.com/features/behaviour
  23820. */
  23821. readonly behaviors: Behavior<Node>[];
  23822. /**
  23823. * Gets an attached behavior by name
  23824. * @param name defines the name of the behavior to look for
  23825. * @see http://doc.babylonjs.com/features/behaviour
  23826. * @returns null if behavior was not found else the requested behavior
  23827. */
  23828. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  23829. /**
  23830. * Returns the latest update of the World matrix
  23831. * @returns a Matrix
  23832. */
  23833. getWorldMatrix(): Matrix;
  23834. /** @hidden */ getWorldMatrixDeterminant(): number;
  23835. /**
  23836. * Returns directly the latest state of the mesh World matrix.
  23837. * A Matrix is returned.
  23838. */
  23839. readonly worldMatrixFromCache: Matrix;
  23840. /** @hidden */ initCache(): void;
  23841. /** @hidden */
  23842. updateCache(force?: boolean): void;
  23843. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  23844. /** @hidden */ isSynchronized(): boolean;
  23845. /** @hidden */ markSyncedWithParent(): void;
  23846. /** @hidden */
  23847. isSynchronizedWithParent(): boolean;
  23848. /** @hidden */
  23849. isSynchronized(): boolean;
  23850. /**
  23851. * Is this node ready to be used/rendered
  23852. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23853. * @return true if the node is ready
  23854. */
  23855. isReady(completeCheck?: boolean): boolean;
  23856. /**
  23857. * Is this node enabled?
  23858. * 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
  23859. * @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
  23860. * @return whether this node (and its parent) is enabled
  23861. */
  23862. isEnabled(checkAncestors?: boolean): boolean;
  23863. /** @hidden */
  23864. protected _syncParentEnabledState(): void;
  23865. /**
  23866. * Set the enabled state of this node
  23867. * @param value defines the new enabled state
  23868. */
  23869. setEnabled(value: boolean): void;
  23870. /**
  23871. * Is this node a descendant of the given node?
  23872. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  23873. * @param ancestor defines the parent node to inspect
  23874. * @returns a boolean indicating if this node is a descendant of the given node
  23875. */
  23876. isDescendantOf(ancestor: Node): boolean;
  23877. /** @hidden */ getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  23878. /**
  23879. * Will return all nodes that have this node as ascendant
  23880. * @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
  23881. * @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
  23882. * @return all children nodes of all types
  23883. */
  23884. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  23885. /**
  23886. * Get all child-meshes of this node
  23887. * @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
  23888. * @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
  23889. * @returns an array of AbstractMesh
  23890. */
  23891. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  23892. /**
  23893. * Get all direct children of this node
  23894. * @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
  23895. * @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)
  23896. * @returns an array of Node
  23897. */
  23898. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  23899. /** @hidden */ setReady(state: boolean): void;
  23900. /**
  23901. * Get an animation by name
  23902. * @param name defines the name of the animation to look for
  23903. * @returns null if not found else the requested animation
  23904. */
  23905. getAnimationByName(name: string): Nullable<Animation>;
  23906. /**
  23907. * Creates an animation range for this node
  23908. * @param name defines the name of the range
  23909. * @param from defines the starting key
  23910. * @param to defines the end key
  23911. */
  23912. createAnimationRange(name: string, from: number, to: number): void;
  23913. /**
  23914. * Delete a specific animation range
  23915. * @param name defines the name of the range to delete
  23916. * @param deleteFrames defines if animation frames from the range must be deleted as well
  23917. */
  23918. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  23919. /**
  23920. * Get an animation range by name
  23921. * @param name defines the name of the animation range to look for
  23922. * @returns null if not found else the requested animation range
  23923. */
  23924. getAnimationRange(name: string): Nullable<AnimationRange>;
  23925. /**
  23926. * Will start the animation sequence
  23927. * @param name defines the range frames for animation sequence
  23928. * @param loop defines if the animation should loop (false by default)
  23929. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  23930. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  23931. * @returns the object created for this animation. If range does not exist, it will return null
  23932. */
  23933. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  23934. /**
  23935. * Serialize animation ranges into a JSON compatible object
  23936. * @returns serialization object
  23937. */
  23938. serializeAnimationRanges(): any;
  23939. /**
  23940. * Computes the world matrix of the node
  23941. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  23942. * @returns the world matrix
  23943. */
  23944. computeWorldMatrix(force?: boolean): Matrix;
  23945. /**
  23946. * Releases resources associated with this node.
  23947. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23948. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23949. */
  23950. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23951. /**
  23952. * Parse animation range data from a serialization object and store them into a given node
  23953. * @param node defines where to store the animation ranges
  23954. * @param parsedNode defines the serialization object to read data from
  23955. * @param scene defines the hosting scene
  23956. */
  23957. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  23958. }
  23959. }
  23960. declare module BABYLON {
  23961. /**
  23962. * Class used to store any kind of animation
  23963. */
  23964. export class Animation {
  23965. /**Name of the animation */
  23966. name: string;
  23967. /**Property to animate */
  23968. targetProperty: string;
  23969. /**The frames per second of the animation */
  23970. framePerSecond: number;
  23971. /**The data type of the animation */
  23972. dataType: number;
  23973. /**The loop mode of the animation */
  23974. loopMode?: number | undefined;
  23975. /**Specifies if blending should be enabled */
  23976. enableBlending?: boolean | undefined;
  23977. /**
  23978. * Use matrix interpolation instead of using direct key value when animating matrices
  23979. */
  23980. static AllowMatricesInterpolation: boolean;
  23981. /**
  23982. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  23983. */
  23984. static AllowMatrixDecomposeForInterpolation: boolean;
  23985. /**
  23986. * Stores the key frames of the animation
  23987. */
  23988. private _keys;
  23989. /**
  23990. * Stores the easing function of the animation
  23991. */
  23992. private _easingFunction;
  23993. /**
  23994. * @hidden Internal use only
  23995. */ runtimeAnimations: RuntimeAnimation[];
  23996. /**
  23997. * The set of event that will be linked to this animation
  23998. */
  23999. private _events;
  24000. /**
  24001. * Stores an array of target property paths
  24002. */
  24003. targetPropertyPath: string[];
  24004. /**
  24005. * Stores the blending speed of the animation
  24006. */
  24007. blendingSpeed: number;
  24008. /**
  24009. * Stores the animation ranges for the animation
  24010. */
  24011. private _ranges;
  24012. /**
  24013. * @hidden Internal use
  24014. */ private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  24015. /**
  24016. * Sets up an animation
  24017. * @param property The property to animate
  24018. * @param animationType The animation type to apply
  24019. * @param framePerSecond The frames per second of the animation
  24020. * @param easingFunction The easing function used in the animation
  24021. * @returns The created animation
  24022. */
  24023. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  24024. /**
  24025. * Create and start an animation on a node
  24026. * @param name defines the name of the global animation that will be run on all nodes
  24027. * @param node defines the root node where the animation will take place
  24028. * @param targetProperty defines property to animate
  24029. * @param framePerSecond defines the number of frame per second yo use
  24030. * @param totalFrame defines the number of frames in total
  24031. * @param from defines the initial value
  24032. * @param to defines the final value
  24033. * @param loopMode defines which loop mode you want to use (off by default)
  24034. * @param easingFunction defines the easing function to use (linear by default)
  24035. * @param onAnimationEnd defines the callback to call when animation end
  24036. * @returns the animatable created for this animation
  24037. */
  24038. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  24039. /**
  24040. * Create and start an animation on a node and its descendants
  24041. * @param name defines the name of the global animation that will be run on all nodes
  24042. * @param node defines the root node where the animation will take place
  24043. * @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
  24044. * @param targetProperty defines property to animate
  24045. * @param framePerSecond defines the number of frame per second to use
  24046. * @param totalFrame defines the number of frames in total
  24047. * @param from defines the initial value
  24048. * @param to defines the final value
  24049. * @param loopMode defines which loop mode you want to use (off by default)
  24050. * @param easingFunction defines the easing function to use (linear by default)
  24051. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  24052. * @returns the list of animatables created for all nodes
  24053. * @example https://www.babylonjs-playground.com/#MH0VLI
  24054. */
  24055. 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[]>;
  24056. /**
  24057. * Creates a new animation, merges it with the existing animations and starts it
  24058. * @param name Name of the animation
  24059. * @param node Node which contains the scene that begins the animations
  24060. * @param targetProperty Specifies which property to animate
  24061. * @param framePerSecond The frames per second of the animation
  24062. * @param totalFrame The total number of frames
  24063. * @param from The frame at the beginning of the animation
  24064. * @param to The frame at the end of the animation
  24065. * @param loopMode Specifies the loop mode of the animation
  24066. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  24067. * @param onAnimationEnd Callback to run once the animation is complete
  24068. * @returns Nullable animation
  24069. */
  24070. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  24071. /**
  24072. * Transition property of an host to the target Value
  24073. * @param property The property to transition
  24074. * @param targetValue The target Value of the property
  24075. * @param host The object where the property to animate belongs
  24076. * @param scene Scene used to run the animation
  24077. * @param frameRate Framerate (in frame/s) to use
  24078. * @param transition The transition type we want to use
  24079. * @param duration The duration of the animation, in milliseconds
  24080. * @param onAnimationEnd Callback trigger at the end of the animation
  24081. * @returns Nullable animation
  24082. */
  24083. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  24084. /**
  24085. * Return the array of runtime animations currently using this animation
  24086. */
  24087. readonly runtimeAnimations: RuntimeAnimation[];
  24088. /**
  24089. * Specifies if any of the runtime animations are currently running
  24090. */
  24091. readonly hasRunningRuntimeAnimations: boolean;
  24092. /**
  24093. * Initializes the animation
  24094. * @param name Name of the animation
  24095. * @param targetProperty Property to animate
  24096. * @param framePerSecond The frames per second of the animation
  24097. * @param dataType The data type of the animation
  24098. * @param loopMode The loop mode of the animation
  24099. * @param enableBlending Specifies if blending should be enabled
  24100. */
  24101. constructor(
  24102. /**Name of the animation */
  24103. name: string,
  24104. /**Property to animate */
  24105. targetProperty: string,
  24106. /**The frames per second of the animation */
  24107. framePerSecond: number,
  24108. /**The data type of the animation */
  24109. dataType: number,
  24110. /**The loop mode of the animation */
  24111. loopMode?: number | undefined,
  24112. /**Specifies if blending should be enabled */
  24113. enableBlending?: boolean | undefined);
  24114. /**
  24115. * Converts the animation to a string
  24116. * @param fullDetails support for multiple levels of logging within scene loading
  24117. * @returns String form of the animation
  24118. */
  24119. toString(fullDetails?: boolean): string;
  24120. /**
  24121. * Add an event to this animation
  24122. * @param event Event to add
  24123. */
  24124. addEvent(event: AnimationEvent): void;
  24125. /**
  24126. * Remove all events found at the given frame
  24127. * @param frame The frame to remove events from
  24128. */
  24129. removeEvents(frame: number): void;
  24130. /**
  24131. * Retrieves all the events from the animation
  24132. * @returns Events from the animation
  24133. */
  24134. getEvents(): AnimationEvent[];
  24135. /**
  24136. * Creates an animation range
  24137. * @param name Name of the animation range
  24138. * @param from Starting frame of the animation range
  24139. * @param to Ending frame of the animation
  24140. */
  24141. createRange(name: string, from: number, to: number): void;
  24142. /**
  24143. * Deletes an animation range by name
  24144. * @param name Name of the animation range to delete
  24145. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  24146. */
  24147. deleteRange(name: string, deleteFrames?: boolean): void;
  24148. /**
  24149. * Gets the animation range by name, or null if not defined
  24150. * @param name Name of the animation range
  24151. * @returns Nullable animation range
  24152. */
  24153. getRange(name: string): Nullable<AnimationRange>;
  24154. /**
  24155. * Gets the key frames from the animation
  24156. * @returns The key frames of the animation
  24157. */
  24158. getKeys(): Array<IAnimationKey>;
  24159. /**
  24160. * Gets the highest frame rate of the animation
  24161. * @returns Highest frame rate of the animation
  24162. */
  24163. getHighestFrame(): number;
  24164. /**
  24165. * Gets the easing function of the animation
  24166. * @returns Easing function of the animation
  24167. */
  24168. getEasingFunction(): IEasingFunction;
  24169. /**
  24170. * Sets the easing function of the animation
  24171. * @param easingFunction A custom mathematical formula for animation
  24172. */
  24173. setEasingFunction(easingFunction: EasingFunction): void;
  24174. /**
  24175. * Interpolates a scalar linearly
  24176. * @param startValue Start value of the animation curve
  24177. * @param endValue End value of the animation curve
  24178. * @param gradient Scalar amount to interpolate
  24179. * @returns Interpolated scalar value
  24180. */
  24181. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  24182. /**
  24183. * Interpolates a scalar cubically
  24184. * @param startValue Start value of the animation curve
  24185. * @param outTangent End tangent of the animation
  24186. * @param endValue End value of the animation curve
  24187. * @param inTangent Start tangent of the animation curve
  24188. * @param gradient Scalar amount to interpolate
  24189. * @returns Interpolated scalar value
  24190. */
  24191. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  24192. /**
  24193. * Interpolates a quaternion using a spherical linear interpolation
  24194. * @param startValue Start value of the animation curve
  24195. * @param endValue End value of the animation curve
  24196. * @param gradient Scalar amount to interpolate
  24197. * @returns Interpolated quaternion value
  24198. */
  24199. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  24200. /**
  24201. * Interpolates a quaternion cubically
  24202. * @param startValue Start value of the animation curve
  24203. * @param outTangent End tangent of the animation curve
  24204. * @param endValue End value of the animation curve
  24205. * @param inTangent Start tangent of the animation curve
  24206. * @param gradient Scalar amount to interpolate
  24207. * @returns Interpolated quaternion value
  24208. */
  24209. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  24210. /**
  24211. * Interpolates a Vector3 linearl
  24212. * @param startValue Start value of the animation curve
  24213. * @param endValue End value of the animation curve
  24214. * @param gradient Scalar amount to interpolate
  24215. * @returns Interpolated scalar value
  24216. */
  24217. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  24218. /**
  24219. * Interpolates a Vector3 cubically
  24220. * @param startValue Start value of the animation curve
  24221. * @param outTangent End tangent of the animation
  24222. * @param endValue End value of the animation curve
  24223. * @param inTangent Start tangent of the animation curve
  24224. * @param gradient Scalar amount to interpolate
  24225. * @returns InterpolatedVector3 value
  24226. */
  24227. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  24228. /**
  24229. * Interpolates a Vector2 linearly
  24230. * @param startValue Start value of the animation curve
  24231. * @param endValue End value of the animation curve
  24232. * @param gradient Scalar amount to interpolate
  24233. * @returns Interpolated Vector2 value
  24234. */
  24235. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  24236. /**
  24237. * Interpolates a Vector2 cubically
  24238. * @param startValue Start value of the animation curve
  24239. * @param outTangent End tangent of the animation
  24240. * @param endValue End value of the animation curve
  24241. * @param inTangent Start tangent of the animation curve
  24242. * @param gradient Scalar amount to interpolate
  24243. * @returns Interpolated Vector2 value
  24244. */
  24245. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  24246. /**
  24247. * Interpolates a size linearly
  24248. * @param startValue Start value of the animation curve
  24249. * @param endValue End value of the animation curve
  24250. * @param gradient Scalar amount to interpolate
  24251. * @returns Interpolated Size value
  24252. */
  24253. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  24254. /**
  24255. * Interpolates a Color3 linearly
  24256. * @param startValue Start value of the animation curve
  24257. * @param endValue End value of the animation curve
  24258. * @param gradient Scalar amount to interpolate
  24259. * @returns Interpolated Color3 value
  24260. */
  24261. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  24262. /**
  24263. * @hidden Internal use only
  24264. */ getKeyValue(value: any): any;
  24265. /**
  24266. * @hidden Internal use only
  24267. */ interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  24268. /**
  24269. * Defines the function to use to interpolate matrices
  24270. * @param startValue defines the start matrix
  24271. * @param endValue defines the end matrix
  24272. * @param gradient defines the gradient between both matrices
  24273. * @param result defines an optional target matrix where to store the interpolation
  24274. * @returns the interpolated matrix
  24275. */
  24276. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  24277. /**
  24278. * Makes a copy of the animation
  24279. * @returns Cloned animation
  24280. */
  24281. clone(): Animation;
  24282. /**
  24283. * Sets the key frames of the animation
  24284. * @param values The animation key frames to set
  24285. */
  24286. setKeys(values: Array<IAnimationKey>): void;
  24287. /**
  24288. * Serializes the animation to an object
  24289. * @returns Serialized object
  24290. */
  24291. serialize(): any;
  24292. /**
  24293. * Float animation type
  24294. */
  24295. private static _ANIMATIONTYPE_FLOAT;
  24296. /**
  24297. * Vector3 animation type
  24298. */
  24299. private static _ANIMATIONTYPE_VECTOR3;
  24300. /**
  24301. * Quaternion animation type
  24302. */
  24303. private static _ANIMATIONTYPE_QUATERNION;
  24304. /**
  24305. * Matrix animation type
  24306. */
  24307. private static _ANIMATIONTYPE_MATRIX;
  24308. /**
  24309. * Color3 animation type
  24310. */
  24311. private static _ANIMATIONTYPE_COLOR3;
  24312. /**
  24313. * Vector2 animation type
  24314. */
  24315. private static _ANIMATIONTYPE_VECTOR2;
  24316. /**
  24317. * Size animation type
  24318. */
  24319. private static _ANIMATIONTYPE_SIZE;
  24320. /**
  24321. * Relative Loop Mode
  24322. */
  24323. private static _ANIMATIONLOOPMODE_RELATIVE;
  24324. /**
  24325. * Cycle Loop Mode
  24326. */
  24327. private static _ANIMATIONLOOPMODE_CYCLE;
  24328. /**
  24329. * Constant Loop Mode
  24330. */
  24331. private static _ANIMATIONLOOPMODE_CONSTANT;
  24332. /**
  24333. * Get the float animation type
  24334. */
  24335. static readonly ANIMATIONTYPE_FLOAT: number;
  24336. /**
  24337. * Get the Vector3 animation type
  24338. */
  24339. static readonly ANIMATIONTYPE_VECTOR3: number;
  24340. /**
  24341. * Get the Vector2 animation type
  24342. */
  24343. static readonly ANIMATIONTYPE_VECTOR2: number;
  24344. /**
  24345. * Get the Size animation type
  24346. */
  24347. static readonly ANIMATIONTYPE_SIZE: number;
  24348. /**
  24349. * Get the Quaternion animation type
  24350. */
  24351. static readonly ANIMATIONTYPE_QUATERNION: number;
  24352. /**
  24353. * Get the Matrix animation type
  24354. */
  24355. static readonly ANIMATIONTYPE_MATRIX: number;
  24356. /**
  24357. * Get the Color3 animation type
  24358. */
  24359. static readonly ANIMATIONTYPE_COLOR3: number;
  24360. /**
  24361. * Get the Relative Loop Mode
  24362. */
  24363. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  24364. /**
  24365. * Get the Cycle Loop Mode
  24366. */
  24367. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  24368. /**
  24369. * Get the Constant Loop Mode
  24370. */
  24371. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  24372. /** @hidden */ private static _UniversalLerp(left: any, right: any, amount: number): any;
  24373. /**
  24374. * Parses an animation object and creates an animation
  24375. * @param parsedAnimation Parsed animation object
  24376. * @returns Animation object
  24377. */
  24378. static Parse(parsedAnimation: any): Animation;
  24379. /**
  24380. * Appends the serialized animations from the source animations
  24381. * @param source Source containing the animations
  24382. * @param destination Target to store the animations
  24383. */
  24384. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  24385. }
  24386. }
  24387. declare module BABYLON {
  24388. /**
  24389. * Base class of all the textures in babylon.
  24390. * It groups all the common properties the materials, post process, lights... might need
  24391. * in order to make a correct use of the texture.
  24392. */
  24393. export class BaseTexture implements IAnimatable {
  24394. /**
  24395. * Default anisotropic filtering level for the application.
  24396. * It is set to 4 as a good tradeoff between perf and quality.
  24397. */
  24398. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  24399. /**
  24400. * Gets or sets the unique id of the texture
  24401. */
  24402. uniqueId: number;
  24403. /**
  24404. * Define the name of the texture.
  24405. */
  24406. name: string;
  24407. /**
  24408. * Gets or sets an object used to store user defined information.
  24409. */
  24410. metadata: any;
  24411. /**
  24412. * For internal use only. Please do not use.
  24413. */
  24414. reservedDataStore: any;
  24415. private _hasAlpha;
  24416. /**
  24417. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  24418. */
  24419. hasAlpha: boolean;
  24420. /**
  24421. * Defines if the alpha value should be determined via the rgb values.
  24422. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  24423. */
  24424. getAlphaFromRGB: boolean;
  24425. /**
  24426. * Intensity or strength of the texture.
  24427. * It is commonly used by materials to fine tune the intensity of the texture
  24428. */
  24429. level: number;
  24430. /**
  24431. * Define the UV chanel to use starting from 0 and defaulting to 0.
  24432. * This is part of the texture as textures usually maps to one uv set.
  24433. */
  24434. coordinatesIndex: number;
  24435. private _coordinatesMode;
  24436. /**
  24437. * How a texture is mapped.
  24438. *
  24439. * | Value | Type | Description |
  24440. * | ----- | ----------------------------------- | ----------- |
  24441. * | 0 | EXPLICIT_MODE | |
  24442. * | 1 | SPHERICAL_MODE | |
  24443. * | 2 | PLANAR_MODE | |
  24444. * | 3 | CUBIC_MODE | |
  24445. * | 4 | PROJECTION_MODE | |
  24446. * | 5 | SKYBOX_MODE | |
  24447. * | 6 | INVCUBIC_MODE | |
  24448. * | 7 | EQUIRECTANGULAR_MODE | |
  24449. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  24450. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  24451. */
  24452. coordinatesMode: number;
  24453. /**
  24454. * | Value | Type | Description |
  24455. * | ----- | ------------------ | ----------- |
  24456. * | 0 | CLAMP_ADDRESSMODE | |
  24457. * | 1 | WRAP_ADDRESSMODE | |
  24458. * | 2 | MIRROR_ADDRESSMODE | |
  24459. */
  24460. wrapU: number;
  24461. /**
  24462. * | Value | Type | Description |
  24463. * | ----- | ------------------ | ----------- |
  24464. * | 0 | CLAMP_ADDRESSMODE | |
  24465. * | 1 | WRAP_ADDRESSMODE | |
  24466. * | 2 | MIRROR_ADDRESSMODE | |
  24467. */
  24468. wrapV: number;
  24469. /**
  24470. * | Value | Type | Description |
  24471. * | ----- | ------------------ | ----------- |
  24472. * | 0 | CLAMP_ADDRESSMODE | |
  24473. * | 1 | WRAP_ADDRESSMODE | |
  24474. * | 2 | MIRROR_ADDRESSMODE | |
  24475. */
  24476. wrapR: number;
  24477. /**
  24478. * With compliant hardware and browser (supporting anisotropic filtering)
  24479. * this defines the level of anisotropic filtering in the texture.
  24480. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  24481. */
  24482. anisotropicFilteringLevel: number;
  24483. /**
  24484. * Define if the texture is a cube texture or if false a 2d texture.
  24485. */
  24486. isCube: boolean;
  24487. /**
  24488. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  24489. */
  24490. is3D: boolean;
  24491. /**
  24492. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  24493. * HDR texture are usually stored in linear space.
  24494. * This only impacts the PBR and Background materials
  24495. */
  24496. gammaSpace: boolean;
  24497. /**
  24498. * Gets whether or not the texture contains RGBD data.
  24499. */
  24500. readonly isRGBD: boolean;
  24501. /**
  24502. * Is Z inverted in the texture (useful in a cube texture).
  24503. */
  24504. invertZ: boolean;
  24505. /**
  24506. * Are mip maps generated for this texture or not.
  24507. */
  24508. readonly noMipmap: boolean;
  24509. /**
  24510. * @hidden
  24511. */
  24512. lodLevelInAlpha: boolean;
  24513. /**
  24514. * With prefiltered texture, defined the offset used during the prefiltering steps.
  24515. */
  24516. lodGenerationOffset: number;
  24517. /**
  24518. * With prefiltered texture, defined the scale used during the prefiltering steps.
  24519. */
  24520. lodGenerationScale: number;
  24521. /**
  24522. * Define if the texture is a render target.
  24523. */
  24524. isRenderTarget: boolean;
  24525. /**
  24526. * Define the unique id of the texture in the scene.
  24527. */
  24528. readonly uid: string;
  24529. /**
  24530. * Return a string representation of the texture.
  24531. * @returns the texture as a string
  24532. */
  24533. toString(): string;
  24534. /**
  24535. * Get the class name of the texture.
  24536. * @returns "BaseTexture"
  24537. */
  24538. getClassName(): string;
  24539. /**
  24540. * Define the list of animation attached to the texture.
  24541. */
  24542. animations: Animation[];
  24543. /**
  24544. * An event triggered when the texture is disposed.
  24545. */
  24546. onDisposeObservable: Observable<BaseTexture>;
  24547. private _onDisposeObserver;
  24548. /**
  24549. * Callback triggered when the texture has been disposed.
  24550. * Kept for back compatibility, you can use the onDisposeObservable instead.
  24551. */
  24552. onDispose: () => void;
  24553. /**
  24554. * Define the current state of the loading sequence when in delayed load mode.
  24555. */
  24556. delayLoadState: number;
  24557. private _scene;
  24558. /** @hidden */ texture: Nullable<InternalTexture>;
  24559. private _uid;
  24560. /**
  24561. * Define if the texture is preventinga material to render or not.
  24562. * If not and the texture is not ready, the engine will use a default black texture instead.
  24563. */
  24564. readonly isBlocking: boolean;
  24565. /**
  24566. * Instantiates a new BaseTexture.
  24567. * Base class of all the textures in babylon.
  24568. * It groups all the common properties the materials, post process, lights... might need
  24569. * in order to make a correct use of the texture.
  24570. * @param scene Define the scene the texture blongs to
  24571. */
  24572. constructor(scene: Nullable<Scene>);
  24573. /**
  24574. * Get the scene the texture belongs to.
  24575. * @returns the scene or null if undefined
  24576. */
  24577. getScene(): Nullable<Scene>;
  24578. /**
  24579. * Get the texture transform matrix used to offset tile the texture for istance.
  24580. * @returns the transformation matrix
  24581. */
  24582. getTextureMatrix(): Matrix;
  24583. /**
  24584. * Get the texture reflection matrix used to rotate/transform the reflection.
  24585. * @returns the reflection matrix
  24586. */
  24587. getReflectionTextureMatrix(): Matrix;
  24588. /**
  24589. * Get the underlying lower level texture from Babylon.
  24590. * @returns the insternal texture
  24591. */
  24592. getInternalTexture(): Nullable<InternalTexture>;
  24593. /**
  24594. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  24595. * @returns true if ready or not blocking
  24596. */
  24597. isReadyOrNotBlocking(): boolean;
  24598. /**
  24599. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  24600. * @returns true if fully ready
  24601. */
  24602. isReady(): boolean;
  24603. private _cachedSize;
  24604. /**
  24605. * Get the size of the texture.
  24606. * @returns the texture size.
  24607. */
  24608. getSize(): ISize;
  24609. /**
  24610. * Get the base size of the texture.
  24611. * It can be different from the size if the texture has been resized for POT for instance
  24612. * @returns the base size
  24613. */
  24614. getBaseSize(): ISize;
  24615. /**
  24616. * Update the sampling mode of the texture.
  24617. * Default is Trilinear mode.
  24618. *
  24619. * | Value | Type | Description |
  24620. * | ----- | ------------------ | ----------- |
  24621. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  24622. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  24623. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  24624. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  24625. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  24626. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  24627. * | 7 | NEAREST_LINEAR | |
  24628. * | 8 | NEAREST_NEAREST | |
  24629. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  24630. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  24631. * | 11 | LINEAR_LINEAR | |
  24632. * | 12 | LINEAR_NEAREST | |
  24633. *
  24634. * > _mag_: magnification filter (close to the viewer)
  24635. * > _min_: minification filter (far from the viewer)
  24636. * > _mip_: filter used between mip map levels
  24637. *@param samplingMode Define the new sampling mode of the texture
  24638. */
  24639. updateSamplingMode(samplingMode: number): void;
  24640. /**
  24641. * Scales the texture if is `canRescale()`
  24642. * @param ratio the resize factor we want to use to rescale
  24643. */
  24644. scale(ratio: number): void;
  24645. /**
  24646. * Get if the texture can rescale.
  24647. */
  24648. readonly canRescale: boolean;
  24649. /** @hidden */ getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  24650. /** @hidden */ rebuild(): void;
  24651. /**
  24652. * Triggers the load sequence in delayed load mode.
  24653. */
  24654. delayLoad(): void;
  24655. /**
  24656. * Clones the texture.
  24657. * @returns the cloned texture
  24658. */
  24659. clone(): Nullable<BaseTexture>;
  24660. /**
  24661. * Get the texture underlying type (INT, FLOAT...)
  24662. */
  24663. readonly textureType: number;
  24664. /**
  24665. * Get the texture underlying format (RGB, RGBA...)
  24666. */
  24667. readonly textureFormat: number;
  24668. /**
  24669. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  24670. * This will returns an RGBA array buffer containing either in values (0-255) or
  24671. * float values (0-1) depending of the underlying buffer type.
  24672. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  24673. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  24674. * @param buffer defines a user defined buffer to fill with data (can be null)
  24675. * @returns The Array buffer containing the pixels data.
  24676. */
  24677. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  24678. /**
  24679. * Release and destroy the underlying lower level texture aka internalTexture.
  24680. */
  24681. releaseInternalTexture(): void;
  24682. /**
  24683. * Get the polynomial representation of the texture data.
  24684. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  24685. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  24686. */
  24687. sphericalPolynomial: Nullable<SphericalPolynomial>;
  24688. /** @hidden */ protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  24689. /** @hidden */ protected readonly _lodTextureMid: Nullable<BaseTexture>;
  24690. /** @hidden */ protected readonly _lodTextureLow: Nullable<BaseTexture>;
  24691. /**
  24692. * Dispose the texture and release its associated resources.
  24693. */
  24694. dispose(): void;
  24695. /**
  24696. * Serialize the texture into a JSON representation that can be parsed later on.
  24697. * @returns the JSON representation of the texture
  24698. */
  24699. serialize(): any;
  24700. /**
  24701. * Helper function to be called back once a list of texture contains only ready textures.
  24702. * @param textures Define the list of textures to wait for
  24703. * @param callback Define the callback triggered once the entire list will be ready
  24704. */
  24705. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  24706. }
  24707. }
  24708. declare module BABYLON {
  24709. /**
  24710. * Uniform buffer objects.
  24711. *
  24712. * Handles blocks of uniform on the GPU.
  24713. *
  24714. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  24715. *
  24716. * For more information, please refer to :
  24717. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  24718. */
  24719. export class UniformBuffer {
  24720. private _engine;
  24721. private _buffer;
  24722. private _data;
  24723. private _bufferData;
  24724. private _dynamic?;
  24725. private _uniformLocations;
  24726. private _uniformSizes;
  24727. private _uniformLocationPointer;
  24728. private _needSync;
  24729. private _noUBO;
  24730. private _currentEffect;
  24731. private static _MAX_UNIFORM_SIZE;
  24732. private static _tempBuffer;
  24733. /**
  24734. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  24735. * This is dynamic to allow compat with webgl 1 and 2.
  24736. * You will need to pass the name of the uniform as well as the value.
  24737. */
  24738. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  24739. /**
  24740. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  24741. * This is dynamic to allow compat with webgl 1 and 2.
  24742. * You will need to pass the name of the uniform as well as the value.
  24743. */
  24744. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  24745. /**
  24746. * Lambda to Update a single float in a uniform buffer.
  24747. * This is dynamic to allow compat with webgl 1 and 2.
  24748. * You will need to pass the name of the uniform as well as the value.
  24749. */
  24750. updateFloat: (name: string, x: number) => void;
  24751. /**
  24752. * Lambda to Update a vec2 of float in a uniform buffer.
  24753. * This is dynamic to allow compat with webgl 1 and 2.
  24754. * You will need to pass the name of the uniform as well as the value.
  24755. */
  24756. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  24757. /**
  24758. * Lambda to Update a vec3 of float in a uniform buffer.
  24759. * This is dynamic to allow compat with webgl 1 and 2.
  24760. * You will need to pass the name of the uniform as well as the value.
  24761. */
  24762. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  24763. /**
  24764. * Lambda to Update a vec4 of float in a uniform buffer.
  24765. * This is dynamic to allow compat with webgl 1 and 2.
  24766. * You will need to pass the name of the uniform as well as the value.
  24767. */
  24768. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  24769. /**
  24770. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  24771. * This is dynamic to allow compat with webgl 1 and 2.
  24772. * You will need to pass the name of the uniform as well as the value.
  24773. */
  24774. updateMatrix: (name: string, mat: Matrix) => void;
  24775. /**
  24776. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  24777. * This is dynamic to allow compat with webgl 1 and 2.
  24778. * You will need to pass the name of the uniform as well as the value.
  24779. */
  24780. updateVector3: (name: string, vector: Vector3) => void;
  24781. /**
  24782. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  24783. * This is dynamic to allow compat with webgl 1 and 2.
  24784. * You will need to pass the name of the uniform as well as the value.
  24785. */
  24786. updateVector4: (name: string, vector: Vector4) => void;
  24787. /**
  24788. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  24789. * This is dynamic to allow compat with webgl 1 and 2.
  24790. * You will need to pass the name of the uniform as well as the value.
  24791. */
  24792. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  24793. /**
  24794. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  24795. * This is dynamic to allow compat with webgl 1 and 2.
  24796. * You will need to pass the name of the uniform as well as the value.
  24797. */
  24798. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  24799. /**
  24800. * Instantiates a new Uniform buffer objects.
  24801. *
  24802. * Handles blocks of uniform on the GPU.
  24803. *
  24804. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  24805. *
  24806. * For more information, please refer to :
  24807. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  24808. * @param engine Define the engine the buffer is associated with
  24809. * @param data Define the data contained in the buffer
  24810. * @param dynamic Define if the buffer is updatable
  24811. */
  24812. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  24813. /**
  24814. * Indicates if the buffer is using the WebGL2 UBO implementation,
  24815. * or just falling back on setUniformXXX calls.
  24816. */
  24817. readonly useUbo: boolean;
  24818. /**
  24819. * Indicates if the WebGL underlying uniform buffer is in sync
  24820. * with the javascript cache data.
  24821. */
  24822. readonly isSync: boolean;
  24823. /**
  24824. * Indicates if the WebGL underlying uniform buffer is dynamic.
  24825. * Also, a dynamic UniformBuffer will disable cache verification and always
  24826. * update the underlying WebGL uniform buffer to the GPU.
  24827. * @returns if Dynamic, otherwise false
  24828. */
  24829. isDynamic(): boolean;
  24830. /**
  24831. * The data cache on JS side.
  24832. * @returns the underlying data as a float array
  24833. */
  24834. getData(): Float32Array;
  24835. /**
  24836. * The underlying WebGL Uniform buffer.
  24837. * @returns the webgl buffer
  24838. */
  24839. getBuffer(): Nullable<WebGLBuffer>;
  24840. /**
  24841. * std140 layout specifies how to align data within an UBO structure.
  24842. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  24843. * for specs.
  24844. */
  24845. private _fillAlignment;
  24846. /**
  24847. * Adds an uniform in the buffer.
  24848. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  24849. * for the layout to be correct !
  24850. * @param name Name of the uniform, as used in the uniform block in the shader.
  24851. * @param size Data size, or data directly.
  24852. */
  24853. addUniform(name: string, size: number | number[]): void;
  24854. /**
  24855. * Adds a Matrix 4x4 to the uniform buffer.
  24856. * @param name Name of the uniform, as used in the uniform block in the shader.
  24857. * @param mat A 4x4 matrix.
  24858. */
  24859. addMatrix(name: string, mat: Matrix): void;
  24860. /**
  24861. * Adds a vec2 to the uniform buffer.
  24862. * @param name Name of the uniform, as used in the uniform block in the shader.
  24863. * @param x Define the x component value of the vec2
  24864. * @param y Define the y component value of the vec2
  24865. */
  24866. addFloat2(name: string, x: number, y: number): void;
  24867. /**
  24868. * Adds a vec3 to the uniform buffer.
  24869. * @param name Name of the uniform, as used in the uniform block in the shader.
  24870. * @param x Define the x component value of the vec3
  24871. * @param y Define the y component value of the vec3
  24872. * @param z Define the z component value of the vec3
  24873. */
  24874. addFloat3(name: string, x: number, y: number, z: number): void;
  24875. /**
  24876. * Adds a vec3 to the uniform buffer.
  24877. * @param name Name of the uniform, as used in the uniform block in the shader.
  24878. * @param color Define the vec3 from a Color
  24879. */
  24880. addColor3(name: string, color: Color3): void;
  24881. /**
  24882. * Adds a vec4 to the uniform buffer.
  24883. * @param name Name of the uniform, as used in the uniform block in the shader.
  24884. * @param color Define the rgb components from a Color
  24885. * @param alpha Define the a component of the vec4
  24886. */
  24887. addColor4(name: string, color: Color3, alpha: number): void;
  24888. /**
  24889. * Adds a vec3 to the uniform buffer.
  24890. * @param name Name of the uniform, as used in the uniform block in the shader.
  24891. * @param vector Define the vec3 components from a Vector
  24892. */
  24893. addVector3(name: string, vector: Vector3): void;
  24894. /**
  24895. * Adds a Matrix 3x3 to the uniform buffer.
  24896. * @param name Name of the uniform, as used in the uniform block in the shader.
  24897. */
  24898. addMatrix3x3(name: string): void;
  24899. /**
  24900. * Adds a Matrix 2x2 to the uniform buffer.
  24901. * @param name Name of the uniform, as used in the uniform block in the shader.
  24902. */
  24903. addMatrix2x2(name: string): void;
  24904. /**
  24905. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  24906. */
  24907. create(): void;
  24908. /** @hidden */ rebuild(): void;
  24909. /**
  24910. * Updates the WebGL Uniform Buffer on the GPU.
  24911. * If the `dynamic` flag is set to true, no cache comparison is done.
  24912. * Otherwise, the buffer will be updated only if the cache differs.
  24913. */
  24914. update(): void;
  24915. /**
  24916. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  24917. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  24918. * @param data Define the flattened data
  24919. * @param size Define the size of the data.
  24920. */
  24921. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  24922. private _updateMatrix3x3ForUniform;
  24923. private _updateMatrix3x3ForEffect;
  24924. private _updateMatrix2x2ForEffect;
  24925. private _updateMatrix2x2ForUniform;
  24926. private _updateFloatForEffect;
  24927. private _updateFloatForUniform;
  24928. private _updateFloat2ForEffect;
  24929. private _updateFloat2ForUniform;
  24930. private _updateFloat3ForEffect;
  24931. private _updateFloat3ForUniform;
  24932. private _updateFloat4ForEffect;
  24933. private _updateFloat4ForUniform;
  24934. private _updateMatrixForEffect;
  24935. private _updateMatrixForUniform;
  24936. private _updateVector3ForEffect;
  24937. private _updateVector3ForUniform;
  24938. private _updateVector4ForEffect;
  24939. private _updateVector4ForUniform;
  24940. private _updateColor3ForEffect;
  24941. private _updateColor3ForUniform;
  24942. private _updateColor4ForEffect;
  24943. private _updateColor4ForUniform;
  24944. /**
  24945. * Sets a sampler uniform on the effect.
  24946. * @param name Define the name of the sampler.
  24947. * @param texture Define the texture to set in the sampler
  24948. */
  24949. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  24950. /**
  24951. * Directly updates the value of the uniform in the cache AND on the GPU.
  24952. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  24953. * @param data Define the flattened data
  24954. */
  24955. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  24956. /**
  24957. * Binds this uniform buffer to an effect.
  24958. * @param effect Define the effect to bind the buffer to
  24959. * @param name Name of the uniform block in the shader.
  24960. */
  24961. bindToEffect(effect: Effect, name: string): void;
  24962. /**
  24963. * Disposes the uniform buffer.
  24964. */
  24965. dispose(): void;
  24966. }
  24967. }
  24968. declare module BABYLON {
  24969. /**
  24970. * This represents the required contract to create a new type of texture loader.
  24971. */
  24972. export interface IInternalTextureLoader {
  24973. /**
  24974. * Defines wether the loader supports cascade loading the different faces.
  24975. */
  24976. supportCascades: boolean;
  24977. /**
  24978. * This returns if the loader support the current file information.
  24979. * @param extension defines the file extension of the file being loaded
  24980. * @param textureFormatInUse defines the current compressed format in use iun the engine
  24981. * @param fallback defines the fallback internal texture if any
  24982. * @param isBase64 defines whether the texture is encoded as a base64
  24983. * @param isBuffer defines whether the texture data are stored as a buffer
  24984. * @returns true if the loader can load the specified file
  24985. */
  24986. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  24987. /**
  24988. * Transform the url before loading if required.
  24989. * @param rootUrl the url of the texture
  24990. * @param textureFormatInUse defines the current compressed format in use iun the engine
  24991. * @returns the transformed texture
  24992. */
  24993. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  24994. /**
  24995. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  24996. * @param rootUrl the url of the texture
  24997. * @param textureFormatInUse defines the current compressed format in use iun the engine
  24998. * @returns the fallback texture
  24999. */
  25000. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  25001. /**
  25002. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  25003. * @param data contains the texture data
  25004. * @param texture defines the BabylonJS internal texture
  25005. * @param createPolynomials will be true if polynomials have been requested
  25006. * @param onLoad defines the callback to trigger once the texture is ready
  25007. * @param onError defines the callback to trigger in case of error
  25008. */
  25009. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  25010. /**
  25011. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  25012. * @param data contains the texture data
  25013. * @param texture defines the BabylonJS internal texture
  25014. * @param callback defines the method to call once ready to upload
  25015. */
  25016. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  25017. }
  25018. }
  25019. declare module BABYLON {
  25020. /**
  25021. * Creation options of the multi render target texture.
  25022. */
  25023. export interface IMultiRenderTargetOptions {
  25024. /**
  25025. * Define if the texture needs to create mip maps after render.
  25026. */
  25027. generateMipMaps?: boolean;
  25028. /**
  25029. * Define the types of all the draw buffers we want to create
  25030. */
  25031. types?: number[];
  25032. /**
  25033. * Define the sampling modes of all the draw buffers we want to create
  25034. */
  25035. samplingModes?: number[];
  25036. /**
  25037. * Define if a depth buffer is required
  25038. */
  25039. generateDepthBuffer?: boolean;
  25040. /**
  25041. * Define if a stencil buffer is required
  25042. */
  25043. generateStencilBuffer?: boolean;
  25044. /**
  25045. * Define if a depth texture is required instead of a depth buffer
  25046. */
  25047. generateDepthTexture?: boolean;
  25048. /**
  25049. * Define the number of desired draw buffers
  25050. */
  25051. textureCount?: number;
  25052. /**
  25053. * Define if aspect ratio should be adapted to the texture or stay the scene one
  25054. */
  25055. doNotChangeAspectRatio?: boolean;
  25056. /**
  25057. * Define the default type of the buffers we are creating
  25058. */
  25059. defaultType?: number;
  25060. }
  25061. /**
  25062. * A multi render target, like a render target provides the ability to render to a texture.
  25063. * Unlike the render target, it can render to several draw buffers in one draw.
  25064. * This is specially interesting in deferred rendering or for any effects requiring more than
  25065. * just one color from a single pass.
  25066. */
  25067. export class MultiRenderTarget extends RenderTargetTexture {
  25068. private _internalTextures;
  25069. private _textures;
  25070. private _multiRenderTargetOptions;
  25071. /**
  25072. * Get if draw buffers are currently supported by the used hardware and browser.
  25073. */
  25074. readonly isSupported: boolean;
  25075. /**
  25076. * Get the list of textures generated by the multi render target.
  25077. */
  25078. readonly textures: Texture[];
  25079. /**
  25080. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  25081. */
  25082. readonly depthTexture: Texture;
  25083. /**
  25084. * Set the wrapping mode on U of all the textures we are rendering to.
  25085. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25086. */
  25087. wrapU: number;
  25088. /**
  25089. * Set the wrapping mode on V of all the textures we are rendering to.
  25090. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25091. */
  25092. wrapV: number;
  25093. /**
  25094. * Instantiate a new multi render target texture.
  25095. * A multi render target, like a render target provides the ability to render to a texture.
  25096. * Unlike the render target, it can render to several draw buffers in one draw.
  25097. * This is specially interesting in deferred rendering or for any effects requiring more than
  25098. * just one color from a single pass.
  25099. * @param name Define the name of the texture
  25100. * @param size Define the size of the buffers to render to
  25101. * @param count Define the number of target we are rendering into
  25102. * @param scene Define the scene the texture belongs to
  25103. * @param options Define the options used to create the multi render target
  25104. */
  25105. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  25106. /** @hidden */ rebuild(): void;
  25107. private _createInternalTextures;
  25108. private _createTextures;
  25109. /**
  25110. * Define the number of samples used if MSAA is enabled.
  25111. */
  25112. samples: number;
  25113. /**
  25114. * Resize all the textures in the multi render target.
  25115. * Be carrefull as it will recreate all the data in the new texture.
  25116. * @param size Define the new size
  25117. */
  25118. resize(size: any): void;
  25119. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  25120. /**
  25121. * Dispose the render targets and their associated resources
  25122. */
  25123. dispose(): void;
  25124. /**
  25125. * Release all the underlying texture used as draw buffers.
  25126. */
  25127. releaseInternalTextures(): void;
  25128. }
  25129. }
  25130. declare module BABYLON {
  25131. /**
  25132. * Class used to work with sound analyzer using fast fourier transform (FFT)
  25133. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25134. */
  25135. export class Analyser {
  25136. /**
  25137. * Gets or sets the smoothing
  25138. * @ignorenaming
  25139. */
  25140. SMOOTHING: number;
  25141. /**
  25142. * Gets or sets the FFT table size
  25143. * @ignorenaming
  25144. */
  25145. FFT_SIZE: number;
  25146. /**
  25147. * Gets or sets the bar graph amplitude
  25148. * @ignorenaming
  25149. */
  25150. BARGRAPHAMPLITUDE: number;
  25151. /**
  25152. * Gets or sets the position of the debug canvas
  25153. * @ignorenaming
  25154. */
  25155. DEBUGCANVASPOS: {
  25156. x: number;
  25157. y: number;
  25158. };
  25159. /**
  25160. * Gets or sets the debug canvas size
  25161. * @ignorenaming
  25162. */
  25163. DEBUGCANVASSIZE: {
  25164. width: number;
  25165. height: number;
  25166. };
  25167. private _byteFreqs;
  25168. private _byteTime;
  25169. private _floatFreqs;
  25170. private _webAudioAnalyser;
  25171. private _debugCanvas;
  25172. private _debugCanvasContext;
  25173. private _scene;
  25174. private _registerFunc;
  25175. private _audioEngine;
  25176. /**
  25177. * Creates a new analyser
  25178. * @param scene defines hosting scene
  25179. */
  25180. constructor(scene: Scene);
  25181. /**
  25182. * Get the number of data values you will have to play with for the visualization
  25183. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  25184. * @returns a number
  25185. */
  25186. getFrequencyBinCount(): number;
  25187. /**
  25188. * Gets the current frequency data as a byte array
  25189. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  25190. * @returns a Uint8Array
  25191. */
  25192. getByteFrequencyData(): Uint8Array;
  25193. /**
  25194. * Gets the current waveform as a byte array
  25195. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  25196. * @returns a Uint8Array
  25197. */
  25198. getByteTimeDomainData(): Uint8Array;
  25199. /**
  25200. * Gets the current frequency data as a float array
  25201. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  25202. * @returns a Float32Array
  25203. */
  25204. getFloatFrequencyData(): Float32Array;
  25205. /**
  25206. * Renders the debug canvas
  25207. */
  25208. drawDebugCanvas(): void;
  25209. /**
  25210. * Stops rendering the debug canvas and removes it
  25211. */
  25212. stopDebugCanvas(): void;
  25213. /**
  25214. * Connects two audio nodes
  25215. * @param inputAudioNode defines first node to connect
  25216. * @param outputAudioNode defines second node to connect
  25217. */
  25218. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  25219. /**
  25220. * Releases all associated resources
  25221. */
  25222. dispose(): void;
  25223. }
  25224. }
  25225. declare module BABYLON {
  25226. /**
  25227. * This represents an audio engine and it is responsible
  25228. * to play, synchronize and analyse sounds throughout the application.
  25229. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25230. */
  25231. export interface IAudioEngine extends IDisposable {
  25232. /**
  25233. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  25234. */
  25235. readonly canUseWebAudio: boolean;
  25236. /**
  25237. * Gets the current AudioContext if available.
  25238. */
  25239. readonly audioContext: Nullable<AudioContext>;
  25240. /**
  25241. * The master gain node defines the global audio volume of your audio engine.
  25242. */
  25243. readonly masterGain: GainNode;
  25244. /**
  25245. * Gets whether or not mp3 are supported by your browser.
  25246. */
  25247. readonly isMP3supported: boolean;
  25248. /**
  25249. * Gets whether or not ogg are supported by your browser.
  25250. */
  25251. readonly isOGGsupported: boolean;
  25252. /**
  25253. * Defines if Babylon should emit a warning if WebAudio is not supported.
  25254. * @ignoreNaming
  25255. */
  25256. WarnedWebAudioUnsupported: boolean;
  25257. /**
  25258. * Defines if the audio engine relies on a custom unlocked button.
  25259. * In this case, the embedded button will not be displayed.
  25260. */
  25261. useCustomUnlockedButton: boolean;
  25262. /**
  25263. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  25264. */
  25265. readonly unlocked: boolean;
  25266. /**
  25267. * Event raised when audio has been unlocked on the browser.
  25268. */
  25269. onAudioUnlockedObservable: Observable<AudioEngine>;
  25270. /**
  25271. * Event raised when audio has been locked on the browser.
  25272. */
  25273. onAudioLockedObservable: Observable<AudioEngine>;
  25274. /**
  25275. * Flags the audio engine in Locked state.
  25276. * This happens due to new browser policies preventing audio to autoplay.
  25277. */
  25278. lock(): void;
  25279. /**
  25280. * Unlocks the audio engine once a user action has been done on the dom.
  25281. * This is helpful to resume play once browser policies have been satisfied.
  25282. */
  25283. unlock(): void;
  25284. }
  25285. /**
  25286. * This represents the default audio engine used in babylon.
  25287. * It is responsible to play, synchronize and analyse sounds throughout the application.
  25288. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25289. */
  25290. export class AudioEngine implements IAudioEngine {
  25291. private _audioContext;
  25292. private _audioContextInitialized;
  25293. private _muteButton;
  25294. private _hostElement;
  25295. /**
  25296. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  25297. */
  25298. canUseWebAudio: boolean;
  25299. /**
  25300. * The master gain node defines the global audio volume of your audio engine.
  25301. */
  25302. masterGain: GainNode;
  25303. /**
  25304. * Defines if Babylon should emit a warning if WebAudio is not supported.
  25305. * @ignoreNaming
  25306. */
  25307. WarnedWebAudioUnsupported: boolean;
  25308. /**
  25309. * Gets whether or not mp3 are supported by your browser.
  25310. */
  25311. isMP3supported: boolean;
  25312. /**
  25313. * Gets whether or not ogg are supported by your browser.
  25314. */
  25315. isOGGsupported: boolean;
  25316. /**
  25317. * Gets whether audio has been unlocked on the device.
  25318. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  25319. * a user interaction has happened.
  25320. */
  25321. unlocked: boolean;
  25322. /**
  25323. * Defines if the audio engine relies on a custom unlocked button.
  25324. * In this case, the embedded button will not be displayed.
  25325. */
  25326. useCustomUnlockedButton: boolean;
  25327. /**
  25328. * Event raised when audio has been unlocked on the browser.
  25329. */
  25330. onAudioUnlockedObservable: Observable<AudioEngine>;
  25331. /**
  25332. * Event raised when audio has been locked on the browser.
  25333. */
  25334. onAudioLockedObservable: Observable<AudioEngine>;
  25335. /**
  25336. * Gets the current AudioContext if available.
  25337. */
  25338. readonly audioContext: Nullable<AudioContext>;
  25339. private _connectedAnalyser;
  25340. /**
  25341. * Instantiates a new audio engine.
  25342. *
  25343. * There should be only one per page as some browsers restrict the number
  25344. * of audio contexts you can create.
  25345. * @param hostElement defines the host element where to display the mute icon if necessary
  25346. */
  25347. constructor(hostElement?: Nullable<HTMLElement>);
  25348. /**
  25349. * Flags the audio engine in Locked state.
  25350. * This happens due to new browser policies preventing audio to autoplay.
  25351. */
  25352. lock(): void;
  25353. /**
  25354. * Unlocks the audio engine once a user action has been done on the dom.
  25355. * This is helpful to resume play once browser policies have been satisfied.
  25356. */
  25357. unlock(): void;
  25358. private _resumeAudioContext;
  25359. private _initializeAudioContext;
  25360. private _tryToRun;
  25361. private _triggerRunningState;
  25362. private _triggerSuspendedState;
  25363. private _displayMuteButton;
  25364. private _moveButtonToTopLeft;
  25365. private _onResize;
  25366. private _hideMuteButton;
  25367. /**
  25368. * Destroy and release the resources associated with the audio ccontext.
  25369. */
  25370. dispose(): void;
  25371. /**
  25372. * Gets the global volume sets on the master gain.
  25373. * @returns the global volume if set or -1 otherwise
  25374. */
  25375. getGlobalVolume(): number;
  25376. /**
  25377. * Sets the global volume of your experience (sets on the master gain).
  25378. * @param newVolume Defines the new global volume of the application
  25379. */
  25380. setGlobalVolume(newVolume: number): void;
  25381. /**
  25382. * Connect the audio engine to an audio analyser allowing some amazing
  25383. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  25384. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  25385. * @param analyser The analyser to connect to the engine
  25386. */
  25387. connectToAnalyser(analyser: Analyser): void;
  25388. }
  25389. }
  25390. declare module BABYLON {
  25391. /**
  25392. * Interface used to present a loading screen while loading a scene
  25393. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  25394. */
  25395. export interface ILoadingScreen {
  25396. /**
  25397. * Function called to display the loading screen
  25398. */
  25399. displayLoadingUI: () => void;
  25400. /**
  25401. * Function called to hide the loading screen
  25402. */
  25403. hideLoadingUI: () => void;
  25404. /**
  25405. * Gets or sets the color to use for the background
  25406. */
  25407. loadingUIBackgroundColor: string;
  25408. /**
  25409. * Gets or sets the text to display while loading
  25410. */
  25411. loadingUIText: string;
  25412. }
  25413. /**
  25414. * Class used for the default loading screen
  25415. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  25416. */
  25417. export class DefaultLoadingScreen implements ILoadingScreen {
  25418. private _renderingCanvas;
  25419. private _loadingText;
  25420. private _loadingDivBackgroundColor;
  25421. private _loadingDiv;
  25422. private _loadingTextDiv;
  25423. /**
  25424. * Creates a new default loading screen
  25425. * @param _renderingCanvas defines the canvas used to render the scene
  25426. * @param _loadingText defines the default text to display
  25427. * @param _loadingDivBackgroundColor defines the default background color
  25428. */
  25429. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  25430. /**
  25431. * Function called to display the loading screen
  25432. */
  25433. displayLoadingUI(): void;
  25434. /**
  25435. * Function called to hide the loading screen
  25436. */
  25437. hideLoadingUI(): void;
  25438. /**
  25439. * Gets or sets the text to display while loading
  25440. */
  25441. loadingUIText: string;
  25442. /**
  25443. * Gets or sets the color to use for the background
  25444. */
  25445. loadingUIBackgroundColor: string;
  25446. private _resizeLoadingUI;
  25447. }
  25448. }
  25449. declare module BABYLON {
  25450. /**
  25451. * Settings for finer control over video usage
  25452. */
  25453. export interface VideoTextureSettings {
  25454. /**
  25455. * Applies `autoplay` to video, if specified
  25456. */
  25457. autoPlay?: boolean;
  25458. /**
  25459. * Applies `loop` to video, if specified
  25460. */
  25461. loop?: boolean;
  25462. /**
  25463. * Automatically updates internal texture from video at every frame in the render loop
  25464. */
  25465. autoUpdateTexture: boolean;
  25466. /**
  25467. * Image src displayed during the video loading or until the user interacts with the video.
  25468. */
  25469. poster?: string;
  25470. }
  25471. /**
  25472. * If you want to display a video in your scene, this is the special texture for that.
  25473. * This special texture works similar to other textures, with the exception of a few parameters.
  25474. * @see https://doc.babylonjs.com/how_to/video_texture
  25475. */
  25476. export class VideoTexture extends Texture {
  25477. /**
  25478. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  25479. */
  25480. readonly autoUpdateTexture: boolean;
  25481. /**
  25482. * The video instance used by the texture internally
  25483. */
  25484. readonly video: HTMLVideoElement;
  25485. private _onUserActionRequestedObservable;
  25486. /**
  25487. * Event triggerd when a dom action is required by the user to play the video.
  25488. * This happens due to recent changes in browser policies preventing video to auto start.
  25489. */
  25490. readonly onUserActionRequestedObservable: Observable<Texture>;
  25491. private _generateMipMaps;
  25492. private _engine;
  25493. private _stillImageCaptured;
  25494. private _displayingPosterTexture;
  25495. private _settings;
  25496. private _createInternalTextureOnEvent;
  25497. /**
  25498. * Creates a video texture.
  25499. * If you want to display a video in your scene, this is the special texture for that.
  25500. * This special texture works similar to other textures, with the exception of a few parameters.
  25501. * @see https://doc.babylonjs.com/how_to/video_texture
  25502. * @param name optional name, will detect from video source, if not defined
  25503. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  25504. * @param scene is obviously the current scene.
  25505. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  25506. * @param invertY is false by default but can be used to invert video on Y axis
  25507. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  25508. * @param settings allows finer control over video usage
  25509. */
  25510. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  25511. private _getName;
  25512. private _getVideo;
  25513. private _createInternalTexture;
  25514. private reset;
  25515. /**
  25516. * @hidden Internal method to initiate `update`.
  25517. */ rebuild(): void;
  25518. /**
  25519. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  25520. */
  25521. update(): void;
  25522. /**
  25523. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  25524. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  25525. */
  25526. updateTexture(isVisible: boolean): void;
  25527. protected _updateInternalTexture: () => void;
  25528. /**
  25529. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  25530. * @param url New url.
  25531. */
  25532. updateURL(url: string): void;
  25533. /**
  25534. * Dispose the texture and release its associated resources.
  25535. */
  25536. dispose(): void;
  25537. /**
  25538. * Creates a video texture straight from your WebCam video feed.
  25539. * @param scene Define the scene the texture should be created in
  25540. * @param onReady Define a callback to triggered once the texture will be ready
  25541. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  25542. */
  25543. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  25544. minWidth: number;
  25545. maxWidth: number;
  25546. minHeight: number;
  25547. maxHeight: number;
  25548. deviceId: string;
  25549. }): void;
  25550. }
  25551. }
  25552. declare module BABYLON {
  25553. /**
  25554. * Interface for attribute information associated with buffer instanciation
  25555. */
  25556. export class InstancingAttributeInfo {
  25557. /**
  25558. * Index/offset of the attribute in the vertex shader
  25559. */
  25560. index: number;
  25561. /**
  25562. * size of the attribute, 1, 2, 3 or 4
  25563. */
  25564. attributeSize: number;
  25565. /**
  25566. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  25567. * default is FLOAT
  25568. */
  25569. attribyteType: number;
  25570. /**
  25571. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  25572. */
  25573. normalized: boolean;
  25574. /**
  25575. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  25576. */
  25577. offset: number;
  25578. /**
  25579. * Name of the GLSL attribute, for debugging purpose only
  25580. */
  25581. attributeName: string;
  25582. }
  25583. /**
  25584. * Define options used to create a depth texture
  25585. */
  25586. export class DepthTextureCreationOptions {
  25587. /** Specifies whether or not a stencil should be allocated in the texture */
  25588. generateStencil?: boolean;
  25589. /** Specifies whether or not bilinear filtering is enable on the texture */
  25590. bilinearFiltering?: boolean;
  25591. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  25592. comparisonFunction?: number;
  25593. /** Specifies if the created texture is a cube texture */
  25594. isCube?: boolean;
  25595. }
  25596. /**
  25597. * Class used to describe the capabilities of the engine relatively to the current browser
  25598. */
  25599. export class EngineCapabilities {
  25600. /** Maximum textures units per fragment shader */
  25601. maxTexturesImageUnits: number;
  25602. /** Maximum texture units per vertex shader */
  25603. maxVertexTextureImageUnits: number;
  25604. /** Maximum textures units in the entire pipeline */
  25605. maxCombinedTexturesImageUnits: number;
  25606. /** Maximum texture size */
  25607. maxTextureSize: number;
  25608. /** Maximum cube texture size */
  25609. maxCubemapTextureSize: number;
  25610. /** Maximum render texture size */
  25611. maxRenderTextureSize: number;
  25612. /** Maximum number of vertex attributes */
  25613. maxVertexAttribs: number;
  25614. /** Maximum number of varyings */
  25615. maxVaryingVectors: number;
  25616. /** Maximum number of uniforms per vertex shader */
  25617. maxVertexUniformVectors: number;
  25618. /** Maximum number of uniforms per fragment shader */
  25619. maxFragmentUniformVectors: number;
  25620. /** Defines if standard derivates (dx/dy) are supported */
  25621. standardDerivatives: boolean;
  25622. /** Defines if s3tc texture compression is supported */
  25623. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  25624. /** Defines if pvrtc texture compression is supported */
  25625. pvrtc: any;
  25626. /** Defines if etc1 texture compression is supported */
  25627. etc1: any;
  25628. /** Defines if etc2 texture compression is supported */
  25629. etc2: any;
  25630. /** Defines if astc texture compression is supported */
  25631. astc: any;
  25632. /** Defines if float textures are supported */
  25633. textureFloat: boolean;
  25634. /** Defines if vertex array objects are supported */
  25635. vertexArrayObject: boolean;
  25636. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  25637. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  25638. /** Gets the maximum level of anisotropy supported */
  25639. maxAnisotropy: number;
  25640. /** Defines if instancing is supported */
  25641. instancedArrays: boolean;
  25642. /** Defines if 32 bits indices are supported */
  25643. uintIndices: boolean;
  25644. /** Defines if high precision shaders are supported */
  25645. highPrecisionShaderSupported: boolean;
  25646. /** Defines if depth reading in the fragment shader is supported */
  25647. fragmentDepthSupported: boolean;
  25648. /** Defines if float texture linear filtering is supported*/
  25649. textureFloatLinearFiltering: boolean;
  25650. /** Defines if rendering to float textures is supported */
  25651. textureFloatRender: boolean;
  25652. /** Defines if half float textures are supported*/
  25653. textureHalfFloat: boolean;
  25654. /** Defines if half float texture linear filtering is supported*/
  25655. textureHalfFloatLinearFiltering: boolean;
  25656. /** Defines if rendering to half float textures is supported */
  25657. textureHalfFloatRender: boolean;
  25658. /** Defines if textureLOD shader command is supported */
  25659. textureLOD: boolean;
  25660. /** Defines if draw buffers extension is supported */
  25661. drawBuffersExtension: boolean;
  25662. /** Defines if depth textures are supported */
  25663. depthTextureExtension: boolean;
  25664. /** Defines if float color buffer are supported */
  25665. colorBufferFloat: boolean;
  25666. /** Gets disjoint timer query extension (null if not supported) */
  25667. timerQuery: EXT_disjoint_timer_query;
  25668. /** Defines if timestamp can be used with timer query */
  25669. canUseTimestampForTimerQuery: boolean;
  25670. /** Function used to let the system compiles shaders in background */
  25671. parallelShaderCompile: {
  25672. MAX_SHADER_COMPILER_THREADS_KHR: number;
  25673. maxShaderCompilerThreadsKHR: (thread: number) => void;
  25674. COMPLETION_STATUS_KHR: number;
  25675. };
  25676. }
  25677. /** Interface defining initialization parameters for Engine class */
  25678. export interface EngineOptions extends WebGLContextAttributes {
  25679. /**
  25680. * Defines if the engine should no exceed a specified device ratio
  25681. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  25682. */
  25683. limitDeviceRatio?: number;
  25684. /**
  25685. * Defines if webvr should be enabled automatically
  25686. * @see http://doc.babylonjs.com/how_to/webvr_camera
  25687. */
  25688. autoEnableWebVR?: boolean;
  25689. /**
  25690. * Defines if webgl2 should be turned off even if supported
  25691. * @see http://doc.babylonjs.com/features/webgl2
  25692. */
  25693. disableWebGL2Support?: boolean;
  25694. /**
  25695. * Defines if webaudio should be initialized as well
  25696. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25697. */
  25698. audioEngine?: boolean;
  25699. /**
  25700. * Defines if animations should run using a deterministic lock step
  25701. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  25702. */
  25703. deterministicLockstep?: boolean;
  25704. /** Defines the maximum steps to use with deterministic lock step mode */
  25705. lockstepMaxSteps?: number;
  25706. /**
  25707. * Defines that engine should ignore context lost events
  25708. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  25709. */
  25710. doNotHandleContextLost?: boolean;
  25711. /**
  25712. * Defines that engine should ignore modifying touch action attribute and style
  25713. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  25714. */
  25715. doNotHandleTouchAction?: boolean;
  25716. }
  25717. /**
  25718. * Defines the interface used by display changed events
  25719. */
  25720. export interface IDisplayChangedEventArgs {
  25721. /** Gets the vrDisplay object (if any) */
  25722. vrDisplay: Nullable<any>;
  25723. /** Gets a boolean indicating if webVR is supported */
  25724. vrSupported: boolean;
  25725. }
  25726. /**
  25727. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  25728. */
  25729. export class Engine {
  25730. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  25731. static ExceptionList: ({
  25732. key: string;
  25733. capture: string;
  25734. captureConstraint: number;
  25735. targets: string[];
  25736. } | {
  25737. key: string;
  25738. capture: null;
  25739. captureConstraint: null;
  25740. targets: string[];
  25741. })[];
  25742. /** Gets the list of created engines */
  25743. static readonly Instances: Engine[];
  25744. /**
  25745. * Gets the latest created engine
  25746. */
  25747. static readonly LastCreatedEngine: Nullable<Engine>;
  25748. /**
  25749. * Gets the latest created scene
  25750. */
  25751. static readonly LastCreatedScene: Nullable<Scene>;
  25752. /**
  25753. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  25754. * @param flag defines which part of the materials must be marked as dirty
  25755. * @param predicate defines a predicate used to filter which materials should be affected
  25756. */
  25757. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  25758. /**
  25759. * Hidden
  25760. */ private static _TextureLoaders: IInternalTextureLoader[];
  25761. /** Defines that alpha blending is disabled */
  25762. static readonly ALPHA_DISABLE: number;
  25763. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  25764. static readonly ALPHA_ADD: number;
  25765. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  25766. static readonly ALPHA_COMBINE: number;
  25767. /** Defines that alpha blending to DEST - SRC * DEST */
  25768. static readonly ALPHA_SUBTRACT: number;
  25769. /** Defines that alpha blending to SRC * DEST */
  25770. static readonly ALPHA_MULTIPLY: number;
  25771. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  25772. static readonly ALPHA_MAXIMIZED: number;
  25773. /** Defines that alpha blending to SRC + DEST */
  25774. static readonly ALPHA_ONEONE: number;
  25775. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  25776. static readonly ALPHA_PREMULTIPLIED: number;
  25777. /**
  25778. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  25779. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  25780. */
  25781. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  25782. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  25783. static readonly ALPHA_INTERPOLATE: number;
  25784. /**
  25785. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  25786. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  25787. */
  25788. static readonly ALPHA_SCREENMODE: number;
  25789. /** Defines that the ressource is not delayed*/
  25790. static readonly DELAYLOADSTATE_NONE: number;
  25791. /** Defines that the ressource was successfully delay loaded */
  25792. static readonly DELAYLOADSTATE_LOADED: number;
  25793. /** Defines that the ressource is currently delay loading */
  25794. static readonly DELAYLOADSTATE_LOADING: number;
  25795. /** Defines that the ressource is delayed and has not started loading */
  25796. static readonly DELAYLOADSTATE_NOTLOADED: number;
  25797. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  25798. static readonly NEVER: number;
  25799. /** 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 */
  25800. static readonly ALWAYS: number;
  25801. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  25802. static readonly LESS: number;
  25803. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  25804. static readonly EQUAL: number;
  25805. /** 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 */
  25806. static readonly LEQUAL: number;
  25807. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  25808. static readonly GREATER: number;
  25809. /** 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 */
  25810. static readonly GEQUAL: number;
  25811. /** 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 */
  25812. static readonly NOTEQUAL: number;
  25813. /** Passed to stencilOperation to specify that stencil value must be kept */
  25814. static readonly KEEP: number;
  25815. /** Passed to stencilOperation to specify that stencil value must be replaced */
  25816. static readonly REPLACE: number;
  25817. /** Passed to stencilOperation to specify that stencil value must be incremented */
  25818. static readonly INCR: number;
  25819. /** Passed to stencilOperation to specify that stencil value must be decremented */
  25820. static readonly DECR: number;
  25821. /** Passed to stencilOperation to specify that stencil value must be inverted */
  25822. static readonly INVERT: number;
  25823. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  25824. static readonly INCR_WRAP: number;
  25825. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  25826. static readonly DECR_WRAP: number;
  25827. /** Texture is not repeating outside of 0..1 UVs */
  25828. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  25829. /** Texture is repeating outside of 0..1 UVs */
  25830. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  25831. /** Texture is repeating and mirrored */
  25832. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  25833. /** ALPHA */
  25834. static readonly TEXTUREFORMAT_ALPHA: number;
  25835. /** LUMINANCE */
  25836. static readonly TEXTUREFORMAT_LUMINANCE: number;
  25837. /** LUMINANCE_ALPHA */
  25838. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  25839. /** RGB */
  25840. static readonly TEXTUREFORMAT_RGB: number;
  25841. /** RGBA */
  25842. static readonly TEXTUREFORMAT_RGBA: number;
  25843. /** RED */
  25844. static readonly TEXTUREFORMAT_RED: number;
  25845. /** RED (2nd reference) */
  25846. static readonly TEXTUREFORMAT_R: number;
  25847. /** RG */
  25848. static readonly TEXTUREFORMAT_RG: number;
  25849. /** RED_INTEGER */
  25850. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  25851. /** RED_INTEGER (2nd reference) */
  25852. static readonly TEXTUREFORMAT_R_INTEGER: number;
  25853. /** RG_INTEGER */
  25854. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  25855. /** RGB_INTEGER */
  25856. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  25857. /** RGBA_INTEGER */
  25858. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  25859. /** UNSIGNED_BYTE */
  25860. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  25861. /** UNSIGNED_BYTE (2nd reference) */
  25862. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  25863. /** FLOAT */
  25864. static readonly TEXTURETYPE_FLOAT: number;
  25865. /** HALF_FLOAT */
  25866. static readonly TEXTURETYPE_HALF_FLOAT: number;
  25867. /** BYTE */
  25868. static readonly TEXTURETYPE_BYTE: number;
  25869. /** SHORT */
  25870. static readonly TEXTURETYPE_SHORT: number;
  25871. /** UNSIGNED_SHORT */
  25872. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  25873. /** INT */
  25874. static readonly TEXTURETYPE_INT: number;
  25875. /** UNSIGNED_INT */
  25876. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  25877. /** UNSIGNED_SHORT_4_4_4_4 */
  25878. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  25879. /** UNSIGNED_SHORT_5_5_5_1 */
  25880. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  25881. /** UNSIGNED_SHORT_5_6_5 */
  25882. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  25883. /** UNSIGNED_INT_2_10_10_10_REV */
  25884. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  25885. /** UNSIGNED_INT_24_8 */
  25886. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  25887. /** UNSIGNED_INT_10F_11F_11F_REV */
  25888. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  25889. /** UNSIGNED_INT_5_9_9_9_REV */
  25890. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  25891. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  25892. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  25893. /** nearest is mag = nearest and min = nearest and mip = linear */
  25894. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  25895. /** Bilinear is mag = linear and min = linear and mip = nearest */
  25896. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  25897. /** Trilinear is mag = linear and min = linear and mip = linear */
  25898. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  25899. /** nearest is mag = nearest and min = nearest and mip = linear */
  25900. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  25901. /** Bilinear is mag = linear and min = linear and mip = nearest */
  25902. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  25903. /** Trilinear is mag = linear and min = linear and mip = linear */
  25904. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  25905. /** mag = nearest and min = nearest and mip = nearest */
  25906. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  25907. /** mag = nearest and min = linear and mip = nearest */
  25908. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  25909. /** mag = nearest and min = linear and mip = linear */
  25910. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  25911. /** mag = nearest and min = linear and mip = none */
  25912. static readonly TEXTURE_NEAREST_LINEAR: number;
  25913. /** mag = nearest and min = nearest and mip = none */
  25914. static readonly TEXTURE_NEAREST_NEAREST: number;
  25915. /** mag = linear and min = nearest and mip = nearest */
  25916. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  25917. /** mag = linear and min = nearest and mip = linear */
  25918. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  25919. /** mag = linear and min = linear and mip = none */
  25920. static readonly TEXTURE_LINEAR_LINEAR: number;
  25921. /** mag = linear and min = nearest and mip = none */
  25922. static readonly TEXTURE_LINEAR_NEAREST: number;
  25923. /** Explicit coordinates mode */
  25924. static readonly TEXTURE_EXPLICIT_MODE: number;
  25925. /** Spherical coordinates mode */
  25926. static readonly TEXTURE_SPHERICAL_MODE: number;
  25927. /** Planar coordinates mode */
  25928. static readonly TEXTURE_PLANAR_MODE: number;
  25929. /** Cubic coordinates mode */
  25930. static readonly TEXTURE_CUBIC_MODE: number;
  25931. /** Projection coordinates mode */
  25932. static readonly TEXTURE_PROJECTION_MODE: number;
  25933. /** Skybox coordinates mode */
  25934. static readonly TEXTURE_SKYBOX_MODE: number;
  25935. /** Inverse Cubic coordinates mode */
  25936. static readonly TEXTURE_INVCUBIC_MODE: number;
  25937. /** Equirectangular coordinates mode */
  25938. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  25939. /** Equirectangular Fixed coordinates mode */
  25940. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  25941. /** Equirectangular Fixed Mirrored coordinates mode */
  25942. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  25943. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  25944. static readonly SCALEMODE_FLOOR: number;
  25945. /** Defines that texture rescaling will look for the nearest power of 2 size */
  25946. static readonly SCALEMODE_NEAREST: number;
  25947. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  25948. static readonly SCALEMODE_CEILING: number;
  25949. /**
  25950. * Returns the current version of the framework
  25951. */
  25952. static readonly Version: string;
  25953. /**
  25954. * Returns a string describing the current engine
  25955. */
  25956. readonly description: string;
  25957. /**
  25958. * Gets or sets the epsilon value used by collision engine
  25959. */
  25960. static CollisionsEpsilon: number;
  25961. /**
  25962. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  25963. */
  25964. static ShadersRepository: string;
  25965. /**
  25966. * Method called to create the default loading screen.
  25967. * This can be overriden in your own app.
  25968. * @param canvas The rendering canvas element
  25969. * @returns The loading screen
  25970. */
  25971. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  25972. /**
  25973. * Method called to create the default rescale post process on each engine.
  25974. */ private static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  25975. /**
  25976. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  25977. */
  25978. forcePOTTextures: boolean;
  25979. /**
  25980. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  25981. */
  25982. isFullscreen: boolean;
  25983. /**
  25984. * Gets a boolean indicating if the pointer is currently locked
  25985. */
  25986. isPointerLock: boolean;
  25987. /**
  25988. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  25989. */
  25990. cullBackFaces: boolean;
  25991. /**
  25992. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  25993. */
  25994. renderEvenInBackground: boolean;
  25995. /**
  25996. * Gets or sets a boolean indicating that cache can be kept between frames
  25997. */
  25998. preventCacheWipeBetweenFrames: boolean;
  25999. /**
  26000. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  26001. **/
  26002. enableOfflineSupport: boolean;
  26003. /**
  26004. * 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)
  26005. **/
  26006. disableManifestCheck: boolean;
  26007. /**
  26008. * Gets the list of created scenes
  26009. */
  26010. scenes: Scene[];
  26011. /**
  26012. * Event raised when a new scene is created
  26013. */
  26014. onNewSceneAddedObservable: Observable<Scene>;
  26015. /**
  26016. * Gets the list of created postprocesses
  26017. */
  26018. postProcesses: PostProcess[];
  26019. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  26020. validateShaderPrograms: boolean;
  26021. /**
  26022. * Observable event triggered each time the rendering canvas is resized
  26023. */
  26024. onResizeObservable: Observable<Engine>;
  26025. /**
  26026. * Observable event triggered each time the canvas loses focus
  26027. */
  26028. onCanvasBlurObservable: Observable<Engine>;
  26029. /**
  26030. * Observable event triggered each time the canvas gains focus
  26031. */
  26032. onCanvasFocusObservable: Observable<Engine>;
  26033. /**
  26034. * Observable event triggered each time the canvas receives pointerout event
  26035. */
  26036. onCanvasPointerOutObservable: Observable<PointerEvent>;
  26037. /**
  26038. * Observable event triggered before each texture is initialized
  26039. */
  26040. onBeforeTextureInitObservable: Observable<Texture>;
  26041. private _vrDisplay;
  26042. private _vrSupported;
  26043. private _oldSize;
  26044. private _oldHardwareScaleFactor;
  26045. private _vrExclusivePointerMode;
  26046. private _webVRInitPromise;
  26047. /**
  26048. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  26049. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  26050. */
  26051. readonly isInVRExclusivePointerMode: boolean;
  26052. /**
  26053. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  26054. */
  26055. disableUniformBuffers: boolean;
  26056. /** @hidden */ uniformBuffers: UniformBuffer[];
  26057. /**
  26058. * Gets a boolean indicating that the engine supports uniform buffers
  26059. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  26060. */
  26061. readonly supportsUniformBuffers: boolean;
  26062. /**
  26063. * Observable raised when the engine begins a new frame
  26064. */
  26065. onBeginFrameObservable: Observable<Engine>;
  26066. /**
  26067. * If set, will be used to request the next animation frame for the render loop
  26068. */
  26069. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  26070. /**
  26071. * Observable raised when the engine ends the current frame
  26072. */
  26073. onEndFrameObservable: Observable<Engine>;
  26074. /**
  26075. * Observable raised when the engine is about to compile a shader
  26076. */
  26077. onBeforeShaderCompilationObservable: Observable<Engine>;
  26078. /**
  26079. * Observable raised when the engine has jsut compiled a shader
  26080. */
  26081. onAfterShaderCompilationObservable: Observable<Engine>;
  26082. /** @hidden */ gl: WebGLRenderingContext;
  26083. private _renderingCanvas;
  26084. private _windowIsBackground;
  26085. private _webGLVersion;
  26086. /**
  26087. * Gets a boolean indicating that only power of 2 textures are supported
  26088. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  26089. */
  26090. readonly needPOTTextures: boolean;
  26091. /** @hidden */ badOS: boolean;
  26092. /** @hidden */ badDesktopOS: boolean;
  26093. /**
  26094. * Gets or sets a value indicating if we want to disable texture binding optimization.
  26095. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  26096. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  26097. */
  26098. disableTextureBindingOptimization: boolean;
  26099. /**
  26100. * Gets the audio engine
  26101. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26102. * @ignorenaming
  26103. */
  26104. static audioEngine: IAudioEngine;
  26105. /**
  26106. * Default AudioEngine factory responsible of creating the Audio Engine.
  26107. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  26108. */
  26109. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  26110. /**
  26111. * Default offline support factory responsible of creating a tool used to store data locally.
  26112. * By default, this will create a Database object if the workload has been embedded.
  26113. */
  26114. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  26115. private _onFocus;
  26116. private _onBlur;
  26117. private _onCanvasPointerOut;
  26118. private _onCanvasBlur;
  26119. private _onCanvasFocus;
  26120. private _onFullscreenChange;
  26121. private _onPointerLockChange;
  26122. private _onVRDisplayPointerRestricted;
  26123. private _onVRDisplayPointerUnrestricted;
  26124. private _onVrDisplayConnect;
  26125. private _onVrDisplayDisconnect;
  26126. private _onVrDisplayPresentChange;
  26127. /**
  26128. * Observable signaled when VR display mode changes
  26129. */
  26130. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  26131. /**
  26132. * Observable signaled when VR request present is complete
  26133. */
  26134. onVRRequestPresentComplete: Observable<boolean>;
  26135. /**
  26136. * Observable signaled when VR request present starts
  26137. */
  26138. onVRRequestPresentStart: Observable<Engine>;
  26139. private _hardwareScalingLevel;
  26140. /** @hidden */
  26141. protected _caps: EngineCapabilities;
  26142. private _pointerLockRequested;
  26143. private _isStencilEnable;
  26144. private _colorWrite;
  26145. private _loadingScreen;
  26146. /** @hidden */ drawCalls: PerfCounter;
  26147. /** @hidden */ textureCollisions: PerfCounter;
  26148. private _glVersion;
  26149. private _glRenderer;
  26150. private _glVendor;
  26151. private _videoTextureSupported;
  26152. private _renderingQueueLaunched;
  26153. private _activeRenderLoops;
  26154. private _deterministicLockstep;
  26155. private _lockstepMaxSteps;
  26156. /**
  26157. * Observable signaled when a context lost event is raised
  26158. */
  26159. onContextLostObservable: Observable<Engine>;
  26160. /**
  26161. * Observable signaled when a context restored event is raised
  26162. */
  26163. onContextRestoredObservable: Observable<Engine>;
  26164. private _onContextLost;
  26165. private _onContextRestored;
  26166. private _contextWasLost;
  26167. private _doNotHandleContextLost;
  26168. /**
  26169. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  26170. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  26171. */
  26172. doNotHandleContextLost: boolean;
  26173. private _performanceMonitor;
  26174. private _fps;
  26175. private _deltaTime;
  26176. /**
  26177. * Turn this value on if you want to pause FPS computation when in background
  26178. */
  26179. disablePerformanceMonitorInBackground: boolean;
  26180. /**
  26181. * Gets the performance monitor attached to this engine
  26182. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  26183. */
  26184. readonly performanceMonitor: PerformanceMonitor;
  26185. /** @hidden */
  26186. protected _depthCullingState: _DepthCullingState;
  26187. /** @hidden */
  26188. protected _stencilState: _StencilState;
  26189. /** @hidden */
  26190. protected _alphaState: _AlphaState;
  26191. /** @hidden */
  26192. protected _alphaMode: number;
  26193. protected _internalTexturesCache: InternalTexture[];
  26194. /** @hidden */
  26195. protected _activeChannel: number;
  26196. private _currentTextureChannel;
  26197. /** @hidden */
  26198. protected _boundTexturesCache: {
  26199. [key: string]: Nullable<InternalTexture>;
  26200. };
  26201. /** @hidden */
  26202. protected _currentEffect: Nullable<Effect>;
  26203. /** @hidden */
  26204. protected _currentProgram: Nullable<WebGLProgram>;
  26205. private _compiledEffects;
  26206. private _vertexAttribArraysEnabled;
  26207. /** @hidden */
  26208. protected _cachedViewport: Nullable<Viewport>;
  26209. private _cachedVertexArrayObject;
  26210. /** @hidden */
  26211. protected _cachedVertexBuffers: any;
  26212. /** @hidden */
  26213. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  26214. /** @hidden */
  26215. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  26216. /** @hidden */
  26217. protected _currentRenderTarget: Nullable<InternalTexture>;
  26218. private _uintIndicesCurrentlySet;
  26219. private _currentBoundBuffer;
  26220. /** @hidden */
  26221. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  26222. private _currentBufferPointers;
  26223. private _currentInstanceLocations;
  26224. private _currentInstanceBuffers;
  26225. private _textureUnits;
  26226. private _firstBoundInternalTextureTracker;
  26227. private _lastBoundInternalTextureTracker;
  26228. private _workingCanvas;
  26229. private _workingContext;
  26230. private _rescalePostProcess;
  26231. private _dummyFramebuffer;
  26232. private _externalData;
  26233. private _bindedRenderFunction;
  26234. private _vaoRecordInProgress;
  26235. private _mustWipeVertexAttributes;
  26236. private _emptyTexture;
  26237. private _emptyCubeTexture;
  26238. private _emptyTexture3D;
  26239. /** @hidden */ frameHandler: number;
  26240. private _nextFreeTextureSlots;
  26241. private _maxSimultaneousTextures;
  26242. private _activeRequests;
  26243. private _texturesSupported;
  26244. private _textureFormatInUse;
  26245. /**
  26246. * Gets the list of texture formats supported
  26247. */
  26248. readonly texturesSupported: Array<string>;
  26249. /**
  26250. * Gets the list of texture formats in use
  26251. */
  26252. readonly textureFormatInUse: Nullable<string>;
  26253. /**
  26254. * Gets the current viewport
  26255. */
  26256. readonly currentViewport: Nullable<Viewport>;
  26257. /**
  26258. * Gets the default empty texture
  26259. */
  26260. readonly emptyTexture: InternalTexture;
  26261. /**
  26262. * Gets the default empty 3D texture
  26263. */
  26264. readonly emptyTexture3D: InternalTexture;
  26265. /**
  26266. * Gets the default empty cube texture
  26267. */
  26268. readonly emptyCubeTexture: InternalTexture;
  26269. /**
  26270. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  26271. */
  26272. readonly premultipliedAlpha: boolean;
  26273. /**
  26274. * Creates a new engine
  26275. * @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
  26276. * @param antialias defines enable antialiasing (default: false)
  26277. * @param options defines further options to be sent to the getContext() function
  26278. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  26279. */
  26280. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  26281. private _disableTouchAction;
  26282. private _rebuildInternalTextures;
  26283. private _rebuildEffects;
  26284. /**
  26285. * Gets a boolean indicating if all created effects are ready
  26286. * @returns true if all effects are ready
  26287. */
  26288. areAllEffectsReady(): boolean;
  26289. private _rebuildBuffers;
  26290. private _initGLContext;
  26291. /**
  26292. * Gets version of the current webGL context
  26293. */
  26294. readonly webGLVersion: number;
  26295. /**
  26296. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  26297. */
  26298. readonly isStencilEnable: boolean;
  26299. private _prepareWorkingCanvas;
  26300. /**
  26301. * Reset the texture cache to empty state
  26302. */
  26303. resetTextureCache(): void;
  26304. /**
  26305. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  26306. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26307. * @returns true if engine is in deterministic lock step mode
  26308. */
  26309. isDeterministicLockStep(): boolean;
  26310. /**
  26311. * Gets the max steps when engine is running in deterministic lock step
  26312. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26313. * @returns the max steps
  26314. */
  26315. getLockstepMaxSteps(): number;
  26316. /**
  26317. * Gets an object containing information about the current webGL context
  26318. * @returns an object containing the vender, the renderer and the version of the current webGL context
  26319. */
  26320. getGlInfo(): {
  26321. vendor: string;
  26322. renderer: string;
  26323. version: string;
  26324. };
  26325. /**
  26326. * Gets current aspect ratio
  26327. * @param camera defines the camera to use to get the aspect ratio
  26328. * @param useScreen defines if screen size must be used (or the current render target if any)
  26329. * @returns a number defining the aspect ratio
  26330. */
  26331. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  26332. /**
  26333. * Gets current screen aspect ratio
  26334. * @returns a number defining the aspect ratio
  26335. */
  26336. getScreenAspectRatio(): number;
  26337. /**
  26338. * Gets the current render width
  26339. * @param useScreen defines if screen size must be used (or the current render target if any)
  26340. * @returns a number defining the current render width
  26341. */
  26342. getRenderWidth(useScreen?: boolean): number;
  26343. /**
  26344. * Gets the current render height
  26345. * @param useScreen defines if screen size must be used (or the current render target if any)
  26346. * @returns a number defining the current render height
  26347. */
  26348. getRenderHeight(useScreen?: boolean): number;
  26349. /**
  26350. * Gets the HTML canvas attached with the current webGL context
  26351. * @returns a HTML canvas
  26352. */
  26353. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  26354. /**
  26355. * Gets the client rect of the HTML canvas attached with the current webGL context
  26356. * @returns a client rectanglee
  26357. */
  26358. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  26359. /**
  26360. * Defines the hardware scaling level.
  26361. * By default the hardware scaling level is computed from the window device ratio.
  26362. * 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.
  26363. * @param level defines the level to use
  26364. */
  26365. setHardwareScalingLevel(level: number): void;
  26366. /**
  26367. * Gets the current hardware scaling level.
  26368. * By default the hardware scaling level is computed from the window device ratio.
  26369. * 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.
  26370. * @returns a number indicating the current hardware scaling level
  26371. */
  26372. getHardwareScalingLevel(): number;
  26373. /**
  26374. * Gets the list of loaded textures
  26375. * @returns an array containing all loaded textures
  26376. */
  26377. getLoadedTexturesCache(): InternalTexture[];
  26378. /**
  26379. * Gets the object containing all engine capabilities
  26380. * @returns the EngineCapabilities object
  26381. */
  26382. getCaps(): EngineCapabilities;
  26383. /**
  26384. * Gets the current depth function
  26385. * @returns a number defining the depth function
  26386. */
  26387. getDepthFunction(): Nullable<number>;
  26388. /**
  26389. * Sets the current depth function
  26390. * @param depthFunc defines the function to use
  26391. */
  26392. setDepthFunction(depthFunc: number): void;
  26393. /**
  26394. * Sets the current depth function to GREATER
  26395. */
  26396. setDepthFunctionToGreater(): void;
  26397. /**
  26398. * Sets the current depth function to GEQUAL
  26399. */
  26400. setDepthFunctionToGreaterOrEqual(): void;
  26401. /**
  26402. * Sets the current depth function to LESS
  26403. */
  26404. setDepthFunctionToLess(): void;
  26405. /**
  26406. * Sets the current depth function to LEQUAL
  26407. */
  26408. setDepthFunctionToLessOrEqual(): void;
  26409. /**
  26410. * Gets a boolean indicating if stencil buffer is enabled
  26411. * @returns the current stencil buffer state
  26412. */
  26413. getStencilBuffer(): boolean;
  26414. /**
  26415. * Enable or disable the stencil buffer
  26416. * @param enable defines if the stencil buffer must be enabled or disabled
  26417. */
  26418. setStencilBuffer(enable: boolean): void;
  26419. /**
  26420. * Gets the current stencil mask
  26421. * @returns a number defining the new stencil mask to use
  26422. */
  26423. getStencilMask(): number;
  26424. /**
  26425. * Sets the current stencil mask
  26426. * @param mask defines the new stencil mask to use
  26427. */
  26428. setStencilMask(mask: number): void;
  26429. /**
  26430. * Gets the current stencil function
  26431. * @returns a number defining the stencil function to use
  26432. */
  26433. getStencilFunction(): number;
  26434. /**
  26435. * Gets the current stencil reference value
  26436. * @returns a number defining the stencil reference value to use
  26437. */
  26438. getStencilFunctionReference(): number;
  26439. /**
  26440. * Gets the current stencil mask
  26441. * @returns a number defining the stencil mask to use
  26442. */
  26443. getStencilFunctionMask(): number;
  26444. /**
  26445. * Sets the current stencil function
  26446. * @param stencilFunc defines the new stencil function to use
  26447. */
  26448. setStencilFunction(stencilFunc: number): void;
  26449. /**
  26450. * Sets the current stencil reference
  26451. * @param reference defines the new stencil reference to use
  26452. */
  26453. setStencilFunctionReference(reference: number): void;
  26454. /**
  26455. * Sets the current stencil mask
  26456. * @param mask defines the new stencil mask to use
  26457. */
  26458. setStencilFunctionMask(mask: number): void;
  26459. /**
  26460. * Gets the current stencil operation when stencil fails
  26461. * @returns a number defining stencil operation to use when stencil fails
  26462. */
  26463. getStencilOperationFail(): number;
  26464. /**
  26465. * Gets the current stencil operation when depth fails
  26466. * @returns a number defining stencil operation to use when depth fails
  26467. */
  26468. getStencilOperationDepthFail(): number;
  26469. /**
  26470. * Gets the current stencil operation when stencil passes
  26471. * @returns a number defining stencil operation to use when stencil passes
  26472. */
  26473. getStencilOperationPass(): number;
  26474. /**
  26475. * Sets the stencil operation to use when stencil fails
  26476. * @param operation defines the stencil operation to use when stencil fails
  26477. */
  26478. setStencilOperationFail(operation: number): void;
  26479. /**
  26480. * Sets the stencil operation to use when depth fails
  26481. * @param operation defines the stencil operation to use when depth fails
  26482. */
  26483. setStencilOperationDepthFail(operation: number): void;
  26484. /**
  26485. * Sets the stencil operation to use when stencil passes
  26486. * @param operation defines the stencil operation to use when stencil passes
  26487. */
  26488. setStencilOperationPass(operation: number): void;
  26489. /**
  26490. * Sets a boolean indicating if the dithering state is enabled or disabled
  26491. * @param value defines the dithering state
  26492. */
  26493. setDitheringState(value: boolean): void;
  26494. /**
  26495. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  26496. * @param value defines the rasterizer state
  26497. */
  26498. setRasterizerState(value: boolean): void;
  26499. /**
  26500. * stop executing a render loop function and remove it from the execution array
  26501. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  26502. */
  26503. stopRenderLoop(renderFunction?: () => void): void;
  26504. /** @hidden */ renderLoop(): void;
  26505. /**
  26506. * Register and execute a render loop. The engine can have more than one render function
  26507. * @param renderFunction defines the function to continuously execute
  26508. */
  26509. runRenderLoop(renderFunction: () => void): void;
  26510. /**
  26511. * Toggle full screen mode
  26512. * @param requestPointerLock defines if a pointer lock should be requested from the user
  26513. */
  26514. switchFullscreen(requestPointerLock: boolean): void;
  26515. /**
  26516. * Enters full screen mode
  26517. * @param requestPointerLock defines if a pointer lock should be requested from the user
  26518. */
  26519. enterFullscreen(requestPointerLock: boolean): void;
  26520. /**
  26521. * Exits full screen mode
  26522. */
  26523. exitFullscreen(): void;
  26524. /**
  26525. * Clear the current render buffer or the current render target (if any is set up)
  26526. * @param color defines the color to use
  26527. * @param backBuffer defines if the back buffer must be cleared
  26528. * @param depth defines if the depth buffer must be cleared
  26529. * @param stencil defines if the stencil buffer must be cleared
  26530. */
  26531. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  26532. /**
  26533. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  26534. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  26535. * @param y defines the y-coordinate of the corner of the clear rectangle
  26536. * @param width defines the width of the clear rectangle
  26537. * @param height defines the height of the clear rectangle
  26538. * @param clearColor defines the clear color
  26539. */
  26540. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  26541. /**
  26542. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  26543. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  26544. * @param y defines the y-coordinate of the corner of the clear rectangle
  26545. * @param width defines the width of the clear rectangle
  26546. * @param height defines the height of the clear rectangle
  26547. */
  26548. enableScissor(x: number, y: number, width: number, height: number): void;
  26549. /**
  26550. * Disable previously set scissor test rectangle
  26551. */
  26552. disableScissor(): void;
  26553. private _viewportCached;
  26554. /** @hidden */ viewport(x: number, y: number, width: number, height: number): void;
  26555. /**
  26556. * Set the WebGL's viewport
  26557. * @param viewport defines the viewport element to be used
  26558. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  26559. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  26560. */
  26561. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  26562. /**
  26563. * Directly set the WebGL Viewport
  26564. * @param x defines the x coordinate of the viewport (in screen space)
  26565. * @param y defines the y coordinate of the viewport (in screen space)
  26566. * @param width defines the width of the viewport (in screen space)
  26567. * @param height defines the height of the viewport (in screen space)
  26568. * @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
  26569. */
  26570. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  26571. /**
  26572. * Begin a new frame
  26573. */
  26574. beginFrame(): void;
  26575. /**
  26576. * Enf the current frame
  26577. */
  26578. endFrame(): void;
  26579. /**
  26580. * Resize the view according to the canvas' size
  26581. */
  26582. resize(): void;
  26583. /**
  26584. * Force a specific size of the canvas
  26585. * @param width defines the new canvas' width
  26586. * @param height defines the new canvas' height
  26587. */
  26588. setSize(width: number, height: number): void;
  26589. /**
  26590. * Gets a boolean indicating if a webVR device was detected
  26591. * @returns true if a webVR device was detected
  26592. */
  26593. isVRDevicePresent(): boolean;
  26594. /**
  26595. * Gets the current webVR device
  26596. * @returns the current webVR device (or null)
  26597. */
  26598. getVRDevice(): any;
  26599. /**
  26600. * Initializes a webVR display and starts listening to display change events
  26601. * The onVRDisplayChangedObservable will be notified upon these changes
  26602. * @returns The onVRDisplayChangedObservable
  26603. */
  26604. initWebVR(): Observable<IDisplayChangedEventArgs>;
  26605. /**
  26606. * Initializes a webVR display and starts listening to display change events
  26607. * The onVRDisplayChangedObservable will be notified upon these changes
  26608. * @returns A promise containing a VRDisplay and if vr is supported
  26609. */
  26610. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  26611. /**
  26612. * Call this function to switch to webVR mode
  26613. * Will do nothing if webVR is not supported or if there is no webVR device
  26614. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26615. */
  26616. enableVR(): void;
  26617. /**
  26618. * Call this function to leave webVR mode
  26619. * Will do nothing if webVR is not supported or if there is no webVR device
  26620. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26621. */
  26622. disableVR(): void;
  26623. private _onVRFullScreenTriggered;
  26624. private _getVRDisplaysAsync;
  26625. /**
  26626. * Binds the frame buffer to the specified texture.
  26627. * @param texture The texture to render to or null for the default canvas
  26628. * @param faceIndex The face of the texture to render to in case of cube texture
  26629. * @param requiredWidth The width of the target to render to
  26630. * @param requiredHeight The height of the target to render to
  26631. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  26632. * @param depthStencilTexture The depth stencil texture to use to render
  26633. * @param lodLevel defines le lod level to bind to the frame buffer
  26634. */
  26635. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  26636. private bindUnboundFramebuffer;
  26637. /**
  26638. * Unbind the current render target texture from the webGL context
  26639. * @param texture defines the render target texture to unbind
  26640. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  26641. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  26642. */
  26643. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  26644. /**
  26645. * Unbind a list of render target textures from the webGL context
  26646. * This is used only when drawBuffer extension or webGL2 are active
  26647. * @param textures defines the render target textures to unbind
  26648. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  26649. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  26650. */
  26651. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  26652. /**
  26653. * Force the mipmap generation for the given render target texture
  26654. * @param texture defines the render target texture to use
  26655. */
  26656. generateMipMapsForCubemap(texture: InternalTexture): void;
  26657. /**
  26658. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  26659. */
  26660. flushFramebuffer(): void;
  26661. /**
  26662. * Unbind the current render target and bind the default framebuffer
  26663. */
  26664. restoreDefaultFramebuffer(): void;
  26665. /**
  26666. * Create an uniform buffer
  26667. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  26668. * @param elements defines the content of the uniform buffer
  26669. * @returns the webGL uniform buffer
  26670. */
  26671. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  26672. /**
  26673. * Create a dynamic uniform buffer
  26674. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  26675. * @param elements defines the content of the uniform buffer
  26676. * @returns the webGL uniform buffer
  26677. */
  26678. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  26679. /**
  26680. * Update an existing uniform buffer
  26681. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  26682. * @param uniformBuffer defines the target uniform buffer
  26683. * @param elements defines the content to update
  26684. * @param offset defines the offset in the uniform buffer where update should start
  26685. * @param count defines the size of the data to update
  26686. */
  26687. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  26688. private _resetVertexBufferBinding;
  26689. /**
  26690. * Creates a vertex buffer
  26691. * @param data the data for the vertex buffer
  26692. * @returns the new WebGL static buffer
  26693. */
  26694. createVertexBuffer(data: DataArray): WebGLBuffer;
  26695. /**
  26696. * Creates a dynamic vertex buffer
  26697. * @param data the data for the dynamic vertex buffer
  26698. * @returns the new WebGL dynamic buffer
  26699. */
  26700. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  26701. /**
  26702. * Update a dynamic index buffer
  26703. * @param indexBuffer defines the target index buffer
  26704. * @param indices defines the data to update
  26705. * @param offset defines the offset in the target index buffer where update should start
  26706. */
  26707. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  26708. /**
  26709. * Updates a dynamic vertex buffer.
  26710. * @param vertexBuffer the vertex buffer to update
  26711. * @param data the data used to update the vertex buffer
  26712. * @param byteOffset the byte offset of the data
  26713. * @param byteLength the byte length of the data
  26714. */
  26715. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  26716. private _resetIndexBufferBinding;
  26717. /**
  26718. * Creates a new index buffer
  26719. * @param indices defines the content of the index buffer
  26720. * @param updatable defines if the index buffer must be updatable
  26721. * @returns a new webGL buffer
  26722. */
  26723. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  26724. /**
  26725. * Bind a webGL buffer to the webGL context
  26726. * @param buffer defines the buffer to bind
  26727. */
  26728. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  26729. /**
  26730. * Bind an uniform buffer to the current webGL context
  26731. * @param buffer defines the buffer to bind
  26732. */
  26733. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  26734. /**
  26735. * Bind a buffer to the current webGL context at a given location
  26736. * @param buffer defines the buffer to bind
  26737. * @param location defines the index where to bind the buffer
  26738. */
  26739. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  26740. /**
  26741. * Bind a specific block at a given index in a specific shader program
  26742. * @param shaderProgram defines the shader program
  26743. * @param blockName defines the block name
  26744. * @param index defines the index where to bind the block
  26745. */
  26746. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  26747. private bindIndexBuffer;
  26748. private bindBuffer;
  26749. /**
  26750. * update the bound buffer with the given data
  26751. * @param data defines the data to update
  26752. */
  26753. updateArrayBuffer(data: Float32Array): void;
  26754. private _vertexAttribPointer;
  26755. private _bindIndexBufferWithCache;
  26756. private _bindVertexBuffersAttributes;
  26757. /**
  26758. * Records a vertex array object
  26759. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  26760. * @param vertexBuffers defines the list of vertex buffers to store
  26761. * @param indexBuffer defines the index buffer to store
  26762. * @param effect defines the effect to store
  26763. * @returns the new vertex array object
  26764. */
  26765. recordVertexArrayObject(vertexBuffers: {
  26766. [key: string]: VertexBuffer;
  26767. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  26768. /**
  26769. * Bind a specific vertex array object
  26770. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  26771. * @param vertexArrayObject defines the vertex array object to bind
  26772. * @param indexBuffer defines the index buffer to bind
  26773. */
  26774. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  26775. /**
  26776. * Bind webGl buffers directly to the webGL context
  26777. * @param vertexBuffer defines the vertex buffer to bind
  26778. * @param indexBuffer defines the index buffer to bind
  26779. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  26780. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  26781. * @param effect defines the effect associated with the vertex buffer
  26782. */
  26783. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  26784. private _unbindVertexArrayObject;
  26785. /**
  26786. * Bind a list of vertex buffers to the webGL context
  26787. * @param vertexBuffers defines the list of vertex buffers to bind
  26788. * @param indexBuffer defines the index buffer to bind
  26789. * @param effect defines the effect associated with the vertex buffers
  26790. */
  26791. bindBuffers(vertexBuffers: {
  26792. [key: string]: Nullable<VertexBuffer>;
  26793. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  26794. /**
  26795. * Unbind all instance attributes
  26796. */
  26797. unbindInstanceAttributes(): void;
  26798. /**
  26799. * Release and free the memory of a vertex array object
  26800. * @param vao defines the vertex array object to delete
  26801. */
  26802. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  26803. /** @hidden */ releaseBuffer(buffer: WebGLBuffer): boolean;
  26804. /**
  26805. * Creates a webGL buffer to use with instanciation
  26806. * @param capacity defines the size of the buffer
  26807. * @returns the webGL buffer
  26808. */
  26809. createInstancesBuffer(capacity: number): WebGLBuffer;
  26810. /**
  26811. * Delete a webGL buffer used with instanciation
  26812. * @param buffer defines the webGL buffer to delete
  26813. */
  26814. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  26815. /**
  26816. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  26817. * @param instancesBuffer defines the webGL buffer to update and bind
  26818. * @param data defines the data to store in the buffer
  26819. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  26820. */
  26821. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  26822. /**
  26823. * Apply all cached states (depth, culling, stencil and alpha)
  26824. */
  26825. applyStates(): void;
  26826. /**
  26827. * Send a draw order
  26828. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  26829. * @param indexStart defines the starting index
  26830. * @param indexCount defines the number of index to draw
  26831. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  26832. */
  26833. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  26834. /**
  26835. * Draw a list of points
  26836. * @param verticesStart defines the index of first vertex to draw
  26837. * @param verticesCount defines the count of vertices to draw
  26838. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  26839. */
  26840. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  26841. /**
  26842. * Draw a list of unindexed primitives
  26843. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  26844. * @param verticesStart defines the index of first vertex to draw
  26845. * @param verticesCount defines the count of vertices to draw
  26846. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  26847. */
  26848. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  26849. /**
  26850. * Draw a list of indexed primitives
  26851. * @param fillMode defines the primitive to use
  26852. * @param indexStart defines the starting index
  26853. * @param indexCount defines the number of index to draw
  26854. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  26855. */
  26856. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  26857. /**
  26858. * Draw a list of unindexed primitives
  26859. * @param fillMode defines the primitive to use
  26860. * @param verticesStart defines the index of first vertex to draw
  26861. * @param verticesCount defines the count of vertices to draw
  26862. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  26863. */
  26864. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  26865. private _drawMode;
  26866. /** @hidden */ releaseEffect(effect: Effect): void;
  26867. /** @hidden */ deleteProgram(program: WebGLProgram): void;
  26868. /**
  26869. * Create a new effect (used to store vertex/fragment shaders)
  26870. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  26871. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  26872. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  26873. * @param samplers defines an array of string used to represent textures
  26874. * @param defines defines the string containing the defines to use to compile the shaders
  26875. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  26876. * @param onCompiled defines a function to call when the effect creation is successful
  26877. * @param onError defines a function to call when the effect creation has failed
  26878. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  26879. * @returns the new Effect
  26880. */
  26881. 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;
  26882. private _compileShader;
  26883. private _compileRawShader;
  26884. /**
  26885. * Directly creates a webGL program
  26886. * @param vertexCode defines the vertex shader code to use
  26887. * @param fragmentCode defines the fragment shader code to use
  26888. * @param context defines the webGL context to use (if not set, the current one will be used)
  26889. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  26890. * @returns the new webGL program
  26891. */
  26892. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  26893. /**
  26894. * Creates a webGL program
  26895. * @param vertexCode defines the vertex shader code to use
  26896. * @param fragmentCode defines the fragment shader code to use
  26897. * @param defines defines the string containing the defines to use to compile the shaders
  26898. * @param context defines the webGL context to use (if not set, the current one will be used)
  26899. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  26900. * @returns the new webGL program
  26901. */
  26902. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  26903. private _createShaderProgram;
  26904. private _finalizeProgram;
  26905. /** @hidden */ isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  26906. /** @hidden */ executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  26907. /**
  26908. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  26909. * @param shaderProgram defines the webGL program to use
  26910. * @param uniformsNames defines the list of uniform names
  26911. * @returns an array of webGL uniform locations
  26912. */
  26913. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  26914. /**
  26915. * Gets the lsit of active attributes for a given webGL program
  26916. * @param shaderProgram defines the webGL program to use
  26917. * @param attributesNames defines the list of attribute names to get
  26918. * @returns an array of indices indicating the offset of each attribute
  26919. */
  26920. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  26921. /**
  26922. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  26923. * @param effect defines the effect to activate
  26924. */
  26925. enableEffect(effect: Nullable<Effect>): void;
  26926. /**
  26927. * Set the value of an uniform to an array of int32
  26928. * @param uniform defines the webGL uniform location where to store the value
  26929. * @param array defines the array of int32 to store
  26930. */
  26931. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  26932. /**
  26933. * Set the value of an uniform to an array of int32 (stored as vec2)
  26934. * @param uniform defines the webGL uniform location where to store the value
  26935. * @param array defines the array of int32 to store
  26936. */
  26937. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  26938. /**
  26939. * Set the value of an uniform to an array of int32 (stored as vec3)
  26940. * @param uniform defines the webGL uniform location where to store the value
  26941. * @param array defines the array of int32 to store
  26942. */
  26943. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  26944. /**
  26945. * Set the value of an uniform to an array of int32 (stored as vec4)
  26946. * @param uniform defines the webGL uniform location where to store the value
  26947. * @param array defines the array of int32 to store
  26948. */
  26949. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  26950. /**
  26951. * Set the value of an uniform to an array of float32
  26952. * @param uniform defines the webGL uniform location where to store the value
  26953. * @param array defines the array of float32 to store
  26954. */
  26955. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  26956. /**
  26957. * Set the value of an uniform to an array of float32 (stored as vec2)
  26958. * @param uniform defines the webGL uniform location where to store the value
  26959. * @param array defines the array of float32 to store
  26960. */
  26961. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  26962. /**
  26963. * Set the value of an uniform to an array of float32 (stored as vec3)
  26964. * @param uniform defines the webGL uniform location where to store the value
  26965. * @param array defines the array of float32 to store
  26966. */
  26967. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  26968. /**
  26969. * Set the value of an uniform to an array of float32 (stored as vec4)
  26970. * @param uniform defines the webGL uniform location where to store the value
  26971. * @param array defines the array of float32 to store
  26972. */
  26973. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  26974. /**
  26975. * Set the value of an uniform to an array of number
  26976. * @param uniform defines the webGL uniform location where to store the value
  26977. * @param array defines the array of number to store
  26978. */
  26979. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  26980. /**
  26981. * Set the value of an uniform to an array of number (stored as vec2)
  26982. * @param uniform defines the webGL uniform location where to store the value
  26983. * @param array defines the array of number to store
  26984. */
  26985. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  26986. /**
  26987. * Set the value of an uniform to an array of number (stored as vec3)
  26988. * @param uniform defines the webGL uniform location where to store the value
  26989. * @param array defines the array of number to store
  26990. */
  26991. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  26992. /**
  26993. * Set the value of an uniform to an array of number (stored as vec4)
  26994. * @param uniform defines the webGL uniform location where to store the value
  26995. * @param array defines the array of number to store
  26996. */
  26997. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  26998. /**
  26999. * Set the value of an uniform to an array of float32 (stored as matrices)
  27000. * @param uniform defines the webGL uniform location where to store the value
  27001. * @param matrices defines the array of float32 to store
  27002. */
  27003. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  27004. /**
  27005. * Set the value of an uniform to a matrix
  27006. * @param uniform defines the webGL uniform location where to store the value
  27007. * @param matrix defines the matrix to store
  27008. */
  27009. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  27010. /**
  27011. * Set the value of an uniform to a matrix (3x3)
  27012. * @param uniform defines the webGL uniform location where to store the value
  27013. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  27014. */
  27015. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27016. /**
  27017. * Set the value of an uniform to a matrix (2x2)
  27018. * @param uniform defines the webGL uniform location where to store the value
  27019. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  27020. */
  27021. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27022. /**
  27023. * Set the value of an uniform to a number (int)
  27024. * @param uniform defines the webGL uniform location where to store the value
  27025. * @param value defines the int number to store
  27026. */
  27027. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  27028. /**
  27029. * Set the value of an uniform to a number (float)
  27030. * @param uniform defines the webGL uniform location where to store the value
  27031. * @param value defines the float number to store
  27032. */
  27033. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  27034. /**
  27035. * Set the value of an uniform to a vec2
  27036. * @param uniform defines the webGL uniform location where to store the value
  27037. * @param x defines the 1st component of the value
  27038. * @param y defines the 2nd component of the value
  27039. */
  27040. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  27041. /**
  27042. * Set the value of an uniform to a vec3
  27043. * @param uniform defines the webGL uniform location where to store the value
  27044. * @param x defines the 1st component of the value
  27045. * @param y defines the 2nd component of the value
  27046. * @param z defines the 3rd component of the value
  27047. */
  27048. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  27049. /**
  27050. * Set the value of an uniform to a boolean
  27051. * @param uniform defines the webGL uniform location where to store the value
  27052. * @param bool defines the boolean to store
  27053. */
  27054. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  27055. /**
  27056. * Set the value of an uniform to a vec4
  27057. * @param uniform defines the webGL uniform location where to store the value
  27058. * @param x defines the 1st component of the value
  27059. * @param y defines the 2nd component of the value
  27060. * @param z defines the 3rd component of the value
  27061. * @param w defines the 4th component of the value
  27062. */
  27063. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  27064. /**
  27065. * Set the value of an uniform to a Color3
  27066. * @param uniform defines the webGL uniform location where to store the value
  27067. * @param color3 defines the color to store
  27068. */
  27069. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  27070. /**
  27071. * Set the value of an uniform to a Color3 and an alpha value
  27072. * @param uniform defines the webGL uniform location where to store the value
  27073. * @param color3 defines the color to store
  27074. * @param alpha defines the alpha component to store
  27075. */
  27076. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  27077. /**
  27078. * Sets a Color4 on a uniform variable
  27079. * @param uniform defines the uniform location
  27080. * @param color4 defines the value to be set
  27081. */
  27082. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  27083. /**
  27084. * Set various states to the webGL context
  27085. * @param culling defines backface culling state
  27086. * @param zOffset defines the value to apply to zOffset (0 by default)
  27087. * @param force defines if states must be applied even if cache is up to date
  27088. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  27089. */
  27090. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  27091. /**
  27092. * Set the z offset to apply to current rendering
  27093. * @param value defines the offset to apply
  27094. */
  27095. setZOffset(value: number): void;
  27096. /**
  27097. * Gets the current value of the zOffset
  27098. * @returns the current zOffset state
  27099. */
  27100. getZOffset(): number;
  27101. /**
  27102. * Enable or disable depth buffering
  27103. * @param enable defines the state to set
  27104. */
  27105. setDepthBuffer(enable: boolean): void;
  27106. /**
  27107. * Gets a boolean indicating if depth writing is enabled
  27108. * @returns the current depth writing state
  27109. */
  27110. getDepthWrite(): boolean;
  27111. /**
  27112. * Enable or disable depth writing
  27113. * @param enable defines the state to set
  27114. */
  27115. setDepthWrite(enable: boolean): void;
  27116. /**
  27117. * Enable or disable color writing
  27118. * @param enable defines the state to set
  27119. */
  27120. setColorWrite(enable: boolean): void;
  27121. /**
  27122. * Gets a boolean indicating if color writing is enabled
  27123. * @returns the current color writing state
  27124. */
  27125. getColorWrite(): boolean;
  27126. /**
  27127. * Sets alpha constants used by some alpha blending modes
  27128. * @param r defines the red component
  27129. * @param g defines the green component
  27130. * @param b defines the blue component
  27131. * @param a defines the alpha component
  27132. */
  27133. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  27134. /**
  27135. * Sets the current alpha mode
  27136. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  27137. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  27138. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  27139. */
  27140. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  27141. /**
  27142. * Gets the current alpha mode
  27143. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  27144. * @returns the current alpha mode
  27145. */
  27146. getAlphaMode(): number;
  27147. /**
  27148. * Clears the list of texture accessible through engine.
  27149. * This can help preventing texture load conflict due to name collision.
  27150. */
  27151. clearInternalTexturesCache(): void;
  27152. /**
  27153. * Force the entire cache to be cleared
  27154. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  27155. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  27156. */
  27157. wipeCaches(bruteForce?: boolean): void;
  27158. /**
  27159. * Set the compressed texture format to use, based on the formats you have, and the formats
  27160. * supported by the hardware / browser.
  27161. *
  27162. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  27163. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  27164. * to API arguments needed to compressed textures. This puts the burden on the container
  27165. * generator to house the arcane code for determining these for current & future formats.
  27166. *
  27167. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  27168. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  27169. *
  27170. * Note: The result of this call is not taken into account when a texture is base64.
  27171. *
  27172. * @param formatsAvailable defines the list of those format families you have created
  27173. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  27174. *
  27175. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  27176. * @returns The extension selected.
  27177. */
  27178. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  27179. private _getSamplingParameters;
  27180. private _partialLoadImg;
  27181. private _cascadeLoadImgs;
  27182. /** @hidden */ createTexture(): WebGLTexture;
  27183. /**
  27184. * Usually called from Texture.ts.
  27185. * Passed information to create a WebGLTexture
  27186. * @param urlArg defines a value which contains one of the following:
  27187. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  27188. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  27189. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  27190. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  27191. * @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)
  27192. * @param scene needed for loading to the correct scene
  27193. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  27194. * @param onLoad optional callback to be called upon successful completion
  27195. * @param onError optional callback to be called upon failure
  27196. * @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
  27197. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  27198. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  27199. * @param forcedExtension defines the extension to use to pick the right loader
  27200. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  27201. * @returns a InternalTexture for assignment back into BABYLON.Texture
  27202. */
  27203. 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;
  27204. private _rescaleTexture;
  27205. /**
  27206. * Update a raw texture
  27207. * @param texture defines the texture to update
  27208. * @param data defines the data to store in the texture
  27209. * @param format defines the format of the data
  27210. * @param invertY defines if data must be stored with Y axis inverted
  27211. * @param compression defines the compression used (null by default)
  27212. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27213. */
  27214. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  27215. /**
  27216. * Creates a raw texture
  27217. * @param data defines the data to store in the texture
  27218. * @param width defines the width of the texture
  27219. * @param height defines the height of the texture
  27220. * @param format defines the format of the data
  27221. * @param generateMipMaps defines if the engine should generate the mip levels
  27222. * @param invertY defines if data must be stored with Y axis inverted
  27223. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  27224. * @param compression defines the compression used (null by default)
  27225. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27226. * @returns the raw texture inside an InternalTexture
  27227. */
  27228. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  27229. private _unpackFlipYCached;
  27230. /**
  27231. * In case you are sharing the context with other applications, it might
  27232. * be interested to not cache the unpack flip y state to ensure a consistent
  27233. * value would be set.
  27234. */
  27235. enableUnpackFlipYCached: boolean;
  27236. /** @hidden */ unpackFlipY(value: boolean): void;
  27237. /** @hidden */ getUnpackAlignement(): number;
  27238. /**
  27239. * Creates a dynamic texture
  27240. * @param width defines the width of the texture
  27241. * @param height defines the height of the texture
  27242. * @param generateMipMaps defines if the engine should generate the mip levels
  27243. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  27244. * @returns the dynamic texture inside an InternalTexture
  27245. */
  27246. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  27247. /**
  27248. * Update the sampling mode of a given texture
  27249. * @param samplingMode defines the required sampling mode
  27250. * @param texture defines the texture to update
  27251. */
  27252. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  27253. /**
  27254. * Update the content of a dynamic texture
  27255. * @param texture defines the texture to update
  27256. * @param canvas defines the canvas containing the source
  27257. * @param invertY defines if data must be stored with Y axis inverted
  27258. * @param premulAlpha defines if alpha is stored as premultiplied
  27259. * @param format defines the format of the data
  27260. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  27261. */
  27262. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  27263. /**
  27264. * Update a video texture
  27265. * @param texture defines the texture to update
  27266. * @param video defines the video element to use
  27267. * @param invertY defines if data must be stored with Y axis inverted
  27268. */
  27269. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  27270. /**
  27271. * Updates a depth texture Comparison Mode and Function.
  27272. * If the comparison Function is equal to 0, the mode will be set to none.
  27273. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  27274. * @param texture The texture to set the comparison function for
  27275. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  27276. */
  27277. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  27278. private _setupDepthStencilTexture;
  27279. /**
  27280. * Creates a depth stencil texture.
  27281. * This is only available in WebGL 2 or with the depth texture extension available.
  27282. * @param size The size of face edge in the texture.
  27283. * @param options The options defining the texture.
  27284. * @returns The texture
  27285. */
  27286. createDepthStencilTexture(size: number | {
  27287. width: number;
  27288. height: number;
  27289. }, options: DepthTextureCreationOptions): InternalTexture;
  27290. /**
  27291. * Creates a depth stencil texture.
  27292. * This is only available in WebGL 2 or with the depth texture extension available.
  27293. * @param size The size of face edge in the texture.
  27294. * @param options The options defining the texture.
  27295. * @returns The texture
  27296. */
  27297. private _createDepthStencilTexture;
  27298. /**
  27299. * Creates a depth stencil cube texture.
  27300. * This is only available in WebGL 2.
  27301. * @param size The size of face edge in the cube texture.
  27302. * @param options The options defining the cube texture.
  27303. * @returns The cube texture
  27304. */
  27305. private _createDepthStencilCubeTexture;
  27306. /**
  27307. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  27308. * @param renderTarget The render target to set the frame buffer for
  27309. */
  27310. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  27311. /**
  27312. * Creates a new render target texture
  27313. * @param size defines the size of the texture
  27314. * @param options defines the options used to create the texture
  27315. * @returns a new render target texture stored in an InternalTexture
  27316. */
  27317. createRenderTargetTexture(size: number | {
  27318. width: number;
  27319. height: number;
  27320. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  27321. /**
  27322. * Create a multi render target texture
  27323. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  27324. * @param size defines the size of the texture
  27325. * @param options defines the creation options
  27326. * @returns the cube texture as an InternalTexture
  27327. */
  27328. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  27329. private _setupFramebufferDepthAttachments;
  27330. /**
  27331. * Updates the sample count of a render target texture
  27332. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  27333. * @param texture defines the texture to update
  27334. * @param samples defines the sample count to set
  27335. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  27336. */
  27337. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  27338. /**
  27339. * Update the sample count for a given multiple render target texture
  27340. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  27341. * @param textures defines the textures to update
  27342. * @param samples defines the sample count to set
  27343. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  27344. */
  27345. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  27346. /** @hidden */ uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  27347. /** @hidden */ uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  27348. /** @hidden */ uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  27349. /** @hidden */ uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  27350. /**
  27351. * Creates a new render target cube texture
  27352. * @param size defines the size of the texture
  27353. * @param options defines the options used to create the texture
  27354. * @returns a new render target cube texture stored in an InternalTexture
  27355. */
  27356. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  27357. /**
  27358. * Creates a cube texture
  27359. * @param rootUrl defines the url where the files to load is located
  27360. * @param scene defines the current scene
  27361. * @param files defines the list of files to load (1 per face)
  27362. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  27363. * @param onLoad defines an optional callback raised when the texture is loaded
  27364. * @param onError defines an optional callback raised if there is an issue to load the texture
  27365. * @param format defines the format of the data
  27366. * @param forcedExtension defines the extension to use to pick the right loader
  27367. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  27368. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  27369. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  27370. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  27371. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  27372. * @returns the cube texture as an InternalTexture
  27373. */
  27374. 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;
  27375. /**
  27376. * @hidden
  27377. */ setCubeMapTextureParams(loadMipmap: boolean): void;
  27378. /**
  27379. * Update a raw cube texture
  27380. * @param texture defines the texture to udpdate
  27381. * @param data defines the data to store
  27382. * @param format defines the data format
  27383. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27384. * @param invertY defines if data must be stored with Y axis inverted
  27385. * @param compression defines the compression used (null by default)
  27386. * @param level defines which level of the texture to update
  27387. */
  27388. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  27389. /**
  27390. * Creates a new raw cube texture
  27391. * @param data defines the array of data to use to create each face
  27392. * @param size defines the size of the textures
  27393. * @param format defines the format of the data
  27394. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  27395. * @param generateMipMaps defines if the engine should generate the mip levels
  27396. * @param invertY defines if data must be stored with Y axis inverted
  27397. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  27398. * @param compression defines the compression used (null by default)
  27399. * @returns the cube texture as an InternalTexture
  27400. */
  27401. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  27402. /**
  27403. * Creates a new raw cube texture from a specified url
  27404. * @param url defines the url where the data is located
  27405. * @param scene defines the current scene
  27406. * @param size defines the size of the textures
  27407. * @param format defines the format of the data
  27408. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  27409. * @param noMipmap defines if the engine should avoid generating the mip levels
  27410. * @param callback defines a callback used to extract texture data from loaded data
  27411. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  27412. * @param onLoad defines a callback called when texture is loaded
  27413. * @param onError defines a callback called if there is an error
  27414. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  27415. * @param invertY defines if data must be stored with Y axis inverted
  27416. * @returns the cube texture as an InternalTexture
  27417. */
  27418. 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;
  27419. /**
  27420. * Update a raw 3D texture
  27421. * @param texture defines the texture to update
  27422. * @param data defines the data to store
  27423. * @param format defines the data format
  27424. * @param invertY defines if data must be stored with Y axis inverted
  27425. * @param compression defines the used compression (can be null)
  27426. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  27427. */
  27428. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  27429. /**
  27430. * Creates a new raw 3D texture
  27431. * @param data defines the data used to create the texture
  27432. * @param width defines the width of the texture
  27433. * @param height defines the height of the texture
  27434. * @param depth defines the depth of the texture
  27435. * @param format defines the format of the texture
  27436. * @param generateMipMaps defines if the engine must generate mip levels
  27437. * @param invertY defines if data must be stored with Y axis inverted
  27438. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  27439. * @param compression defines the compressed used (can be null)
  27440. * @param textureType defines the compressed used (can be null)
  27441. * @returns a new raw 3D texture (stored in an InternalTexture)
  27442. */
  27443. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  27444. private _prepareWebGLTextureContinuation;
  27445. private _prepareWebGLTexture;
  27446. private _convertRGBtoRGBATextureData;
  27447. /** @hidden */ releaseFramebufferObjects(texture: InternalTexture): void;
  27448. /** @hidden */ releaseTexture(texture: InternalTexture): void;
  27449. private setProgram;
  27450. private _boundUniforms;
  27451. /**
  27452. * Binds an effect to the webGL context
  27453. * @param effect defines the effect to bind
  27454. */
  27455. bindSamplers(effect: Effect): void;
  27456. private _moveBoundTextureOnTop;
  27457. private _getCorrectTextureChannel;
  27458. private _linkTrackers;
  27459. private _removeDesignatedSlot;
  27460. private _activateCurrentTexture;
  27461. /** @hidden */ bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  27462. /** @hidden */ bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  27463. /**
  27464. * Sets a texture to the webGL context from a postprocess
  27465. * @param channel defines the channel to use
  27466. * @param postProcess defines the source postprocess
  27467. */
  27468. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  27469. /**
  27470. * Binds the output of the passed in post process to the texture channel specified
  27471. * @param channel The channel the texture should be bound to
  27472. * @param postProcess The post process which's output should be bound
  27473. */
  27474. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  27475. /**
  27476. * Unbind all textures from the webGL context
  27477. */
  27478. unbindAllTextures(): void;
  27479. /**
  27480. * Sets a texture to the according uniform.
  27481. * @param channel The texture channel
  27482. * @param uniform The uniform to set
  27483. * @param texture The texture to apply
  27484. */
  27485. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  27486. /**
  27487. * Sets a depth stencil texture from a render target to the according uniform.
  27488. * @param channel The texture channel
  27489. * @param uniform The uniform to set
  27490. * @param texture The render target texture containing the depth stencil texture to apply
  27491. */
  27492. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  27493. private _bindSamplerUniformToChannel;
  27494. private _getTextureWrapMode;
  27495. private _setTexture;
  27496. /**
  27497. * Sets an array of texture to the webGL context
  27498. * @param channel defines the channel where the texture array must be set
  27499. * @param uniform defines the associated uniform location
  27500. * @param textures defines the array of textures to bind
  27501. */
  27502. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  27503. /** @hidden */ setAnisotropicLevel(target: number, texture: BaseTexture): void;
  27504. private _setTextureParameterFloat;
  27505. private _setTextureParameterInteger;
  27506. /**
  27507. * Reads pixels from the current frame buffer. Please note that this function can be slow
  27508. * @param x defines the x coordinate of the rectangle where pixels must be read
  27509. * @param y defines the y coordinate of the rectangle where pixels must be read
  27510. * @param width defines the width of the rectangle where pixels must be read
  27511. * @param height defines the height of the rectangle where pixels must be read
  27512. * @returns a Uint8Array containing RGBA colors
  27513. */
  27514. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  27515. /**
  27516. * Add an externaly attached data from its key.
  27517. * This method call will fail and return false, if such key already exists.
  27518. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  27519. * @param key the unique key that identifies the data
  27520. * @param data the data object to associate to the key for this Engine instance
  27521. * @return true if no such key were already present and the data was added successfully, false otherwise
  27522. */
  27523. addExternalData<T>(key: string, data: T): boolean;
  27524. /**
  27525. * Get an externaly attached data from its key
  27526. * @param key the unique key that identifies the data
  27527. * @return the associated data, if present (can be null), or undefined if not present
  27528. */
  27529. getExternalData<T>(key: string): T;
  27530. /**
  27531. * Get an externaly attached data from its key, create it using a factory if it's not already present
  27532. * @param key the unique key that identifies the data
  27533. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  27534. * @return the associated data, can be null if the factory returned null.
  27535. */
  27536. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  27537. /**
  27538. * Remove an externaly attached data from the Engine instance
  27539. * @param key the unique key that identifies the data
  27540. * @return true if the data was successfully removed, false if it doesn't exist
  27541. */
  27542. removeExternalData(key: string): boolean;
  27543. /**
  27544. * Unbind all vertex attributes from the webGL context
  27545. */
  27546. unbindAllAttributes(): void;
  27547. /**
  27548. * 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
  27549. */
  27550. releaseEffects(): void;
  27551. /**
  27552. * Dispose and release all associated resources
  27553. */
  27554. dispose(): void;
  27555. /**
  27556. * Display the loading screen
  27557. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27558. */
  27559. displayLoadingUI(): void;
  27560. /**
  27561. * Hide the loading screen
  27562. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27563. */
  27564. hideLoadingUI(): void;
  27565. /**
  27566. * Gets the current loading screen object
  27567. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27568. */
  27569. /**
  27570. * Sets the current loading screen object
  27571. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27572. */
  27573. loadingScreen: ILoadingScreen;
  27574. /**
  27575. * Sets the current loading screen text
  27576. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27577. */
  27578. loadingUIText: string;
  27579. /**
  27580. * Sets the current loading screen background color
  27581. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27582. */
  27583. loadingUIBackgroundColor: string;
  27584. /**
  27585. * Attach a new callback raised when context lost event is fired
  27586. * @param callback defines the callback to call
  27587. */
  27588. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  27589. /**
  27590. * Attach a new callback raised when context restored event is fired
  27591. * @param callback defines the callback to call
  27592. */
  27593. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  27594. /**
  27595. * Gets the source code of the vertex shader associated with a specific webGL program
  27596. * @param program defines the program to use
  27597. * @returns a string containing the source code of the vertex shader associated with the program
  27598. */
  27599. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  27600. /**
  27601. * Gets the source code of the fragment shader associated with a specific webGL program
  27602. * @param program defines the program to use
  27603. * @returns a string containing the source code of the fragment shader associated with the program
  27604. */
  27605. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  27606. /**
  27607. * Get the current error code of the webGL context
  27608. * @returns the error code
  27609. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  27610. */
  27611. getError(): number;
  27612. /**
  27613. * Gets the current framerate
  27614. * @returns a number representing the framerate
  27615. */
  27616. getFps(): number;
  27617. /**
  27618. * Gets the time spent between current and previous frame
  27619. * @returns a number representing the delta time in ms
  27620. */
  27621. getDeltaTime(): number;
  27622. private _measureFps;
  27623. /** @hidden */ readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  27624. private _canRenderToFloatFramebuffer;
  27625. private _canRenderToHalfFloatFramebuffer;
  27626. private _canRenderToFramebuffer;
  27627. /** @hidden */ getWebGLTextureType(type: number): number;
  27628. private _getInternalFormat;
  27629. /** @hidden */ getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  27630. /** @hidden */ getRGBAMultiSampleBufferFormat(type: number): number;
  27631. /** @hidden */ loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  27632. /** @hidden */ loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  27633. private _partialLoadFile;
  27634. private _cascadeLoadFiles;
  27635. /**
  27636. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  27637. * @returns true if the engine can be created
  27638. * @ignorenaming
  27639. */
  27640. static isSupported(): boolean;
  27641. }
  27642. }
  27643. declare module BABYLON {
  27644. /**
  27645. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  27646. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  27647. */
  27648. export class EffectFallbacks {
  27649. private _defines;
  27650. private _currentRank;
  27651. private _maxRank;
  27652. private _mesh;
  27653. /**
  27654. * Removes the fallback from the bound mesh.
  27655. */
  27656. unBindMesh(): void;
  27657. /**
  27658. * Adds a fallback on the specified property.
  27659. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  27660. * @param define The name of the define in the shader
  27661. */
  27662. addFallback(rank: number, define: string): void;
  27663. /**
  27664. * Sets the mesh to use CPU skinning when needing to fallback.
  27665. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  27666. * @param mesh The mesh to use the fallbacks.
  27667. */
  27668. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  27669. /**
  27670. * Checks to see if more fallbacks are still availible.
  27671. */
  27672. readonly isMoreFallbacks: boolean;
  27673. /**
  27674. * Removes the defines that shoould be removed when falling back.
  27675. * @param currentDefines defines the current define statements for the shader.
  27676. * @param effect defines the current effect we try to compile
  27677. * @returns The resulting defines with defines of the current rank removed.
  27678. */
  27679. reduce(currentDefines: string, effect: Effect): string;
  27680. }
  27681. /**
  27682. * Options to be used when creating an effect.
  27683. */
  27684. export class EffectCreationOptions {
  27685. /**
  27686. * Atrributes that will be used in the shader.
  27687. */
  27688. attributes: string[];
  27689. /**
  27690. * Uniform varible names that will be set in the shader.
  27691. */
  27692. uniformsNames: string[];
  27693. /**
  27694. * Uniform buffer varible names that will be set in the shader.
  27695. */
  27696. uniformBuffersNames: string[];
  27697. /**
  27698. * Sampler texture variable names that will be set in the shader.
  27699. */
  27700. samplers: string[];
  27701. /**
  27702. * Define statements that will be set in the shader.
  27703. */
  27704. defines: any;
  27705. /**
  27706. * Possible fallbacks for this effect to improve performance when needed.
  27707. */
  27708. fallbacks: Nullable<EffectFallbacks>;
  27709. /**
  27710. * Callback that will be called when the shader is compiled.
  27711. */
  27712. onCompiled: Nullable<(effect: Effect) => void>;
  27713. /**
  27714. * Callback that will be called if an error occurs during shader compilation.
  27715. */
  27716. onError: Nullable<(effect: Effect, errors: string) => void>;
  27717. /**
  27718. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  27719. */
  27720. indexParameters: any;
  27721. /**
  27722. * Max number of lights that can be used in the shader.
  27723. */
  27724. maxSimultaneousLights: number;
  27725. /**
  27726. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  27727. */
  27728. transformFeedbackVaryings: Nullable<string[]>;
  27729. }
  27730. /**
  27731. * Effect containing vertex and fragment shader that can be executed on an object.
  27732. */
  27733. export class Effect {
  27734. /**
  27735. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27736. */
  27737. static ShadersRepository: string;
  27738. /**
  27739. * Name of the effect.
  27740. */
  27741. name: any;
  27742. /**
  27743. * String container all the define statements that should be set on the shader.
  27744. */
  27745. defines: string;
  27746. /**
  27747. * Callback that will be called when the shader is compiled.
  27748. */
  27749. onCompiled: Nullable<(effect: Effect) => void>;
  27750. /**
  27751. * Callback that will be called if an error occurs during shader compilation.
  27752. */
  27753. onError: Nullable<(effect: Effect, errors: string) => void>;
  27754. /**
  27755. * Callback that will be called when effect is bound.
  27756. */
  27757. onBind: Nullable<(effect: Effect) => void>;
  27758. /**
  27759. * Unique ID of the effect.
  27760. */
  27761. uniqueId: number;
  27762. /**
  27763. * Observable that will be called when the shader is compiled.
  27764. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  27765. */
  27766. onCompileObservable: Observable<Effect>;
  27767. /**
  27768. * Observable that will be called if an error occurs during shader compilation.
  27769. */
  27770. onErrorObservable: Observable<Effect>;
  27771. /** @hidden */ onBindObservable: Nullable<Observable<Effect>>;
  27772. /**
  27773. * Observable that will be called when effect is bound.
  27774. */
  27775. readonly onBindObservable: Observable<Effect>;
  27776. /** @hidden */ bonesComputationForcedToCPU: boolean;
  27777. private static _uniqueIdSeed;
  27778. private _engine;
  27779. private _uniformBuffersNames;
  27780. private _uniformsNames;
  27781. private _samplers;
  27782. private _isReady;
  27783. private _compilationError;
  27784. private _attributesNames;
  27785. private _attributes;
  27786. private _uniforms;
  27787. /**
  27788. * Key for the effect.
  27789. * @hidden
  27790. */ key: string;
  27791. private _indexParameters;
  27792. private _fallbacks;
  27793. private _vertexSourceCode;
  27794. private _fragmentSourceCode;
  27795. private _vertexSourceCodeOverride;
  27796. private _fragmentSourceCodeOverride;
  27797. private _transformFeedbackVaryings;
  27798. /**
  27799. * Compiled shader to webGL program.
  27800. * @hidden
  27801. */ program: WebGLProgram;
  27802. private _valueCache;
  27803. private static _baseCache;
  27804. /**
  27805. * Instantiates an effect.
  27806. * An effect can be used to create/manage/execute vertex and fragment shaders.
  27807. * @param baseName Name of the effect.
  27808. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  27809. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  27810. * @param samplers List of sampler variables that will be passed to the shader.
  27811. * @param engine Engine to be used to render the effect
  27812. * @param defines Define statements to be added to the shader.
  27813. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  27814. * @param onCompiled Callback that will be called when the shader is compiled.
  27815. * @param onError Callback that will be called if an error occurs during shader compilation.
  27816. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  27817. */
  27818. 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);
  27819. /**
  27820. * Unique key for this effect
  27821. */
  27822. readonly key: string;
  27823. /**
  27824. * If the effect has been compiled and prepared.
  27825. * @returns if the effect is compiled and prepared.
  27826. */
  27827. isReady(): boolean;
  27828. /**
  27829. * The engine the effect was initialized with.
  27830. * @returns the engine.
  27831. */
  27832. getEngine(): Engine;
  27833. /**
  27834. * The compiled webGL program for the effect
  27835. * @returns the webGL program.
  27836. */
  27837. getProgram(): WebGLProgram;
  27838. /**
  27839. * The set of names of attribute variables for the shader.
  27840. * @returns An array of attribute names.
  27841. */
  27842. getAttributesNames(): string[];
  27843. /**
  27844. * Returns the attribute at the given index.
  27845. * @param index The index of the attribute.
  27846. * @returns The location of the attribute.
  27847. */
  27848. getAttributeLocation(index: number): number;
  27849. /**
  27850. * Returns the attribute based on the name of the variable.
  27851. * @param name of the attribute to look up.
  27852. * @returns the attribute location.
  27853. */
  27854. getAttributeLocationByName(name: string): number;
  27855. /**
  27856. * The number of attributes.
  27857. * @returns the numnber of attributes.
  27858. */
  27859. getAttributesCount(): number;
  27860. /**
  27861. * Gets the index of a uniform variable.
  27862. * @param uniformName of the uniform to look up.
  27863. * @returns the index.
  27864. */
  27865. getUniformIndex(uniformName: string): number;
  27866. /**
  27867. * Returns the attribute based on the name of the variable.
  27868. * @param uniformName of the uniform to look up.
  27869. * @returns the location of the uniform.
  27870. */
  27871. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  27872. /**
  27873. * Returns an array of sampler variable names
  27874. * @returns The array of sampler variable neames.
  27875. */
  27876. getSamplers(): string[];
  27877. /**
  27878. * The error from the last compilation.
  27879. * @returns the error string.
  27880. */
  27881. getCompilationError(): string;
  27882. /**
  27883. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  27884. * @param func The callback to be used.
  27885. */
  27886. executeWhenCompiled(func: (effect: Effect) => void): void;
  27887. private _checkIsReady;
  27888. /** @hidden */ loadVertexShader(vertex: any, callback: (data: any) => void): void;
  27889. /** @hidden */ loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  27890. /** @hidden */ dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  27891. private _processShaderConversion;
  27892. private _processIncludes;
  27893. private _processPrecision;
  27894. /**
  27895. * Recompiles the webGL program
  27896. * @param vertexSourceCode The source code for the vertex shader.
  27897. * @param fragmentSourceCode The source code for the fragment shader.
  27898. * @param onCompiled Callback called when completed.
  27899. * @param onError Callback called on error.
  27900. * @hidden
  27901. */ rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  27902. /**
  27903. * Gets the uniform locations of the the specified variable names
  27904. * @param names THe names of the variables to lookup.
  27905. * @returns Array of locations in the same order as variable names.
  27906. */
  27907. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  27908. /**
  27909. * Prepares the effect
  27910. * @hidden
  27911. */ prepareEffect(): void;
  27912. /**
  27913. * Checks if the effect is supported. (Must be called after compilation)
  27914. */
  27915. readonly isSupported: boolean;
  27916. /**
  27917. * Binds a texture to the engine to be used as output of the shader.
  27918. * @param channel Name of the output variable.
  27919. * @param texture Texture to bind.
  27920. * @hidden
  27921. */ bindTexture(channel: string, texture: InternalTexture): void;
  27922. /**
  27923. * Sets a texture on the engine to be used in the shader.
  27924. * @param channel Name of the sampler variable.
  27925. * @param texture Texture to set.
  27926. */
  27927. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  27928. /**
  27929. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  27930. * @param channel Name of the sampler variable.
  27931. * @param texture Texture to set.
  27932. */
  27933. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  27934. /**
  27935. * Sets an array of textures on the engine to be used in the shader.
  27936. * @param channel Name of the variable.
  27937. * @param textures Textures to set.
  27938. */
  27939. setTextureArray(channel: string, textures: BaseTexture[]): void;
  27940. /**
  27941. * 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)
  27942. * @param channel Name of the sampler variable.
  27943. * @param postProcess Post process to get the input texture from.
  27944. */
  27945. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  27946. /**
  27947. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  27948. * 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)
  27949. * @param channel Name of the sampler variable.
  27950. * @param postProcess Post process to get the output texture from.
  27951. */
  27952. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  27953. /** @hidden */ cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  27954. /** @hidden */ cacheFloat2(uniformName: string, x: number, y: number): boolean;
  27955. /** @hidden */ cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  27956. /** @hidden */ cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  27957. /**
  27958. * Binds a buffer to a uniform.
  27959. * @param buffer Buffer to bind.
  27960. * @param name Name of the uniform variable to bind to.
  27961. */
  27962. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  27963. /**
  27964. * Binds block to a uniform.
  27965. * @param blockName Name of the block to bind.
  27966. * @param index Index to bind.
  27967. */
  27968. bindUniformBlock(blockName: string, index: number): void;
  27969. /**
  27970. * Sets an interger value on a uniform variable.
  27971. * @param uniformName Name of the variable.
  27972. * @param value Value to be set.
  27973. * @returns this effect.
  27974. */
  27975. setInt(uniformName: string, value: number): Effect;
  27976. /**
  27977. * Sets an int array on a uniform variable.
  27978. * @param uniformName Name of the variable.
  27979. * @param array array to be set.
  27980. * @returns this effect.
  27981. */
  27982. setIntArray(uniformName: string, array: Int32Array): Effect;
  27983. /**
  27984. * 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)
  27985. * @param uniformName Name of the variable.
  27986. * @param array array to be set.
  27987. * @returns this effect.
  27988. */
  27989. setIntArray2(uniformName: string, array: Int32Array): Effect;
  27990. /**
  27991. * 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)
  27992. * @param uniformName Name of the variable.
  27993. * @param array array to be set.
  27994. * @returns this effect.
  27995. */
  27996. setIntArray3(uniformName: string, array: Int32Array): Effect;
  27997. /**
  27998. * 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)
  27999. * @param uniformName Name of the variable.
  28000. * @param array array to be set.
  28001. * @returns this effect.
  28002. */
  28003. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28004. /**
  28005. * Sets an float array on a uniform variable.
  28006. * @param uniformName Name of the variable.
  28007. * @param array array to be set.
  28008. * @returns this effect.
  28009. */
  28010. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28011. /**
  28012. * 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)
  28013. * @param uniformName Name of the variable.
  28014. * @param array array to be set.
  28015. * @returns this effect.
  28016. */
  28017. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28018. /**
  28019. * 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)
  28020. * @param uniformName Name of the variable.
  28021. * @param array array to be set.
  28022. * @returns this effect.
  28023. */
  28024. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28025. /**
  28026. * 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)
  28027. * @param uniformName Name of the variable.
  28028. * @param array array to be set.
  28029. * @returns this effect.
  28030. */
  28031. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28032. /**
  28033. * Sets an array on a uniform variable.
  28034. * @param uniformName Name of the variable.
  28035. * @param array array to be set.
  28036. * @returns this effect.
  28037. */
  28038. setArray(uniformName: string, array: number[]): Effect;
  28039. /**
  28040. * 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)
  28041. * @param uniformName Name of the variable.
  28042. * @param array array to be set.
  28043. * @returns this effect.
  28044. */
  28045. setArray2(uniformName: string, array: number[]): Effect;
  28046. /**
  28047. * 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)
  28048. * @param uniformName Name of the variable.
  28049. * @param array array to be set.
  28050. * @returns this effect.
  28051. */
  28052. setArray3(uniformName: string, array: number[]): Effect;
  28053. /**
  28054. * 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)
  28055. * @param uniformName Name of the variable.
  28056. * @param array array to be set.
  28057. * @returns this effect.
  28058. */
  28059. setArray4(uniformName: string, array: number[]): Effect;
  28060. /**
  28061. * Sets matrices on a uniform variable.
  28062. * @param uniformName Name of the variable.
  28063. * @param matrices matrices to be set.
  28064. * @returns this effect.
  28065. */
  28066. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28067. /**
  28068. * Sets matrix on a uniform variable.
  28069. * @param uniformName Name of the variable.
  28070. * @param matrix matrix to be set.
  28071. * @returns this effect.
  28072. */
  28073. setMatrix(uniformName: string, matrix: Matrix): Effect;
  28074. /**
  28075. * 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)
  28076. * @param uniformName Name of the variable.
  28077. * @param matrix matrix to be set.
  28078. * @returns this effect.
  28079. */
  28080. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28081. /**
  28082. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28083. * @param uniformName Name of the variable.
  28084. * @param matrix matrix to be set.
  28085. * @returns this effect.
  28086. */
  28087. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28088. /**
  28089. * Sets a float on a uniform variable.
  28090. * @param uniformName Name of the variable.
  28091. * @param value value to be set.
  28092. * @returns this effect.
  28093. */
  28094. setFloat(uniformName: string, value: number): Effect;
  28095. /**
  28096. * Sets a boolean on a uniform variable.
  28097. * @param uniformName Name of the variable.
  28098. * @param bool value to be set.
  28099. * @returns this effect.
  28100. */
  28101. setBool(uniformName: string, bool: boolean): Effect;
  28102. /**
  28103. * Sets a Vector2 on a uniform variable.
  28104. * @param uniformName Name of the variable.
  28105. * @param vector2 vector2 to be set.
  28106. * @returns this effect.
  28107. */
  28108. setVector2(uniformName: string, vector2: Vector2): Effect;
  28109. /**
  28110. * Sets a float2 on a uniform variable.
  28111. * @param uniformName Name of the variable.
  28112. * @param x First float in float2.
  28113. * @param y Second float in float2.
  28114. * @returns this effect.
  28115. */
  28116. setFloat2(uniformName: string, x: number, y: number): Effect;
  28117. /**
  28118. * Sets a Vector3 on a uniform variable.
  28119. * @param uniformName Name of the variable.
  28120. * @param vector3 Value to be set.
  28121. * @returns this effect.
  28122. */
  28123. setVector3(uniformName: string, vector3: Vector3): Effect;
  28124. /**
  28125. * Sets a float3 on a uniform variable.
  28126. * @param uniformName Name of the variable.
  28127. * @param x First float in float3.
  28128. * @param y Second float in float3.
  28129. * @param z Third float in float3.
  28130. * @returns this effect.
  28131. */
  28132. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28133. /**
  28134. * Sets a Vector4 on a uniform variable.
  28135. * @param uniformName Name of the variable.
  28136. * @param vector4 Value to be set.
  28137. * @returns this effect.
  28138. */
  28139. setVector4(uniformName: string, vector4: Vector4): Effect;
  28140. /**
  28141. * Sets a float4 on a uniform variable.
  28142. * @param uniformName Name of the variable.
  28143. * @param x First float in float4.
  28144. * @param y Second float in float4.
  28145. * @param z Third float in float4.
  28146. * @param w Fourth float in float4.
  28147. * @returns this effect.
  28148. */
  28149. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28150. /**
  28151. * Sets a Color3 on a uniform variable.
  28152. * @param uniformName Name of the variable.
  28153. * @param color3 Value to be set.
  28154. * @returns this effect.
  28155. */
  28156. setColor3(uniformName: string, color3: Color3): Effect;
  28157. /**
  28158. * Sets a Color4 on a uniform variable.
  28159. * @param uniformName Name of the variable.
  28160. * @param color3 Value to be set.
  28161. * @param alpha Alpha value to be set.
  28162. * @returns this effect.
  28163. */
  28164. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  28165. /**
  28166. * Sets a Color4 on a uniform variable
  28167. * @param uniformName defines the name of the variable
  28168. * @param color4 defines the value to be set
  28169. * @returns this effect.
  28170. */
  28171. setDirectColor4(uniformName: string, color4: Color4): Effect;
  28172. /**
  28173. * This function will add a new shader to the shader store
  28174. * @param name the name of the shader
  28175. * @param pixelShader optional pixel shader content
  28176. * @param vertexShader optional vertex shader content
  28177. */
  28178. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28179. /**
  28180. * Store of each shader (The can be looked up using effect.key)
  28181. */
  28182. static ShadersStore: {
  28183. [key: string]: string;
  28184. };
  28185. /**
  28186. * Store of each included file for a shader (The can be looked up using effect.key)
  28187. */
  28188. static IncludesShadersStore: {
  28189. [key: string]: string;
  28190. };
  28191. /**
  28192. * Resets the cache of effects.
  28193. */
  28194. static ResetCache(): void;
  28195. }
  28196. }
  28197. declare module BABYLON {
  28198. /**
  28199. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28200. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28201. * 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;
  28202. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28203. */
  28204. export class ColorCurves {
  28205. private _dirty;
  28206. private _tempColor;
  28207. private _globalCurve;
  28208. private _highlightsCurve;
  28209. private _midtonesCurve;
  28210. private _shadowsCurve;
  28211. private _positiveCurve;
  28212. private _negativeCurve;
  28213. private _globalHue;
  28214. private _globalDensity;
  28215. private _globalSaturation;
  28216. private _globalExposure;
  28217. /**
  28218. * Gets the global Hue value.
  28219. * 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).
  28220. */
  28221. /**
  28222. * Sets the global Hue value.
  28223. * 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).
  28224. */
  28225. globalHue: number;
  28226. /**
  28227. * Gets the global Density value.
  28228. * 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.
  28229. * Values less than zero provide a filter of opposite hue.
  28230. */
  28231. /**
  28232. * Sets the global Density value.
  28233. * 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.
  28234. * Values less than zero provide a filter of opposite hue.
  28235. */
  28236. globalDensity: number;
  28237. /**
  28238. * Gets the global Saturation value.
  28239. * 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.
  28240. */
  28241. /**
  28242. * Sets the global Saturation value.
  28243. * 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.
  28244. */
  28245. globalSaturation: number;
  28246. /**
  28247. * Gets the global Exposure value.
  28248. * 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.
  28249. */
  28250. /**
  28251. * Sets the global Exposure value.
  28252. * 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.
  28253. */
  28254. globalExposure: number;
  28255. private _highlightsHue;
  28256. private _highlightsDensity;
  28257. private _highlightsSaturation;
  28258. private _highlightsExposure;
  28259. /**
  28260. * Gets the highlights Hue value.
  28261. * 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).
  28262. */
  28263. /**
  28264. * Sets the highlights Hue value.
  28265. * 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).
  28266. */
  28267. highlightsHue: number;
  28268. /**
  28269. * Gets the highlights Density value.
  28270. * 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.
  28271. * Values less than zero provide a filter of opposite hue.
  28272. */
  28273. /**
  28274. * Sets the highlights Density value.
  28275. * 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.
  28276. * Values less than zero provide a filter of opposite hue.
  28277. */
  28278. highlightsDensity: number;
  28279. /**
  28280. * Gets the highlights Saturation value.
  28281. * 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.
  28282. */
  28283. /**
  28284. * Sets the highlights Saturation value.
  28285. * 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.
  28286. */
  28287. highlightsSaturation: number;
  28288. /**
  28289. * Gets the highlights Exposure value.
  28290. * 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.
  28291. */
  28292. /**
  28293. * Sets the highlights Exposure value.
  28294. * 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.
  28295. */
  28296. highlightsExposure: number;
  28297. private _midtonesHue;
  28298. private _midtonesDensity;
  28299. private _midtonesSaturation;
  28300. private _midtonesExposure;
  28301. /**
  28302. * Gets the midtones Hue value.
  28303. * 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).
  28304. */
  28305. /**
  28306. * Sets the midtones Hue value.
  28307. * 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).
  28308. */
  28309. midtonesHue: number;
  28310. /**
  28311. * Gets the midtones Density value.
  28312. * 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.
  28313. * Values less than zero provide a filter of opposite hue.
  28314. */
  28315. /**
  28316. * Sets the midtones Density value.
  28317. * 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.
  28318. * Values less than zero provide a filter of opposite hue.
  28319. */
  28320. midtonesDensity: number;
  28321. /**
  28322. * Gets the midtones Saturation value.
  28323. * 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.
  28324. */
  28325. /**
  28326. * Sets the midtones Saturation value.
  28327. * 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.
  28328. */
  28329. midtonesSaturation: number;
  28330. /**
  28331. * Gets the midtones Exposure value.
  28332. * 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.
  28333. */
  28334. /**
  28335. * Sets the midtones Exposure value.
  28336. * 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.
  28337. */
  28338. midtonesExposure: number;
  28339. private _shadowsHue;
  28340. private _shadowsDensity;
  28341. private _shadowsSaturation;
  28342. private _shadowsExposure;
  28343. /**
  28344. * Gets the shadows Hue value.
  28345. * 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).
  28346. */
  28347. /**
  28348. * Sets the shadows Hue value.
  28349. * 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).
  28350. */
  28351. shadowsHue: number;
  28352. /**
  28353. * Gets the shadows Density value.
  28354. * 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.
  28355. * Values less than zero provide a filter of opposite hue.
  28356. */
  28357. /**
  28358. * Sets the shadows Density value.
  28359. * 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.
  28360. * Values less than zero provide a filter of opposite hue.
  28361. */
  28362. shadowsDensity: number;
  28363. /**
  28364. * Gets the shadows Saturation value.
  28365. * 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.
  28366. */
  28367. /**
  28368. * Sets the shadows Saturation value.
  28369. * 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.
  28370. */
  28371. shadowsSaturation: number;
  28372. /**
  28373. * Gets the shadows Exposure value.
  28374. * 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.
  28375. */
  28376. /**
  28377. * Sets the shadows Exposure value.
  28378. * 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.
  28379. */
  28380. shadowsExposure: number;
  28381. /**
  28382. * Returns the class name
  28383. * @returns The class name
  28384. */
  28385. getClassName(): string;
  28386. /**
  28387. * Binds the color curves to the shader.
  28388. * @param colorCurves The color curve to bind
  28389. * @param effect The effect to bind to
  28390. * @param positiveUniform The positive uniform shader parameter
  28391. * @param neutralUniform The neutral uniform shader parameter
  28392. * @param negativeUniform The negative uniform shader parameter
  28393. */
  28394. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  28395. /**
  28396. * Prepare the list of uniforms associated with the ColorCurves effects.
  28397. * @param uniformsList The list of uniforms used in the effect
  28398. */
  28399. static PrepareUniforms(uniformsList: string[]): void;
  28400. /**
  28401. * Returns color grading data based on a hue, density, saturation and exposure value.
  28402. * @param filterHue The hue of the color filter.
  28403. * @param filterDensity The density of the color filter.
  28404. * @param saturation The saturation.
  28405. * @param exposure The exposure.
  28406. * @param result The result data container.
  28407. */
  28408. private getColorGradingDataToRef;
  28409. /**
  28410. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  28411. * @param value The input slider value in range [-100,100].
  28412. * @returns Adjusted value.
  28413. */
  28414. private static applyColorGradingSliderNonlinear;
  28415. /**
  28416. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  28417. * @param hue The hue (H) input.
  28418. * @param saturation The saturation (S) input.
  28419. * @param brightness The brightness (B) input.
  28420. * @result An RGBA color represented as Vector4.
  28421. */
  28422. private static fromHSBToRef;
  28423. /**
  28424. * Returns a value clamped between min and max
  28425. * @param value The value to clamp
  28426. * @param min The minimum of value
  28427. * @param max The maximum of value
  28428. * @returns The clamped value.
  28429. */
  28430. private static clamp;
  28431. /**
  28432. * Clones the current color curve instance.
  28433. * @return The cloned curves
  28434. */
  28435. clone(): ColorCurves;
  28436. /**
  28437. * Serializes the current color curve instance to a json representation.
  28438. * @return a JSON representation
  28439. */
  28440. serialize(): any;
  28441. /**
  28442. * Parses the color curve from a json representation.
  28443. * @param source the JSON source to parse
  28444. * @return The parsed curves
  28445. */
  28446. static Parse(source: any): ColorCurves;
  28447. }
  28448. }
  28449. declare module BABYLON {
  28450. /**
  28451. * Interface to follow in your material defines to integrate easily the
  28452. * Image proccessing functions.
  28453. * @hidden
  28454. */
  28455. export interface IImageProcessingConfigurationDefines {
  28456. IMAGEPROCESSING: boolean;
  28457. VIGNETTE: boolean;
  28458. VIGNETTEBLENDMODEMULTIPLY: boolean;
  28459. VIGNETTEBLENDMODEOPAQUE: boolean;
  28460. TONEMAPPING: boolean;
  28461. TONEMAPPING_ACES: boolean;
  28462. CONTRAST: boolean;
  28463. EXPOSURE: boolean;
  28464. COLORCURVES: boolean;
  28465. COLORGRADING: boolean;
  28466. COLORGRADING3D: boolean;
  28467. SAMPLER3DGREENDEPTH: boolean;
  28468. SAMPLER3DBGRMAP: boolean;
  28469. IMAGEPROCESSINGPOSTPROCESS: boolean;
  28470. }
  28471. /**
  28472. * @hidden
  28473. */
  28474. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  28475. IMAGEPROCESSING: boolean;
  28476. VIGNETTE: boolean;
  28477. VIGNETTEBLENDMODEMULTIPLY: boolean;
  28478. VIGNETTEBLENDMODEOPAQUE: boolean;
  28479. TONEMAPPING: boolean;
  28480. TONEMAPPING_ACES: boolean;
  28481. CONTRAST: boolean;
  28482. COLORCURVES: boolean;
  28483. COLORGRADING: boolean;
  28484. COLORGRADING3D: boolean;
  28485. SAMPLER3DGREENDEPTH: boolean;
  28486. SAMPLER3DBGRMAP: boolean;
  28487. IMAGEPROCESSINGPOSTPROCESS: boolean;
  28488. EXPOSURE: boolean;
  28489. constructor();
  28490. }
  28491. /**
  28492. * This groups together the common properties used for image processing either in direct forward pass
  28493. * or through post processing effect depending on the use of the image processing pipeline in your scene
  28494. * or not.
  28495. */
  28496. export class ImageProcessingConfiguration {
  28497. /**
  28498. * Default tone mapping applied in BabylonJS.
  28499. */
  28500. static readonly TONEMAPPING_STANDARD: number;
  28501. /**
  28502. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  28503. * to other engines rendering to increase portability.
  28504. */
  28505. static readonly TONEMAPPING_ACES: number;
  28506. /**
  28507. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  28508. */
  28509. colorCurves: Nullable<ColorCurves>;
  28510. private _colorCurvesEnabled;
  28511. /**
  28512. * Gets wether the color curves effect is enabled.
  28513. */
  28514. /**
  28515. * Sets wether the color curves effect is enabled.
  28516. */
  28517. colorCurvesEnabled: boolean;
  28518. private _colorGradingTexture;
  28519. /**
  28520. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  28521. */
  28522. /**
  28523. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  28524. */
  28525. colorGradingTexture: Nullable<BaseTexture>;
  28526. private _colorGradingEnabled;
  28527. /**
  28528. * Gets wether the color grading effect is enabled.
  28529. */
  28530. /**
  28531. * Sets wether the color grading effect is enabled.
  28532. */
  28533. colorGradingEnabled: boolean;
  28534. private _colorGradingWithGreenDepth;
  28535. /**
  28536. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  28537. */
  28538. /**
  28539. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  28540. */
  28541. colorGradingWithGreenDepth: boolean;
  28542. private _colorGradingBGR;
  28543. /**
  28544. * Gets wether the color grading texture contains BGR values.
  28545. */
  28546. /**
  28547. * Sets wether the color grading texture contains BGR values.
  28548. */
  28549. colorGradingBGR: boolean;
  28550. /** @hidden */ exposure: number;
  28551. /**
  28552. * Gets the Exposure used in the effect.
  28553. */
  28554. /**
  28555. * Sets the Exposure used in the effect.
  28556. */
  28557. exposure: number;
  28558. private _toneMappingEnabled;
  28559. /**
  28560. * Gets wether the tone mapping effect is enabled.
  28561. */
  28562. /**
  28563. * Sets wether the tone mapping effect is enabled.
  28564. */
  28565. toneMappingEnabled: boolean;
  28566. private _toneMappingType;
  28567. /**
  28568. * Gets the type of tone mapping effect.
  28569. */
  28570. /**
  28571. * Sets the type of tone mapping effect used in BabylonJS.
  28572. */
  28573. toneMappingType: number;
  28574. protected _contrast: number;
  28575. /**
  28576. * Gets the contrast used in the effect.
  28577. */
  28578. /**
  28579. * Sets the contrast used in the effect.
  28580. */
  28581. contrast: number;
  28582. /**
  28583. * Vignette stretch size.
  28584. */
  28585. vignetteStretch: number;
  28586. /**
  28587. * Vignette centre X Offset.
  28588. */
  28589. vignetteCentreX: number;
  28590. /**
  28591. * Vignette centre Y Offset.
  28592. */
  28593. vignetteCentreY: number;
  28594. /**
  28595. * Vignette weight or intensity of the vignette effect.
  28596. */
  28597. vignetteWeight: number;
  28598. /**
  28599. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  28600. * if vignetteEnabled is set to true.
  28601. */
  28602. vignetteColor: Color4;
  28603. /**
  28604. * Camera field of view used by the Vignette effect.
  28605. */
  28606. vignetteCameraFov: number;
  28607. private _vignetteBlendMode;
  28608. /**
  28609. * Gets the vignette blend mode allowing different kind of effect.
  28610. */
  28611. /**
  28612. * Sets the vignette blend mode allowing different kind of effect.
  28613. */
  28614. vignetteBlendMode: number;
  28615. private _vignetteEnabled;
  28616. /**
  28617. * Gets wether the vignette effect is enabled.
  28618. */
  28619. /**
  28620. * Sets wether the vignette effect is enabled.
  28621. */
  28622. vignetteEnabled: boolean;
  28623. private _applyByPostProcess;
  28624. /**
  28625. * Gets wether the image processing is applied through a post process or not.
  28626. */
  28627. /**
  28628. * Sets wether the image processing is applied through a post process or not.
  28629. */
  28630. applyByPostProcess: boolean;
  28631. private _isEnabled;
  28632. /**
  28633. * Gets wether the image processing is enabled or not.
  28634. */
  28635. /**
  28636. * Sets wether the image processing is enabled or not.
  28637. */
  28638. isEnabled: boolean;
  28639. /**
  28640. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  28641. */
  28642. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  28643. /**
  28644. * Method called each time the image processing information changes requires to recompile the effect.
  28645. */
  28646. protected _updateParameters(): void;
  28647. /**
  28648. * Gets the current class name.
  28649. * @return "ImageProcessingConfiguration"
  28650. */
  28651. getClassName(): string;
  28652. /**
  28653. * Prepare the list of uniforms associated with the Image Processing effects.
  28654. * @param uniforms The list of uniforms used in the effect
  28655. * @param defines the list of defines currently in use
  28656. */
  28657. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  28658. /**
  28659. * Prepare the list of samplers associated with the Image Processing effects.
  28660. * @param samplersList The list of uniforms used in the effect
  28661. * @param defines the list of defines currently in use
  28662. */
  28663. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  28664. /**
  28665. * Prepare the list of defines associated to the shader.
  28666. * @param defines the list of defines to complete
  28667. * @param forPostProcess Define if we are currently in post process mode or not
  28668. */
  28669. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  28670. /**
  28671. * Returns true if all the image processing information are ready.
  28672. * @returns True if ready, otherwise, false
  28673. */
  28674. isReady(): boolean;
  28675. /**
  28676. * Binds the image processing to the shader.
  28677. * @param effect The effect to bind to
  28678. * @param aspectRatio Define the current aspect ratio of the effect
  28679. */
  28680. bind(effect: Effect, aspectRatio?: number): void;
  28681. /**
  28682. * Clones the current image processing instance.
  28683. * @return The cloned image processing
  28684. */
  28685. clone(): ImageProcessingConfiguration;
  28686. /**
  28687. * Serializes the current image processing instance to a json representation.
  28688. * @return a JSON representation
  28689. */
  28690. serialize(): any;
  28691. /**
  28692. * Parses the image processing from a json representation.
  28693. * @param source the JSON source to parse
  28694. * @return The parsed image processing
  28695. */
  28696. static Parse(source: any): ImageProcessingConfiguration;
  28697. private static _VIGNETTEMODE_MULTIPLY;
  28698. private static _VIGNETTEMODE_OPAQUE;
  28699. /**
  28700. * Used to apply the vignette as a mix with the pixel color.
  28701. */
  28702. static readonly VIGNETTEMODE_MULTIPLY: number;
  28703. /**
  28704. * Used to apply the vignette as a replacement of the pixel color.
  28705. */
  28706. static readonly VIGNETTEMODE_OPAQUE: number;
  28707. }
  28708. }
  28709. declare module BABYLON {
  28710. /**
  28711. * This represents all the required information to add a fresnel effect on a material:
  28712. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28713. */
  28714. export class FresnelParameters {
  28715. private _isEnabled;
  28716. /**
  28717. * Define if the fresnel effect is enable or not.
  28718. */
  28719. isEnabled: boolean;
  28720. /**
  28721. * Define the color used on edges (grazing angle)
  28722. */
  28723. leftColor: Color3;
  28724. /**
  28725. * Define the color used on center
  28726. */
  28727. rightColor: Color3;
  28728. /**
  28729. * Define bias applied to computed fresnel term
  28730. */
  28731. bias: number;
  28732. /**
  28733. * Defined the power exponent applied to fresnel term
  28734. */
  28735. power: number;
  28736. /**
  28737. * Clones the current fresnel and its valuues
  28738. * @returns a clone fresnel configuration
  28739. */
  28740. clone(): FresnelParameters;
  28741. /**
  28742. * Serializes the current fresnel parameters to a JSON representation.
  28743. * @return the JSON serialization
  28744. */
  28745. serialize(): any;
  28746. /**
  28747. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28748. * @param parsedFresnelParameters Define the JSON representation
  28749. * @returns the parsed parameters
  28750. */
  28751. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28752. }
  28753. }
  28754. declare module BABYLON {
  28755. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28756. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28757. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28758. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28759. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28760. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28761. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28762. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28763. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28764. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28765. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28766. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28767. /**
  28768. * Decorator used to define property that can be serialized as reference to a camera
  28769. * @param sourceName defines the name of the property to decorate
  28770. */
  28771. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28772. /**
  28773. * Class used to help serialization objects
  28774. */
  28775. export class SerializationHelper {
  28776. /** hidden */ private static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  28777. /** hidden */ private static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  28778. /** hidden */ private static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  28779. /** hidden */ private static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  28780. /**
  28781. * Appends the serialized animations from the source animations
  28782. * @param source Source containing the animations
  28783. * @param destination Target to store the animations
  28784. */
  28785. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28786. /**
  28787. * Static function used to serialized a specific entity
  28788. * @param entity defines the entity to serialize
  28789. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28790. * @returns a JSON compatible object representing the serialization of the entity
  28791. */
  28792. static Serialize<T>(entity: T, serializationObject?: any): any;
  28793. /**
  28794. * Creates a new entity from a serialization data object
  28795. * @param creationFunction defines a function used to instanciated the new entity
  28796. * @param source defines the source serialization data
  28797. * @param scene defines the hosting scene
  28798. * @param rootUrl defines the root url for resources
  28799. * @returns a new entity
  28800. */
  28801. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28802. /**
  28803. * Clones an object
  28804. * @param creationFunction defines the function used to instanciate the new object
  28805. * @param source defines the source object
  28806. * @returns the cloned object
  28807. */
  28808. static Clone<T>(creationFunction: () => T, source: T): T;
  28809. /**
  28810. * Instanciates a new object based on a source one (some data will be shared between both object)
  28811. * @param creationFunction defines the function used to instanciate the new object
  28812. * @param source defines the source object
  28813. * @returns the new object
  28814. */
  28815. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28816. }
  28817. }
  28818. declare module BABYLON {
  28819. /**
  28820. * This is the base class of all the camera used in the application.
  28821. * @see http://doc.babylonjs.com/features/cameras
  28822. */
  28823. export class Camera extends Node {
  28824. /** @hidden */ private static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  28825. /**
  28826. * This is the default projection mode used by the cameras.
  28827. * It helps recreating a feeling of perspective and better appreciate depth.
  28828. * This is the best way to simulate real life cameras.
  28829. */
  28830. static readonly PERSPECTIVE_CAMERA: number;
  28831. /**
  28832. * This helps creating camera with an orthographic mode.
  28833. * 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.
  28834. */
  28835. static readonly ORTHOGRAPHIC_CAMERA: number;
  28836. /**
  28837. * This is the default FOV mode for perspective cameras.
  28838. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  28839. */
  28840. static readonly FOVMODE_VERTICAL_FIXED: number;
  28841. /**
  28842. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  28843. */
  28844. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  28845. /**
  28846. * This specifies ther is no need for a camera rig.
  28847. * Basically only one eye is rendered corresponding to the camera.
  28848. */
  28849. static readonly RIG_MODE_NONE: number;
  28850. /**
  28851. * Simulates a camera Rig with one blue eye and one red eye.
  28852. * This can be use with 3d blue and red glasses.
  28853. */
  28854. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  28855. /**
  28856. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  28857. */
  28858. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  28859. /**
  28860. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  28861. */
  28862. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  28863. /**
  28864. * Defines that both eyes of the camera will be rendered over under each other.
  28865. */
  28866. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  28867. /**
  28868. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  28869. */
  28870. static readonly RIG_MODE_VR: number;
  28871. /**
  28872. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  28873. */
  28874. static readonly RIG_MODE_WEBVR: number;
  28875. /**
  28876. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  28877. */
  28878. static readonly RIG_MODE_CUSTOM: number;
  28879. /**
  28880. * Defines if by default attaching controls should prevent the default javascript event to continue.
  28881. */
  28882. static ForceAttachControlToAlwaysPreventDefault: boolean;
  28883. /**
  28884. * @hidden
  28885. * Might be removed once multiview will be a thing
  28886. */
  28887. static UseAlternateWebVRRendering: boolean;
  28888. /**
  28889. * Define the input manager associated with the camera.
  28890. */
  28891. inputs: CameraInputsManager<Camera>;
  28892. /**
  28893. * Define the current local position of the camera in the scene
  28894. */
  28895. position: Vector3;
  28896. /**
  28897. * The vector the camera should consider as up.
  28898. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  28899. */
  28900. upVector: Vector3;
  28901. /**
  28902. * Define the current limit on the left side for an orthographic camera
  28903. * In scene unit
  28904. */
  28905. orthoLeft: Nullable<number>;
  28906. /**
  28907. * Define the current limit on the right side for an orthographic camera
  28908. * In scene unit
  28909. */
  28910. orthoRight: Nullable<number>;
  28911. /**
  28912. * Define the current limit on the bottom side for an orthographic camera
  28913. * In scene unit
  28914. */
  28915. orthoBottom: Nullable<number>;
  28916. /**
  28917. * Define the current limit on the top side for an orthographic camera
  28918. * In scene unit
  28919. */
  28920. orthoTop: Nullable<number>;
  28921. /**
  28922. * Field Of View is set in Radians. (default is 0.8)
  28923. */
  28924. fov: number;
  28925. /**
  28926. * Define the minimum distance the camera can see from.
  28927. * This is important to note that the depth buffer are not infinite and the closer it starts
  28928. * the more your scene might encounter depth fighting issue.
  28929. */
  28930. minZ: number;
  28931. /**
  28932. * Define the maximum distance the camera can see to.
  28933. * This is important to note that the depth buffer are not infinite and the further it end
  28934. * the more your scene might encounter depth fighting issue.
  28935. */
  28936. maxZ: number;
  28937. /**
  28938. * Define the default inertia of the camera.
  28939. * This helps giving a smooth feeling to the camera movement.
  28940. */
  28941. inertia: number;
  28942. /**
  28943. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  28944. */
  28945. mode: number;
  28946. /**
  28947. * Define wether the camera is intermediate.
  28948. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  28949. */
  28950. isIntermediate: boolean;
  28951. /**
  28952. * Define the viewport of the camera.
  28953. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  28954. */
  28955. viewport: Viewport;
  28956. /**
  28957. * Restricts the camera to viewing objects with the same layerMask.
  28958. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  28959. */
  28960. layerMask: number;
  28961. /**
  28962. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  28963. */
  28964. fovMode: number;
  28965. /**
  28966. * Rig mode of the camera.
  28967. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  28968. * This is normally controlled byt the camera themselves as internal use.
  28969. */
  28970. cameraRigMode: number;
  28971. /**
  28972. * Defines the distance between both "eyes" in case of a RIG
  28973. */
  28974. interaxialDistance: number;
  28975. /**
  28976. * Defines if stereoscopic rendering is done side by side or over under.
  28977. */
  28978. isStereoscopicSideBySide: boolean;
  28979. /**
  28980. * 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
  28981. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  28982. * else in the scene.
  28983. */
  28984. customRenderTargets: RenderTargetTexture[];
  28985. /**
  28986. * When set, the camera will render to this render target instead of the default canvas
  28987. */
  28988. outputRenderTarget: Nullable<RenderTargetTexture>;
  28989. /**
  28990. * Observable triggered when the camera view matrix has changed.
  28991. */
  28992. onViewMatrixChangedObservable: Observable<Camera>;
  28993. /**
  28994. * Observable triggered when the camera Projection matrix has changed.
  28995. */
  28996. onProjectionMatrixChangedObservable: Observable<Camera>;
  28997. /**
  28998. * Observable triggered when the inputs have been processed.
  28999. */
  29000. onAfterCheckInputsObservable: Observable<Camera>;
  29001. /**
  29002. * Observable triggered when reset has been called and applied to the camera.
  29003. */
  29004. onRestoreStateObservable: Observable<Camera>;
  29005. /** @hidden */ cameraRigParams: any;
  29006. /** @hidden */ rigCameras: Camera[];
  29007. /** @hidden */ rigPostProcess: Nullable<PostProcess>;
  29008. protected _webvrViewMatrix: Matrix;
  29009. /** @hidden */ skipRendering: boolean;
  29010. /** @hidden */ alternateCamera: Camera;
  29011. /** @hidden */ projectionMatrix: Matrix;
  29012. /** @hidden */ postProcesses: Nullable<PostProcess>[];
  29013. /** @hidden */ activeMeshes: SmartArray<AbstractMesh>;
  29014. protected _globalPosition: Vector3;
  29015. /** hidden */ computedViewMatrix: Matrix;
  29016. private _doNotComputeProjectionMatrix;
  29017. private _transformMatrix;
  29018. private _frustumPlanes;
  29019. private _refreshFrustumPlanes;
  29020. private _storedFov;
  29021. private _stateStored;
  29022. /**
  29023. * Instantiates a new camera object.
  29024. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29025. * @see http://doc.babylonjs.com/features/cameras
  29026. * @param name Defines the name of the camera in the scene
  29027. * @param position Defines the position of the camera
  29028. * @param scene Defines the scene the camera belongs too
  29029. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29030. */
  29031. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29032. /**
  29033. * Store current camera state (fov, position, etc..)
  29034. * @returns the camera
  29035. */
  29036. storeState(): Camera;
  29037. /**
  29038. * Restores the camera state values if it has been stored. You must call storeState() first
  29039. */
  29040. protected _restoreStateValues(): boolean;
  29041. /**
  29042. * Restored camera state. You must call storeState() first.
  29043. * @returns true if restored and false otherwise
  29044. */
  29045. restoreState(): boolean;
  29046. /**
  29047. * Gets the class name of the camera.
  29048. * @returns the class name
  29049. */
  29050. getClassName(): string;
  29051. /** @hidden */ protected readonly _isCamera: boolean;
  29052. /**
  29053. * Gets a string representation of the camera useful for debug purpose.
  29054. * @param fullDetails Defines that a more verboe level of logging is required
  29055. * @returns the string representation
  29056. */
  29057. toString(fullDetails?: boolean): string;
  29058. /**
  29059. * Gets the current world space position of the camera.
  29060. */
  29061. readonly globalPosition: Vector3;
  29062. /**
  29063. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29064. * @returns the active meshe list
  29065. */
  29066. getActiveMeshes(): SmartArray<AbstractMesh>;
  29067. /**
  29068. * Check wether a mesh is part of the current active mesh list of the camera
  29069. * @param mesh Defines the mesh to check
  29070. * @returns true if active, false otherwise
  29071. */
  29072. isActiveMesh(mesh: Mesh): boolean;
  29073. /**
  29074. * Is this camera ready to be used/rendered
  29075. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29076. * @return true if the camera is ready
  29077. */
  29078. isReady(completeCheck?: boolean): boolean;
  29079. /** @hidden */ initCache(): void;
  29080. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  29081. /** @hidden */ isSynchronized(): boolean;
  29082. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  29083. /** @hidden */ isSynchronizedProjectionMatrix(): boolean;
  29084. /**
  29085. * Attach the input controls to a specific dom element to get the input from.
  29086. * @param element Defines the element the controls should be listened from
  29087. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29088. */
  29089. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29090. /**
  29091. * Detach the current controls from the specified dom element.
  29092. * @param element Defines the element to stop listening the inputs from
  29093. */
  29094. detachControl(element: HTMLElement): void;
  29095. /**
  29096. * Update the camera state according to the different inputs gathered during the frame.
  29097. */
  29098. update(): void;
  29099. /** @hidden */ checkInputs(): void;
  29100. /** @hidden */
  29101. readonly rigCameras: Camera[];
  29102. /**
  29103. * Gets the post process used by the rig cameras
  29104. */
  29105. readonly rigPostProcess: Nullable<PostProcess>;
  29106. /**
  29107. * Internal, gets the first post proces.
  29108. * @returns the first post process to be run on this camera.
  29109. */ getFirstPostProcess(): Nullable<PostProcess>;
  29110. private _cascadePostProcessesToRigCams;
  29111. /**
  29112. * Attach a post process to the camera.
  29113. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29114. * @param postProcess The post process to attach to the camera
  29115. * @param insertAt The position of the post process in case several of them are in use in the scene
  29116. * @returns the position the post process has been inserted at
  29117. */
  29118. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29119. /**
  29120. * Detach a post process to the camera.
  29121. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29122. * @param postProcess The post process to detach from the camera
  29123. */
  29124. detachPostProcess(postProcess: PostProcess): void;
  29125. /**
  29126. * Gets the current world matrix of the camera
  29127. */
  29128. getWorldMatrix(): Matrix;
  29129. /** @hidden */ getViewMatrix(): Matrix;
  29130. /**
  29131. * Gets the current view matrix of the camera.
  29132. * @param force forces the camera to recompute the matrix without looking at the cached state
  29133. * @returns the view matrix
  29134. */
  29135. getViewMatrix(force?: boolean): Matrix;
  29136. /**
  29137. * Freeze the projection matrix.
  29138. * It will prevent the cache check of the camera projection compute and can speed up perf
  29139. * if no parameter of the camera are meant to change
  29140. * @param projection Defines manually a projection if necessary
  29141. */
  29142. freezeProjectionMatrix(projection?: Matrix): void;
  29143. /**
  29144. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29145. */
  29146. unfreezeProjectionMatrix(): void;
  29147. /**
  29148. * Gets the current projection matrix of the camera.
  29149. * @param force forces the camera to recompute the matrix without looking at the cached state
  29150. * @returns the projection matrix
  29151. */
  29152. getProjectionMatrix(force?: boolean): Matrix;
  29153. /**
  29154. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29155. * @returns a Matrix
  29156. */
  29157. getTransformationMatrix(): Matrix;
  29158. private _updateFrustumPlanes;
  29159. /**
  29160. * Checks if a cullable object (mesh...) is in the camera frustum
  29161. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29162. * @param target The object to check
  29163. * @returns true if the object is in frustum otherwise false
  29164. */
  29165. isInFrustum(target: ICullable): boolean;
  29166. /**
  29167. * Checks if a cullable object (mesh...) is in the camera frustum
  29168. * Unlike isInFrustum this cheks the full bounding box
  29169. * @param target The object to check
  29170. * @returns true if the object is in frustum otherwise false
  29171. */
  29172. isCompletelyInFrustum(target: ICullable): boolean;
  29173. /**
  29174. * Gets a ray in the forward direction from the camera.
  29175. * @param length Defines the length of the ray to create
  29176. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29177. * @param origin Defines the start point of the ray which defaults to the camera position
  29178. * @returns the forward ray
  29179. */
  29180. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29181. /**
  29182. * Releases resources associated with this node.
  29183. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29184. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29185. */
  29186. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29187. /**
  29188. * Gets the left camera of a rig setup in case of Rigged Camera
  29189. */
  29190. readonly leftCamera: Nullable<FreeCamera>;
  29191. /**
  29192. * Gets the right camera of a rig setup in case of Rigged Camera
  29193. */
  29194. readonly rightCamera: Nullable<FreeCamera>;
  29195. /**
  29196. * Gets the left camera target of a rig setup in case of Rigged Camera
  29197. * @returns the target position
  29198. */
  29199. getLeftTarget(): Nullable<Vector3>;
  29200. /**
  29201. * Gets the right camera target of a rig setup in case of Rigged Camera
  29202. * @returns the target position
  29203. */
  29204. getRightTarget(): Nullable<Vector3>;
  29205. /**
  29206. * @hidden
  29207. */
  29208. setCameraRigMode(mode: number, rigParams: any): void;
  29209. /** @hidden */ private static _setStereoscopicRigMode(camera: Camera): void;
  29210. /** @hidden */ private static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29211. /** @hidden */ private static _setVRRigMode(camera: Camera, rigParams: any): void;
  29212. /** @hidden */ private static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29213. /** @hidden */ getVRProjectionMatrix(): Matrix;
  29214. protected _updateCameraRotationMatrix(): void;
  29215. protected _updateWebVRCameraRotationMatrix(): void;
  29216. /**
  29217. * This function MUST be overwritten by the different WebVR cameras available.
  29218. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29219. * @hidden
  29220. */ getWebVRProjectionMatrix(): Matrix;
  29221. /**
  29222. * This function MUST be overwritten by the different WebVR cameras available.
  29223. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29224. * @hidden
  29225. */ getWebVRViewMatrix(): Matrix;
  29226. /** @hidden */
  29227. setCameraRigParameter(name: string, value: any): void;
  29228. /**
  29229. * needs to be overridden by children so sub has required properties to be copied
  29230. * @hidden
  29231. */
  29232. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29233. /**
  29234. * May need to be overridden by children
  29235. * @hidden
  29236. */ updateRigCameras(): void;
  29237. /** @hidden */ setupInputs(): void;
  29238. /**
  29239. * Serialiaze the camera setup to a json represention
  29240. * @returns the JSON representation
  29241. */
  29242. serialize(): any;
  29243. /**
  29244. * Clones the current camera.
  29245. * @param name The cloned camera name
  29246. * @returns the cloned camera
  29247. */
  29248. clone(name: string): Camera;
  29249. /**
  29250. * Gets the direction of the camera relative to a given local axis.
  29251. * @param localAxis Defines the reference axis to provide a relative direction.
  29252. * @return the direction
  29253. */
  29254. getDirection(localAxis: Vector3): Vector3;
  29255. /**
  29256. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29257. * @param localAxis Defines the reference axis to provide a relative direction.
  29258. * @param result Defines the vector to store the result in
  29259. */
  29260. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29261. /**
  29262. * Gets a camera constructor for a given camera type
  29263. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29264. * @param name The name of the camera the result will be able to instantiate
  29265. * @param scene The scene the result will construct the camera in
  29266. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29267. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29268. * @returns a factory method to construc the camera
  29269. */
  29270. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29271. /**
  29272. * Compute the world matrix of the camera.
  29273. * @returns the camera workd matrix
  29274. */
  29275. computeWorldMatrix(): Matrix;
  29276. /**
  29277. * Parse a JSON and creates the camera from the parsed information
  29278. * @param parsedCamera The JSON to parse
  29279. * @param scene The scene to instantiate the camera in
  29280. * @returns the newly constructed camera
  29281. */
  29282. static Parse(parsedCamera: any, scene: Scene): Camera;
  29283. }
  29284. }
  29285. declare module BABYLON {
  29286. /**
  29287. * Interface for any object that can request an animation frame
  29288. */
  29289. export interface ICustomAnimationFrameRequester {
  29290. /**
  29291. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  29292. */
  29293. renderFunction?: Function;
  29294. /**
  29295. * Called to request the next frame to render to
  29296. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  29297. */
  29298. requestAnimationFrame: Function;
  29299. /**
  29300. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  29301. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  29302. */
  29303. requestID?: number;
  29304. }
  29305. /**
  29306. * Interface containing an array of animations
  29307. */
  29308. export interface IAnimatable {
  29309. /**
  29310. * Array of animations
  29311. */
  29312. animations: Array<Animation>;
  29313. }
  29314. /** Interface used by value gradients (color, factor, ...) */
  29315. export interface IValueGradient {
  29316. /**
  29317. * Gets or sets the gradient value (between 0 and 1)
  29318. */
  29319. gradient: number;
  29320. }
  29321. /** Class used to store color4 gradient */
  29322. export class ColorGradient implements IValueGradient {
  29323. /**
  29324. * Gets or sets the gradient value (between 0 and 1)
  29325. */
  29326. gradient: number;
  29327. /**
  29328. * Gets or sets first associated color
  29329. */
  29330. color1: Color4;
  29331. /**
  29332. * Gets or sets second associated color
  29333. */
  29334. color2?: Color4;
  29335. /**
  29336. * Will get a color picked randomly between color1 and color2.
  29337. * If color2 is undefined then color1 will be used
  29338. * @param result defines the target Color4 to store the result in
  29339. */
  29340. getColorToRef(result: Color4): void;
  29341. }
  29342. /** Class used to store color 3 gradient */
  29343. export class Color3Gradient implements IValueGradient {
  29344. /**
  29345. * Gets or sets the gradient value (between 0 and 1)
  29346. */
  29347. gradient: number;
  29348. /**
  29349. * Gets or sets the associated color
  29350. */
  29351. color: Color3;
  29352. }
  29353. /** Class used to store factor gradient */
  29354. export class FactorGradient implements IValueGradient {
  29355. /**
  29356. * Gets or sets the gradient value (between 0 and 1)
  29357. */
  29358. gradient: number;
  29359. /**
  29360. * Gets or sets first associated factor
  29361. */
  29362. factor1: number;
  29363. /**
  29364. * Gets or sets second associated factor
  29365. */
  29366. factor2?: number;
  29367. /**
  29368. * Will get a number picked randomly between factor1 and factor2.
  29369. * If factor2 is undefined then factor1 will be used
  29370. * @returns the picked number
  29371. */
  29372. getFactor(): number;
  29373. }
  29374. /**
  29375. * @ignore
  29376. * Application error to support additional information when loading a file
  29377. */
  29378. export class LoadFileError extends Error {
  29379. /** defines the optional XHR request */
  29380. request?: XMLHttpRequest | undefined;
  29381. private static _setPrototypeOf;
  29382. /**
  29383. * Creates a new LoadFileError
  29384. * @param message defines the message of the error
  29385. * @param request defines the optional XHR request
  29386. */
  29387. constructor(message: string,
  29388. /** defines the optional XHR request */
  29389. request?: XMLHttpRequest | undefined);
  29390. }
  29391. /**
  29392. * Class used to define a retry strategy when error happens while loading assets
  29393. */
  29394. export class RetryStrategy {
  29395. /**
  29396. * Function used to defines an exponential back off strategy
  29397. * @param maxRetries defines the maximum number of retries (3 by default)
  29398. * @param baseInterval defines the interval between retries
  29399. * @returns the strategy function to use
  29400. */
  29401. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  29402. }
  29403. /**
  29404. * File request interface
  29405. */
  29406. export interface IFileRequest {
  29407. /**
  29408. * Raised when the request is complete (success or error).
  29409. */
  29410. onCompleteObservable: Observable<IFileRequest>;
  29411. /**
  29412. * Aborts the request for a file.
  29413. */
  29414. abort: () => void;
  29415. }
  29416. /**
  29417. * Class containing a set of static utilities functions
  29418. */
  29419. export class Tools {
  29420. /**
  29421. * Gets or sets the base URL to use to load assets
  29422. */
  29423. static BaseUrl: string;
  29424. /**
  29425. * Enable/Disable Custom HTTP Request Headers globally.
  29426. * default = false
  29427. * @see CustomRequestHeaders
  29428. */
  29429. static UseCustomRequestHeaders: boolean;
  29430. /**
  29431. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  29432. * i.e. when loading files, where the server/service expects an Authorization header.
  29433. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  29434. */
  29435. static CustomRequestHeaders: {
  29436. [key: string]: string;
  29437. };
  29438. /**
  29439. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  29440. */
  29441. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  29442. /**
  29443. * Default behaviour for cors in the application.
  29444. * It can be a string if the expected behavior is identical in the entire app.
  29445. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  29446. */
  29447. static CorsBehavior: string | ((url: string | string[]) => string);
  29448. /**
  29449. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  29450. * @ignorenaming
  29451. */
  29452. static UseFallbackTexture: boolean;
  29453. /**
  29454. * Use this object to register external classes like custom textures or material
  29455. * to allow the laoders to instantiate them
  29456. */
  29457. static RegisteredExternalClasses: {
  29458. [key: string]: Object;
  29459. };
  29460. /**
  29461. * Texture content used if a texture cannot loaded
  29462. * @ignorenaming
  29463. */
  29464. static fallbackTexture: string;
  29465. /**
  29466. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  29467. * @param u defines the coordinate on X axis
  29468. * @param v defines the coordinate on Y axis
  29469. * @param width defines the width of the source data
  29470. * @param height defines the height of the source data
  29471. * @param pixels defines the source byte array
  29472. * @param color defines the output color
  29473. */
  29474. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  29475. /**
  29476. * Interpolates between a and b via alpha
  29477. * @param a The lower value (returned when alpha = 0)
  29478. * @param b The upper value (returned when alpha = 1)
  29479. * @param alpha The interpolation-factor
  29480. * @return The mixed value
  29481. */
  29482. static Mix(a: number, b: number, alpha: number): number;
  29483. /**
  29484. * Tries to instantiate a new object from a given class name
  29485. * @param className defines the class name to instantiate
  29486. * @returns the new object or null if the system was not able to do the instantiation
  29487. */
  29488. static Instantiate(className: string): any;
  29489. /**
  29490. * Provides a slice function that will work even on IE
  29491. * @param data defines the array to slice
  29492. * @param start defines the start of the data (optional)
  29493. * @param end defines the end of the data (optional)
  29494. * @returns the new sliced array
  29495. */
  29496. static Slice<T>(data: T, start?: number, end?: number): T;
  29497. /**
  29498. * Polyfill for setImmediate
  29499. * @param action defines the action to execute after the current execution block
  29500. */
  29501. static SetImmediate(action: () => void): void;
  29502. /**
  29503. * Function indicating if a number is an exponent of 2
  29504. * @param value defines the value to test
  29505. * @returns true if the value is an exponent of 2
  29506. */
  29507. static IsExponentOfTwo(value: number): boolean;
  29508. private static _tmpFloatArray;
  29509. /**
  29510. * Returns the nearest 32-bit single precision float representation of a Number
  29511. * @param value A Number. If the parameter is of a different type, it will get converted
  29512. * to a number or to NaN if it cannot be converted
  29513. * @returns number
  29514. */
  29515. static FloatRound(value: number): number;
  29516. /**
  29517. * Find the next highest power of two.
  29518. * @param x Number to start search from.
  29519. * @return Next highest power of two.
  29520. */
  29521. static CeilingPOT(x: number): number;
  29522. /**
  29523. * Find the next lowest power of two.
  29524. * @param x Number to start search from.
  29525. * @return Next lowest power of two.
  29526. */
  29527. static FloorPOT(x: number): number;
  29528. /**
  29529. * Find the nearest power of two.
  29530. * @param x Number to start search from.
  29531. * @return Next nearest power of two.
  29532. */
  29533. static NearestPOT(x: number): number;
  29534. /**
  29535. * Get the closest exponent of two
  29536. * @param value defines the value to approximate
  29537. * @param max defines the maximum value to return
  29538. * @param mode defines how to define the closest value
  29539. * @returns closest exponent of two of the given value
  29540. */
  29541. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  29542. /**
  29543. * Extracts the filename from a path
  29544. * @param path defines the path to use
  29545. * @returns the filename
  29546. */
  29547. static GetFilename(path: string): string;
  29548. /**
  29549. * Extracts the "folder" part of a path (everything before the filename).
  29550. * @param uri The URI to extract the info from
  29551. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  29552. * @returns The "folder" part of the path
  29553. */
  29554. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  29555. /**
  29556. * Extracts text content from a DOM element hierarchy
  29557. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  29558. */
  29559. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  29560. /**
  29561. * Convert an angle in radians to degrees
  29562. * @param angle defines the angle to convert
  29563. * @returns the angle in degrees
  29564. */
  29565. static ToDegrees(angle: number): number;
  29566. /**
  29567. * Convert an angle in degrees to radians
  29568. * @param angle defines the angle to convert
  29569. * @returns the angle in radians
  29570. */
  29571. static ToRadians(angle: number): number;
  29572. /**
  29573. * Encode a buffer to a base64 string
  29574. * @param buffer defines the buffer to encode
  29575. * @returns the encoded string
  29576. */
  29577. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  29578. /**
  29579. * Extracts minimum and maximum values from a list of indexed positions
  29580. * @param positions defines the positions to use
  29581. * @param indices defines the indices to the positions
  29582. * @param indexStart defines the start index
  29583. * @param indexCount defines the end index
  29584. * @param bias defines bias value to add to the result
  29585. * @return minimum and maximum values
  29586. */
  29587. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  29588. minimum: Vector3;
  29589. maximum: Vector3;
  29590. };
  29591. /**
  29592. * Extracts minimum and maximum values from a list of positions
  29593. * @param positions defines the positions to use
  29594. * @param start defines the start index in the positions array
  29595. * @param count defines the number of positions to handle
  29596. * @param bias defines bias value to add to the result
  29597. * @param stride defines the stride size to use (distance between two positions in the positions array)
  29598. * @return minimum and maximum values
  29599. */
  29600. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  29601. minimum: Vector3;
  29602. maximum: Vector3;
  29603. };
  29604. /**
  29605. * Returns an array if obj is not an array
  29606. * @param obj defines the object to evaluate as an array
  29607. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  29608. * @returns either obj directly if obj is an array or a new array containing obj
  29609. */
  29610. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  29611. /**
  29612. * Gets the pointer prefix to use
  29613. * @returns "pointer" if touch is enabled. Else returns "mouse"
  29614. */
  29615. static GetPointerPrefix(): string;
  29616. /**
  29617. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  29618. * @param func - the function to be called
  29619. * @param requester - the object that will request the next frame. Falls back to window.
  29620. * @returns frame number
  29621. */
  29622. static QueueNewFrame(func: () => void, requester?: any): number;
  29623. /**
  29624. * Ask the browser to promote the current element to fullscreen rendering mode
  29625. * @param element defines the DOM element to promote
  29626. */
  29627. static RequestFullscreen(element: HTMLElement): void;
  29628. /**
  29629. * Asks the browser to exit fullscreen mode
  29630. */
  29631. static ExitFullscreen(): void;
  29632. /**
  29633. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  29634. * @param url define the url we are trying
  29635. * @param element define the dom element where to configure the cors policy
  29636. */
  29637. static SetCorsBehavior(url: string | string[], element: {
  29638. crossOrigin: string | null;
  29639. }): void;
  29640. /**
  29641. * Removes unwanted characters from an url
  29642. * @param url defines the url to clean
  29643. * @returns the cleaned url
  29644. */
  29645. static CleanUrl(url: string): string;
  29646. /**
  29647. * Gets or sets a function used to pre-process url before using them to load assets
  29648. */
  29649. static PreprocessUrl: (url: string) => string;
  29650. /**
  29651. * Loads an image as an HTMLImageElement.
  29652. * @param input url string, ArrayBuffer, or Blob to load
  29653. * @param onLoad callback called when the image successfully loads
  29654. * @param onError callback called when the image fails to load
  29655. * @param offlineProvider offline provider for caching
  29656. * @returns the HTMLImageElement of the loaded image
  29657. */
  29658. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  29659. /**
  29660. * Loads a file
  29661. * @param url url string, ArrayBuffer, or Blob to load
  29662. * @param onSuccess callback called when the file successfully loads
  29663. * @param onProgress callback called while file is loading (if the server supports this mode)
  29664. * @param offlineProvider defines the offline provider for caching
  29665. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  29666. * @param onError callback called when the file fails to load
  29667. * @returns a file request object
  29668. */
  29669. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  29670. /**
  29671. * Load a script (identified by an url). When the url returns, the
  29672. * content of this file is added into a new script element, attached to the DOM (body element)
  29673. * @param scriptUrl defines the url of the script to laod
  29674. * @param onSuccess defines the callback called when the script is loaded
  29675. * @param onError defines the callback to call if an error occurs
  29676. */
  29677. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  29678. /**
  29679. * Loads a file from a blob
  29680. * @param fileToLoad defines the blob to use
  29681. * @param callback defines the callback to call when data is loaded
  29682. * @param progressCallback defines the callback to call during loading process
  29683. * @returns a file request object
  29684. */
  29685. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  29686. /**
  29687. * Loads a file
  29688. * @param fileToLoad defines the file to load
  29689. * @param callback defines the callback to call when data is loaded
  29690. * @param progressCallBack defines the callback to call during loading process
  29691. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  29692. * @returns a file request object
  29693. */
  29694. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  29695. /**
  29696. * Creates a data url from a given string content
  29697. * @param content defines the content to convert
  29698. * @returns the new data url link
  29699. */
  29700. static FileAsURL(content: string): string;
  29701. /**
  29702. * Format the given number to a specific decimal format
  29703. * @param value defines the number to format
  29704. * @param decimals defines the number of decimals to use
  29705. * @returns the formatted string
  29706. */
  29707. static Format(value: number, decimals?: number): string;
  29708. /**
  29709. * Checks if a given vector is inside a specific range
  29710. * @param v defines the vector to test
  29711. * @param min defines the minimum range
  29712. * @param max defines the maximum range
  29713. */
  29714. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  29715. /**
  29716. * Tries to copy an object by duplicating every property
  29717. * @param source defines the source object
  29718. * @param destination defines the target object
  29719. * @param doNotCopyList defines a list of properties to avoid
  29720. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  29721. */
  29722. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  29723. /**
  29724. * Gets a boolean indicating if the given object has no own property
  29725. * @param obj defines the object to test
  29726. * @returns true if object has no own property
  29727. */
  29728. static IsEmpty(obj: any): boolean;
  29729. /**
  29730. * Function used to register events at window level
  29731. * @param events defines the events to register
  29732. */
  29733. static RegisterTopRootEvents(events: {
  29734. name: string;
  29735. handler: Nullable<(e: FocusEvent) => any>;
  29736. }[]): void;
  29737. /**
  29738. * Function used to unregister events from window level
  29739. * @param events defines the events to unregister
  29740. */
  29741. static UnregisterTopRootEvents(events: {
  29742. name: string;
  29743. handler: Nullable<(e: FocusEvent) => any>;
  29744. }[]): void;
  29745. /**
  29746. * Dumps the current bound framebuffer
  29747. * @param width defines the rendering width
  29748. * @param height defines the rendering height
  29749. * @param engine defines the hosting engine
  29750. * @param successCallback defines the callback triggered once the data are available
  29751. * @param mimeType defines the mime type of the result
  29752. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  29753. */
  29754. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  29755. /**
  29756. * Converts the canvas data to blob.
  29757. * This acts as a polyfill for browsers not supporting the to blob function.
  29758. * @param canvas Defines the canvas to extract the data from
  29759. * @param successCallback Defines the callback triggered once the data are available
  29760. * @param mimeType Defines the mime type of the result
  29761. */
  29762. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  29763. /**
  29764. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  29765. * @param successCallback defines the callback triggered once the data are available
  29766. * @param mimeType defines the mime type of the result
  29767. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  29768. */
  29769. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  29770. /**
  29771. * Downloads a blob in the browser
  29772. * @param blob defines the blob to download
  29773. * @param fileName defines the name of the downloaded file
  29774. */
  29775. static Download(blob: Blob, fileName: string): void;
  29776. /**
  29777. * Captures a screenshot of the current rendering
  29778. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  29779. * @param engine defines the rendering engine
  29780. * @param camera defines the source camera
  29781. * @param size This parameter can be set to a single number or to an object with the
  29782. * following (optional) properties: precision, width, height. If a single number is passed,
  29783. * it will be used for both width and height. If an object is passed, the screenshot size
  29784. * will be derived from the parameters. The precision property is a multiplier allowing
  29785. * rendering at a higher or lower resolution
  29786. * @param successCallback defines the callback receives a single parameter which contains the
  29787. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  29788. * src parameter of an <img> to display it
  29789. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  29790. * Check your browser for supported MIME types
  29791. */
  29792. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  29793. /**
  29794. * Generates an image screenshot from the specified camera.
  29795. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  29796. * @param engine The engine to use for rendering
  29797. * @param camera The camera to use for rendering
  29798. * @param size This parameter can be set to a single number or to an object with the
  29799. * following (optional) properties: precision, width, height. If a single number is passed,
  29800. * it will be used for both width and height. If an object is passed, the screenshot size
  29801. * will be derived from the parameters. The precision property is a multiplier allowing
  29802. * rendering at a higher or lower resolution
  29803. * @param successCallback The callback receives a single parameter which contains the
  29804. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  29805. * src parameter of an <img> to display it
  29806. * @param mimeType The MIME type of the screenshot image (default: image/png).
  29807. * Check your browser for supported MIME types
  29808. * @param samples Texture samples (default: 1)
  29809. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  29810. * @param fileName A name for for the downloaded file.
  29811. */
  29812. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  29813. /**
  29814. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29815. * Be aware Math.random() could cause collisions, but:
  29816. * "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"
  29817. * @returns a pseudo random id
  29818. */
  29819. static RandomId(): string;
  29820. /**
  29821. * Test if the given uri is a base64 string
  29822. * @param uri The uri to test
  29823. * @return True if the uri is a base64 string or false otherwise
  29824. */
  29825. static IsBase64(uri: string): boolean;
  29826. /**
  29827. * Decode the given base64 uri.
  29828. * @param uri The uri to decode
  29829. * @return The decoded base64 data.
  29830. */
  29831. static DecodeBase64(uri: string): ArrayBuffer;
  29832. /**
  29833. * No log
  29834. */
  29835. static readonly NoneLogLevel: number;
  29836. /**
  29837. * Only message logs
  29838. */
  29839. static readonly MessageLogLevel: number;
  29840. /**
  29841. * Only warning logs
  29842. */
  29843. static readonly WarningLogLevel: number;
  29844. /**
  29845. * Only error logs
  29846. */
  29847. static readonly ErrorLogLevel: number;
  29848. /**
  29849. * All logs
  29850. */
  29851. static readonly AllLogLevel: number;
  29852. /**
  29853. * Gets a value indicating the number of loading errors
  29854. * @ignorenaming
  29855. */
  29856. static readonly errorsCount: number;
  29857. /**
  29858. * Callback called when a new log is added
  29859. */
  29860. static OnNewCacheEntry: (entry: string) => void;
  29861. /**
  29862. * Log a message to the console
  29863. * @param message defines the message to log
  29864. */
  29865. static Log(message: string): void;
  29866. /**
  29867. * Write a warning message to the console
  29868. * @param message defines the message to log
  29869. */
  29870. static Warn(message: string): void;
  29871. /**
  29872. * Write an error message to the console
  29873. * @param message defines the message to log
  29874. */
  29875. static Error(message: string): void;
  29876. /**
  29877. * Gets current log cache (list of logs)
  29878. */
  29879. static readonly LogCache: string;
  29880. /**
  29881. * Clears the log cache
  29882. */
  29883. static ClearLogCache(): void;
  29884. /**
  29885. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  29886. */
  29887. static LogLevels: number;
  29888. /**
  29889. * Checks if the loaded document was accessed via `file:`-Protocol.
  29890. * @returns boolean
  29891. */
  29892. static IsFileURL(): boolean;
  29893. /**
  29894. * Checks if the window object exists
  29895. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  29896. */
  29897. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  29898. /**
  29899. * No performance log
  29900. */
  29901. static readonly PerformanceNoneLogLevel: number;
  29902. /**
  29903. * Use user marks to log performance
  29904. */
  29905. static readonly PerformanceUserMarkLogLevel: number;
  29906. /**
  29907. * Log performance to the console
  29908. */
  29909. static readonly PerformanceConsoleLogLevel: number;
  29910. private static _performance;
  29911. /**
  29912. * Sets the current performance log level
  29913. */
  29914. static PerformanceLogLevel: number;
  29915. private static _StartPerformanceCounterDisabled;
  29916. private static _EndPerformanceCounterDisabled;
  29917. private static _StartUserMark;
  29918. private static _EndUserMark;
  29919. private static _StartPerformanceConsole;
  29920. private static _EndPerformanceConsole;
  29921. /**
  29922. * Injects the @see CustomRequestHeaders into the given request
  29923. * @param request the request that should be used for injection
  29924. */
  29925. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  29926. /**
  29927. * Starts a performance counter
  29928. */
  29929. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  29930. /**
  29931. * Ends a specific performance coutner
  29932. */
  29933. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  29934. /**
  29935. * Gets either window.performance.now() if supported or Date.now() else
  29936. */
  29937. static readonly Now: number;
  29938. /**
  29939. * This method will return the name of the class used to create the instance of the given object.
  29940. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  29941. * @param object the object to get the class name from
  29942. * @param isType defines if the object is actually a type
  29943. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  29944. */
  29945. static GetClassName(object: any, isType?: boolean): string;
  29946. /**
  29947. * Gets the first element of an array satisfying a given predicate
  29948. * @param array defines the array to browse
  29949. * @param predicate defines the predicate to use
  29950. * @returns null if not found or the element
  29951. */
  29952. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  29953. /**
  29954. * This method will return the name of the full name of the class, including its owning module (if any).
  29955. * 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).
  29956. * @param object the object to get the class name from
  29957. * @param isType defines if the object is actually a type
  29958. * @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.
  29959. * @ignorenaming
  29960. */
  29961. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  29962. /**
  29963. * Returns a promise that resolves after the given amount of time.
  29964. * @param delay Number of milliseconds to delay
  29965. * @returns Promise that resolves after the given amount of time
  29966. */
  29967. static DelayAsync(delay: number): Promise<void>;
  29968. /**
  29969. * Gets the current gradient from an array of IValueGradient
  29970. * @param ratio defines the current ratio to get
  29971. * @param gradients defines the array of IValueGradient
  29972. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  29973. */
  29974. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  29975. }
  29976. /**
  29977. * This class is used to track a performance counter which is number based.
  29978. * The user has access to many properties which give statistics of different nature.
  29979. *
  29980. * The implementer can track two kinds of Performance Counter: time and count.
  29981. * 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.
  29982. * 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.
  29983. */
  29984. export class PerfCounter {
  29985. /**
  29986. * Gets or sets a global boolean to turn on and off all the counters
  29987. */
  29988. static Enabled: boolean;
  29989. /**
  29990. * Returns the smallest value ever
  29991. */
  29992. readonly min: number;
  29993. /**
  29994. * Returns the biggest value ever
  29995. */
  29996. readonly max: number;
  29997. /**
  29998. * Returns the average value since the performance counter is running
  29999. */
  30000. readonly average: number;
  30001. /**
  30002. * Returns the average value of the last second the counter was monitored
  30003. */
  30004. readonly lastSecAverage: number;
  30005. /**
  30006. * Returns the current value
  30007. */
  30008. readonly current: number;
  30009. /**
  30010. * Gets the accumulated total
  30011. */
  30012. readonly total: number;
  30013. /**
  30014. * Gets the total value count
  30015. */
  30016. readonly count: number;
  30017. /**
  30018. * Creates a new counter
  30019. */
  30020. constructor();
  30021. /**
  30022. * Call this method to start monitoring a new frame.
  30023. * 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.
  30024. */
  30025. fetchNewFrame(): void;
  30026. /**
  30027. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30028. * @param newCount the count value to add to the monitored count
  30029. * @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.
  30030. */
  30031. addCount(newCount: number, fetchResult: boolean): void;
  30032. /**
  30033. * Start monitoring this performance counter
  30034. */
  30035. beginMonitoring(): void;
  30036. /**
  30037. * Compute the time lapsed since the previous beginMonitoring() call.
  30038. * @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
  30039. */
  30040. endMonitoring(newFrame?: boolean): void;
  30041. private _fetchResult;
  30042. private _startMonitoringTime;
  30043. private _min;
  30044. private _max;
  30045. private _average;
  30046. private _current;
  30047. private _totalValueCount;
  30048. private _totalAccumulated;
  30049. private _lastSecAverage;
  30050. private _lastSecAccumulated;
  30051. private _lastSecTime;
  30052. private _lastSecValueCount;
  30053. }
  30054. /**
  30055. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  30056. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  30057. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  30058. * @param name The name of the class, case should be preserved
  30059. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  30060. */
  30061. export function className(name: string, module?: string): (target: Object) => void;
  30062. /**
  30063. * An implementation of a loop for asynchronous functions.
  30064. */
  30065. export class AsyncLoop {
  30066. /**
  30067. * Defines the number of iterations for the loop
  30068. */
  30069. iterations: number;
  30070. /**
  30071. * Defines the current index of the loop.
  30072. */
  30073. index: number;
  30074. private _done;
  30075. private _fn;
  30076. private _successCallback;
  30077. /**
  30078. * Constructor.
  30079. * @param iterations the number of iterations.
  30080. * @param func the function to run each iteration
  30081. * @param successCallback the callback that will be called upon succesful execution
  30082. * @param offset starting offset.
  30083. */
  30084. constructor(
  30085. /**
  30086. * Defines the number of iterations for the loop
  30087. */
  30088. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  30089. /**
  30090. * Execute the next iteration. Must be called after the last iteration was finished.
  30091. */
  30092. executeNext(): void;
  30093. /**
  30094. * Break the loop and run the success callback.
  30095. */
  30096. breakLoop(): void;
  30097. /**
  30098. * Create and run an async loop.
  30099. * @param iterations the number of iterations.
  30100. * @param fn the function to run each iteration
  30101. * @param successCallback the callback that will be called upon succesful execution
  30102. * @param offset starting offset.
  30103. * @returns the created async loop object
  30104. */
  30105. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  30106. /**
  30107. * A for-loop that will run a given number of iterations synchronous and the rest async.
  30108. * @param iterations total number of iterations
  30109. * @param syncedIterations number of synchronous iterations in each async iteration.
  30110. * @param fn the function to call each iteration.
  30111. * @param callback a success call back that will be called when iterating stops.
  30112. * @param breakFunction a break condition (optional)
  30113. * @param timeout timeout settings for the setTimeout function. default - 0.
  30114. * @returns the created async loop object
  30115. */
  30116. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  30117. }
  30118. }
  30119. declare module BABYLON {
  30120. /** @hidden */
  30121. export interface ICollisionCoordinator {
  30122. createCollider(): Collider;
  30123. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30124. init(scene: Scene): void;
  30125. }
  30126. /** @hidden */
  30127. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  30128. private _scene;
  30129. private _scaledPosition;
  30130. private _scaledVelocity;
  30131. private _finalPosition;
  30132. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30133. createCollider(): Collider;
  30134. init(scene: Scene): void;
  30135. private _collideWithWorld;
  30136. }
  30137. }
  30138. declare module BABYLON {
  30139. /**
  30140. * This class defines the direct association between an animation and a target
  30141. */
  30142. export class TargetedAnimation {
  30143. /**
  30144. * Animation to perform
  30145. */
  30146. animation: Animation;
  30147. /**
  30148. * Target to animate
  30149. */
  30150. target: any;
  30151. }
  30152. /**
  30153. * Use this class to create coordinated animations on multiple targets
  30154. */
  30155. export class AnimationGroup implements IDisposable {
  30156. /** The name of the animation group */
  30157. name: string;
  30158. private _scene;
  30159. private _targetedAnimations;
  30160. private _animatables;
  30161. private _from;
  30162. private _to;
  30163. private _isStarted;
  30164. private _isPaused;
  30165. private _speedRatio;
  30166. /**
  30167. * Gets or sets the unique id of the node
  30168. */
  30169. uniqueId: number;
  30170. /**
  30171. * This observable will notify when one animation have ended
  30172. */
  30173. onAnimationEndObservable: Observable<TargetedAnimation>;
  30174. /**
  30175. * Observer raised when one animation loops
  30176. */
  30177. onAnimationLoopObservable: Observable<TargetedAnimation>;
  30178. /**
  30179. * This observable will notify when all animations have ended.
  30180. */
  30181. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  30182. /**
  30183. * This observable will notify when all animations have paused.
  30184. */
  30185. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  30186. /**
  30187. * This observable will notify when all animations are playing.
  30188. */
  30189. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  30190. /**
  30191. * Gets the first frame
  30192. */
  30193. readonly from: number;
  30194. /**
  30195. * Gets the last frame
  30196. */
  30197. readonly to: number;
  30198. /**
  30199. * Define if the animations are started
  30200. */
  30201. readonly isStarted: boolean;
  30202. /**
  30203. * Gets a value indicating that the current group is playing
  30204. */
  30205. readonly isPlaying: boolean;
  30206. /**
  30207. * Gets or sets the speed ratio to use for all animations
  30208. */
  30209. /**
  30210. * Gets or sets the speed ratio to use for all animations
  30211. */
  30212. speedRatio: number;
  30213. /**
  30214. * Gets the targeted animations for this animation group
  30215. */
  30216. readonly targetedAnimations: Array<TargetedAnimation>;
  30217. /**
  30218. * returning the list of animatables controlled by this animation group.
  30219. */
  30220. readonly animatables: Array<Animatable>;
  30221. /**
  30222. * Instantiates a new Animation Group.
  30223. * This helps managing several animations at once.
  30224. * @see http://doc.babylonjs.com/how_to/group
  30225. * @param name Defines the name of the group
  30226. * @param scene Defines the scene the group belongs to
  30227. */
  30228. constructor(
  30229. /** The name of the animation group */
  30230. name: string, scene?: Nullable<Scene>);
  30231. /**
  30232. * Add an animation (with its target) in the group
  30233. * @param animation defines the animation we want to add
  30234. * @param target defines the target of the animation
  30235. * @returns the TargetedAnimation object
  30236. */
  30237. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  30238. /**
  30239. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  30240. * It can add constant keys at begin or end
  30241. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  30242. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  30243. * @returns the animation group
  30244. */
  30245. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  30246. /**
  30247. * Start all animations on given targets
  30248. * @param loop defines if animations must loop
  30249. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  30250. * @param from defines the from key (optional)
  30251. * @param to defines the to key (optional)
  30252. * @returns the current animation group
  30253. */
  30254. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  30255. /**
  30256. * Pause all animations
  30257. * @returns the animation group
  30258. */
  30259. pause(): AnimationGroup;
  30260. /**
  30261. * Play all animations to initial state
  30262. * This function will start() the animations if they were not started or will restart() them if they were paused
  30263. * @param loop defines if animations must loop
  30264. * @returns the animation group
  30265. */
  30266. play(loop?: boolean): AnimationGroup;
  30267. /**
  30268. * Reset all animations to initial state
  30269. * @returns the animation group
  30270. */
  30271. reset(): AnimationGroup;
  30272. /**
  30273. * Restart animations from key 0
  30274. * @returns the animation group
  30275. */
  30276. restart(): AnimationGroup;
  30277. /**
  30278. * Stop all animations
  30279. * @returns the animation group
  30280. */
  30281. stop(): AnimationGroup;
  30282. /**
  30283. * Set animation weight for all animatables
  30284. * @param weight defines the weight to use
  30285. * @return the animationGroup
  30286. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  30287. */
  30288. setWeightForAllAnimatables(weight: number): AnimationGroup;
  30289. /**
  30290. * Synchronize and normalize all animatables with a source animatable
  30291. * @param root defines the root animatable to synchronize with
  30292. * @return the animationGroup
  30293. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  30294. */
  30295. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  30296. /**
  30297. * Goes to a specific frame in this animation group
  30298. * @param frame the frame number to go to
  30299. * @return the animationGroup
  30300. */
  30301. goToFrame(frame: number): AnimationGroup;
  30302. /**
  30303. * Dispose all associated resources
  30304. */
  30305. dispose(): void;
  30306. private _checkAnimationGroupEnded;
  30307. /**
  30308. * Returns a new AnimationGroup object parsed from the source provided.
  30309. * @param parsedAnimationGroup defines the source
  30310. * @param scene defines the scene that will receive the animationGroup
  30311. * @returns a new AnimationGroup
  30312. */
  30313. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  30314. /**
  30315. * Returns the string "AnimationGroup"
  30316. * @returns "AnimationGroup"
  30317. */
  30318. getClassName(): string;
  30319. /**
  30320. * Creates a detailled string about the object
  30321. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  30322. * @returns a string representing the object
  30323. */
  30324. toString(fullDetails?: boolean): string;
  30325. }
  30326. }
  30327. declare module BABYLON {
  30328. /**
  30329. * Define an interface for all classes that will hold resources
  30330. */
  30331. export interface IDisposable {
  30332. /**
  30333. * Releases all held resources
  30334. */
  30335. dispose(): void;
  30336. }
  30337. /** Interface defining initialization parameters for Scene class */
  30338. export interface SceneOptions {
  30339. /**
  30340. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  30341. * It will improve performance when the number of geometries becomes important.
  30342. */
  30343. useGeometryUniqueIdsMap?: boolean;
  30344. /**
  30345. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  30346. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  30347. */
  30348. useMaterialMeshMap?: boolean;
  30349. /**
  30350. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  30351. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  30352. */
  30353. useClonedMeshhMap?: boolean;
  30354. }
  30355. /**
  30356. * Represents a scene to be rendered by the engine.
  30357. * @see http://doc.babylonjs.com/features/scene
  30358. */
  30359. export class Scene extends AbstractScene implements IAnimatable {
  30360. private static _uniqueIdCounter;
  30361. /** The fog is deactivated */
  30362. static readonly FOGMODE_NONE: number;
  30363. /** The fog density is following an exponential function */
  30364. static readonly FOGMODE_EXP: number;
  30365. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  30366. static readonly FOGMODE_EXP2: number;
  30367. /** The fog density is following a linear function. */
  30368. static readonly FOGMODE_LINEAR: number;
  30369. /**
  30370. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  30371. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30372. */
  30373. static MinDeltaTime: number;
  30374. /**
  30375. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  30376. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30377. */
  30378. static MaxDeltaTime: number;
  30379. /**
  30380. * Factory used to create the default material.
  30381. * @param name The name of the material to create
  30382. * @param scene The scene to create the material for
  30383. * @returns The default material
  30384. */
  30385. static DefaultMaterialFactory(scene: Scene): Material;
  30386. /**
  30387. * Factory used to create the a collision coordinator.
  30388. * @returns The collision coordinator
  30389. */
  30390. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  30391. /** @hidden */ protected readonly _isScene: boolean;
  30392. /**
  30393. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  30394. */
  30395. autoClear: boolean;
  30396. /**
  30397. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  30398. */
  30399. autoClearDepthAndStencil: boolean;
  30400. /**
  30401. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  30402. */
  30403. clearColor: Color4;
  30404. /**
  30405. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  30406. */
  30407. ambientColor: Color3;
  30408. /** @hidden */ environmentBRDFTexture: BaseTexture;
  30409. /** @hidden */
  30410. protected _environmentTexture: Nullable<BaseTexture>;
  30411. /**
  30412. * Texture used in all pbr material as the reflection texture.
  30413. * As in the majority of the scene they are the same (exception for multi room and so on),
  30414. * this is easier to reference from here than from all the materials.
  30415. */
  30416. /**
  30417. * Texture used in all pbr material as the reflection texture.
  30418. * As in the majority of the scene they are the same (exception for multi room and so on),
  30419. * this is easier to set here than in all the materials.
  30420. */
  30421. environmentTexture: Nullable<BaseTexture>;
  30422. /** @hidden */
  30423. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30424. /**
  30425. * Default image processing configuration used either in the rendering
  30426. * Forward main pass or through the imageProcessingPostProcess if present.
  30427. * As in the majority of the scene they are the same (exception for multi camera),
  30428. * this is easier to reference from here than from all the materials and post process.
  30429. *
  30430. * No setter as we it is a shared configuration, you can set the values instead.
  30431. */
  30432. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  30433. private _forceWireframe;
  30434. /**
  30435. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  30436. */
  30437. forceWireframe: boolean;
  30438. private _forcePointsCloud;
  30439. /**
  30440. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  30441. */
  30442. forcePointsCloud: boolean;
  30443. /**
  30444. * Gets or sets the active clipplane 1
  30445. */
  30446. clipPlane: Nullable<Plane>;
  30447. /**
  30448. * Gets or sets the active clipplane 2
  30449. */
  30450. clipPlane2: Nullable<Plane>;
  30451. /**
  30452. * Gets or sets the active clipplane 3
  30453. */
  30454. clipPlane3: Nullable<Plane>;
  30455. /**
  30456. * Gets or sets the active clipplane 4
  30457. */
  30458. clipPlane4: Nullable<Plane>;
  30459. /**
  30460. * Gets or sets a boolean indicating if animations are enabled
  30461. */
  30462. animationsEnabled: boolean;
  30463. private _animationPropertiesOverride;
  30464. /**
  30465. * Gets or sets the animation properties override
  30466. */
  30467. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  30468. /**
  30469. * Gets or sets a boolean indicating if a constant deltatime has to be used
  30470. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  30471. */
  30472. useConstantAnimationDeltaTime: boolean;
  30473. /**
  30474. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  30475. * Please note that it requires to run a ray cast through the scene on every frame
  30476. */
  30477. constantlyUpdateMeshUnderPointer: boolean;
  30478. /**
  30479. * Defines the HTML cursor to use when hovering over interactive elements
  30480. */
  30481. hoverCursor: string;
  30482. /**
  30483. * Defines the HTML default cursor to use (empty by default)
  30484. */
  30485. defaultCursor: string;
  30486. /**
  30487. * This is used to call preventDefault() on pointer down
  30488. * in order to block unwanted artifacts like system double clicks
  30489. */
  30490. preventDefaultOnPointerDown: boolean;
  30491. /**
  30492. * This is used to call preventDefault() on pointer up
  30493. * in order to block unwanted artifacts like system double clicks
  30494. */
  30495. preventDefaultOnPointerUp: boolean;
  30496. /**
  30497. * Gets or sets user defined metadata
  30498. */
  30499. metadata: any;
  30500. /**
  30501. * For internal use only. Please do not use.
  30502. */
  30503. reservedDataStore: any;
  30504. /**
  30505. * Gets the name of the plugin used to load this scene (null by default)
  30506. */
  30507. loadingPluginName: string;
  30508. /**
  30509. * Use this array to add regular expressions used to disable offline support for specific urls
  30510. */
  30511. disableOfflineSupportExceptionRules: RegExp[];
  30512. /**
  30513. * An event triggered when the scene is disposed.
  30514. */
  30515. onDisposeObservable: Observable<Scene>;
  30516. private _onDisposeObserver;
  30517. /** Sets a function to be executed when this scene is disposed. */
  30518. onDispose: () => void;
  30519. /**
  30520. * An event triggered before rendering the scene (right after animations and physics)
  30521. */
  30522. onBeforeRenderObservable: Observable<Scene>;
  30523. private _onBeforeRenderObserver;
  30524. /** Sets a function to be executed before rendering this scene */
  30525. beforeRender: Nullable<() => void>;
  30526. /**
  30527. * An event triggered after rendering the scene
  30528. */
  30529. onAfterRenderObservable: Observable<Scene>;
  30530. private _onAfterRenderObserver;
  30531. /** Sets a function to be executed after rendering this scene */
  30532. afterRender: Nullable<() => void>;
  30533. /**
  30534. * An event triggered before animating the scene
  30535. */
  30536. onBeforeAnimationsObservable: Observable<Scene>;
  30537. /**
  30538. * An event triggered after animations processing
  30539. */
  30540. onAfterAnimationsObservable: Observable<Scene>;
  30541. /**
  30542. * An event triggered before draw calls are ready to be sent
  30543. */
  30544. onBeforeDrawPhaseObservable: Observable<Scene>;
  30545. /**
  30546. * An event triggered after draw calls have been sent
  30547. */
  30548. onAfterDrawPhaseObservable: Observable<Scene>;
  30549. /**
  30550. * An event triggered when the scene is ready
  30551. */
  30552. onReadyObservable: Observable<Scene>;
  30553. /**
  30554. * An event triggered before rendering a camera
  30555. */
  30556. onBeforeCameraRenderObservable: Observable<Camera>;
  30557. private _onBeforeCameraRenderObserver;
  30558. /** Sets a function to be executed before rendering a camera*/
  30559. beforeCameraRender: () => void;
  30560. /**
  30561. * An event triggered after rendering a camera
  30562. */
  30563. onAfterCameraRenderObservable: Observable<Camera>;
  30564. private _onAfterCameraRenderObserver;
  30565. /** Sets a function to be executed after rendering a camera*/
  30566. afterCameraRender: () => void;
  30567. /**
  30568. * An event triggered when active meshes evaluation is about to start
  30569. */
  30570. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  30571. /**
  30572. * An event triggered when active meshes evaluation is done
  30573. */
  30574. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  30575. /**
  30576. * An event triggered when particles rendering is about to start
  30577. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  30578. */
  30579. onBeforeParticlesRenderingObservable: Observable<Scene>;
  30580. /**
  30581. * An event triggered when particles rendering is done
  30582. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  30583. */
  30584. onAfterParticlesRenderingObservable: Observable<Scene>;
  30585. /**
  30586. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  30587. */
  30588. onDataLoadedObservable: Observable<Scene>;
  30589. /**
  30590. * An event triggered when a camera is created
  30591. */
  30592. onNewCameraAddedObservable: Observable<Camera>;
  30593. /**
  30594. * An event triggered when a camera is removed
  30595. */
  30596. onCameraRemovedObservable: Observable<Camera>;
  30597. /**
  30598. * An event triggered when a light is created
  30599. */
  30600. onNewLightAddedObservable: Observable<Light>;
  30601. /**
  30602. * An event triggered when a light is removed
  30603. */
  30604. onLightRemovedObservable: Observable<Light>;
  30605. /**
  30606. * An event triggered when a geometry is created
  30607. */
  30608. onNewGeometryAddedObservable: Observable<Geometry>;
  30609. /**
  30610. * An event triggered when a geometry is removed
  30611. */
  30612. onGeometryRemovedObservable: Observable<Geometry>;
  30613. /**
  30614. * An event triggered when a transform node is created
  30615. */
  30616. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  30617. /**
  30618. * An event triggered when a transform node is removed
  30619. */
  30620. onTransformNodeRemovedObservable: Observable<TransformNode>;
  30621. /**
  30622. * An event triggered when a mesh is created
  30623. */
  30624. onNewMeshAddedObservable: Observable<AbstractMesh>;
  30625. /**
  30626. * An event triggered when a mesh is removed
  30627. */
  30628. onMeshRemovedObservable: Observable<AbstractMesh>;
  30629. /**
  30630. * An event triggered when a material is created
  30631. */
  30632. onNewMaterialAddedObservable: Observable<Material>;
  30633. /**
  30634. * An event triggered when a material is removed
  30635. */
  30636. onMaterialRemovedObservable: Observable<Material>;
  30637. /**
  30638. * An event triggered when a texture is created
  30639. */
  30640. onNewTextureAddedObservable: Observable<BaseTexture>;
  30641. /**
  30642. * An event triggered when a texture is removed
  30643. */
  30644. onTextureRemovedObservable: Observable<BaseTexture>;
  30645. /**
  30646. * An event triggered when render targets are about to be rendered
  30647. * Can happen multiple times per frame.
  30648. */
  30649. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  30650. /**
  30651. * An event triggered when render targets were rendered.
  30652. * Can happen multiple times per frame.
  30653. */
  30654. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  30655. /**
  30656. * An event triggered before calculating deterministic simulation step
  30657. */
  30658. onBeforeStepObservable: Observable<Scene>;
  30659. /**
  30660. * An event triggered after calculating deterministic simulation step
  30661. */
  30662. onAfterStepObservable: Observable<Scene>;
  30663. /**
  30664. * An event triggered when the activeCamera property is updated
  30665. */
  30666. onActiveCameraChanged: Observable<Scene>;
  30667. /**
  30668. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  30669. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  30670. * 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)
  30671. */
  30672. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  30673. /**
  30674. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  30675. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  30676. * 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)
  30677. */
  30678. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  30679. /**
  30680. * This Observable will when a mesh has been imported into the scene.
  30681. */
  30682. onMeshImportedObservable: Observable<AbstractMesh>;
  30683. /** @hidden */ registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  30684. /**
  30685. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  30686. */
  30687. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  30688. /**
  30689. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  30690. */
  30691. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  30692. /**
  30693. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  30694. */
  30695. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  30696. private _onPointerMove;
  30697. private _onPointerDown;
  30698. private _onPointerUp;
  30699. /** Callback called when a pointer move is detected */
  30700. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  30701. /** Callback called when a pointer down is detected */
  30702. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  30703. /** Callback called when a pointer up is detected */
  30704. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  30705. /** Callback called when a pointer pick is detected */
  30706. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  30707. /**
  30708. * 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).
  30709. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  30710. */
  30711. onPrePointerObservable: Observable<PointerInfoPre>;
  30712. /**
  30713. * Observable event triggered each time an input event is received from the rendering canvas
  30714. */
  30715. onPointerObservable: Observable<PointerInfo>;
  30716. /**
  30717. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  30718. */
  30719. readonly unTranslatedPointer: Vector2;
  30720. /** The distance in pixel that you have to move to prevent some events */
  30721. static DragMovementThreshold: number;
  30722. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  30723. static LongPressDelay: number;
  30724. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  30725. static DoubleClickDelay: number;
  30726. /** If you need to check double click without raising a single click at first click, enable this flag */
  30727. static ExclusiveDoubleClickMode: boolean;
  30728. private _initClickEvent;
  30729. private _initActionManager;
  30730. private _delayedSimpleClick;
  30731. private _delayedSimpleClickTimeout;
  30732. private _previousDelayedSimpleClickTimeout;
  30733. private _meshPickProceed;
  30734. private _previousButtonPressed;
  30735. private _currentPickResult;
  30736. private _previousPickResult;
  30737. private _totalPointersPressed;
  30738. private _doubleClickOccured;
  30739. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  30740. cameraToUseForPointers: Nullable<Camera>;
  30741. private _pointerX;
  30742. private _pointerY;
  30743. private _unTranslatedPointerX;
  30744. private _unTranslatedPointerY;
  30745. private _startingPointerPosition;
  30746. private _previousStartingPointerPosition;
  30747. private _startingPointerTime;
  30748. private _previousStartingPointerTime;
  30749. private _pointerCaptures;
  30750. private _timeAccumulator;
  30751. private _currentStepId;
  30752. private _currentInternalStep;
  30753. /** @hidden */ mirroredCameraPosition: Nullable<Vector3>;
  30754. /**
  30755. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  30756. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  30757. */
  30758. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  30759. /**
  30760. * Observable event triggered each time an keyboard event is received from the hosting window
  30761. */
  30762. onKeyboardObservable: Observable<KeyboardInfo>;
  30763. private _onKeyDown;
  30764. private _onKeyUp;
  30765. private _onCanvasFocusObserver;
  30766. private _onCanvasBlurObserver;
  30767. private _useRightHandedSystem;
  30768. /**
  30769. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  30770. */
  30771. useRightHandedSystem: boolean;
  30772. /**
  30773. * Sets the step Id used by deterministic lock step
  30774. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30775. * @param newStepId defines the step Id
  30776. */
  30777. setStepId(newStepId: number): void;
  30778. /**
  30779. * Gets the step Id used by deterministic lock step
  30780. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30781. * @returns the step Id
  30782. */
  30783. getStepId(): number;
  30784. /**
  30785. * Gets the internal step used by deterministic lock step
  30786. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30787. * @returns the internal step
  30788. */
  30789. getInternalStep(): number;
  30790. private _fogEnabled;
  30791. /**
  30792. * Gets or sets a boolean indicating if fog is enabled on this scene
  30793. * @see http://doc.babylonjs.com/babylon101/environment#fog
  30794. * (Default is true)
  30795. */
  30796. fogEnabled: boolean;
  30797. private _fogMode;
  30798. /**
  30799. * Gets or sets the fog mode to use
  30800. * @see http://doc.babylonjs.com/babylon101/environment#fog
  30801. * | mode | value |
  30802. * | --- | --- |
  30803. * | FOGMODE_NONE | 0 |
  30804. * | FOGMODE_EXP | 1 |
  30805. * | FOGMODE_EXP2 | 2 |
  30806. * | FOGMODE_LINEAR | 3 |
  30807. */
  30808. fogMode: number;
  30809. /**
  30810. * Gets or sets the fog color to use
  30811. * @see http://doc.babylonjs.com/babylon101/environment#fog
  30812. * (Default is Color3(0.2, 0.2, 0.3))
  30813. */
  30814. fogColor: Color3;
  30815. /**
  30816. * Gets or sets the fog density to use
  30817. * @see http://doc.babylonjs.com/babylon101/environment#fog
  30818. * (Default is 0.1)
  30819. */
  30820. fogDensity: number;
  30821. /**
  30822. * Gets or sets the fog start distance to use
  30823. * @see http://doc.babylonjs.com/babylon101/environment#fog
  30824. * (Default is 0)
  30825. */
  30826. fogStart: number;
  30827. /**
  30828. * Gets or sets the fog end distance to use
  30829. * @see http://doc.babylonjs.com/babylon101/environment#fog
  30830. * (Default is 1000)
  30831. */
  30832. fogEnd: number;
  30833. private _shadowsEnabled;
  30834. /**
  30835. * Gets or sets a boolean indicating if shadows are enabled on this scene
  30836. */
  30837. shadowsEnabled: boolean;
  30838. private _lightsEnabled;
  30839. /**
  30840. * Gets or sets a boolean indicating if lights are enabled on this scene
  30841. */
  30842. lightsEnabled: boolean;
  30843. /** All of the active cameras added to this scene. */
  30844. activeCameras: Camera[];
  30845. private _activeCamera;
  30846. /** Gets or sets the current active camera */
  30847. activeCamera: Nullable<Camera>;
  30848. private _defaultMaterial;
  30849. /** The default material used on meshes when no material is affected */
  30850. /** The default material used on meshes when no material is affected */
  30851. defaultMaterial: Material;
  30852. private _texturesEnabled;
  30853. /**
  30854. * Gets or sets a boolean indicating if textures are enabled on this scene
  30855. */
  30856. texturesEnabled: boolean;
  30857. /**
  30858. * Gets or sets a boolean indicating if particles are enabled on this scene
  30859. */
  30860. particlesEnabled: boolean;
  30861. /**
  30862. * Gets or sets a boolean indicating if sprites are enabled on this scene
  30863. */
  30864. spritesEnabled: boolean;
  30865. private _skeletonsEnabled;
  30866. /**
  30867. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  30868. */
  30869. skeletonsEnabled: boolean;
  30870. /**
  30871. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  30872. */
  30873. lensFlaresEnabled: boolean;
  30874. /**
  30875. * Gets or sets a boolean indicating if collisions are enabled on this scene
  30876. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  30877. */
  30878. collisionsEnabled: boolean;
  30879. private _collisionCoordinator;
  30880. /** @hidden */
  30881. readonly collisionCoordinator: ICollisionCoordinator;
  30882. /**
  30883. * Defines the gravity applied to this scene (used only for collisions)
  30884. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  30885. */
  30886. gravity: Vector3;
  30887. /**
  30888. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  30889. */
  30890. postProcessesEnabled: boolean;
  30891. /**
  30892. * The list of postprocesses added to the scene
  30893. */
  30894. postProcesses: PostProcess[];
  30895. /**
  30896. * Gets the current postprocess manager
  30897. */
  30898. postProcessManager: PostProcessManager;
  30899. /**
  30900. * Gets or sets a boolean indicating if render targets are enabled on this scene
  30901. */
  30902. renderTargetsEnabled: boolean;
  30903. /**
  30904. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  30905. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  30906. */
  30907. dumpNextRenderTargets: boolean;
  30908. /**
  30909. * The list of user defined render targets added to the scene
  30910. */
  30911. customRenderTargets: RenderTargetTexture[];
  30912. /**
  30913. * Defines if texture loading must be delayed
  30914. * If true, textures will only be loaded when they need to be rendered
  30915. */
  30916. useDelayedTextureLoading: boolean;
  30917. /**
  30918. * Gets the list of meshes imported to the scene through SceneLoader
  30919. */
  30920. importedMeshesFiles: String[];
  30921. /**
  30922. * Gets or sets a boolean indicating if probes are enabled on this scene
  30923. */
  30924. probesEnabled: boolean;
  30925. /**
  30926. * Gets or sets the current offline provider to use to store scene data
  30927. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  30928. */
  30929. offlineProvider: IOfflineProvider;
  30930. /**
  30931. * Gets or sets the action manager associated with the scene
  30932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  30933. */
  30934. actionManager: AbstractActionManager;
  30935. private _meshesForIntersections;
  30936. /**
  30937. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  30938. */
  30939. proceduralTexturesEnabled: boolean;
  30940. private _engine;
  30941. private _totalVertices;
  30942. /** @hidden */ activeIndices: PerfCounter;
  30943. /** @hidden */ activeParticles: PerfCounter;
  30944. /** @hidden */ activeBones: PerfCounter;
  30945. private _animationRatio;
  30946. /** @hidden */ animationTimeLast: number;
  30947. /** @hidden */ animationTime: number;
  30948. /**
  30949. * Gets or sets a general scale for animation speed
  30950. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  30951. */
  30952. animationTimeScale: number;
  30953. /** @hidden */ cachedMaterial: Nullable<Material>;
  30954. /** @hidden */ cachedEffect: Nullable<Effect>;
  30955. /** @hidden */ cachedVisibility: Nullable<number>;
  30956. private _renderId;
  30957. private _frameId;
  30958. private _executeWhenReadyTimeoutId;
  30959. private _intermediateRendering;
  30960. private _viewUpdateFlag;
  30961. private _projectionUpdateFlag;
  30962. private _alternateViewUpdateFlag;
  30963. private _alternateProjectionUpdateFlag;
  30964. /** @hidden */ toBeDisposed: Nullable<IDisposable>[];
  30965. private _activeRequests;
  30966. /** @hidden */ pendingData: any[];
  30967. private _isDisposed;
  30968. /**
  30969. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  30970. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  30971. */
  30972. dispatchAllSubMeshesOfActiveMeshes: boolean;
  30973. private _activeMeshes;
  30974. private _processedMaterials;
  30975. private _renderTargets;
  30976. /** @hidden */ activeParticleSystems: SmartArray<IParticleSystem>;
  30977. private _activeSkeletons;
  30978. private _softwareSkinnedMeshes;
  30979. private _renderingManager;
  30980. /** @hidden */ activeAnimatables: Animatable[];
  30981. private _transformMatrix;
  30982. private _sceneUbo;
  30983. private _alternateSceneUbo;
  30984. private _viewMatrix;
  30985. private _projectionMatrix;
  30986. private _alternateViewMatrix;
  30987. private _alternateProjectionMatrix;
  30988. private _alternateTransformMatrix;
  30989. private _useAlternateCameraConfiguration;
  30990. private _alternateRendering;
  30991. private _wheelEventName;
  30992. /** @hidden */ forcedViewPosition: Nullable<Vector3>;
  30993. /** @hidden */ protected readonly _isAlternateRenderingEnabled: boolean;
  30994. private _frustumPlanes;
  30995. /**
  30996. * Gets the list of frustum planes (built from the active camera)
  30997. */
  30998. readonly frustumPlanes: Plane[];
  30999. /**
  31000. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  31001. * This is useful if there are more lights that the maximum simulteanous authorized
  31002. */
  31003. requireLightSorting: boolean;
  31004. /** @hidden */
  31005. readonly useMaterialMeshMap: boolean;
  31006. /** @hidden */
  31007. readonly useClonedMeshhMap: boolean;
  31008. private _pointerOverMesh;
  31009. private _pickedDownMesh;
  31010. private _pickedUpMesh;
  31011. private _externalData;
  31012. private _uid;
  31013. /**
  31014. * @hidden
  31015. * Backing store of defined scene components.
  31016. */ components: ISceneComponent[];
  31017. /**
  31018. * @hidden
  31019. * Backing store of defined scene components.
  31020. */ serializableComponents: ISceneSerializableComponent[];
  31021. /**
  31022. * List of components to register on the next registration step.
  31023. */
  31024. private _transientComponents;
  31025. /**
  31026. * Registers the transient components if needed.
  31027. */
  31028. private _registerTransientComponents;
  31029. /**
  31030. * @hidden
  31031. * Add a component to the scene.
  31032. * Note that the ccomponent could be registered on th next frame if this is called after
  31033. * the register component stage.
  31034. * @param component Defines the component to add to the scene
  31035. */ addComponent(component: ISceneComponent): void;
  31036. /**
  31037. * @hidden
  31038. * Gets a component from the scene.
  31039. * @param name defines the name of the component to retrieve
  31040. * @returns the component or null if not present
  31041. */ getComponent(name: string): Nullable<ISceneComponent>;
  31042. /**
  31043. * @hidden
  31044. * Defines the actions happening before camera updates.
  31045. */ beforeCameraUpdateStage: Stage<SimpleStageAction>;
  31046. /**
  31047. * @hidden
  31048. * Defines the actions happening before clear the canvas.
  31049. */ beforeClearStage: Stage<SimpleStageAction>;
  31050. /**
  31051. * @hidden
  31052. * Defines the actions when collecting render targets for the frame.
  31053. */ gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  31054. /**
  31055. * @hidden
  31056. * Defines the actions happening for one camera in the frame.
  31057. */ gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  31058. /**
  31059. * @hidden
  31060. * Defines the actions happening during the per mesh ready checks.
  31061. */ isReadyForMeshStage: Stage<MeshStageAction>;
  31062. /**
  31063. * @hidden
  31064. * Defines the actions happening before evaluate active mesh checks.
  31065. */ beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  31066. /**
  31067. * @hidden
  31068. * Defines the actions happening during the evaluate sub mesh checks.
  31069. */ evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  31070. /**
  31071. * @hidden
  31072. * Defines the actions happening during the active mesh stage.
  31073. */ activeMeshStage: Stage<ActiveMeshStageAction>;
  31074. /**
  31075. * @hidden
  31076. * Defines the actions happening during the per camera render target step.
  31077. */ cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  31078. /**
  31079. * @hidden
  31080. * Defines the actions happening just before the active camera is drawing.
  31081. */ beforeCameraDrawStage: Stage<CameraStageAction>;
  31082. /**
  31083. * @hidden
  31084. * Defines the actions happening just before a render target is drawing.
  31085. */ beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  31086. /**
  31087. * @hidden
  31088. * Defines the actions happening just before a rendering group is drawing.
  31089. */ beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  31090. /**
  31091. * @hidden
  31092. * Defines the actions happening just before a mesh is drawing.
  31093. */ beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  31094. /**
  31095. * @hidden
  31096. * Defines the actions happening just after a mesh has been drawn.
  31097. */ afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  31098. /**
  31099. * @hidden
  31100. * Defines the actions happening just after a rendering group has been drawn.
  31101. */ afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  31102. /**
  31103. * @hidden
  31104. * Defines the actions happening just after the active camera has been drawn.
  31105. */ afterCameraDrawStage: Stage<CameraStageAction>;
  31106. /**
  31107. * @hidden
  31108. * Defines the actions happening just after a render target has been drawn.
  31109. */ afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  31110. /**
  31111. * @hidden
  31112. * Defines the actions happening just after rendering all cameras and computing intersections.
  31113. */ afterRenderStage: Stage<SimpleStageAction>;
  31114. /**
  31115. * @hidden
  31116. * Defines the actions happening when a pointer move event happens.
  31117. */ pointerMoveStage: Stage<PointerMoveStageAction>;
  31118. /**
  31119. * @hidden
  31120. * Defines the actions happening when a pointer down event happens.
  31121. */ pointerDownStage: Stage<PointerUpDownStageAction>;
  31122. /**
  31123. * @hidden
  31124. * Defines the actions happening when a pointer up event happens.
  31125. */ pointerUpStage: Stage<PointerUpDownStageAction>;
  31126. /**
  31127. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  31128. */
  31129. private geometriesByUniqueId;
  31130. /**
  31131. * Creates a new Scene
  31132. * @param engine defines the engine to use to render this scene
  31133. * @param options defines the scene options
  31134. */
  31135. constructor(engine: Engine, options?: SceneOptions);
  31136. private _defaultMeshCandidates;
  31137. /**
  31138. * @hidden
  31139. */ getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  31140. private _defaultSubMeshCandidates;
  31141. /**
  31142. * @hidden
  31143. */ getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  31144. /**
  31145. * Sets the default candidate providers for the scene.
  31146. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  31147. * and getCollidingSubMeshCandidates to their default function
  31148. */
  31149. setDefaultCandidateProviders(): void;
  31150. /**
  31151. * Gets the mesh that is currently under the pointer
  31152. */
  31153. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31154. /**
  31155. * Gets or sets the current on-screen X position of the pointer
  31156. */
  31157. pointerX: number;
  31158. /**
  31159. * Gets or sets the current on-screen Y position of the pointer
  31160. */
  31161. pointerY: number;
  31162. /**
  31163. * Gets the cached material (ie. the latest rendered one)
  31164. * @returns the cached material
  31165. */
  31166. getCachedMaterial(): Nullable<Material>;
  31167. /**
  31168. * Gets the cached effect (ie. the latest rendered one)
  31169. * @returns the cached effect
  31170. */
  31171. getCachedEffect(): Nullable<Effect>;
  31172. /**
  31173. * Gets the cached visibility state (ie. the latest rendered one)
  31174. * @returns the cached visibility state
  31175. */
  31176. getCachedVisibility(): Nullable<number>;
  31177. /**
  31178. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  31179. * @param material defines the current material
  31180. * @param effect defines the current effect
  31181. * @param visibility defines the current visibility state
  31182. * @returns true if one parameter is not cached
  31183. */
  31184. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  31185. /**
  31186. * Gets the engine associated with the scene
  31187. * @returns an Engine
  31188. */
  31189. getEngine(): Engine;
  31190. /**
  31191. * Gets the total number of vertices rendered per frame
  31192. * @returns the total number of vertices rendered per frame
  31193. */
  31194. getTotalVertices(): number;
  31195. /**
  31196. * Gets the performance counter for total vertices
  31197. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31198. */
  31199. readonly totalVerticesPerfCounter: PerfCounter;
  31200. /**
  31201. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  31202. * @returns the total number of active indices rendered per frame
  31203. */
  31204. getActiveIndices(): number;
  31205. /**
  31206. * Gets the performance counter for active indices
  31207. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31208. */
  31209. readonly totalActiveIndicesPerfCounter: PerfCounter;
  31210. /**
  31211. * Gets the total number of active particles rendered per frame
  31212. * @returns the total number of active particles rendered per frame
  31213. */
  31214. getActiveParticles(): number;
  31215. /**
  31216. * Gets the performance counter for active particles
  31217. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31218. */
  31219. readonly activeParticlesPerfCounter: PerfCounter;
  31220. /**
  31221. * Gets the total number of active bones rendered per frame
  31222. * @returns the total number of active bones rendered per frame
  31223. */
  31224. getActiveBones(): number;
  31225. /**
  31226. * Gets the performance counter for active bones
  31227. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31228. */
  31229. readonly activeBonesPerfCounter: PerfCounter;
  31230. /**
  31231. * Gets the array of active meshes
  31232. * @returns an array of AbstractMesh
  31233. */
  31234. getActiveMeshes(): SmartArray<AbstractMesh>;
  31235. /**
  31236. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  31237. * @returns a number
  31238. */
  31239. getAnimationRatio(): number;
  31240. /**
  31241. * Gets an unique Id for the current render phase
  31242. * @returns a number
  31243. */
  31244. getRenderId(): number;
  31245. /**
  31246. * Gets an unique Id for the current frame
  31247. * @returns a number
  31248. */
  31249. getFrameId(): number;
  31250. /** Call this function if you want to manually increment the render Id*/
  31251. incrementRenderId(): void;
  31252. private _updatePointerPosition;
  31253. private _createUbo;
  31254. private _createAlternateUbo;
  31255. private _setRayOnPointerInfo;
  31256. /**
  31257. * Use this method to simulate a pointer move on a mesh
  31258. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31259. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31260. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31261. * @returns the current scene
  31262. */
  31263. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  31264. private _processPointerMove;
  31265. private _checkPrePointerObservable;
  31266. /**
  31267. * Use this method to simulate a pointer down on a mesh
  31268. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31269. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31270. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31271. * @returns the current scene
  31272. */
  31273. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  31274. private _processPointerDown;
  31275. /**
  31276. * Use this method to simulate a pointer up on a mesh
  31277. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31278. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31279. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31280. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31281. * @returns the current scene
  31282. */
  31283. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  31284. private _processPointerUp;
  31285. /**
  31286. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31287. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31288. * @returns true if the pointer was captured
  31289. */
  31290. isPointerCaptured(pointerId?: number): boolean;
  31291. /** @hidden */ isPointerSwiping(): boolean;
  31292. /**
  31293. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31294. * @param attachUp defines if you want to attach events to pointerup
  31295. * @param attachDown defines if you want to attach events to pointerdown
  31296. * @param attachMove defines if you want to attach events to pointermove
  31297. */
  31298. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  31299. /** Detaches all event handlers*/
  31300. detachControl(): void;
  31301. /**
  31302. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  31303. * Delay loaded resources are not taking in account
  31304. * @return true if all required resources are ready
  31305. */
  31306. isReady(): boolean;
  31307. /** Resets all cached information relative to material (including effect and visibility) */
  31308. resetCachedMaterial(): void;
  31309. /**
  31310. * Registers a function to be called before every frame render
  31311. * @param func defines the function to register
  31312. */
  31313. registerBeforeRender(func: () => void): void;
  31314. /**
  31315. * Unregisters a function called before every frame render
  31316. * @param func defines the function to unregister
  31317. */
  31318. unregisterBeforeRender(func: () => void): void;
  31319. /**
  31320. * Registers a function to be called after every frame render
  31321. * @param func defines the function to register
  31322. */
  31323. registerAfterRender(func: () => void): void;
  31324. /**
  31325. * Unregisters a function called after every frame render
  31326. * @param func defines the function to unregister
  31327. */
  31328. unregisterAfterRender(func: () => void): void;
  31329. private _executeOnceBeforeRender;
  31330. /**
  31331. * The provided function will run before render once and will be disposed afterwards.
  31332. * A timeout delay can be provided so that the function will be executed in N ms.
  31333. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  31334. * @param func The function to be executed.
  31335. * @param timeout optional delay in ms
  31336. */
  31337. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  31338. /** @hidden */ addPendingData(data: any): void;
  31339. /** @hidden */ removePendingData(data: any): void;
  31340. /**
  31341. * Returns the number of items waiting to be loaded
  31342. * @returns the number of items waiting to be loaded
  31343. */
  31344. getWaitingItemsCount(): number;
  31345. /**
  31346. * Returns a boolean indicating if the scene is still loading data
  31347. */
  31348. readonly isLoading: boolean;
  31349. /**
  31350. * Registers a function to be executed when the scene is ready
  31351. * @param {Function} func - the function to be executed
  31352. */
  31353. executeWhenReady(func: () => void): void;
  31354. /**
  31355. * Returns a promise that resolves when the scene is ready
  31356. * @returns A promise that resolves when the scene is ready
  31357. */
  31358. whenReadyAsync(): Promise<void>;
  31359. /** @hidden */ checkIsReady(): void;
  31360. /**
  31361. * Gets all animatable attached to the scene
  31362. */
  31363. readonly animatables: Animatable[];
  31364. /**
  31365. * Resets the last animation time frame.
  31366. * Useful to override when animations start running when loading a scene for the first time.
  31367. */
  31368. resetLastAnimationTimeFrame(): void;
  31369. /** @hidden */ switchToAlternateCameraConfiguration(active: boolean): void;
  31370. /**
  31371. * Gets the current view matrix
  31372. * @returns a Matrix
  31373. */
  31374. getViewMatrix(): Matrix;
  31375. /**
  31376. * Gets the current projection matrix
  31377. * @returns a Matrix
  31378. */
  31379. getProjectionMatrix(): Matrix;
  31380. /**
  31381. * Gets the current transform matrix
  31382. * @returns a Matrix made of View * Projection
  31383. */
  31384. getTransformMatrix(): Matrix;
  31385. /**
  31386. * Sets the current transform matrix
  31387. * @param view defines the View matrix to use
  31388. * @param projection defines the Projection matrix to use
  31389. */
  31390. setTransformMatrix(view: Matrix, projection: Matrix): void;
  31391. /** @hidden */ setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  31392. /**
  31393. * Gets the uniform buffer used to store scene data
  31394. * @returns a UniformBuffer
  31395. */
  31396. getSceneUniformBuffer(): UniformBuffer;
  31397. /**
  31398. * Gets an unique (relatively to the current scene) Id
  31399. * @returns an unique number for the scene
  31400. */
  31401. getUniqueId(): number;
  31402. /**
  31403. * Add a mesh to the list of scene's meshes
  31404. * @param newMesh defines the mesh to add
  31405. * @param recursive if all child meshes should also be added to the scene
  31406. */
  31407. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  31408. /**
  31409. * Remove a mesh for the list of scene's meshes
  31410. * @param toRemove defines the mesh to remove
  31411. * @param recursive if all child meshes should also be removed from the scene
  31412. * @returns the index where the mesh was in the mesh list
  31413. */
  31414. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  31415. /**
  31416. * Add a transform node to the list of scene's transform nodes
  31417. * @param newTransformNode defines the transform node to add
  31418. */
  31419. addTransformNode(newTransformNode: TransformNode): void;
  31420. /**
  31421. * Remove a transform node for the list of scene's transform nodes
  31422. * @param toRemove defines the transform node to remove
  31423. * @returns the index where the transform node was in the transform node list
  31424. */
  31425. removeTransformNode(toRemove: TransformNode): number;
  31426. /**
  31427. * Remove a skeleton for the list of scene's skeletons
  31428. * @param toRemove defines the skeleton to remove
  31429. * @returns the index where the skeleton was in the skeleton list
  31430. */
  31431. removeSkeleton(toRemove: Skeleton): number;
  31432. /**
  31433. * Remove a morph target for the list of scene's morph targets
  31434. * @param toRemove defines the morph target to remove
  31435. * @returns the index where the morph target was in the morph target list
  31436. */
  31437. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  31438. /**
  31439. * Remove a light for the list of scene's lights
  31440. * @param toRemove defines the light to remove
  31441. * @returns the index where the light was in the light list
  31442. */
  31443. removeLight(toRemove: Light): number;
  31444. /**
  31445. * Remove a camera for the list of scene's cameras
  31446. * @param toRemove defines the camera to remove
  31447. * @returns the index where the camera was in the camera list
  31448. */
  31449. removeCamera(toRemove: Camera): number;
  31450. /**
  31451. * Remove a particle system for the list of scene's particle systems
  31452. * @param toRemove defines the particle system to remove
  31453. * @returns the index where the particle system was in the particle system list
  31454. */
  31455. removeParticleSystem(toRemove: IParticleSystem): number;
  31456. /**
  31457. * Remove a animation for the list of scene's animations
  31458. * @param toRemove defines the animation to remove
  31459. * @returns the index where the animation was in the animation list
  31460. */
  31461. removeAnimation(toRemove: Animation): number;
  31462. /**
  31463. * Removes the given animation group from this scene.
  31464. * @param toRemove The animation group to remove
  31465. * @returns The index of the removed animation group
  31466. */
  31467. removeAnimationGroup(toRemove: AnimationGroup): number;
  31468. /**
  31469. * Removes the given multi-material from this scene.
  31470. * @param toRemove The multi-material to remove
  31471. * @returns The index of the removed multi-material
  31472. */
  31473. removeMultiMaterial(toRemove: MultiMaterial): number;
  31474. /**
  31475. * Removes the given material from this scene.
  31476. * @param toRemove The material to remove
  31477. * @returns The index of the removed material
  31478. */
  31479. removeMaterial(toRemove: Material): number;
  31480. /**
  31481. * Removes the given action manager from this scene.
  31482. * @param toRemove The action manager to remove
  31483. * @returns The index of the removed action manager
  31484. */
  31485. removeActionManager(toRemove: AbstractActionManager): number;
  31486. /**
  31487. * Removes the given texture from this scene.
  31488. * @param toRemove The texture to remove
  31489. * @returns The index of the removed texture
  31490. */
  31491. removeTexture(toRemove: BaseTexture): number;
  31492. /**
  31493. * Adds the given light to this scene
  31494. * @param newLight The light to add
  31495. */
  31496. addLight(newLight: Light): void;
  31497. /**
  31498. * Sorts the list list based on light priorities
  31499. */
  31500. sortLightsByPriority(): void;
  31501. /**
  31502. * Adds the given camera to this scene
  31503. * @param newCamera The camera to add
  31504. */
  31505. addCamera(newCamera: Camera): void;
  31506. /**
  31507. * Adds the given skeleton to this scene
  31508. * @param newSkeleton The skeleton to add
  31509. */
  31510. addSkeleton(newSkeleton: Skeleton): void;
  31511. /**
  31512. * Adds the given particle system to this scene
  31513. * @param newParticleSystem The particle system to add
  31514. */
  31515. addParticleSystem(newParticleSystem: IParticleSystem): void;
  31516. /**
  31517. * Adds the given animation to this scene
  31518. * @param newAnimation The animation to add
  31519. */
  31520. addAnimation(newAnimation: Animation): void;
  31521. /**
  31522. * Adds the given animation group to this scene.
  31523. * @param newAnimationGroup The animation group to add
  31524. */
  31525. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  31526. /**
  31527. * Adds the given multi-material to this scene
  31528. * @param newMultiMaterial The multi-material to add
  31529. */
  31530. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  31531. /**
  31532. * Adds the given material to this scene
  31533. * @param newMaterial The material to add
  31534. */
  31535. addMaterial(newMaterial: Material): void;
  31536. /**
  31537. * Adds the given morph target to this scene
  31538. * @param newMorphTargetManager The morph target to add
  31539. */
  31540. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  31541. /**
  31542. * Adds the given geometry to this scene
  31543. * @param newGeometry The geometry to add
  31544. */
  31545. addGeometry(newGeometry: Geometry): void;
  31546. /**
  31547. * Adds the given action manager to this scene
  31548. * @param newActionManager The action manager to add
  31549. */
  31550. addActionManager(newActionManager: AbstractActionManager): void;
  31551. /**
  31552. * Adds the given texture to this scene.
  31553. * @param newTexture The texture to add
  31554. */
  31555. addTexture(newTexture: BaseTexture): void;
  31556. /**
  31557. * Switch active camera
  31558. * @param newCamera defines the new active camera
  31559. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  31560. */
  31561. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  31562. /**
  31563. * sets the active camera of the scene using its ID
  31564. * @param id defines the camera's ID
  31565. * @return the new active camera or null if none found.
  31566. */
  31567. setActiveCameraByID(id: string): Nullable<Camera>;
  31568. /**
  31569. * sets the active camera of the scene using its name
  31570. * @param name defines the camera's name
  31571. * @returns the new active camera or null if none found.
  31572. */
  31573. setActiveCameraByName(name: string): Nullable<Camera>;
  31574. /**
  31575. * get an animation group using its name
  31576. * @param name defines the material's name
  31577. * @return the animation group or null if none found.
  31578. */
  31579. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  31580. /**
  31581. * get a material using its id
  31582. * @param id defines the material's ID
  31583. * @return the material or null if none found.
  31584. */
  31585. getMaterialByID(id: string): Nullable<Material>;
  31586. /**
  31587. * Gets a material using its name
  31588. * @param name defines the material's name
  31589. * @return the material or null if none found.
  31590. */
  31591. getMaterialByName(name: string): Nullable<Material>;
  31592. /**
  31593. * Gets a camera using its id
  31594. * @param id defines the id to look for
  31595. * @returns the camera or null if not found
  31596. */
  31597. getCameraByID(id: string): Nullable<Camera>;
  31598. /**
  31599. * Gets a camera using its unique id
  31600. * @param uniqueId defines the unique id to look for
  31601. * @returns the camera or null if not found
  31602. */
  31603. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  31604. /**
  31605. * Gets a camera using its name
  31606. * @param name defines the camera's name
  31607. * @return the camera or null if none found.
  31608. */
  31609. getCameraByName(name: string): Nullable<Camera>;
  31610. /**
  31611. * Gets a bone using its id
  31612. * @param id defines the bone's id
  31613. * @return the bone or null if not found
  31614. */
  31615. getBoneByID(id: string): Nullable<Bone>;
  31616. /**
  31617. * Gets a bone using its id
  31618. * @param name defines the bone's name
  31619. * @return the bone or null if not found
  31620. */
  31621. getBoneByName(name: string): Nullable<Bone>;
  31622. /**
  31623. * Gets a light node using its name
  31624. * @param name defines the the light's name
  31625. * @return the light or null if none found.
  31626. */
  31627. getLightByName(name: string): Nullable<Light>;
  31628. /**
  31629. * Gets a light node using its id
  31630. * @param id defines the light's id
  31631. * @return the light or null if none found.
  31632. */
  31633. getLightByID(id: string): Nullable<Light>;
  31634. /**
  31635. * Gets a light node using its scene-generated unique ID
  31636. * @param uniqueId defines the light's unique id
  31637. * @return the light or null if none found.
  31638. */
  31639. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  31640. /**
  31641. * Gets a particle system by id
  31642. * @param id defines the particle system id
  31643. * @return the corresponding system or null if none found
  31644. */
  31645. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  31646. /**
  31647. * Gets a geometry using its ID
  31648. * @param id defines the geometry's id
  31649. * @return the geometry or null if none found.
  31650. */
  31651. getGeometryByID(id: string): Nullable<Geometry>;
  31652. private _getGeometryByUniqueID;
  31653. /**
  31654. * Add a new geometry to this scene
  31655. * @param geometry defines the geometry to be added to the scene.
  31656. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  31657. * @return a boolean defining if the geometry was added or not
  31658. */
  31659. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  31660. /**
  31661. * Removes an existing geometry
  31662. * @param geometry defines the geometry to be removed from the scene
  31663. * @return a boolean defining if the geometry was removed or not
  31664. */
  31665. removeGeometry(geometry: Geometry): boolean;
  31666. /**
  31667. * Gets the list of geometries attached to the scene
  31668. * @returns an array of Geometry
  31669. */
  31670. getGeometries(): Geometry[];
  31671. /**
  31672. * Gets the first added mesh found of a given ID
  31673. * @param id defines the id to search for
  31674. * @return the mesh found or null if not found at all
  31675. */
  31676. getMeshByID(id: string): Nullable<AbstractMesh>;
  31677. /**
  31678. * Gets a list of meshes using their id
  31679. * @param id defines the id to search for
  31680. * @returns a list of meshes
  31681. */
  31682. getMeshesByID(id: string): Array<AbstractMesh>;
  31683. /**
  31684. * Gets the first added transform node found of a given ID
  31685. * @param id defines the id to search for
  31686. * @return the found transform node or null if not found at all.
  31687. */
  31688. getTransformNodeByID(id: string): Nullable<TransformNode>;
  31689. /**
  31690. * Gets a list of transform nodes using their id
  31691. * @param id defines the id to search for
  31692. * @returns a list of transform nodes
  31693. */
  31694. getTransformNodesByID(id: string): Array<TransformNode>;
  31695. /**
  31696. * Gets a mesh with its auto-generated unique id
  31697. * @param uniqueId defines the unique id to search for
  31698. * @return the found mesh or null if not found at all.
  31699. */
  31700. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  31701. /**
  31702. * Gets a the last added mesh using a given id
  31703. * @param id defines the id to search for
  31704. * @return the found mesh or null if not found at all.
  31705. */
  31706. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  31707. /**
  31708. * Gets a the last added node (Mesh, Camera, Light) using a given id
  31709. * @param id defines the id to search for
  31710. * @return the found node or null if not found at all
  31711. */
  31712. getLastEntryByID(id: string): Nullable<Node>;
  31713. /**
  31714. * Gets a node (Mesh, Camera, Light) using a given id
  31715. * @param id defines the id to search for
  31716. * @return the found node or null if not found at all
  31717. */
  31718. getNodeByID(id: string): Nullable<Node>;
  31719. /**
  31720. * Gets a node (Mesh, Camera, Light) using a given name
  31721. * @param name defines the name to search for
  31722. * @return the found node or null if not found at all.
  31723. */
  31724. getNodeByName(name: string): Nullable<Node>;
  31725. /**
  31726. * Gets a mesh using a given name
  31727. * @param name defines the name to search for
  31728. * @return the found mesh or null if not found at all.
  31729. */
  31730. getMeshByName(name: string): Nullable<AbstractMesh>;
  31731. /**
  31732. * Gets a transform node using a given name
  31733. * @param name defines the name to search for
  31734. * @return the found transform node or null if not found at all.
  31735. */
  31736. getTransformNodeByName(name: string): Nullable<TransformNode>;
  31737. /**
  31738. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  31739. * @param id defines the id to search for
  31740. * @return the found skeleton or null if not found at all.
  31741. */
  31742. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  31743. /**
  31744. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  31745. * @param id defines the id to search for
  31746. * @return the found skeleton or null if not found at all.
  31747. */
  31748. getSkeletonById(id: string): Nullable<Skeleton>;
  31749. /**
  31750. * Gets a skeleton using a given name
  31751. * @param name defines the name to search for
  31752. * @return the found skeleton or null if not found at all.
  31753. */
  31754. getSkeletonByName(name: string): Nullable<Skeleton>;
  31755. /**
  31756. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  31757. * @param id defines the id to search for
  31758. * @return the found morph target manager or null if not found at all.
  31759. */
  31760. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  31761. /**
  31762. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  31763. * @param id defines the id to search for
  31764. * @return the found morph target or null if not found at all.
  31765. */
  31766. getMorphTargetById(id: string): Nullable<MorphTarget>;
  31767. /**
  31768. * Gets a boolean indicating if the given mesh is active
  31769. * @param mesh defines the mesh to look for
  31770. * @returns true if the mesh is in the active list
  31771. */
  31772. isActiveMesh(mesh: AbstractMesh): boolean;
  31773. /**
  31774. * Return a unique id as a string which can serve as an identifier for the scene
  31775. */
  31776. readonly uid: string;
  31777. /**
  31778. * Add an externaly attached data from its key.
  31779. * This method call will fail and return false, if such key already exists.
  31780. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  31781. * @param key the unique key that identifies the data
  31782. * @param data the data object to associate to the key for this Engine instance
  31783. * @return true if no such key were already present and the data was added successfully, false otherwise
  31784. */
  31785. addExternalData<T>(key: string, data: T): boolean;
  31786. /**
  31787. * Get an externaly attached data from its key
  31788. * @param key the unique key that identifies the data
  31789. * @return the associated data, if present (can be null), or undefined if not present
  31790. */
  31791. getExternalData<T>(key: string): Nullable<T>;
  31792. /**
  31793. * Get an externaly attached data from its key, create it using a factory if it's not already present
  31794. * @param key the unique key that identifies the data
  31795. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  31796. * @return the associated data, can be null if the factory returned null.
  31797. */
  31798. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  31799. /**
  31800. * Remove an externaly attached data from the Engine instance
  31801. * @param key the unique key that identifies the data
  31802. * @return true if the data was successfully removed, false if it doesn't exist
  31803. */
  31804. removeExternalData(key: string): boolean;
  31805. private _evaluateSubMesh;
  31806. /**
  31807. * Clear the processed materials smart array preventing retention point in material dispose.
  31808. */
  31809. freeProcessedMaterials(): void;
  31810. private _preventFreeActiveMeshesAndRenderingGroups;
  31811. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  31812. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  31813. * when disposing several meshes in a row or a hierarchy of meshes.
  31814. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  31815. */
  31816. blockfreeActiveMeshesAndRenderingGroups: boolean;
  31817. /**
  31818. * Clear the active meshes smart array preventing retention point in mesh dispose.
  31819. */
  31820. freeActiveMeshes(): void;
  31821. /**
  31822. * Clear the info related to rendering groups preventing retention points during dispose.
  31823. */
  31824. freeRenderingGroups(): void;
  31825. /** @hidden */ isInIntermediateRendering(): boolean;
  31826. /**
  31827. * Lambda returning the list of potentially active meshes.
  31828. */
  31829. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  31830. /**
  31831. * Lambda returning the list of potentially active sub meshes.
  31832. */
  31833. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  31834. /**
  31835. * Lambda returning the list of potentially intersecting sub meshes.
  31836. */
  31837. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  31838. /**
  31839. * Lambda returning the list of potentially colliding sub meshes.
  31840. */
  31841. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  31842. private _activeMeshesFrozen;
  31843. /**
  31844. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  31845. * @returns the current scene
  31846. */
  31847. freezeActiveMeshes(): Scene;
  31848. /**
  31849. * Use this function to restart evaluating active meshes on every frame
  31850. * @returns the current scene
  31851. */
  31852. unfreezeActiveMeshes(): Scene;
  31853. private _evaluateActiveMeshes;
  31854. private _activeMesh;
  31855. /**
  31856. * Update the transform matrix to update from the current active camera
  31857. * @param force defines a boolean used to force the update even if cache is up to date
  31858. */
  31859. updateTransformMatrix(force?: boolean): void;
  31860. /**
  31861. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  31862. * @param alternateCamera defines the camera to use
  31863. */
  31864. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  31865. /** @hidden */ allowPostProcessClearColor: boolean;
  31866. private _renderForCamera;
  31867. private _processSubCameras;
  31868. private _checkIntersections;
  31869. /** @hidden */ advancePhysicsEngineStep(step: number): void;
  31870. /**
  31871. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  31872. */
  31873. getDeterministicFrameTime: () => number;
  31874. /** @hidden */ animate(): void;
  31875. /**
  31876. * Render the scene
  31877. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  31878. */
  31879. render(updateCameras?: boolean): void;
  31880. /**
  31881. * Freeze all materials
  31882. * A frozen material will not be updatable but should be faster to render
  31883. */
  31884. freezeMaterials(): void;
  31885. /**
  31886. * Unfreeze all materials
  31887. * A frozen material will not be updatable but should be faster to render
  31888. */
  31889. unfreezeMaterials(): void;
  31890. /**
  31891. * Releases all held ressources
  31892. */
  31893. dispose(): void;
  31894. /**
  31895. * Gets if the scene is already disposed
  31896. */
  31897. readonly isDisposed: boolean;
  31898. /**
  31899. * Call this function to reduce memory footprint of the scene.
  31900. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  31901. */
  31902. clearCachedVertexData(): void;
  31903. /**
  31904. * This function will remove the local cached buffer data from texture.
  31905. * It will save memory but will prevent the texture from being rebuilt
  31906. */
  31907. cleanCachedTextureBuffer(): void;
  31908. /**
  31909. * Get the world extend vectors with an optional filter
  31910. *
  31911. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  31912. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  31913. */
  31914. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  31915. min: Vector3;
  31916. max: Vector3;
  31917. };
  31918. /**
  31919. * Creates a ray that can be used to pick in the scene
  31920. * @param x defines the x coordinate of the origin (on-screen)
  31921. * @param y defines the y coordinate of the origin (on-screen)
  31922. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  31923. * @param camera defines the camera to use for the picking
  31924. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  31925. * @returns a Ray
  31926. */
  31927. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  31928. /**
  31929. * Creates a ray that can be used to pick in the scene
  31930. * @param x defines the x coordinate of the origin (on-screen)
  31931. * @param y defines the y coordinate of the origin (on-screen)
  31932. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  31933. * @param result defines the ray where to store the picking ray
  31934. * @param camera defines the camera to use for the picking
  31935. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  31936. * @returns the current scene
  31937. */
  31938. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  31939. /**
  31940. * Creates a ray that can be used to pick in the scene
  31941. * @param x defines the x coordinate of the origin (on-screen)
  31942. * @param y defines the y coordinate of the origin (on-screen)
  31943. * @param camera defines the camera to use for the picking
  31944. * @returns a Ray
  31945. */
  31946. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  31947. /**
  31948. * Creates a ray that can be used to pick in the scene
  31949. * @param x defines the x coordinate of the origin (on-screen)
  31950. * @param y defines the y coordinate of the origin (on-screen)
  31951. * @param result defines the ray where to store the picking ray
  31952. * @param camera defines the camera to use for the picking
  31953. * @returns the current scene
  31954. */
  31955. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  31956. /** Launch a ray to try to pick a mesh in the scene
  31957. * @param x position on screen
  31958. * @param y position on screen
  31959. * @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
  31960. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  31961. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  31962. * @returns a PickingInfo
  31963. */
  31964. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  31965. /** Use the given ray to pick a mesh in the scene
  31966. * @param ray The ray to use to pick meshes
  31967. * @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
  31968. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  31969. * @returns a PickingInfo
  31970. */
  31971. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  31972. /**
  31973. * Launch a ray to try to pick a mesh in the scene
  31974. * @param x X position on screen
  31975. * @param y Y position on screen
  31976. * @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
  31977. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  31978. * @returns an array of PickingInfo
  31979. */
  31980. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  31981. /**
  31982. * Launch a ray to try to pick a mesh in the scene
  31983. * @param ray Ray to use
  31984. * @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
  31985. * @returns an array of PickingInfo
  31986. */
  31987. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  31988. /**
  31989. * Force the value of meshUnderPointer
  31990. * @param mesh defines the mesh to use
  31991. */
  31992. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  31993. /**
  31994. * Gets the mesh under the pointer
  31995. * @returns a Mesh or null if no mesh is under the pointer
  31996. */
  31997. getPointerOverMesh(): Nullable<AbstractMesh>;
  31998. /** @hidden */ rebuildGeometries(): void;
  31999. /** @hidden */ rebuildTextures(): void;
  32000. private _getByTags;
  32001. /**
  32002. * Get a list of meshes by tags
  32003. * @param tagsQuery defines the tags query to use
  32004. * @param forEach defines a predicate used to filter results
  32005. * @returns an array of Mesh
  32006. */
  32007. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  32008. /**
  32009. * Get a list of cameras by tags
  32010. * @param tagsQuery defines the tags query to use
  32011. * @param forEach defines a predicate used to filter results
  32012. * @returns an array of Camera
  32013. */
  32014. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  32015. /**
  32016. * Get a list of lights by tags
  32017. * @param tagsQuery defines the tags query to use
  32018. * @param forEach defines a predicate used to filter results
  32019. * @returns an array of Light
  32020. */
  32021. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  32022. /**
  32023. * Get a list of materials by tags
  32024. * @param tagsQuery defines the tags query to use
  32025. * @param forEach defines a predicate used to filter results
  32026. * @returns an array of Material
  32027. */
  32028. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  32029. /**
  32030. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  32031. * This allowed control for front to back rendering or reversly depending of the special needs.
  32032. *
  32033. * @param renderingGroupId The rendering group id corresponding to its index
  32034. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  32035. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  32036. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  32037. */
  32038. 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;
  32039. /**
  32040. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  32041. *
  32042. * @param renderingGroupId The rendering group id corresponding to its index
  32043. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  32044. * @param depth Automatically clears depth between groups if true and autoClear is true.
  32045. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  32046. */
  32047. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  32048. /**
  32049. * Gets the current auto clear configuration for one rendering group of the rendering
  32050. * manager.
  32051. * @param index the rendering group index to get the information for
  32052. * @returns The auto clear setup for the requested rendering group
  32053. */
  32054. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  32055. private _blockMaterialDirtyMechanism;
  32056. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  32057. blockMaterialDirtyMechanism: boolean;
  32058. /**
  32059. * Will flag all materials as dirty to trigger new shader compilation
  32060. * @param flag defines the flag used to specify which material part must be marked as dirty
  32061. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  32062. */
  32063. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32064. /** @hidden */ loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  32065. /** @hidden */ loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32066. }
  32067. }
  32068. declare module BABYLON {
  32069. /**
  32070. * Set of assets to keep when moving a scene into an asset container.
  32071. */
  32072. export class KeepAssets extends AbstractScene {
  32073. }
  32074. /**
  32075. * Container with a set of assets that can be added or removed from a scene.
  32076. */
  32077. export class AssetContainer extends AbstractScene {
  32078. /**
  32079. * The scene the AssetContainer belongs to.
  32080. */
  32081. scene: Scene;
  32082. /**
  32083. * Instantiates an AssetContainer.
  32084. * @param scene The scene the AssetContainer belongs to.
  32085. */
  32086. constructor(scene: Scene);
  32087. /**
  32088. * Adds all the assets from the container to the scene.
  32089. */
  32090. addAllToScene(): void;
  32091. /**
  32092. * Removes all the assets in the container from the scene
  32093. */
  32094. removeAllFromScene(): void;
  32095. /**
  32096. * Disposes all the assets in the container
  32097. */
  32098. dispose(): void;
  32099. private _moveAssets;
  32100. /**
  32101. * Removes all the assets contained in the scene and adds them to the container.
  32102. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  32103. */
  32104. moveAllFromScene(keepAssets?: KeepAssets): void;
  32105. /**
  32106. * 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.
  32107. * @returns the root mesh
  32108. */
  32109. createRootMesh(): Mesh;
  32110. }
  32111. }
  32112. declare module BABYLON {
  32113. /**
  32114. * Defines how the parser contract is defined.
  32115. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  32116. */
  32117. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  32118. /**
  32119. * Defines how the individual parser contract is defined.
  32120. * These parser can parse an individual asset
  32121. */
  32122. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  32123. /**
  32124. * Base class of the scene acting as a container for the different elements composing a scene.
  32125. * This class is dynamically extended by the different components of the scene increasing
  32126. * flexibility and reducing coupling
  32127. */
  32128. export abstract class AbstractScene {
  32129. /**
  32130. * Stores the list of available parsers in the application.
  32131. */
  32132. private static _BabylonFileParsers;
  32133. /**
  32134. * Stores the list of available individual parsers in the application.
  32135. */
  32136. private static _IndividualBabylonFileParsers;
  32137. /**
  32138. * Adds a parser in the list of available ones
  32139. * @param name Defines the name of the parser
  32140. * @param parser Defines the parser to add
  32141. */
  32142. static AddParser(name: string, parser: BabylonFileParser): void;
  32143. /**
  32144. * Gets a general parser from the list of avaialble ones
  32145. * @param name Defines the name of the parser
  32146. * @returns the requested parser or null
  32147. */
  32148. static GetParser(name: string): Nullable<BabylonFileParser>;
  32149. /**
  32150. * Adds n individual parser in the list of available ones
  32151. * @param name Defines the name of the parser
  32152. * @param parser Defines the parser to add
  32153. */
  32154. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  32155. /**
  32156. * Gets an individual parser from the list of avaialble ones
  32157. * @param name Defines the name of the parser
  32158. * @returns the requested parser or null
  32159. */
  32160. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  32161. /**
  32162. * Parser json data and populate both a scene and its associated container object
  32163. * @param jsonData Defines the data to parse
  32164. * @param scene Defines the scene to parse the data for
  32165. * @param container Defines the container attached to the parsing sequence
  32166. * @param rootUrl Defines the root url of the data
  32167. */
  32168. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  32169. /**
  32170. * Gets the list of root nodes (ie. nodes with no parent)
  32171. */
  32172. rootNodes: Node[];
  32173. /** All of the cameras added to this scene
  32174. * @see http://doc.babylonjs.com/babylon101/cameras
  32175. */
  32176. cameras: Camera[];
  32177. /**
  32178. * All of the lights added to this scene
  32179. * @see http://doc.babylonjs.com/babylon101/lights
  32180. */
  32181. lights: Light[];
  32182. /**
  32183. * All of the (abstract) meshes added to this scene
  32184. */
  32185. meshes: AbstractMesh[];
  32186. /**
  32187. * The list of skeletons added to the scene
  32188. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32189. */
  32190. skeletons: Skeleton[];
  32191. /**
  32192. * All of the particle systems added to this scene
  32193. * @see http://doc.babylonjs.com/babylon101/particles
  32194. */
  32195. particleSystems: IParticleSystem[];
  32196. /**
  32197. * Gets a list of Animations associated with the scene
  32198. */
  32199. animations: Animation[];
  32200. /**
  32201. * All of the animation groups added to this scene
  32202. * @see http://doc.babylonjs.com/how_to/group
  32203. */
  32204. animationGroups: AnimationGroup[];
  32205. /**
  32206. * All of the multi-materials added to this scene
  32207. * @see http://doc.babylonjs.com/how_to/multi_materials
  32208. */
  32209. multiMaterials: MultiMaterial[];
  32210. /**
  32211. * All of the materials added to this scene
  32212. * In the context of a Scene, it is not supposed to be modified manually.
  32213. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  32214. * Note also that the order of the Material wihin the array is not significant and might change.
  32215. * @see http://doc.babylonjs.com/babylon101/materials
  32216. */
  32217. materials: Material[];
  32218. /**
  32219. * The list of morph target managers added to the scene
  32220. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  32221. */
  32222. morphTargetManagers: MorphTargetManager[];
  32223. /**
  32224. * The list of geometries used in the scene.
  32225. */
  32226. geometries: Geometry[];
  32227. /**
  32228. * All of the tranform nodes added to this scene
  32229. * In the context of a Scene, it is not supposed to be modified manually.
  32230. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  32231. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  32232. * @see http://doc.babylonjs.com/how_to/transformnode
  32233. */
  32234. transformNodes: TransformNode[];
  32235. /**
  32236. * ActionManagers available on the scene.
  32237. */
  32238. actionManagers: AbstractActionManager[];
  32239. /**
  32240. * Textures to keep.
  32241. */
  32242. textures: BaseTexture[];
  32243. }
  32244. }
  32245. declare module BABYLON {
  32246. /**
  32247. * Defines a sound that can be played in the application.
  32248. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  32249. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32250. */
  32251. export class Sound {
  32252. /**
  32253. * The name of the sound in the scene.
  32254. */
  32255. name: string;
  32256. /**
  32257. * Does the sound autoplay once loaded.
  32258. */
  32259. autoplay: boolean;
  32260. /**
  32261. * Does the sound loop after it finishes playing once.
  32262. */
  32263. loop: boolean;
  32264. /**
  32265. * Does the sound use a custom attenuation curve to simulate the falloff
  32266. * happening when the source gets further away from the camera.
  32267. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  32268. */
  32269. useCustomAttenuation: boolean;
  32270. /**
  32271. * The sound track id this sound belongs to.
  32272. */
  32273. soundTrackId: number;
  32274. /**
  32275. * Is this sound currently played.
  32276. */
  32277. isPlaying: boolean;
  32278. /**
  32279. * Is this sound currently paused.
  32280. */
  32281. isPaused: boolean;
  32282. /**
  32283. * Does this sound enables spatial sound.
  32284. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32285. */
  32286. spatialSound: boolean;
  32287. /**
  32288. * Define the reference distance the sound should be heard perfectly.
  32289. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32290. */
  32291. refDistance: number;
  32292. /**
  32293. * Define the roll off factor of spatial sounds.
  32294. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32295. */
  32296. rolloffFactor: number;
  32297. /**
  32298. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  32299. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32300. */
  32301. maxDistance: number;
  32302. /**
  32303. * Define the distance attenuation model the sound will follow.
  32304. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32305. */
  32306. distanceModel: string;
  32307. /**
  32308. * @hidden
  32309. * Back Compat
  32310. **/
  32311. onended: () => any;
  32312. /**
  32313. * Observable event when the current playing sound finishes.
  32314. */
  32315. onEndedObservable: Observable<Sound>;
  32316. private _panningModel;
  32317. private _playbackRate;
  32318. private _streaming;
  32319. private _startTime;
  32320. private _startOffset;
  32321. private _position;
  32322. /** @hidden */ positionInEmitterSpace: boolean;
  32323. private _localDirection;
  32324. private _volume;
  32325. private _isReadyToPlay;
  32326. private _isDirectional;
  32327. private _readyToPlayCallback;
  32328. private _audioBuffer;
  32329. private _soundSource;
  32330. private _streamingSource;
  32331. private _soundPanner;
  32332. private _soundGain;
  32333. private _inputAudioNode;
  32334. private _outputAudioNode;
  32335. private _coneInnerAngle;
  32336. private _coneOuterAngle;
  32337. private _coneOuterGain;
  32338. private _scene;
  32339. private _connectedTransformNode;
  32340. private _customAttenuationFunction;
  32341. private _registerFunc;
  32342. private _isOutputConnected;
  32343. private _htmlAudioElement;
  32344. private _urlType;
  32345. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  32346. /**
  32347. * Create a sound and attach it to a scene
  32348. * @param name Name of your sound
  32349. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  32350. * @param scene defines the scene the sound belongs to
  32351. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  32352. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  32353. */
  32354. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  32355. /**
  32356. * Release the sound and its associated resources
  32357. */
  32358. dispose(): void;
  32359. /**
  32360. * Gets if the sounds is ready to be played or not.
  32361. * @returns true if ready, otherwise false
  32362. */
  32363. isReady(): boolean;
  32364. private _soundLoaded;
  32365. /**
  32366. * Sets the data of the sound from an audiobuffer
  32367. * @param audioBuffer The audioBuffer containing the data
  32368. */
  32369. setAudioBuffer(audioBuffer: AudioBuffer): void;
  32370. /**
  32371. * Updates the current sounds options such as maxdistance, loop...
  32372. * @param options A JSON object containing values named as the object properties
  32373. */
  32374. updateOptions(options: any): void;
  32375. private _createSpatialParameters;
  32376. private _updateSpatialParameters;
  32377. /**
  32378. * Switch the panning model to HRTF:
  32379. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  32380. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32381. */
  32382. switchPanningModelToHRTF(): void;
  32383. /**
  32384. * Switch the panning model to Equal Power:
  32385. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  32386. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32387. */
  32388. switchPanningModelToEqualPower(): void;
  32389. private _switchPanningModel;
  32390. /**
  32391. * Connect this sound to a sound track audio node like gain...
  32392. * @param soundTrackAudioNode the sound track audio node to connect to
  32393. */
  32394. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  32395. /**
  32396. * Transform this sound into a directional source
  32397. * @param coneInnerAngle Size of the inner cone in degree
  32398. * @param coneOuterAngle Size of the outer cone in degree
  32399. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  32400. */
  32401. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  32402. /**
  32403. * Gets or sets the inner angle for the directional cone.
  32404. */
  32405. /**
  32406. * Gets or sets the inner angle for the directional cone.
  32407. */
  32408. directionalConeInnerAngle: number;
  32409. /**
  32410. * Gets or sets the outer angle for the directional cone.
  32411. */
  32412. /**
  32413. * Gets or sets the outer angle for the directional cone.
  32414. */
  32415. directionalConeOuterAngle: number;
  32416. /**
  32417. * Sets the position of the emitter if spatial sound is enabled
  32418. * @param newPosition Defines the new posisiton
  32419. */
  32420. setPosition(newPosition: Vector3): void;
  32421. /**
  32422. * Sets the local direction of the emitter if spatial sound is enabled
  32423. * @param newLocalDirection Defines the new local direction
  32424. */
  32425. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  32426. private _updateDirection;
  32427. /** @hidden */
  32428. updateDistanceFromListener(): void;
  32429. /**
  32430. * Sets a new custom attenuation function for the sound.
  32431. * @param callback Defines the function used for the attenuation
  32432. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  32433. */
  32434. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  32435. /**
  32436. * Play the sound
  32437. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  32438. * @param offset (optional) Start the sound setting it at a specific time
  32439. */
  32440. play(time?: number, offset?: number): void;
  32441. private _onended;
  32442. /**
  32443. * Stop the sound
  32444. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  32445. */
  32446. stop(time?: number): void;
  32447. /**
  32448. * Put the sound in pause
  32449. */
  32450. pause(): void;
  32451. /**
  32452. * Sets a dedicated volume for this sounds
  32453. * @param newVolume Define the new volume of the sound
  32454. * @param time Define in how long the sound should be at this value
  32455. */
  32456. setVolume(newVolume: number, time?: number): void;
  32457. /**
  32458. * Set the sound play back rate
  32459. * @param newPlaybackRate Define the playback rate the sound should be played at
  32460. */
  32461. setPlaybackRate(newPlaybackRate: number): void;
  32462. /**
  32463. * Gets the volume of the sound.
  32464. * @returns the volume of the sound
  32465. */
  32466. getVolume(): number;
  32467. /**
  32468. * Attach the sound to a dedicated mesh
  32469. * @param transformNode The transform node to connect the sound with
  32470. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  32471. */
  32472. attachToMesh(transformNode: TransformNode): void;
  32473. /**
  32474. * Detach the sound from the previously attached mesh
  32475. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  32476. */
  32477. detachFromMesh(): void;
  32478. private _onRegisterAfterWorldMatrixUpdate;
  32479. /**
  32480. * Clone the current sound in the scene.
  32481. * @returns the new sound clone
  32482. */
  32483. clone(): Nullable<Sound>;
  32484. /**
  32485. * Gets the current underlying audio buffer containing the data
  32486. * @returns the audio buffer
  32487. */
  32488. getAudioBuffer(): Nullable<AudioBuffer>;
  32489. /**
  32490. * Serializes the Sound in a JSON representation
  32491. * @returns the JSON representation of the sound
  32492. */
  32493. serialize(): any;
  32494. /**
  32495. * Parse a JSON representation of a sound to innstantiate in a given scene
  32496. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  32497. * @param scene Define the scene the new parsed sound should be created in
  32498. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  32499. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  32500. * @returns the newly parsed sound
  32501. */
  32502. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  32503. }
  32504. }
  32505. declare module BABYLON {
  32506. /**
  32507. * This defines an action helpful to play a defined sound on a triggered action.
  32508. */
  32509. export class PlaySoundAction extends Action {
  32510. private _sound;
  32511. /**
  32512. * Instantiate the action
  32513. * @param triggerOptions defines the trigger options
  32514. * @param sound defines the sound to play
  32515. * @param condition defines the trigger related conditions
  32516. */
  32517. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  32518. /** @hidden */ prepare(): void;
  32519. /**
  32520. * Execute the action and play the sound.
  32521. */
  32522. execute(): void;
  32523. /**
  32524. * Serializes the actions and its related information.
  32525. * @param parent defines the object to serialize in
  32526. * @returns the serialized object
  32527. */
  32528. serialize(parent: any): any;
  32529. }
  32530. /**
  32531. * This defines an action helpful to stop a defined sound on a triggered action.
  32532. */
  32533. export class StopSoundAction extends Action {
  32534. private _sound;
  32535. /**
  32536. * Instantiate the action
  32537. * @param triggerOptions defines the trigger options
  32538. * @param sound defines the sound to stop
  32539. * @param condition defines the trigger related conditions
  32540. */
  32541. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  32542. /** @hidden */ prepare(): void;
  32543. /**
  32544. * Execute the action and stop the sound.
  32545. */
  32546. execute(): void;
  32547. /**
  32548. * Serializes the actions and its related information.
  32549. * @param parent defines the object to serialize in
  32550. * @returns the serialized object
  32551. */
  32552. serialize(parent: any): any;
  32553. }
  32554. }
  32555. declare module BABYLON {
  32556. /**
  32557. * This defines an action responsible to change the value of a property
  32558. * by interpolating between its current value and the newly set one once triggered.
  32559. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32560. */
  32561. export class InterpolateValueAction extends Action {
  32562. /**
  32563. * Defines the path of the property where the value should be interpolated
  32564. */
  32565. propertyPath: string;
  32566. /**
  32567. * Defines the target value at the end of the interpolation.
  32568. */
  32569. value: any;
  32570. /**
  32571. * Defines the time it will take for the property to interpolate to the value.
  32572. */
  32573. duration: number;
  32574. /**
  32575. * Defines if the other scene animations should be stopped when the action has been triggered
  32576. */
  32577. stopOtherAnimations?: boolean;
  32578. /**
  32579. * Defines a callback raised once the interpolation animation has been done.
  32580. */
  32581. onInterpolationDone?: () => void;
  32582. /**
  32583. * Observable triggered once the interpolation animation has been done.
  32584. */
  32585. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  32586. private _target;
  32587. private _effectiveTarget;
  32588. private _property;
  32589. /**
  32590. * Instantiate the action
  32591. * @param triggerOptions defines the trigger options
  32592. * @param target defines the object containing the value to interpolate
  32593. * @param propertyPath defines the path to the property in the target object
  32594. * @param value defines the target value at the end of the interpolation
  32595. * @param duration deines the time it will take for the property to interpolate to the value.
  32596. * @param condition defines the trigger related conditions
  32597. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  32598. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  32599. */
  32600. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  32601. /** @hidden */ prepare(): void;
  32602. /**
  32603. * Execute the action starts the value interpolation.
  32604. */
  32605. execute(): void;
  32606. /**
  32607. * Serializes the actions and its related information.
  32608. * @param parent defines the object to serialize in
  32609. * @returns the serialized object
  32610. */
  32611. serialize(parent: any): any;
  32612. }
  32613. }
  32614. declare module BABYLON {
  32615. /**
  32616. * Options allowed during the creation of a sound track.
  32617. */
  32618. export interface ISoundTrackOptions {
  32619. /**
  32620. * The volume the sound track should take during creation
  32621. */
  32622. volume?: number;
  32623. /**
  32624. * Define if the sound track is the main sound track of the scene
  32625. */
  32626. mainTrack?: boolean;
  32627. }
  32628. /**
  32629. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  32630. * It will be also used in a future release to apply effects on a specific track.
  32631. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  32632. */
  32633. export class SoundTrack {
  32634. /**
  32635. * The unique identifier of the sound track in the scene.
  32636. */
  32637. id: number;
  32638. /**
  32639. * The list of sounds included in the sound track.
  32640. */
  32641. soundCollection: Array<Sound>;
  32642. private _outputAudioNode;
  32643. private _scene;
  32644. private _isMainTrack;
  32645. private _connectedAnalyser;
  32646. private _options;
  32647. private _isInitialized;
  32648. /**
  32649. * Creates a new sound track.
  32650. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  32651. * @param scene Define the scene the sound track belongs to
  32652. * @param options
  32653. */
  32654. constructor(scene: Scene, options?: ISoundTrackOptions);
  32655. private _initializeSoundTrackAudioGraph;
  32656. /**
  32657. * Release the sound track and its associated resources
  32658. */
  32659. dispose(): void;
  32660. /**
  32661. * Adds a sound to this sound track
  32662. * @param sound define the cound to add
  32663. * @ignoreNaming
  32664. */
  32665. AddSound(sound: Sound): void;
  32666. /**
  32667. * Removes a sound to this sound track
  32668. * @param sound define the cound to remove
  32669. * @ignoreNaming
  32670. */
  32671. RemoveSound(sound: Sound): void;
  32672. /**
  32673. * Set a global volume for the full sound track.
  32674. * @param newVolume Define the new volume of the sound track
  32675. */
  32676. setVolume(newVolume: number): void;
  32677. /**
  32678. * Switch the panning model to HRTF:
  32679. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  32680. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32681. */
  32682. switchPanningModelToHRTF(): void;
  32683. /**
  32684. * Switch the panning model to Equal Power:
  32685. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  32686. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32687. */
  32688. switchPanningModelToEqualPower(): void;
  32689. /**
  32690. * Connect the sound track to an audio analyser allowing some amazing
  32691. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32692. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32693. * @param analyser The analyser to connect to the engine
  32694. */
  32695. connectToAnalyser(analyser: Analyser): void;
  32696. }
  32697. }
  32698. declare module BABYLON {
  32699. interface AbstractScene {
  32700. /**
  32701. * The list of sounds used in the scene.
  32702. */
  32703. sounds: Nullable<Array<Sound>>;
  32704. }
  32705. interface Scene {
  32706. /**
  32707. * @hidden
  32708. * Backing field
  32709. */ mainSoundTrack: SoundTrack;
  32710. /**
  32711. * The main sound track played by the scene.
  32712. * It cotains your primary collection of sounds.
  32713. */
  32714. mainSoundTrack: SoundTrack;
  32715. /**
  32716. * The list of sound tracks added to the scene
  32717. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32718. */
  32719. soundTracks: Nullable<Array<SoundTrack>>;
  32720. /**
  32721. * Gets a sound using a given name
  32722. * @param name defines the name to search for
  32723. * @return the found sound or null if not found at all.
  32724. */
  32725. getSoundByName(name: string): Nullable<Sound>;
  32726. /**
  32727. * Gets or sets if audio support is enabled
  32728. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32729. */
  32730. audioEnabled: boolean;
  32731. /**
  32732. * Gets or sets if audio will be output to headphones
  32733. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32734. */
  32735. headphone: boolean;
  32736. }
  32737. /**
  32738. * Defines the sound scene component responsible to manage any sounds
  32739. * in a given scene.
  32740. */
  32741. export class AudioSceneComponent implements ISceneSerializableComponent {
  32742. /**
  32743. * The component name helpfull to identify the component in the list of scene components.
  32744. */
  32745. readonly name: string;
  32746. /**
  32747. * The scene the component belongs to.
  32748. */
  32749. scene: Scene;
  32750. private _audioEnabled;
  32751. /**
  32752. * Gets whether audio is enabled or not.
  32753. * Please use related enable/disable method to switch state.
  32754. */
  32755. readonly audioEnabled: boolean;
  32756. private _headphone;
  32757. /**
  32758. * Gets whether audio is outputing to headphone or not.
  32759. * Please use the according Switch methods to change output.
  32760. */
  32761. readonly headphone: boolean;
  32762. /**
  32763. * Creates a new instance of the component for the given scene
  32764. * @param scene Defines the scene to register the component in
  32765. */
  32766. constructor(scene: Scene);
  32767. /**
  32768. * Registers the component in a given scene
  32769. */
  32770. register(): void;
  32771. /**
  32772. * Rebuilds the elements related to this component in case of
  32773. * context lost for instance.
  32774. */
  32775. rebuild(): void;
  32776. /**
  32777. * Serializes the component data to the specified json object
  32778. * @param serializationObject The object to serialize to
  32779. */
  32780. serialize(serializationObject: any): void;
  32781. /**
  32782. * Adds all the element from the container to the scene
  32783. * @param container the container holding the elements
  32784. */
  32785. addFromContainer(container: AbstractScene): void;
  32786. /**
  32787. * Removes all the elements in the container from the scene
  32788. * @param container contains the elements to remove
  32789. */
  32790. removeFromContainer(container: AbstractScene): void;
  32791. /**
  32792. * Disposes the component and the associated ressources.
  32793. */
  32794. dispose(): void;
  32795. /**
  32796. * Disables audio in the associated scene.
  32797. */
  32798. disableAudio(): void;
  32799. /**
  32800. * Enables audio in the associated scene.
  32801. */
  32802. enableAudio(): void;
  32803. /**
  32804. * Switch audio to headphone output.
  32805. */
  32806. switchAudioModeForHeadphones(): void;
  32807. /**
  32808. * Switch audio to normal speakers.
  32809. */
  32810. switchAudioModeForNormalSpeakers(): void;
  32811. private _afterRender;
  32812. }
  32813. }
  32814. declare module BABYLON {
  32815. /**
  32816. * Wraps one or more Sound objects and selects one with random weight for playback.
  32817. */
  32818. export class WeightedSound {
  32819. /** When true a Sound will be selected and played when the current playing Sound completes. */
  32820. loop: boolean;
  32821. private _coneInnerAngle;
  32822. private _coneOuterAngle;
  32823. private _volume;
  32824. /** A Sound is currently playing. */
  32825. isPlaying: boolean;
  32826. /** A Sound is currently paused. */
  32827. isPaused: boolean;
  32828. private _sounds;
  32829. private _weights;
  32830. private _currentIndex?;
  32831. /**
  32832. * Creates a new WeightedSound from the list of sounds given.
  32833. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  32834. * @param sounds Array of Sounds that will be selected from.
  32835. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  32836. */
  32837. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  32838. /**
  32839. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  32840. */
  32841. /**
  32842. * The size of cone in degress for a directional sound in which there will be no attenuation.
  32843. */
  32844. directionalConeInnerAngle: number;
  32845. /**
  32846. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  32847. * Listener angles between innerAngle and outerAngle will falloff linearly.
  32848. */
  32849. /**
  32850. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  32851. * Listener angles between innerAngle and outerAngle will falloff linearly.
  32852. */
  32853. directionalConeOuterAngle: number;
  32854. /**
  32855. * Playback volume.
  32856. */
  32857. /**
  32858. * Playback volume.
  32859. */
  32860. volume: number;
  32861. private _onended;
  32862. /**
  32863. * Suspend playback
  32864. */
  32865. pause(): void;
  32866. /**
  32867. * Stop playback
  32868. */
  32869. stop(): void;
  32870. /**
  32871. * Start playback.
  32872. * @param startOffset Position the clip head at a specific time in seconds.
  32873. */
  32874. play(startOffset?: number): void;
  32875. }
  32876. }
  32877. declare module BABYLON {
  32878. /**
  32879. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  32880. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  32881. */
  32882. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  32883. /**
  32884. * Gets the name of the behavior.
  32885. */
  32886. readonly name: string;
  32887. /**
  32888. * The easing function used by animations
  32889. */
  32890. static EasingFunction: BackEase;
  32891. /**
  32892. * The easing mode used by animations
  32893. */
  32894. static EasingMode: number;
  32895. /**
  32896. * The duration of the animation, in milliseconds
  32897. */
  32898. transitionDuration: number;
  32899. /**
  32900. * Length of the distance animated by the transition when lower radius is reached
  32901. */
  32902. lowerRadiusTransitionRange: number;
  32903. /**
  32904. * Length of the distance animated by the transition when upper radius is reached
  32905. */
  32906. upperRadiusTransitionRange: number;
  32907. private _autoTransitionRange;
  32908. /**
  32909. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  32910. */
  32911. /**
  32912. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  32913. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  32914. */
  32915. autoTransitionRange: boolean;
  32916. private _attachedCamera;
  32917. private _onAfterCheckInputsObserver;
  32918. private _onMeshTargetChangedObserver;
  32919. /**
  32920. * Initializes the behavior.
  32921. */
  32922. init(): void;
  32923. /**
  32924. * Attaches the behavior to its arc rotate camera.
  32925. * @param camera Defines the camera to attach the behavior to
  32926. */
  32927. attach(camera: ArcRotateCamera): void;
  32928. /**
  32929. * Detaches the behavior from its current arc rotate camera.
  32930. */
  32931. detach(): void;
  32932. private _radiusIsAnimating;
  32933. private _radiusBounceTransition;
  32934. private _animatables;
  32935. private _cachedWheelPrecision;
  32936. /**
  32937. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  32938. * @param radiusLimit The limit to check against.
  32939. * @return Bool to indicate if at limit.
  32940. */
  32941. private _isRadiusAtLimit;
  32942. /**
  32943. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  32944. * @param radiusDelta The delta by which to animate to. Can be negative.
  32945. */
  32946. private _applyBoundRadiusAnimation;
  32947. /**
  32948. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  32949. */
  32950. protected _clearAnimationLocks(): void;
  32951. /**
  32952. * Stops and removes all animations that have been applied to the camera
  32953. */
  32954. stopAllAnimations(): void;
  32955. }
  32956. }
  32957. declare module BABYLON {
  32958. /**
  32959. * 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.
  32960. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  32961. */
  32962. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  32963. /**
  32964. * Gets the name of the behavior.
  32965. */
  32966. readonly name: string;
  32967. private _mode;
  32968. private _radiusScale;
  32969. private _positionScale;
  32970. private _defaultElevation;
  32971. private _elevationReturnTime;
  32972. private _elevationReturnWaitTime;
  32973. private _zoomStopsAnimation;
  32974. private _framingTime;
  32975. /**
  32976. * The easing function used by animations
  32977. */
  32978. static EasingFunction: ExponentialEase;
  32979. /**
  32980. * The easing mode used by animations
  32981. */
  32982. static EasingMode: number;
  32983. /**
  32984. * Sets the current mode used by the behavior
  32985. */
  32986. /**
  32987. * Gets current mode used by the behavior.
  32988. */
  32989. mode: number;
  32990. /**
  32991. * Sets the scale applied to the radius (1 by default)
  32992. */
  32993. /**
  32994. * Gets the scale applied to the radius
  32995. */
  32996. radiusScale: number;
  32997. /**
  32998. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  32999. */
  33000. /**
  33001. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33002. */
  33003. positionScale: number;
  33004. /**
  33005. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33006. * behaviour is triggered, in radians.
  33007. */
  33008. /**
  33009. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33010. * behaviour is triggered, in radians.
  33011. */
  33012. defaultElevation: number;
  33013. /**
  33014. * Sets the time (in milliseconds) taken to return to the default beta position.
  33015. * Negative value indicates camera should not return to default.
  33016. */
  33017. /**
  33018. * Gets the time (in milliseconds) taken to return to the default beta position.
  33019. * Negative value indicates camera should not return to default.
  33020. */
  33021. elevationReturnTime: number;
  33022. /**
  33023. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  33024. */
  33025. /**
  33026. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  33027. */
  33028. elevationReturnWaitTime: number;
  33029. /**
  33030. * Sets the flag that indicates if user zooming should stop animation.
  33031. */
  33032. /**
  33033. * Gets the flag that indicates if user zooming should stop animation.
  33034. */
  33035. zoomStopsAnimation: boolean;
  33036. /**
  33037. * Sets the transition time when framing the mesh, in milliseconds
  33038. */
  33039. /**
  33040. * Gets the transition time when framing the mesh, in milliseconds
  33041. */
  33042. framingTime: number;
  33043. /**
  33044. * Define if the behavior should automatically change the configured
  33045. * camera limits and sensibilities.
  33046. */
  33047. autoCorrectCameraLimitsAndSensibility: boolean;
  33048. private _onPrePointerObservableObserver;
  33049. private _onAfterCheckInputsObserver;
  33050. private _onMeshTargetChangedObserver;
  33051. private _attachedCamera;
  33052. private _isPointerDown;
  33053. private _lastInteractionTime;
  33054. /**
  33055. * Initializes the behavior.
  33056. */
  33057. init(): void;
  33058. /**
  33059. * Attaches the behavior to its arc rotate camera.
  33060. * @param camera Defines the camera to attach the behavior to
  33061. */
  33062. attach(camera: ArcRotateCamera): void;
  33063. /**
  33064. * Detaches the behavior from its current arc rotate camera.
  33065. */
  33066. detach(): void;
  33067. private _animatables;
  33068. private _betaIsAnimating;
  33069. private _betaTransition;
  33070. private _radiusTransition;
  33071. private _vectorTransition;
  33072. /**
  33073. * Targets the given mesh and updates zoom level accordingly.
  33074. * @param mesh The mesh to target.
  33075. * @param radius Optional. If a cached radius position already exists, overrides default.
  33076. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33077. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33078. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33079. */
  33080. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33081. /**
  33082. * Targets the given mesh with its children and updates zoom level accordingly.
  33083. * @param mesh The mesh to target.
  33084. * @param radius Optional. If a cached radius position already exists, overrides default.
  33085. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33086. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33087. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33088. */
  33089. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33090. /**
  33091. * Targets the given meshes with their children and updates zoom level accordingly.
  33092. * @param meshes The mesh to target.
  33093. * @param radius Optional. If a cached radius position already exists, overrides default.
  33094. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33095. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33096. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33097. */
  33098. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33099. /**
  33100. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  33101. * @param minimumWorld Determines the smaller position of the bounding box extend
  33102. * @param maximumWorld Determines the bigger position of the bounding box extend
  33103. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33104. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33105. */
  33106. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33107. /**
  33108. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  33109. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  33110. * frustum width.
  33111. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  33112. * to fully enclose the mesh in the viewing frustum.
  33113. */
  33114. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  33115. /**
  33116. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  33117. * is automatically returned to its default position (expected to be above ground plane).
  33118. */
  33119. private _maintainCameraAboveGround;
  33120. /**
  33121. * Returns the frustum slope based on the canvas ratio and camera FOV
  33122. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  33123. */
  33124. private _getFrustumSlope;
  33125. /**
  33126. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  33127. */
  33128. private _clearAnimationLocks;
  33129. /**
  33130. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  33131. */
  33132. private _applyUserInteraction;
  33133. /**
  33134. * Stops and removes all animations that have been applied to the camera
  33135. */
  33136. stopAllAnimations(): void;
  33137. /**
  33138. * Gets a value indicating if the user is moving the camera
  33139. */
  33140. readonly isUserIsMoving: boolean;
  33141. /**
  33142. * The camera can move all the way towards the mesh.
  33143. */
  33144. static IgnoreBoundsSizeMode: number;
  33145. /**
  33146. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  33147. */
  33148. static FitFrustumSidesMode: number;
  33149. }
  33150. }
  33151. declare module BABYLON {
  33152. /**
  33153. * Manage the pointers inputs to control an arc rotate camera.
  33154. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  33155. */
  33156. export class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  33157. /**
  33158. * Defines the camera the input is attached to.
  33159. */
  33160. camera: ArcRotateCamera;
  33161. /**
  33162. * Defines the buttons associated with the input to handle camera move.
  33163. */
  33164. buttons: number[];
  33165. /**
  33166. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  33167. */
  33168. angularSensibilityX: number;
  33169. /**
  33170. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  33171. */
  33172. angularSensibilityY: number;
  33173. /**
  33174. * Defines the pointer pinch precision or how fast is the camera zooming.
  33175. */
  33176. pinchPrecision: number;
  33177. /**
  33178. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  33179. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  33180. */
  33181. pinchDeltaPercentage: number;
  33182. /**
  33183. * Defines the pointer panning sensibility or how fast is the camera moving.
  33184. */
  33185. panningSensibility: number;
  33186. /**
  33187. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  33188. */
  33189. multiTouchPanning: boolean;
  33190. /**
  33191. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  33192. */
  33193. multiTouchPanAndZoom: boolean;
  33194. /**
  33195. * Revers pinch action direction.
  33196. */
  33197. pinchInwards: boolean;
  33198. private _isPanClick;
  33199. private _pointerInput;
  33200. private _observer;
  33201. private _onMouseMove;
  33202. private _onGestureStart;
  33203. private _onGesture;
  33204. private _MSGestureHandler;
  33205. private _onLostFocus;
  33206. private _onContextMenu;
  33207. /**
  33208. * Attach the input controls to a specific dom element to get the input from.
  33209. * @param element Defines the element the controls should be listened from
  33210. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  33211. */
  33212. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33213. /**
  33214. * Detach the current controls from the specified dom element.
  33215. * @param element Defines the element to stop listening the inputs from
  33216. */
  33217. detachControl(element: Nullable<HTMLElement>): void;
  33218. /**
  33219. * Gets the class name of the current intput.
  33220. * @returns the class name
  33221. */
  33222. getClassName(): string;
  33223. /**
  33224. * Get the friendly name associated with the input class.
  33225. * @returns the input friendly name
  33226. */
  33227. getSimpleName(): string;
  33228. }
  33229. }
  33230. declare module BABYLON {
  33231. /**
  33232. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  33233. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  33234. */
  33235. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  33236. /**
  33237. * Defines the camera the input is attached to.
  33238. */
  33239. camera: ArcRotateCamera;
  33240. /**
  33241. * Defines the list of key codes associated with the up action (increase alpha)
  33242. */
  33243. keysUp: number[];
  33244. /**
  33245. * Defines the list of key codes associated with the down action (decrease alpha)
  33246. */
  33247. keysDown: number[];
  33248. /**
  33249. * Defines the list of key codes associated with the left action (increase beta)
  33250. */
  33251. keysLeft: number[];
  33252. /**
  33253. * Defines the list of key codes associated with the right action (decrease beta)
  33254. */
  33255. keysRight: number[];
  33256. /**
  33257. * Defines the list of key codes associated with the reset action.
  33258. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  33259. */
  33260. keysReset: number[];
  33261. /**
  33262. * Defines the panning sensibility of the inputs.
  33263. * (How fast is the camera paning)
  33264. */
  33265. panningSensibility: number;
  33266. /**
  33267. * Defines the zooming sensibility of the inputs.
  33268. * (How fast is the camera zooming)
  33269. */
  33270. zoomingSensibility: number;
  33271. /**
  33272. * Defines wether maintaining the alt key down switch the movement mode from
  33273. * orientation to zoom.
  33274. */
  33275. useAltToZoom: boolean;
  33276. /**
  33277. * Rotation speed of the camera
  33278. */
  33279. angularSpeed: number;
  33280. private _keys;
  33281. private _ctrlPressed;
  33282. private _altPressed;
  33283. private _onCanvasBlurObserver;
  33284. private _onKeyboardObserver;
  33285. private _engine;
  33286. private _scene;
  33287. /**
  33288. * Attach the input controls to a specific dom element to get the input from.
  33289. * @param element Defines the element the controls should be listened from
  33290. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  33291. */
  33292. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33293. /**
  33294. * Detach the current controls from the specified dom element.
  33295. * @param element Defines the element to stop listening the inputs from
  33296. */
  33297. detachControl(element: Nullable<HTMLElement>): void;
  33298. /**
  33299. * Update the current camera state depending on the inputs that have been used this frame.
  33300. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  33301. */
  33302. checkInputs(): void;
  33303. /**
  33304. * Gets the class name of the current intput.
  33305. * @returns the class name
  33306. */
  33307. getClassName(): string;
  33308. /**
  33309. * Get the friendly name associated with the input class.
  33310. * @returns the input friendly name
  33311. */
  33312. getSimpleName(): string;
  33313. }
  33314. }
  33315. declare module BABYLON {
  33316. /**
  33317. * Manage the mouse wheel inputs to control an arc rotate camera.
  33318. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  33319. */
  33320. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  33321. /**
  33322. * Defines the camera the input is attached to.
  33323. */
  33324. camera: ArcRotateCamera;
  33325. /**
  33326. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  33327. */
  33328. wheelPrecision: number;
  33329. /**
  33330. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  33331. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  33332. */
  33333. wheelDeltaPercentage: number;
  33334. private _wheel;
  33335. private _observer;
  33336. /**
  33337. * Attach the input controls to a specific dom element to get the input from.
  33338. * @param element Defines the element the controls should be listened from
  33339. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  33340. */
  33341. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33342. /**
  33343. * Detach the current controls from the specified dom element.
  33344. * @param element Defines the element to stop listening the inputs from
  33345. */
  33346. detachControl(element: Nullable<HTMLElement>): void;
  33347. /**
  33348. * Gets the class name of the current intput.
  33349. * @returns the class name
  33350. */
  33351. getClassName(): string;
  33352. /**
  33353. * Get the friendly name associated with the input class.
  33354. * @returns the input friendly name
  33355. */
  33356. getSimpleName(): string;
  33357. }
  33358. }
  33359. declare module BABYLON {
  33360. /**
  33361. * Default Inputs manager for the ArcRotateCamera.
  33362. * It groups all the default supported inputs for ease of use.
  33363. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  33364. */
  33365. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  33366. /**
  33367. * Instantiates a new ArcRotateCameraInputsManager.
  33368. * @param camera Defines the camera the inputs belong to
  33369. */
  33370. constructor(camera: ArcRotateCamera);
  33371. /**
  33372. * Add mouse wheel input support to the input manager.
  33373. * @returns the current input manager
  33374. */
  33375. addMouseWheel(): ArcRotateCameraInputsManager;
  33376. /**
  33377. * Add pointers input support to the input manager.
  33378. * @returns the current input manager
  33379. */
  33380. addPointers(): ArcRotateCameraInputsManager;
  33381. /**
  33382. * Add keyboard input support to the input manager.
  33383. * @returns the current input manager
  33384. */
  33385. addKeyboard(): ArcRotateCameraInputsManager;
  33386. }
  33387. }
  33388. declare module BABYLON {
  33389. /**
  33390. * This represents an orbital type of camera.
  33391. *
  33392. * 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.
  33393. * 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.
  33394. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  33395. */
  33396. export class ArcRotateCamera extends TargetCamera {
  33397. /**
  33398. * Defines the rotation angle of the camera along the longitudinal axis.
  33399. */
  33400. alpha: number;
  33401. /**
  33402. * Defines the rotation angle of the camera along the latitudinal axis.
  33403. */
  33404. beta: number;
  33405. /**
  33406. * Defines the radius of the camera from it s target point.
  33407. */
  33408. radius: number;
  33409. protected _target: Vector3;
  33410. protected _targetHost: Nullable<AbstractMesh>;
  33411. /**
  33412. * Defines the target point of the camera.
  33413. * The camera looks towards it form the radius distance.
  33414. */
  33415. target: Vector3;
  33416. /**
  33417. * Current inertia value on the longitudinal axis.
  33418. * The bigger this number the longer it will take for the camera to stop.
  33419. */
  33420. inertialAlphaOffset: number;
  33421. /**
  33422. * Current inertia value on the latitudinal axis.
  33423. * The bigger this number the longer it will take for the camera to stop.
  33424. */
  33425. inertialBetaOffset: number;
  33426. /**
  33427. * Current inertia value on the radius axis.
  33428. * The bigger this number the longer it will take for the camera to stop.
  33429. */
  33430. inertialRadiusOffset: number;
  33431. /**
  33432. * Minimum allowed angle on the longitudinal axis.
  33433. * This can help limiting how the Camera is able to move in the scene.
  33434. */
  33435. lowerAlphaLimit: Nullable<number>;
  33436. /**
  33437. * Maximum allowed angle on the longitudinal axis.
  33438. * This can help limiting how the Camera is able to move in the scene.
  33439. */
  33440. upperAlphaLimit: Nullable<number>;
  33441. /**
  33442. * Minimum allowed angle on the latitudinal axis.
  33443. * This can help limiting how the Camera is able to move in the scene.
  33444. */
  33445. lowerBetaLimit: number;
  33446. /**
  33447. * Maximum allowed angle on the latitudinal axis.
  33448. * This can help limiting how the Camera is able to move in the scene.
  33449. */
  33450. upperBetaLimit: number;
  33451. /**
  33452. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  33453. * This can help limiting how the Camera is able to move in the scene.
  33454. */
  33455. lowerRadiusLimit: Nullable<number>;
  33456. /**
  33457. * Maximum allowed distance of the camera to the target (The camera can not get further).
  33458. * This can help limiting how the Camera is able to move in the scene.
  33459. */
  33460. upperRadiusLimit: Nullable<number>;
  33461. /**
  33462. * Defines the current inertia value used during panning of the camera along the X axis.
  33463. */
  33464. inertialPanningX: number;
  33465. /**
  33466. * Defines the current inertia value used during panning of the camera along the Y axis.
  33467. */
  33468. inertialPanningY: number;
  33469. /**
  33470. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  33471. * Basically if your fingers moves away from more than this distance you will be considered
  33472. * in pinch mode.
  33473. */
  33474. pinchToPanMaxDistance: number;
  33475. /**
  33476. * Defines the maximum distance the camera can pan.
  33477. * This could help keeping the cammera always in your scene.
  33478. */
  33479. panningDistanceLimit: Nullable<number>;
  33480. /**
  33481. * Defines the target of the camera before paning.
  33482. */
  33483. panningOriginTarget: Vector3;
  33484. /**
  33485. * Defines the value of the inertia used during panning.
  33486. * 0 would mean stop inertia and one would mean no decelleration at all.
  33487. */
  33488. panningInertia: number;
  33489. /**
  33490. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  33491. */
  33492. angularSensibilityX: number;
  33493. /**
  33494. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  33495. */
  33496. angularSensibilityY: number;
  33497. /**
  33498. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  33499. */
  33500. pinchPrecision: number;
  33501. /**
  33502. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  33503. * It will be used instead of pinchDeltaPrecision if different from 0.
  33504. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  33505. */
  33506. pinchDeltaPercentage: number;
  33507. /**
  33508. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  33509. */
  33510. panningSensibility: number;
  33511. /**
  33512. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  33513. */
  33514. keysUp: number[];
  33515. /**
  33516. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  33517. */
  33518. keysDown: number[];
  33519. /**
  33520. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  33521. */
  33522. keysLeft: number[];
  33523. /**
  33524. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  33525. */
  33526. keysRight: number[];
  33527. /**
  33528. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  33529. */
  33530. wheelPrecision: number;
  33531. /**
  33532. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  33533. * It will be used instead of pinchDeltaPrecision if different from 0.
  33534. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  33535. */
  33536. wheelDeltaPercentage: number;
  33537. /**
  33538. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  33539. */
  33540. zoomOnFactor: number;
  33541. /**
  33542. * Defines a screen offset for the camera position.
  33543. */
  33544. targetScreenOffset: Vector2;
  33545. /**
  33546. * Allows the camera to be completely reversed.
  33547. * If false the camera can not arrive upside down.
  33548. */
  33549. allowUpsideDown: boolean;
  33550. /**
  33551. * Define if double tap/click is used to restore the previously saved state of the camera.
  33552. */
  33553. useInputToRestoreState: boolean;
  33554. /** @hidden */ viewMatrix: Matrix;
  33555. /** @hidden */ useCtrlForPanning: boolean;
  33556. /** @hidden */ panningMouseButton: number;
  33557. /**
  33558. * Defines the input associated to the camera.
  33559. */
  33560. inputs: ArcRotateCameraInputsManager;
  33561. /** @hidden */ reset: () => void;
  33562. /**
  33563. * Defines the allowed panning axis.
  33564. */
  33565. panningAxis: Vector3;
  33566. protected _localDirection: Vector3;
  33567. protected _transformedDirection: Vector3;
  33568. private _bouncingBehavior;
  33569. /**
  33570. * Gets the bouncing behavior of the camera if it has been enabled.
  33571. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  33572. */
  33573. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  33574. /**
  33575. * Defines if the bouncing behavior of the camera is enabled on the camera.
  33576. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  33577. */
  33578. useBouncingBehavior: boolean;
  33579. private _framingBehavior;
  33580. /**
  33581. * Gets the framing behavior of the camera if it has been enabled.
  33582. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  33583. */
  33584. readonly framingBehavior: Nullable<FramingBehavior>;
  33585. /**
  33586. * Defines if the framing behavior of the camera is enabled on the camera.
  33587. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  33588. */
  33589. useFramingBehavior: boolean;
  33590. private _autoRotationBehavior;
  33591. /**
  33592. * Gets the auto rotation behavior of the camera if it has been enabled.
  33593. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  33594. */
  33595. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  33596. /**
  33597. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  33598. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  33599. */
  33600. useAutoRotationBehavior: boolean;
  33601. /**
  33602. * Observable triggered when the mesh target has been changed on the camera.
  33603. */
  33604. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  33605. /**
  33606. * Event raised when the camera is colliding with a mesh.
  33607. */
  33608. onCollide: (collidedMesh: AbstractMesh) => void;
  33609. /**
  33610. * Defines whether the camera should check collision with the objects oh the scene.
  33611. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  33612. */
  33613. checkCollisions: boolean;
  33614. /**
  33615. * Defines the collision radius of the camera.
  33616. * This simulates a sphere around the camera.
  33617. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  33618. */
  33619. collisionRadius: Vector3;
  33620. protected _collider: Collider;
  33621. protected _previousPosition: Vector3;
  33622. protected _collisionVelocity: Vector3;
  33623. protected _newPosition: Vector3;
  33624. protected _previousAlpha: number;
  33625. protected _previousBeta: number;
  33626. protected _previousRadius: number;
  33627. protected _collisionTriggered: boolean;
  33628. protected _targetBoundingCenter: Nullable<Vector3>;
  33629. private _computationVector;
  33630. private _tempAxisVector;
  33631. private _tempAxisRotationMatrix;
  33632. /**
  33633. * Instantiates a new ArcRotateCamera in a given scene
  33634. * @param name Defines the name of the camera
  33635. * @param alpha Defines the camera rotation along the logitudinal axis
  33636. * @param beta Defines the camera rotation along the latitudinal axis
  33637. * @param radius Defines the camera distance from its target
  33638. * @param target Defines the camera target
  33639. * @param scene Defines the scene the camera belongs to
  33640. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  33641. */
  33642. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  33643. /** @hidden */ initCache(): void;
  33644. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  33645. protected _getTargetPosition(): Vector3;
  33646. private _storedAlpha;
  33647. private _storedBeta;
  33648. private _storedRadius;
  33649. private _storedTarget;
  33650. /**
  33651. * Stores the current state of the camera (alpha, beta, radius and target)
  33652. * @returns the camera itself
  33653. */
  33654. storeState(): Camera;
  33655. /**
  33656. * @hidden
  33657. * Restored camera state. You must call storeState() first
  33658. */ restoreStateValues(): boolean;
  33659. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  33660. /**
  33661. * Attached controls to the current camera.
  33662. * @param element Defines the element the controls should be listened from
  33663. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  33664. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  33665. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  33666. */
  33667. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  33668. /**
  33669. * Detach the current controls from the camera.
  33670. * The camera will stop reacting to inputs.
  33671. * @param element Defines the element to stop listening the inputs from
  33672. */
  33673. detachControl(element: HTMLElement): void;
  33674. /** @hidden */ checkInputs(): void;
  33675. protected _checkLimits(): void;
  33676. /**
  33677. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  33678. */
  33679. rebuildAnglesAndRadius(): void;
  33680. /**
  33681. * Use a position to define the current camera related information like aplha, beta and radius
  33682. * @param position Defines the position to set the camera at
  33683. */
  33684. setPosition(position: Vector3): void;
  33685. /**
  33686. * Defines the target the camera should look at.
  33687. * This will automatically adapt alpha beta and radius to fit within the new target.
  33688. * @param target Defines the new target as a Vector or a mesh
  33689. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  33690. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  33691. */
  33692. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  33693. /** @hidden */ getViewMatrix(): Matrix;
  33694. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  33695. /**
  33696. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  33697. * @param meshes Defines the mesh to zoom on
  33698. * @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)
  33699. */
  33700. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  33701. /**
  33702. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  33703. * The target will be changed but the radius
  33704. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  33705. * @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)
  33706. */
  33707. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  33708. min: Vector3;
  33709. max: Vector3;
  33710. distance: number;
  33711. }, doNotUpdateMaxZ?: boolean): void;
  33712. /**
  33713. * @override
  33714. * Override Camera.createRigCamera
  33715. */
  33716. createRigCamera(name: string, cameraIndex: number): Camera;
  33717. /**
  33718. * @hidden
  33719. * @override
  33720. * Override Camera._updateRigCameras
  33721. */ updateRigCameras(): void;
  33722. /**
  33723. * Destroy the camera and release the current resources hold by it.
  33724. */
  33725. dispose(): void;
  33726. /**
  33727. * Gets the current object class name.
  33728. * @return the class name
  33729. */
  33730. getClassName(): string;
  33731. }
  33732. }
  33733. declare module BABYLON {
  33734. /**
  33735. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  33736. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  33737. */
  33738. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  33739. /**
  33740. * Gets the name of the behavior.
  33741. */
  33742. readonly name: string;
  33743. private _zoomStopsAnimation;
  33744. private _idleRotationSpeed;
  33745. private _idleRotationWaitTime;
  33746. private _idleRotationSpinupTime;
  33747. /**
  33748. * Sets the flag that indicates if user zooming should stop animation.
  33749. */
  33750. /**
  33751. * Gets the flag that indicates if user zooming should stop animation.
  33752. */
  33753. zoomStopsAnimation: boolean;
  33754. /**
  33755. * Sets the default speed at which the camera rotates around the model.
  33756. */
  33757. /**
  33758. * Gets the default speed at which the camera rotates around the model.
  33759. */
  33760. idleRotationSpeed: number;
  33761. /**
  33762. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  33763. */
  33764. /**
  33765. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  33766. */
  33767. idleRotationWaitTime: number;
  33768. /**
  33769. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  33770. */
  33771. /**
  33772. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  33773. */
  33774. idleRotationSpinupTime: number;
  33775. /**
  33776. * Gets a value indicating if the camera is currently rotating because of this behavior
  33777. */
  33778. readonly rotationInProgress: boolean;
  33779. private _onPrePointerObservableObserver;
  33780. private _onAfterCheckInputsObserver;
  33781. private _attachedCamera;
  33782. private _isPointerDown;
  33783. private _lastFrameTime;
  33784. private _lastInteractionTime;
  33785. private _cameraRotationSpeed;
  33786. /**
  33787. * Initializes the behavior.
  33788. */
  33789. init(): void;
  33790. /**
  33791. * Attaches the behavior to its arc rotate camera.
  33792. * @param camera Defines the camera to attach the behavior to
  33793. */
  33794. attach(camera: ArcRotateCamera): void;
  33795. /**
  33796. * Detaches the behavior from its current arc rotate camera.
  33797. */
  33798. detach(): void;
  33799. /**
  33800. * Returns true if user is scrolling.
  33801. * @return true if user is scrolling.
  33802. */
  33803. private _userIsZooming;
  33804. private _lastFrameRadius;
  33805. private _shouldAnimationStopForInteraction;
  33806. /**
  33807. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  33808. */
  33809. private _applyUserInteraction;
  33810. private _userIsMoving;
  33811. }
  33812. }
  33813. declare module BABYLON {
  33814. /**
  33815. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  33816. */
  33817. export class AttachToBoxBehavior implements Behavior<Mesh> {
  33818. private ui;
  33819. /**
  33820. * The name of the behavior
  33821. */
  33822. name: string;
  33823. /**
  33824. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  33825. */
  33826. distanceAwayFromFace: number;
  33827. /**
  33828. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  33829. */
  33830. distanceAwayFromBottomOfFace: number;
  33831. private _faceVectors;
  33832. private _target;
  33833. private _scene;
  33834. private _onRenderObserver;
  33835. private _tmpMatrix;
  33836. private _tmpVector;
  33837. /**
  33838. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  33839. * @param ui The transform node that should be attched to the mesh
  33840. */
  33841. constructor(ui: TransformNode);
  33842. /**
  33843. * Initializes the behavior
  33844. */
  33845. init(): void;
  33846. private _closestFace;
  33847. private _zeroVector;
  33848. private _lookAtTmpMatrix;
  33849. private _lookAtToRef;
  33850. /**
  33851. * Attaches the AttachToBoxBehavior to the passed in mesh
  33852. * @param target The mesh that the specified node will be attached to
  33853. */
  33854. attach(target: Mesh): void;
  33855. /**
  33856. * Detaches the behavior from the mesh
  33857. */
  33858. detach(): void;
  33859. }
  33860. }
  33861. declare module BABYLON {
  33862. /**
  33863. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  33864. */
  33865. export class FadeInOutBehavior implements Behavior<Mesh> {
  33866. /**
  33867. * Time in milliseconds to delay before fading in (Default: 0)
  33868. */
  33869. delay: number;
  33870. /**
  33871. * Time in milliseconds for the mesh to fade in (Default: 300)
  33872. */
  33873. fadeInTime: number;
  33874. private _millisecondsPerFrame;
  33875. private _hovered;
  33876. private _hoverValue;
  33877. private _ownerNode;
  33878. /**
  33879. * Instatiates the FadeInOutBehavior
  33880. */
  33881. constructor();
  33882. /**
  33883. * The name of the behavior
  33884. */
  33885. readonly name: string;
  33886. /**
  33887. * Initializes the behavior
  33888. */
  33889. init(): void;
  33890. /**
  33891. * Attaches the fade behavior on the passed in mesh
  33892. * @param ownerNode The mesh that will be faded in/out once attached
  33893. */
  33894. attach(ownerNode: Mesh): void;
  33895. /**
  33896. * Detaches the behavior from the mesh
  33897. */
  33898. detach(): void;
  33899. /**
  33900. * Triggers the mesh to begin fading in or out
  33901. * @param value if the object should fade in or out (true to fade in)
  33902. */
  33903. fadeIn(value: boolean): void;
  33904. private _update;
  33905. private _setAllVisibility;
  33906. }
  33907. }
  33908. declare module BABYLON {
  33909. /**
  33910. * Class containing a set of static utilities functions for managing Pivots
  33911. * @hidden
  33912. */
  33913. export class PivotTools {
  33914. private static _PivotCached;
  33915. private static _OldPivotPoint;
  33916. private static _PivotTranslation;
  33917. private static _PivotTmpVector;
  33918. /** @hidden */ private static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  33919. /** @hidden */ private static _RestorePivotPoint(mesh: AbstractMesh): void;
  33920. }
  33921. }
  33922. declare module BABYLON {
  33923. /**
  33924. * Class containing static functions to help procedurally build meshes
  33925. */
  33926. export class PlaneBuilder {
  33927. /**
  33928. * Creates a plane mesh
  33929. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  33930. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  33931. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  33932. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  33933. * * 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
  33934. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33935. * @param name defines the name of the mesh
  33936. * @param options defines the options used to create the mesh
  33937. * @param scene defines the hosting scene
  33938. * @returns the plane mesh
  33939. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  33940. */
  33941. static CreatePlane(name: string, options: {
  33942. size?: number;
  33943. width?: number;
  33944. height?: number;
  33945. sideOrientation?: number;
  33946. frontUVs?: Vector4;
  33947. backUVs?: Vector4;
  33948. updatable?: boolean;
  33949. sourcePlane?: Plane;
  33950. }, scene: Scene): Mesh;
  33951. }
  33952. }
  33953. declare module BABYLON {
  33954. /**
  33955. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  33956. */
  33957. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  33958. private static _AnyMouseID;
  33959. private _attachedNode;
  33960. private _dragPlane;
  33961. private _scene;
  33962. private _pointerObserver;
  33963. private _beforeRenderObserver;
  33964. private static _planeScene;
  33965. /**
  33966. * 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)
  33967. */
  33968. maxDragAngle: number;
  33969. /**
  33970. * @hidden
  33971. */ useAlternatePickedPointAboveMaxDragAngle: boolean;
  33972. /**
  33973. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  33974. */
  33975. currentDraggingPointerID: number;
  33976. /**
  33977. * The last position where the pointer hit the drag plane in world space
  33978. */
  33979. lastDragPosition: Vector3;
  33980. /**
  33981. * If the behavior is currently in a dragging state
  33982. */
  33983. dragging: boolean;
  33984. /**
  33985. * 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)
  33986. */
  33987. dragDeltaRatio: number;
  33988. /**
  33989. * If the drag plane orientation should be updated during the dragging (Default: true)
  33990. */
  33991. updateDragPlane: boolean;
  33992. private _debugMode;
  33993. private _moving;
  33994. /**
  33995. * Fires each time the attached mesh is dragged with the pointer
  33996. * * delta between last drag position and current drag position in world space
  33997. * * dragDistance along the drag axis
  33998. * * dragPlaneNormal normal of the current drag plane used during the drag
  33999. * * dragPlanePoint in world space where the drag intersects the drag plane
  34000. */
  34001. onDragObservable: Observable<{
  34002. delta: Vector3;
  34003. dragPlanePoint: Vector3;
  34004. dragPlaneNormal: Vector3;
  34005. dragDistance: number;
  34006. pointerId: number;
  34007. }>;
  34008. /**
  34009. * Fires each time a drag begins (eg. mouse down on mesh)
  34010. */
  34011. onDragStartObservable: Observable<{
  34012. dragPlanePoint: Vector3;
  34013. pointerId: number;
  34014. }>;
  34015. /**
  34016. * Fires each time a drag ends (eg. mouse release after drag)
  34017. */
  34018. onDragEndObservable: Observable<{
  34019. dragPlanePoint: Vector3;
  34020. pointerId: number;
  34021. }>;
  34022. /**
  34023. * If the attached mesh should be moved when dragged
  34024. */
  34025. moveAttached: boolean;
  34026. /**
  34027. * If the drag behavior will react to drag events (Default: true)
  34028. */
  34029. enabled: boolean;
  34030. /**
  34031. * If camera controls should be detached during the drag
  34032. */
  34033. detachCameraControls: boolean;
  34034. /**
  34035. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  34036. */
  34037. useObjectOrienationForDragging: boolean;
  34038. private _options;
  34039. /**
  34040. * Creates a pointer drag behavior that can be attached to a mesh
  34041. * @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)
  34042. */
  34043. constructor(options?: {
  34044. dragAxis?: Vector3;
  34045. dragPlaneNormal?: Vector3;
  34046. });
  34047. /**
  34048. * Predicate to determine if it is valid to move the object to a new position when it is moved
  34049. */
  34050. validateDrag: (targetPosition: Vector3) => boolean;
  34051. /**
  34052. * The name of the behavior
  34053. */
  34054. readonly name: string;
  34055. /**
  34056. * Initializes the behavior
  34057. */
  34058. init(): void;
  34059. private _tmpVector;
  34060. private _alternatePickedPoint;
  34061. private _worldDragAxis;
  34062. private _targetPosition;
  34063. private _attachedElement;
  34064. /**
  34065. * Attaches the drag behavior the passed in mesh
  34066. * @param ownerNode The mesh that will be dragged around once attached
  34067. */
  34068. attach(ownerNode: AbstractMesh): void;
  34069. /**
  34070. * Force relase the drag action by code.
  34071. */
  34072. releaseDrag(): void;
  34073. private _startDragRay;
  34074. private _lastPointerRay;
  34075. /**
  34076. * Simulates the start of a pointer drag event on the behavior
  34077. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  34078. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  34079. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  34080. */
  34081. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  34082. private _startDrag;
  34083. private _dragDelta;
  34084. private _moveDrag;
  34085. private _pickWithRayOnDragPlane;
  34086. private _pointA;
  34087. private _pointB;
  34088. private _pointC;
  34089. private _lineA;
  34090. private _lineB;
  34091. private _localAxis;
  34092. private _lookAt;
  34093. private _updateDragPlanePosition;
  34094. /**
  34095. * Detaches the behavior from the mesh
  34096. */
  34097. detach(): void;
  34098. }
  34099. }
  34100. declare module BABYLON {
  34101. /**
  34102. * A behavior that when attached to a mesh will allow the mesh to be scaled
  34103. */
  34104. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  34105. private _dragBehaviorA;
  34106. private _dragBehaviorB;
  34107. private _startDistance;
  34108. private _initialScale;
  34109. private _targetScale;
  34110. private _ownerNode;
  34111. private _sceneRenderObserver;
  34112. /**
  34113. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  34114. */
  34115. constructor();
  34116. /**
  34117. * The name of the behavior
  34118. */
  34119. readonly name: string;
  34120. /**
  34121. * Initializes the behavior
  34122. */
  34123. init(): void;
  34124. private _getCurrentDistance;
  34125. /**
  34126. * Attaches the scale behavior the passed in mesh
  34127. * @param ownerNode The mesh that will be scaled around once attached
  34128. */
  34129. attach(ownerNode: Mesh): void;
  34130. /**
  34131. * Detaches the behavior from the mesh
  34132. */
  34133. detach(): void;
  34134. }
  34135. }
  34136. declare module BABYLON {
  34137. /**
  34138. * 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
  34139. */
  34140. export class SixDofDragBehavior implements Behavior<Mesh> {
  34141. private static _virtualScene;
  34142. private _ownerNode;
  34143. private _sceneRenderObserver;
  34144. private _scene;
  34145. private _targetPosition;
  34146. private _virtualOriginMesh;
  34147. private _virtualDragMesh;
  34148. private _pointerObserver;
  34149. private _moving;
  34150. private _startingOrientation;
  34151. /**
  34152. * 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)
  34153. */
  34154. private zDragFactor;
  34155. /**
  34156. * If the object should rotate to face the drag origin
  34157. */
  34158. rotateDraggedObject: boolean;
  34159. /**
  34160. * If the behavior is currently in a dragging state
  34161. */
  34162. dragging: boolean;
  34163. /**
  34164. * 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)
  34165. */
  34166. dragDeltaRatio: number;
  34167. /**
  34168. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  34169. */
  34170. currentDraggingPointerID: number;
  34171. /**
  34172. * If camera controls should be detached during the drag
  34173. */
  34174. detachCameraControls: boolean;
  34175. /**
  34176. * Fires each time a drag starts
  34177. */
  34178. onDragStartObservable: Observable<{}>;
  34179. /**
  34180. * Fires each time a drag ends (eg. mouse release after drag)
  34181. */
  34182. onDragEndObservable: Observable<{}>;
  34183. /**
  34184. * 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
  34185. */
  34186. constructor();
  34187. /**
  34188. * The name of the behavior
  34189. */
  34190. readonly name: string;
  34191. /**
  34192. * Initializes the behavior
  34193. */
  34194. init(): void;
  34195. /**
  34196. * Attaches the scale behavior the passed in mesh
  34197. * @param ownerNode The mesh that will be scaled around once attached
  34198. */
  34199. attach(ownerNode: Mesh): void;
  34200. /**
  34201. * Detaches the behavior from the mesh
  34202. */
  34203. detach(): void;
  34204. }
  34205. }
  34206. declare module BABYLON {
  34207. /**
  34208. * Class used to apply inverse kinematics to bones
  34209. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  34210. */
  34211. export class BoneIKController {
  34212. private static _tmpVecs;
  34213. private static _tmpQuat;
  34214. private static _tmpMats;
  34215. /**
  34216. * Gets or sets the target mesh
  34217. */
  34218. targetMesh: AbstractMesh;
  34219. /** Gets or sets the mesh used as pole */
  34220. poleTargetMesh: AbstractMesh;
  34221. /**
  34222. * Gets or sets the bone used as pole
  34223. */
  34224. poleTargetBone: Nullable<Bone>;
  34225. /**
  34226. * Gets or sets the target position
  34227. */
  34228. targetPosition: Vector3;
  34229. /**
  34230. * Gets or sets the pole target position
  34231. */
  34232. poleTargetPosition: Vector3;
  34233. /**
  34234. * Gets or sets the pole target local offset
  34235. */
  34236. poleTargetLocalOffset: Vector3;
  34237. /**
  34238. * Gets or sets the pole angle
  34239. */
  34240. poleAngle: number;
  34241. /**
  34242. * Gets or sets the mesh associated with the controller
  34243. */
  34244. mesh: AbstractMesh;
  34245. /**
  34246. * 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)
  34247. */
  34248. slerpAmount: number;
  34249. private _bone1Quat;
  34250. private _bone1Mat;
  34251. private _bone2Ang;
  34252. private _bone1;
  34253. private _bone2;
  34254. private _bone1Length;
  34255. private _bone2Length;
  34256. private _maxAngle;
  34257. private _maxReach;
  34258. private _rightHandedSystem;
  34259. private _bendAxis;
  34260. private _slerping;
  34261. private _adjustRoll;
  34262. /**
  34263. * Gets or sets maximum allowed angle
  34264. */
  34265. maxAngle: number;
  34266. /**
  34267. * Creates a new BoneIKController
  34268. * @param mesh defines the mesh to control
  34269. * @param bone defines the bone to control
  34270. * @param options defines options to set up the controller
  34271. */
  34272. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  34273. targetMesh?: AbstractMesh;
  34274. poleTargetMesh?: AbstractMesh;
  34275. poleTargetBone?: Bone;
  34276. poleTargetLocalOffset?: Vector3;
  34277. poleAngle?: number;
  34278. bendAxis?: Vector3;
  34279. maxAngle?: number;
  34280. slerpAmount?: number;
  34281. });
  34282. private _setMaxAngle;
  34283. /**
  34284. * Force the controller to update the bones
  34285. */
  34286. update(): void;
  34287. }
  34288. }
  34289. declare module BABYLON {
  34290. /**
  34291. * Class used to make a bone look toward a point in space
  34292. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  34293. */
  34294. export class BoneLookController {
  34295. private static _tmpVecs;
  34296. private static _tmpQuat;
  34297. private static _tmpMats;
  34298. /**
  34299. * The target Vector3 that the bone will look at
  34300. */
  34301. target: Vector3;
  34302. /**
  34303. * The mesh that the bone is attached to
  34304. */
  34305. mesh: AbstractMesh;
  34306. /**
  34307. * The bone that will be looking to the target
  34308. */
  34309. bone: Bone;
  34310. /**
  34311. * The up axis of the coordinate system that is used when the bone is rotated
  34312. */
  34313. upAxis: Vector3;
  34314. /**
  34315. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  34316. */
  34317. upAxisSpace: Space;
  34318. /**
  34319. * Used to make an adjustment to the yaw of the bone
  34320. */
  34321. adjustYaw: number;
  34322. /**
  34323. * Used to make an adjustment to the pitch of the bone
  34324. */
  34325. adjustPitch: number;
  34326. /**
  34327. * Used to make an adjustment to the roll of the bone
  34328. */
  34329. adjustRoll: number;
  34330. /**
  34331. * 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)
  34332. */
  34333. slerpAmount: number;
  34334. private _minYaw;
  34335. private _maxYaw;
  34336. private _minPitch;
  34337. private _maxPitch;
  34338. private _minYawSin;
  34339. private _minYawCos;
  34340. private _maxYawSin;
  34341. private _maxYawCos;
  34342. private _midYawConstraint;
  34343. private _minPitchTan;
  34344. private _maxPitchTan;
  34345. private _boneQuat;
  34346. private _slerping;
  34347. private _transformYawPitch;
  34348. private _transformYawPitchInv;
  34349. private _firstFrameSkipped;
  34350. private _yawRange;
  34351. private _fowardAxis;
  34352. /**
  34353. * Gets or sets the minimum yaw angle that the bone can look to
  34354. */
  34355. minYaw: number;
  34356. /**
  34357. * Gets or sets the maximum yaw angle that the bone can look to
  34358. */
  34359. maxYaw: number;
  34360. /**
  34361. * Gets or sets the minimum pitch angle that the bone can look to
  34362. */
  34363. minPitch: number;
  34364. /**
  34365. * Gets or sets the maximum pitch angle that the bone can look to
  34366. */
  34367. maxPitch: number;
  34368. /**
  34369. * Create a BoneLookController
  34370. * @param mesh the mesh that the bone belongs to
  34371. * @param bone the bone that will be looking to the target
  34372. * @param target the target Vector3 to look at
  34373. * @param options optional settings:
  34374. * * maxYaw: the maximum angle the bone will yaw to
  34375. * * minYaw: the minimum angle the bone will yaw to
  34376. * * maxPitch: the maximum angle the bone will pitch to
  34377. * * minPitch: the minimum angle the bone will yaw to
  34378. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  34379. * * upAxis: the up axis of the coordinate system
  34380. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  34381. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  34382. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  34383. * * adjustYaw: used to make an adjustment to the yaw of the bone
  34384. * * adjustPitch: used to make an adjustment to the pitch of the bone
  34385. * * adjustRoll: used to make an adjustment to the roll of the bone
  34386. **/
  34387. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  34388. maxYaw?: number;
  34389. minYaw?: number;
  34390. maxPitch?: number;
  34391. minPitch?: number;
  34392. slerpAmount?: number;
  34393. upAxis?: Vector3;
  34394. upAxisSpace?: Space;
  34395. yawAxis?: Vector3;
  34396. pitchAxis?: Vector3;
  34397. adjustYaw?: number;
  34398. adjustPitch?: number;
  34399. adjustRoll?: number;
  34400. });
  34401. /**
  34402. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  34403. */
  34404. update(): void;
  34405. private _getAngleDiff;
  34406. private _getAngleBetween;
  34407. private _isAngleBetween;
  34408. }
  34409. }
  34410. declare module BABYLON {
  34411. /**
  34412. * Manage the gamepad inputs to control an arc rotate camera.
  34413. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34414. */
  34415. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  34416. /**
  34417. * Defines the camera the input is attached to.
  34418. */
  34419. camera: ArcRotateCamera;
  34420. /**
  34421. * Defines the gamepad the input is gathering event from.
  34422. */
  34423. gamepad: Nullable<Gamepad>;
  34424. /**
  34425. * Defines the gamepad rotation sensiblity.
  34426. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  34427. */
  34428. gamepadRotationSensibility: number;
  34429. /**
  34430. * Defines the gamepad move sensiblity.
  34431. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  34432. */
  34433. gamepadMoveSensibility: number;
  34434. private _onGamepadConnectedObserver;
  34435. private _onGamepadDisconnectedObserver;
  34436. /**
  34437. * Attach the input controls to a specific dom element to get the input from.
  34438. * @param element Defines the element the controls should be listened from
  34439. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34440. */
  34441. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34442. /**
  34443. * Detach the current controls from the specified dom element.
  34444. * @param element Defines the element to stop listening the inputs from
  34445. */
  34446. detachControl(element: Nullable<HTMLElement>): void;
  34447. /**
  34448. * Update the current camera state depending on the inputs that have been used this frame.
  34449. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34450. */
  34451. checkInputs(): void;
  34452. /**
  34453. * Gets the class name of the current intput.
  34454. * @returns the class name
  34455. */
  34456. getClassName(): string;
  34457. /**
  34458. * Get the friendly name associated with the input class.
  34459. * @returns the input friendly name
  34460. */
  34461. getSimpleName(): string;
  34462. }
  34463. }
  34464. declare module BABYLON {
  34465. interface ArcRotateCameraInputsManager {
  34466. /**
  34467. * Add orientation input support to the input manager.
  34468. * @returns the current input manager
  34469. */
  34470. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  34471. }
  34472. /**
  34473. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  34474. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34475. */
  34476. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  34477. /**
  34478. * Defines the camera the input is attached to.
  34479. */
  34480. camera: ArcRotateCamera;
  34481. /**
  34482. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  34483. */
  34484. alphaCorrection: number;
  34485. /**
  34486. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  34487. */
  34488. gammaCorrection: number;
  34489. private _alpha;
  34490. private _gamma;
  34491. private _dirty;
  34492. private _deviceOrientationHandler;
  34493. /**
  34494. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  34495. */
  34496. constructor();
  34497. /**
  34498. * Attach the input controls to a specific dom element to get the input from.
  34499. * @param element Defines the element the controls should be listened from
  34500. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34501. */
  34502. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34503. /** @hidden */ onOrientationEvent(evt: DeviceOrientationEvent): void;
  34504. /**
  34505. * Update the current camera state depending on the inputs that have been used this frame.
  34506. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34507. */
  34508. checkInputs(): void;
  34509. /**
  34510. * Detach the current controls from the specified dom element.
  34511. * @param element Defines the element to stop listening the inputs from
  34512. */
  34513. detachControl(element: Nullable<HTMLElement>): void;
  34514. /**
  34515. * Gets the class name of the current intput.
  34516. * @returns the class name
  34517. */
  34518. getClassName(): string;
  34519. /**
  34520. * Get the friendly name associated with the input class.
  34521. * @returns the input friendly name
  34522. */
  34523. getSimpleName(): string;
  34524. }
  34525. }
  34526. declare module BABYLON {
  34527. /**
  34528. * Listen to mouse events to control the camera.
  34529. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34530. */
  34531. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  34532. /**
  34533. * Defines the camera the input is attached to.
  34534. */
  34535. camera: FlyCamera;
  34536. /**
  34537. * Defines if touch is enabled. (Default is true.)
  34538. */
  34539. touchEnabled: boolean;
  34540. /**
  34541. * Defines the buttons associated with the input to handle camera rotation.
  34542. */
  34543. buttons: number[];
  34544. /**
  34545. * Assign buttons for Yaw control.
  34546. */
  34547. buttonsYaw: number[];
  34548. /**
  34549. * Assign buttons for Pitch control.
  34550. */
  34551. buttonsPitch: number[];
  34552. /**
  34553. * Assign buttons for Roll control.
  34554. */
  34555. buttonsRoll: number[];
  34556. /**
  34557. * Detect if any button is being pressed while mouse is moved.
  34558. * -1 = Mouse locked.
  34559. * 0 = Left button.
  34560. * 1 = Middle Button.
  34561. * 2 = Right Button.
  34562. */
  34563. activeButton: number;
  34564. /**
  34565. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  34566. * Higher values reduce its sensitivity.
  34567. */
  34568. angularSensibility: number;
  34569. private _mousemoveCallback;
  34570. private _observer;
  34571. private _rollObserver;
  34572. private previousPosition;
  34573. private noPreventDefault;
  34574. private element;
  34575. /**
  34576. * Listen to mouse events to control the camera.
  34577. * @param touchEnabled Define if touch is enabled. (Default is true.)
  34578. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34579. */
  34580. constructor(touchEnabled?: boolean);
  34581. /**
  34582. * Attach the mouse control to the HTML DOM element.
  34583. * @param element Defines the element that listens to the input events.
  34584. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  34585. */
  34586. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34587. /**
  34588. * Detach the current controls from the specified dom element.
  34589. * @param element Defines the element to stop listening the inputs from
  34590. */
  34591. detachControl(element: Nullable<HTMLElement>): void;
  34592. /**
  34593. * Gets the class name of the current input.
  34594. * @returns the class name.
  34595. */
  34596. getClassName(): string;
  34597. /**
  34598. * Get the friendly name associated with the input class.
  34599. * @returns the input's friendly name.
  34600. */
  34601. getSimpleName(): string;
  34602. private _pointerInput;
  34603. private _onMouseMove;
  34604. /**
  34605. * Rotate camera by mouse offset.
  34606. */
  34607. private rotateCamera;
  34608. }
  34609. }
  34610. declare module BABYLON {
  34611. /**
  34612. * Default Inputs manager for the FlyCamera.
  34613. * It groups all the default supported inputs for ease of use.
  34614. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34615. */
  34616. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  34617. /**
  34618. * Instantiates a new FlyCameraInputsManager.
  34619. * @param camera Defines the camera the inputs belong to.
  34620. */
  34621. constructor(camera: FlyCamera);
  34622. /**
  34623. * Add keyboard input support to the input manager.
  34624. * @returns the new FlyCameraKeyboardMoveInput().
  34625. */
  34626. addKeyboard(): FlyCameraInputsManager;
  34627. /**
  34628. * Add mouse input support to the input manager.
  34629. * @param touchEnabled Enable touch screen support.
  34630. * @returns the new FlyCameraMouseInput().
  34631. */
  34632. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  34633. }
  34634. }
  34635. declare module BABYLON {
  34636. /**
  34637. * This is a flying camera, designed for 3D movement and rotation in all directions,
  34638. * such as in a 3D Space Shooter or a Flight Simulator.
  34639. */
  34640. export class FlyCamera extends TargetCamera {
  34641. /**
  34642. * Define the collision ellipsoid of the camera.
  34643. * This is helpful for simulating a camera body, like a player's body.
  34644. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  34645. */
  34646. ellipsoid: Vector3;
  34647. /**
  34648. * Define an offset for the position of the ellipsoid around the camera.
  34649. * This can be helpful if the camera is attached away from the player's body center,
  34650. * such as at its head.
  34651. */
  34652. ellipsoidOffset: Vector3;
  34653. /**
  34654. * Enable or disable collisions of the camera with the rest of the scene objects.
  34655. */
  34656. checkCollisions: boolean;
  34657. /**
  34658. * Enable or disable gravity on the camera.
  34659. */
  34660. applyGravity: boolean;
  34661. /**
  34662. * Define the current direction the camera is moving to.
  34663. */
  34664. cameraDirection: Vector3;
  34665. /**
  34666. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  34667. * This overrides and empties cameraRotation.
  34668. */
  34669. rotationQuaternion: Quaternion;
  34670. /**
  34671. * Track Roll to maintain the wanted Rolling when looking around.
  34672. */ trackRoll: number;
  34673. /**
  34674. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  34675. */
  34676. rollCorrect: number;
  34677. /**
  34678. * Mimic a banked turn, Rolling the camera when Yawing.
  34679. * It's recommended to use rollCorrect = 10 for faster banking correction.
  34680. */
  34681. bankedTurn: boolean;
  34682. /**
  34683. * Limit in radians for how much Roll banking will add. (Default: 90°)
  34684. */
  34685. bankedTurnLimit: number;
  34686. /**
  34687. * Value of 0 disables the banked Roll.
  34688. * Value of 1 is equal to the Yaw angle in radians.
  34689. */
  34690. bankedTurnMultiplier: number;
  34691. /**
  34692. * The inputs manager loads all the input sources, such as keyboard and mouse.
  34693. */
  34694. inputs: FlyCameraInputsManager;
  34695. /**
  34696. * Gets the input sensibility for mouse input.
  34697. * Higher values reduce sensitivity.
  34698. */
  34699. /**
  34700. * Sets the input sensibility for a mouse input.
  34701. * Higher values reduce sensitivity.
  34702. */
  34703. angularSensibility: number;
  34704. /**
  34705. * Get the keys for camera movement forward.
  34706. */
  34707. /**
  34708. * Set the keys for camera movement forward.
  34709. */
  34710. keysForward: number[];
  34711. /**
  34712. * Get the keys for camera movement backward.
  34713. */
  34714. keysBackward: number[];
  34715. /**
  34716. * Get the keys for camera movement up.
  34717. */
  34718. /**
  34719. * Set the keys for camera movement up.
  34720. */
  34721. keysUp: number[];
  34722. /**
  34723. * Get the keys for camera movement down.
  34724. */
  34725. /**
  34726. * Set the keys for camera movement down.
  34727. */
  34728. keysDown: number[];
  34729. /**
  34730. * Get the keys for camera movement left.
  34731. */
  34732. /**
  34733. * Set the keys for camera movement left.
  34734. */
  34735. keysLeft: number[];
  34736. /**
  34737. * Set the keys for camera movement right.
  34738. */
  34739. /**
  34740. * Set the keys for camera movement right.
  34741. */
  34742. keysRight: number[];
  34743. /**
  34744. * Event raised when the camera collides with a mesh in the scene.
  34745. */
  34746. onCollide: (collidedMesh: AbstractMesh) => void;
  34747. private _collider;
  34748. private _needMoveForGravity;
  34749. private _oldPosition;
  34750. private _diffPosition;
  34751. private _newPosition;
  34752. /** @hidden */ localDirection: Vector3;
  34753. /** @hidden */ transformedDirection: Vector3;
  34754. /**
  34755. * Instantiates a FlyCamera.
  34756. * This is a flying camera, designed for 3D movement and rotation in all directions,
  34757. * such as in a 3D Space Shooter or a Flight Simulator.
  34758. * @param name Define the name of the camera in the scene.
  34759. * @param position Define the starting position of the camera in the scene.
  34760. * @param scene Define the scene the camera belongs to.
  34761. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  34762. */
  34763. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  34764. /**
  34765. * Attach a control to the HTML DOM element.
  34766. * @param element Defines the element that listens to the input events.
  34767. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  34768. */
  34769. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34770. /**
  34771. * Detach a control from the HTML DOM element.
  34772. * The camera will stop reacting to that input.
  34773. * @param element Defines the element that listens to the input events.
  34774. */
  34775. detachControl(element: HTMLElement): void;
  34776. private _collisionMask;
  34777. /**
  34778. * Get the mask that the camera ignores in collision events.
  34779. */
  34780. /**
  34781. * Set the mask that the camera ignores in collision events.
  34782. */
  34783. collisionMask: number;
  34784. /** @hidden */ collideWithWorld(displacement: Vector3): void;
  34785. /** @hidden */
  34786. private _onCollisionPositionChange;
  34787. /** @hidden */ checkInputs(): void;
  34788. /** @hidden */ decideIfNeedsToMove(): boolean;
  34789. /** @hidden */ updatePosition(): void;
  34790. /**
  34791. * Restore the Roll to its target value at the rate specified.
  34792. * @param rate - Higher means slower restoring.
  34793. * @hidden
  34794. */
  34795. restoreRoll(rate: number): void;
  34796. /**
  34797. * Destroy the camera and release the current resources held by it.
  34798. */
  34799. dispose(): void;
  34800. /**
  34801. * Get the current object class name.
  34802. * @returns the class name.
  34803. */
  34804. getClassName(): string;
  34805. }
  34806. }
  34807. declare module BABYLON {
  34808. /**
  34809. * Listen to keyboard events to control the camera.
  34810. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34811. */
  34812. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  34813. /**
  34814. * Defines the camera the input is attached to.
  34815. */
  34816. camera: FlyCamera;
  34817. /**
  34818. * The list of keyboard keys used to control the forward move of the camera.
  34819. */
  34820. keysForward: number[];
  34821. /**
  34822. * The list of keyboard keys used to control the backward move of the camera.
  34823. */
  34824. keysBackward: number[];
  34825. /**
  34826. * The list of keyboard keys used to control the forward move of the camera.
  34827. */
  34828. keysUp: number[];
  34829. /**
  34830. * The list of keyboard keys used to control the backward move of the camera.
  34831. */
  34832. keysDown: number[];
  34833. /**
  34834. * The list of keyboard keys used to control the right strafe move of the camera.
  34835. */
  34836. keysRight: number[];
  34837. /**
  34838. * The list of keyboard keys used to control the left strafe move of the camera.
  34839. */
  34840. keysLeft: number[];
  34841. private _keys;
  34842. private _onCanvasBlurObserver;
  34843. private _onKeyboardObserver;
  34844. private _engine;
  34845. private _scene;
  34846. /**
  34847. * Attach the input controls to a specific dom element to get the input from.
  34848. * @param element Defines the element the controls should be listened from
  34849. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34850. */
  34851. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34852. /**
  34853. * Detach the current controls from the specified dom element.
  34854. * @param element Defines the element to stop listening the inputs from
  34855. */
  34856. detachControl(element: Nullable<HTMLElement>): void;
  34857. /**
  34858. * Gets the class name of the current intput.
  34859. * @returns the class name
  34860. */
  34861. getClassName(): string;
  34862. /** @hidden */ onLostFocus(e: FocusEvent): void;
  34863. /**
  34864. * Get the friendly name associated with the input class.
  34865. * @returns the input friendly name
  34866. */
  34867. getSimpleName(): string;
  34868. /**
  34869. * Update the current camera state depending on the inputs that have been used this frame.
  34870. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34871. */
  34872. checkInputs(): void;
  34873. }
  34874. }
  34875. declare module BABYLON {
  34876. interface FreeCameraInputsManager {
  34877. /**
  34878. * Add orientation input support to the input manager.
  34879. * @returns the current input manager
  34880. */
  34881. addDeviceOrientation(): FreeCameraInputsManager;
  34882. }
  34883. /**
  34884. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  34885. * Screen rotation is taken into account.
  34886. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34887. */
  34888. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  34889. private _camera;
  34890. private _screenOrientationAngle;
  34891. private _constantTranform;
  34892. private _screenQuaternion;
  34893. private _alpha;
  34894. private _beta;
  34895. private _gamma;
  34896. /**
  34897. * Instantiates a new input
  34898. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34899. */
  34900. constructor();
  34901. /**
  34902. * Define the camera controlled by the input.
  34903. */
  34904. camera: FreeCamera;
  34905. /**
  34906. * Attach the input controls to a specific dom element to get the input from.
  34907. * @param element Defines the element the controls should be listened from
  34908. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34909. */
  34910. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34911. private _orientationChanged;
  34912. private _deviceOrientation;
  34913. /**
  34914. * Detach the current controls from the specified dom element.
  34915. * @param element Defines the element to stop listening the inputs from
  34916. */
  34917. detachControl(element: Nullable<HTMLElement>): void;
  34918. /**
  34919. * Update the current camera state depending on the inputs that have been used this frame.
  34920. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34921. */
  34922. checkInputs(): void;
  34923. /**
  34924. * Gets the class name of the current intput.
  34925. * @returns the class name
  34926. */
  34927. getClassName(): string;
  34928. /**
  34929. * Get the friendly name associated with the input class.
  34930. * @returns the input friendly name
  34931. */
  34932. getSimpleName(): string;
  34933. }
  34934. }
  34935. declare module BABYLON {
  34936. /**
  34937. * Manage the gamepad inputs to control a free camera.
  34938. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34939. */
  34940. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  34941. /**
  34942. * Define the camera the input is attached to.
  34943. */
  34944. camera: FreeCamera;
  34945. /**
  34946. * Define the Gamepad controlling the input
  34947. */
  34948. gamepad: Nullable<Gamepad>;
  34949. /**
  34950. * Defines the gamepad rotation sensiblity.
  34951. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  34952. */
  34953. gamepadAngularSensibility: number;
  34954. /**
  34955. * Defines the gamepad move sensiblity.
  34956. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  34957. */
  34958. gamepadMoveSensibility: number;
  34959. private _onGamepadConnectedObserver;
  34960. private _onGamepadDisconnectedObserver;
  34961. private _cameraTransform;
  34962. private _deltaTransform;
  34963. private _vector3;
  34964. private _vector2;
  34965. /**
  34966. * Attach the input controls to a specific dom element to get the input from.
  34967. * @param element Defines the element the controls should be listened from
  34968. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34969. */
  34970. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34971. /**
  34972. * Detach the current controls from the specified dom element.
  34973. * @param element Defines the element to stop listening the inputs from
  34974. */
  34975. detachControl(element: Nullable<HTMLElement>): void;
  34976. /**
  34977. * Update the current camera state depending on the inputs that have been used this frame.
  34978. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34979. */
  34980. checkInputs(): void;
  34981. /**
  34982. * Gets the class name of the current intput.
  34983. * @returns the class name
  34984. */
  34985. getClassName(): string;
  34986. /**
  34987. * Get the friendly name associated with the input class.
  34988. * @returns the input friendly name
  34989. */
  34990. getSimpleName(): string;
  34991. }
  34992. }
  34993. declare module BABYLON {
  34994. /**
  34995. * Defines the potential axis of a Joystick
  34996. */
  34997. export enum JoystickAxis {
  34998. /** X axis */
  34999. X = 0,
  35000. /** Y axis */
  35001. Y = 1,
  35002. /** Z axis */
  35003. Z = 2
  35004. }
  35005. /**
  35006. * Class used to define virtual joystick (used in touch mode)
  35007. */
  35008. export class VirtualJoystick {
  35009. /**
  35010. * Gets or sets a boolean indicating that left and right values must be inverted
  35011. */
  35012. reverseLeftRight: boolean;
  35013. /**
  35014. * Gets or sets a boolean indicating that up and down values must be inverted
  35015. */
  35016. reverseUpDown: boolean;
  35017. /**
  35018. * Gets the offset value for the position (ie. the change of the position value)
  35019. */
  35020. deltaPosition: Vector3;
  35021. /**
  35022. * Gets a boolean indicating if the virtual joystick was pressed
  35023. */
  35024. pressed: boolean;
  35025. /**
  35026. * Canvas the virtual joystick will render onto, default z-index of this is 5
  35027. */
  35028. static Canvas: Nullable<HTMLCanvasElement>;
  35029. private static _globalJoystickIndex;
  35030. private static vjCanvasContext;
  35031. private static vjCanvasWidth;
  35032. private static vjCanvasHeight;
  35033. private static halfWidth;
  35034. private _action;
  35035. private _axisTargetedByLeftAndRight;
  35036. private _axisTargetedByUpAndDown;
  35037. private _joystickSensibility;
  35038. private _inversedSensibility;
  35039. private _joystickPointerID;
  35040. private _joystickColor;
  35041. private _joystickPointerPos;
  35042. private _joystickPreviousPointerPos;
  35043. private _joystickPointerStartPos;
  35044. private _deltaJoystickVector;
  35045. private _leftJoystick;
  35046. private _touches;
  35047. private _onPointerDownHandlerRef;
  35048. private _onPointerMoveHandlerRef;
  35049. private _onPointerUpHandlerRef;
  35050. private _onResize;
  35051. /**
  35052. * Creates a new virtual joystick
  35053. * @param leftJoystick defines that the joystick is for left hand (false by default)
  35054. */
  35055. constructor(leftJoystick?: boolean);
  35056. /**
  35057. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  35058. * @param newJoystickSensibility defines the new sensibility
  35059. */
  35060. setJoystickSensibility(newJoystickSensibility: number): void;
  35061. private _onPointerDown;
  35062. private _onPointerMove;
  35063. private _onPointerUp;
  35064. /**
  35065. * Change the color of the virtual joystick
  35066. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  35067. */
  35068. setJoystickColor(newColor: string): void;
  35069. /**
  35070. * Defines a callback to call when the joystick is touched
  35071. * @param action defines the callback
  35072. */
  35073. setActionOnTouch(action: () => any): void;
  35074. /**
  35075. * Defines which axis you'd like to control for left & right
  35076. * @param axis defines the axis to use
  35077. */
  35078. setAxisForLeftRight(axis: JoystickAxis): void;
  35079. /**
  35080. * Defines which axis you'd like to control for up & down
  35081. * @param axis defines the axis to use
  35082. */
  35083. setAxisForUpDown(axis: JoystickAxis): void;
  35084. private _drawVirtualJoystick;
  35085. /**
  35086. * Release internal HTML canvas
  35087. */
  35088. releaseCanvas(): void;
  35089. }
  35090. }
  35091. declare module BABYLON {
  35092. interface FreeCameraInputsManager {
  35093. /**
  35094. * Add virtual joystick input support to the input manager.
  35095. * @returns the current input manager
  35096. */
  35097. addVirtualJoystick(): FreeCameraInputsManager;
  35098. }
  35099. /**
  35100. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  35101. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35102. */
  35103. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  35104. /**
  35105. * Defines the camera the input is attached to.
  35106. */
  35107. camera: FreeCamera;
  35108. private _leftjoystick;
  35109. private _rightjoystick;
  35110. /**
  35111. * Gets the left stick of the virtual joystick.
  35112. * @returns The virtual Joystick
  35113. */
  35114. getLeftJoystick(): VirtualJoystick;
  35115. /**
  35116. * Gets the right stick of the virtual joystick.
  35117. * @returns The virtual Joystick
  35118. */
  35119. getRightJoystick(): VirtualJoystick;
  35120. /**
  35121. * Update the current camera state depending on the inputs that have been used this frame.
  35122. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35123. */
  35124. checkInputs(): void;
  35125. /**
  35126. * Attach the input controls to a specific dom element to get the input from.
  35127. * @param element Defines the element the controls should be listened from
  35128. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35129. */
  35130. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35131. /**
  35132. * Detach the current controls from the specified dom element.
  35133. * @param element Defines the element to stop listening the inputs from
  35134. */
  35135. detachControl(element: Nullable<HTMLElement>): void;
  35136. /**
  35137. * Gets the class name of the current intput.
  35138. * @returns the class name
  35139. */
  35140. getClassName(): string;
  35141. /**
  35142. * Get the friendly name associated with the input class.
  35143. * @returns the input friendly name
  35144. */
  35145. getSimpleName(): string;
  35146. }
  35147. }
  35148. declare module BABYLON {
  35149. /**
  35150. * This represents a FPS type of camera controlled by touch.
  35151. * This is like a universal camera minus the Gamepad controls.
  35152. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  35153. */
  35154. export class TouchCamera extends FreeCamera {
  35155. /**
  35156. * Defines the touch sensibility for rotation.
  35157. * The higher the faster.
  35158. */
  35159. touchAngularSensibility: number;
  35160. /**
  35161. * Defines the touch sensibility for move.
  35162. * The higher the faster.
  35163. */
  35164. touchMoveSensibility: number;
  35165. /**
  35166. * Instantiates a new touch camera.
  35167. * This represents a FPS type of camera controlled by touch.
  35168. * This is like a universal camera minus the Gamepad controls.
  35169. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  35170. * @param name Define the name of the camera in the scene
  35171. * @param position Define the start position of the camera in the scene
  35172. * @param scene Define the scene the camera belongs to
  35173. */
  35174. constructor(name: string, position: Vector3, scene: Scene);
  35175. /**
  35176. * Gets the current object class name.
  35177. * @return the class name
  35178. */
  35179. getClassName(): string;
  35180. /** @hidden */ setupInputs(): void;
  35181. }
  35182. }
  35183. declare module BABYLON {
  35184. /**
  35185. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  35186. * being tilted forward or back and left or right.
  35187. */
  35188. export class DeviceOrientationCamera extends FreeCamera {
  35189. private _initialQuaternion;
  35190. private _quaternionCache;
  35191. /**
  35192. * Creates a new device orientation camera
  35193. * @param name The name of the camera
  35194. * @param position The start position camera
  35195. * @param scene The scene the camera belongs to
  35196. */
  35197. constructor(name: string, position: Vector3, scene: Scene);
  35198. /**
  35199. * Gets the current instance class name ("DeviceOrientationCamera").
  35200. * This helps avoiding instanceof at run time.
  35201. * @returns the class name
  35202. */
  35203. getClassName(): string;
  35204. /**
  35205. * @hidden
  35206. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  35207. */ checkInputs(): void;
  35208. /**
  35209. * Reset the camera to its default orientation on the specified axis only.
  35210. * @param axis The axis to reset
  35211. */
  35212. resetToCurrentRotation(axis?: Axis): void;
  35213. }
  35214. }
  35215. declare module BABYLON {
  35216. /**
  35217. * Manage the keyboard inputs to control the movement of a follow camera.
  35218. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35219. */
  35220. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  35221. /**
  35222. * Defines the camera the input is attached to.
  35223. */
  35224. camera: FollowCamera;
  35225. /**
  35226. * Defines the list of key codes associated with the up action (increase heightOffset)
  35227. */
  35228. keysHeightOffsetIncr: number[];
  35229. /**
  35230. * Defines the list of key codes associated with the down action (decrease heightOffset)
  35231. */
  35232. keysHeightOffsetDecr: number[];
  35233. /**
  35234. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  35235. */
  35236. keysHeightOffsetModifierAlt: boolean;
  35237. /**
  35238. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  35239. */
  35240. keysHeightOffsetModifierCtrl: boolean;
  35241. /**
  35242. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  35243. */
  35244. keysHeightOffsetModifierShift: boolean;
  35245. /**
  35246. * Defines the list of key codes associated with the left action (increase rotationOffset)
  35247. */
  35248. keysRotationOffsetIncr: number[];
  35249. /**
  35250. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  35251. */
  35252. keysRotationOffsetDecr: number[];
  35253. /**
  35254. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  35255. */
  35256. keysRotationOffsetModifierAlt: boolean;
  35257. /**
  35258. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  35259. */
  35260. keysRotationOffsetModifierCtrl: boolean;
  35261. /**
  35262. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  35263. */
  35264. keysRotationOffsetModifierShift: boolean;
  35265. /**
  35266. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  35267. */
  35268. keysRadiusIncr: number[];
  35269. /**
  35270. * Defines the list of key codes associated with the zoom-out action (increase radius)
  35271. */
  35272. keysRadiusDecr: number[];
  35273. /**
  35274. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  35275. */
  35276. keysRadiusModifierAlt: boolean;
  35277. /**
  35278. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  35279. */
  35280. keysRadiusModifierCtrl: boolean;
  35281. /**
  35282. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  35283. */
  35284. keysRadiusModifierShift: boolean;
  35285. /**
  35286. * Defines the rate of change of heightOffset.
  35287. */
  35288. heightSensibility: number;
  35289. /**
  35290. * Defines the rate of change of rotationOffset.
  35291. */
  35292. rotationSensibility: number;
  35293. /**
  35294. * Defines the rate of change of radius.
  35295. */
  35296. radiusSensibility: number;
  35297. private _keys;
  35298. private _ctrlPressed;
  35299. private _altPressed;
  35300. private _shiftPressed;
  35301. private _onCanvasBlurObserver;
  35302. private _onKeyboardObserver;
  35303. private _engine;
  35304. private _scene;
  35305. /**
  35306. * Attach the input controls to a specific dom element to get the input from.
  35307. * @param element Defines the element the controls should be listened from
  35308. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35309. */
  35310. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35311. /**
  35312. * Detach the current controls from the specified dom element.
  35313. * @param element Defines the element to stop listening the inputs from
  35314. */
  35315. detachControl(element: Nullable<HTMLElement>): void;
  35316. /**
  35317. * Update the current camera state depending on the inputs that have been used this frame.
  35318. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35319. */
  35320. checkInputs(): void;
  35321. /**
  35322. * Gets the class name of the current input.
  35323. * @returns the class name
  35324. */
  35325. getClassName(): string;
  35326. /**
  35327. * Get the friendly name associated with the input class.
  35328. * @returns the input friendly name
  35329. */
  35330. getSimpleName(): string;
  35331. /**
  35332. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  35333. * allow modification of the heightOffset value.
  35334. */
  35335. private _modifierHeightOffset;
  35336. /**
  35337. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  35338. * allow modification of the rotationOffset value.
  35339. */
  35340. private _modifierRotationOffset;
  35341. /**
  35342. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  35343. * allow modification of the radius value.
  35344. */
  35345. private _modifierRadius;
  35346. }
  35347. }
  35348. declare module BABYLON {
  35349. /**
  35350. * Manage the mouse wheel inputs to control a follow camera.
  35351. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35352. */
  35353. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  35354. /**
  35355. * Defines the camera the input is attached to.
  35356. */
  35357. camera: FollowCamera;
  35358. /**
  35359. * Moue wheel controls zoom. (Moue wheel modifies camera.radius value.)
  35360. */
  35361. axisControlRadius: boolean;
  35362. /**
  35363. * Moue wheel controls height. (Moue wheel modifies camera.heightOffset value.)
  35364. */
  35365. axisControlHeight: boolean;
  35366. /**
  35367. * Moue wheel controls angle. (Moue wheel modifies camera.rotationOffset value.)
  35368. */
  35369. axisControlRotation: boolean;
  35370. /**
  35371. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  35372. * relation to mouseWheel events.
  35373. */
  35374. wheelPrecision: number;
  35375. /**
  35376. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35377. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35378. */
  35379. wheelDeltaPercentage: number;
  35380. private _wheel;
  35381. private _observer;
  35382. /**
  35383. * Attach the input controls to a specific dom element to get the input from.
  35384. * @param element Defines the element the controls should be listened from
  35385. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35386. */
  35387. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35388. /**
  35389. * Detach the current controls from the specified dom element.
  35390. * @param element Defines the element to stop listening the inputs from
  35391. */
  35392. detachControl(element: Nullable<HTMLElement>): void;
  35393. /**
  35394. * Gets the class name of the current intput.
  35395. * @returns the class name
  35396. */
  35397. getClassName(): string;
  35398. /**
  35399. * Get the friendly name associated with the input class.
  35400. * @returns the input friendly name
  35401. */
  35402. getSimpleName(): string;
  35403. }
  35404. }
  35405. declare module BABYLON {
  35406. /**
  35407. * Default Inputs manager for the FollowCamera.
  35408. * It groups all the default supported inputs for ease of use.
  35409. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35410. */
  35411. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  35412. /**
  35413. * Instantiates a new FollowCameraInputsManager.
  35414. * @param camera Defines the camera the inputs belong to
  35415. */
  35416. constructor(camera: FollowCamera);
  35417. /**
  35418. * Add keyboard input support to the input manager.
  35419. * @returns the current input manager
  35420. */
  35421. addKeyboard(): FollowCameraInputsManager;
  35422. /**
  35423. * Add mouse wheel input support to the input manager.
  35424. * @returns the current input manager
  35425. */
  35426. addMouseWheel(): FollowCameraInputsManager;
  35427. /**
  35428. * Add pointers input support to the input manager.
  35429. * @returns the current input manager
  35430. */
  35431. addPointers(): FollowCameraInputsManager;
  35432. /**
  35433. * Add orientation input support to the input manager.
  35434. * @returns the current input manager
  35435. */
  35436. addVRDeviceOrientation(): FollowCameraInputsManager;
  35437. }
  35438. }
  35439. declare module BABYLON {
  35440. /**
  35441. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  35442. * an arc rotate version arcFollowCamera are available.
  35443. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  35444. */
  35445. export class FollowCamera extends TargetCamera {
  35446. /**
  35447. * Distance the follow camera should follow an object at
  35448. */
  35449. radius: number;
  35450. /**
  35451. * Minimum allowed distance of the camera to the axis of rotation
  35452. * (The camera can not get closer).
  35453. * This can help limiting how the Camera is able to move in the scene.
  35454. */
  35455. lowerRadiusLimit: Nullable<number>;
  35456. /**
  35457. * Maximum allowed distance of the camera to the axis of rotation
  35458. * (The camera can not get further).
  35459. * This can help limiting how the Camera is able to move in the scene.
  35460. */
  35461. upperRadiusLimit: Nullable<number>;
  35462. /**
  35463. * Define a rotation offset between the camera and the object it follows
  35464. */
  35465. rotationOffset: number;
  35466. /**
  35467. * Minimum allowed angle to camera position relative to target object.
  35468. * This can help limiting how the Camera is able to move in the scene.
  35469. */
  35470. lowerRotationOffsetLimit: Nullable<number>;
  35471. /**
  35472. * Maximum allowed angle to camera position relative to target object.
  35473. * This can help limiting how the Camera is able to move in the scene.
  35474. */
  35475. upperRotationOffsetLimit: Nullable<number>;
  35476. /**
  35477. * Define a height offset between the camera and the object it follows.
  35478. * It can help following an object from the top (like a car chaing a plane)
  35479. */
  35480. heightOffset: number;
  35481. /**
  35482. * Minimum allowed height of camera position relative to target object.
  35483. * This can help limiting how the Camera is able to move in the scene.
  35484. */
  35485. lowerHeightOffsetLimit: Nullable<number>;
  35486. /**
  35487. * Maximum allowed height of camera position relative to target object.
  35488. * This can help limiting how the Camera is able to move in the scene.
  35489. */
  35490. upperHeightOffsetLimit: Nullable<number>;
  35491. /**
  35492. * Define how fast the camera can accelerate to follow it s target.
  35493. */
  35494. cameraAcceleration: number;
  35495. /**
  35496. * Define the speed limit of the camera following an object.
  35497. */
  35498. maxCameraSpeed: number;
  35499. /**
  35500. * Define the target of the camera.
  35501. */
  35502. lockedTarget: Nullable<AbstractMesh>;
  35503. /**
  35504. * Defines the input associated with the camera.
  35505. */
  35506. inputs: FollowCameraInputsManager;
  35507. /**
  35508. * Instantiates the follow camera.
  35509. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  35510. * @param name Define the name of the camera in the scene
  35511. * @param position Define the position of the camera
  35512. * @param scene Define the scene the camera belong to
  35513. * @param lockedTarget Define the target of the camera
  35514. */
  35515. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  35516. private _follow;
  35517. /**
  35518. * Attached controls to the current camera.
  35519. * @param element Defines the element the controls should be listened from
  35520. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35521. */
  35522. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35523. /**
  35524. * Detach the current controls from the camera.
  35525. * The camera will stop reacting to inputs.
  35526. * @param element Defines the element to stop listening the inputs from
  35527. */
  35528. detachControl(element: HTMLElement): void;
  35529. /** @hidden */ checkInputs(): void;
  35530. private _checkLimits;
  35531. /**
  35532. * Gets the camera class name.
  35533. * @returns the class name
  35534. */
  35535. getClassName(): string;
  35536. }
  35537. /**
  35538. * Arc Rotate version of the follow camera.
  35539. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  35540. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  35541. */
  35542. export class ArcFollowCamera extends TargetCamera {
  35543. /** The longitudinal angle of the camera */
  35544. alpha: number;
  35545. /** The latitudinal angle of the camera */
  35546. beta: number;
  35547. /** The radius of the camera from its target */
  35548. radius: number;
  35549. /** Define the camera target (the messh it should follow) */
  35550. target: Nullable<AbstractMesh>;
  35551. private _cartesianCoordinates;
  35552. /**
  35553. * Instantiates a new ArcFollowCamera
  35554. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  35555. * @param name Define the name of the camera
  35556. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  35557. * @param beta Define the rotation angle of the camera around the elevation axis
  35558. * @param radius Define the radius of the camera from its target point
  35559. * @param target Define the target of the camera
  35560. * @param scene Define the scene the camera belongs to
  35561. */
  35562. constructor(name: string,
  35563. /** The longitudinal angle of the camera */
  35564. alpha: number,
  35565. /** The latitudinal angle of the camera */
  35566. beta: number,
  35567. /** The radius of the camera from its target */
  35568. radius: number,
  35569. /** Define the camera target (the messh it should follow) */
  35570. target: Nullable<AbstractMesh>, scene: Scene);
  35571. private _follow;
  35572. /** @hidden */ checkInputs(): void;
  35573. /**
  35574. * Returns the class name of the object.
  35575. * It is mostly used internally for serialization purposes.
  35576. */
  35577. getClassName(): string;
  35578. }
  35579. }
  35580. declare module BABYLON {
  35581. /**
  35582. * 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,
  35583. * which still works and will still be found in many Playgrounds.
  35584. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  35585. */
  35586. export class UniversalCamera extends TouchCamera {
  35587. /**
  35588. * Defines the gamepad rotation sensiblity.
  35589. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35590. */
  35591. gamepadAngularSensibility: number;
  35592. /**
  35593. * Defines the gamepad move sensiblity.
  35594. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35595. */
  35596. gamepadMoveSensibility: number;
  35597. /**
  35598. * 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,
  35599. * which still works and will still be found in many Playgrounds.
  35600. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  35601. * @param name Define the name of the camera in the scene
  35602. * @param position Define the start position of the camera in the scene
  35603. * @param scene Define the scene the camera belongs to
  35604. */
  35605. constructor(name: string, position: Vector3, scene: Scene);
  35606. /**
  35607. * Gets the current object class name.
  35608. * @return the class name
  35609. */
  35610. getClassName(): string;
  35611. }
  35612. }
  35613. declare module BABYLON {
  35614. /**
  35615. * This represents a FPS type of camera. This is only here for back compat purpose.
  35616. * Please use the UniversalCamera instead as both are identical.
  35617. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  35618. */
  35619. export class GamepadCamera extends UniversalCamera {
  35620. /**
  35621. * Instantiates a new Gamepad Camera
  35622. * This represents a FPS type of camera. This is only here for back compat purpose.
  35623. * Please use the UniversalCamera instead as both are identical.
  35624. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  35625. * @param name Define the name of the camera in the scene
  35626. * @param position Define the start position of the camera in the scene
  35627. * @param scene Define the scene the camera belongs to
  35628. */
  35629. constructor(name: string, position: Vector3, scene: Scene);
  35630. /**
  35631. * Gets the current object class name.
  35632. * @return the class name
  35633. */
  35634. getClassName(): string;
  35635. }
  35636. }
  35637. declare module BABYLON {
  35638. /** @hidden */
  35639. export var passPixelShader: {
  35640. name: string;
  35641. shader: string;
  35642. };
  35643. }
  35644. declare module BABYLON {
  35645. /** @hidden */
  35646. export var passCubePixelShader: {
  35647. name: string;
  35648. shader: string;
  35649. };
  35650. }
  35651. declare module BABYLON {
  35652. /**
  35653. * PassPostProcess which produces an output the same as it's input
  35654. */
  35655. export class PassPostProcess extends PostProcess {
  35656. /**
  35657. * Creates the PassPostProcess
  35658. * @param name The name of the effect.
  35659. * @param options The required width/height ratio to downsize to before computing the render pass.
  35660. * @param camera The camera to apply the render pass to.
  35661. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35662. * @param engine The engine which the post process will be applied. (default: current engine)
  35663. * @param reusable If the post process can be reused on the same frame. (default: false)
  35664. * @param textureType The type of texture to be used when performing the post processing.
  35665. * @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)
  35666. */
  35667. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35668. }
  35669. /**
  35670. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  35671. */
  35672. export class PassCubePostProcess extends PostProcess {
  35673. private _face;
  35674. /**
  35675. * Gets or sets the cube face to display.
  35676. * * 0 is +X
  35677. * * 1 is -X
  35678. * * 2 is +Y
  35679. * * 3 is -Y
  35680. * * 4 is +Z
  35681. * * 5 is -Z
  35682. */
  35683. face: number;
  35684. /**
  35685. * Creates the PassCubePostProcess
  35686. * @param name The name of the effect.
  35687. * @param options The required width/height ratio to downsize to before computing the render pass.
  35688. * @param camera The camera to apply the render pass to.
  35689. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35690. * @param engine The engine which the post process will be applied. (default: current engine)
  35691. * @param reusable If the post process can be reused on the same frame. (default: false)
  35692. * @param textureType The type of texture to be used when performing the post processing.
  35693. * @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)
  35694. */
  35695. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35696. }
  35697. }
  35698. declare module BABYLON {
  35699. /** @hidden */
  35700. export var anaglyphPixelShader: {
  35701. name: string;
  35702. shader: string;
  35703. };
  35704. }
  35705. declare module BABYLON {
  35706. /**
  35707. * Postprocess used to generate anaglyphic rendering
  35708. */
  35709. export class AnaglyphPostProcess extends PostProcess {
  35710. private _passedProcess;
  35711. /**
  35712. * Creates a new AnaglyphPostProcess
  35713. * @param name defines postprocess name
  35714. * @param options defines creation options or target ratio scale
  35715. * @param rigCameras defines cameras using this postprocess
  35716. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  35717. * @param engine defines hosting engine
  35718. * @param reusable defines if the postprocess will be reused multiple times per frame
  35719. */
  35720. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  35721. }
  35722. }
  35723. declare module BABYLON {
  35724. /**
  35725. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  35726. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  35727. */
  35728. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  35729. /**
  35730. * Creates a new AnaglyphArcRotateCamera
  35731. * @param name defines camera name
  35732. * @param alpha defines alpha angle (in radians)
  35733. * @param beta defines beta angle (in radians)
  35734. * @param radius defines radius
  35735. * @param target defines camera target
  35736. * @param interaxialDistance defines distance between each color axis
  35737. * @param scene defines the hosting scene
  35738. */
  35739. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  35740. /**
  35741. * Gets camera class name
  35742. * @returns AnaglyphArcRotateCamera
  35743. */
  35744. getClassName(): string;
  35745. }
  35746. }
  35747. declare module BABYLON {
  35748. /**
  35749. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  35750. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  35751. */
  35752. export class AnaglyphFreeCamera extends FreeCamera {
  35753. /**
  35754. * Creates a new AnaglyphFreeCamera
  35755. * @param name defines camera name
  35756. * @param position defines initial position
  35757. * @param interaxialDistance defines distance between each color axis
  35758. * @param scene defines the hosting scene
  35759. */
  35760. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  35761. /**
  35762. * Gets camera class name
  35763. * @returns AnaglyphFreeCamera
  35764. */
  35765. getClassName(): string;
  35766. }
  35767. }
  35768. declare module BABYLON {
  35769. /**
  35770. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  35771. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  35772. */
  35773. export class AnaglyphGamepadCamera extends GamepadCamera {
  35774. /**
  35775. * Creates a new AnaglyphGamepadCamera
  35776. * @param name defines camera name
  35777. * @param position defines initial position
  35778. * @param interaxialDistance defines distance between each color axis
  35779. * @param scene defines the hosting scene
  35780. */
  35781. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  35782. /**
  35783. * Gets camera class name
  35784. * @returns AnaglyphGamepadCamera
  35785. */
  35786. getClassName(): string;
  35787. }
  35788. }
  35789. declare module BABYLON {
  35790. /**
  35791. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  35792. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  35793. */
  35794. export class AnaglyphUniversalCamera extends UniversalCamera {
  35795. /**
  35796. * Creates a new AnaglyphUniversalCamera
  35797. * @param name defines camera name
  35798. * @param position defines initial position
  35799. * @param interaxialDistance defines distance between each color axis
  35800. * @param scene defines the hosting scene
  35801. */
  35802. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  35803. /**
  35804. * Gets camera class name
  35805. * @returns AnaglyphUniversalCamera
  35806. */
  35807. getClassName(): string;
  35808. }
  35809. }
  35810. declare module BABYLON {
  35811. /** @hidden */
  35812. export var stereoscopicInterlacePixelShader: {
  35813. name: string;
  35814. shader: string;
  35815. };
  35816. }
  35817. declare module BABYLON {
  35818. /**
  35819. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  35820. */
  35821. export class StereoscopicInterlacePostProcess extends PostProcess {
  35822. private _stepSize;
  35823. private _passedProcess;
  35824. /**
  35825. * Initializes a StereoscopicInterlacePostProcess
  35826. * @param name The name of the effect.
  35827. * @param rigCameras The rig cameras to be appled to the post process
  35828. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  35829. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35830. * @param engine The engine which the post process will be applied. (default: current engine)
  35831. * @param reusable If the post process can be reused on the same frame. (default: false)
  35832. */
  35833. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35834. }
  35835. }
  35836. declare module BABYLON {
  35837. /**
  35838. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  35839. * @see http://doc.babylonjs.com/features/cameras
  35840. */
  35841. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  35842. /**
  35843. * Creates a new StereoscopicArcRotateCamera
  35844. * @param name defines camera name
  35845. * @param alpha defines alpha angle (in radians)
  35846. * @param beta defines beta angle (in radians)
  35847. * @param radius defines radius
  35848. * @param target defines camera target
  35849. * @param interaxialDistance defines distance between each color axis
  35850. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  35851. * @param scene defines the hosting scene
  35852. */
  35853. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  35854. /**
  35855. * Gets camera class name
  35856. * @returns StereoscopicArcRotateCamera
  35857. */
  35858. getClassName(): string;
  35859. }
  35860. }
  35861. declare module BABYLON {
  35862. /**
  35863. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  35864. * @see http://doc.babylonjs.com/features/cameras
  35865. */
  35866. export class StereoscopicFreeCamera extends FreeCamera {
  35867. /**
  35868. * Creates a new StereoscopicFreeCamera
  35869. * @param name defines camera name
  35870. * @param position defines initial position
  35871. * @param interaxialDistance defines distance between each color axis
  35872. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  35873. * @param scene defines the hosting scene
  35874. */
  35875. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  35876. /**
  35877. * Gets camera class name
  35878. * @returns StereoscopicFreeCamera
  35879. */
  35880. getClassName(): string;
  35881. }
  35882. }
  35883. declare module BABYLON {
  35884. /**
  35885. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  35886. * @see http://doc.babylonjs.com/features/cameras
  35887. */
  35888. export class StereoscopicGamepadCamera extends GamepadCamera {
  35889. /**
  35890. * Creates a new StereoscopicGamepadCamera
  35891. * @param name defines camera name
  35892. * @param position defines initial position
  35893. * @param interaxialDistance defines distance between each color axis
  35894. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  35895. * @param scene defines the hosting scene
  35896. */
  35897. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  35898. /**
  35899. * Gets camera class name
  35900. * @returns StereoscopicGamepadCamera
  35901. */
  35902. getClassName(): string;
  35903. }
  35904. }
  35905. declare module BABYLON {
  35906. /**
  35907. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  35908. * @see http://doc.babylonjs.com/features/cameras
  35909. */
  35910. export class StereoscopicUniversalCamera extends UniversalCamera {
  35911. /**
  35912. * Creates a new StereoscopicUniversalCamera
  35913. * @param name defines camera name
  35914. * @param position defines initial position
  35915. * @param interaxialDistance defines distance between each color axis
  35916. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  35917. * @param scene defines the hosting scene
  35918. */
  35919. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  35920. /**
  35921. * Gets camera class name
  35922. * @returns StereoscopicUniversalCamera
  35923. */
  35924. getClassName(): string;
  35925. }
  35926. }
  35927. declare module BABYLON {
  35928. /**
  35929. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  35930. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  35931. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  35932. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  35933. */
  35934. export class VirtualJoysticksCamera extends FreeCamera {
  35935. /**
  35936. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  35937. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  35938. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  35939. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  35940. * @param name Define the name of the camera in the scene
  35941. * @param position Define the start position of the camera in the scene
  35942. * @param scene Define the scene the camera belongs to
  35943. */
  35944. constructor(name: string, position: Vector3, scene: Scene);
  35945. /**
  35946. * Gets the current object class name.
  35947. * @return the class name
  35948. */
  35949. getClassName(): string;
  35950. }
  35951. }
  35952. declare module BABYLON {
  35953. /**
  35954. * This represents all the required metrics to create a VR camera.
  35955. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  35956. */
  35957. export class VRCameraMetrics {
  35958. /**
  35959. * Define the horizontal resolution off the screen.
  35960. */
  35961. hResolution: number;
  35962. /**
  35963. * Define the vertical resolution off the screen.
  35964. */
  35965. vResolution: number;
  35966. /**
  35967. * Define the horizontal screen size.
  35968. */
  35969. hScreenSize: number;
  35970. /**
  35971. * Define the vertical screen size.
  35972. */
  35973. vScreenSize: number;
  35974. /**
  35975. * Define the vertical screen center position.
  35976. */
  35977. vScreenCenter: number;
  35978. /**
  35979. * Define the distance of the eyes to the screen.
  35980. */
  35981. eyeToScreenDistance: number;
  35982. /**
  35983. * Define the distance between both lenses
  35984. */
  35985. lensSeparationDistance: number;
  35986. /**
  35987. * Define the distance between both viewer's eyes.
  35988. */
  35989. interpupillaryDistance: number;
  35990. /**
  35991. * Define the distortion factor of the VR postprocess.
  35992. * Please, touch with care.
  35993. */
  35994. distortionK: number[];
  35995. /**
  35996. * Define the chromatic aberration correction factors for the VR post process.
  35997. */
  35998. chromaAbCorrection: number[];
  35999. /**
  36000. * Define the scale factor of the post process.
  36001. * The smaller the better but the slower.
  36002. */
  36003. postProcessScaleFactor: number;
  36004. /**
  36005. * Define an offset for the lens center.
  36006. */
  36007. lensCenterOffset: number;
  36008. /**
  36009. * Define if the current vr camera should compensate the distortion of the lense or not.
  36010. */
  36011. compensateDistortion: boolean;
  36012. /**
  36013. * Gets the rendering aspect ratio based on the provided resolutions.
  36014. */
  36015. readonly aspectRatio: number;
  36016. /**
  36017. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  36018. */
  36019. readonly aspectRatioFov: number;
  36020. /**
  36021. * @hidden
  36022. */
  36023. readonly leftHMatrix: Matrix;
  36024. /**
  36025. * @hidden
  36026. */
  36027. readonly rightHMatrix: Matrix;
  36028. /**
  36029. * @hidden
  36030. */
  36031. readonly leftPreViewMatrix: Matrix;
  36032. /**
  36033. * @hidden
  36034. */
  36035. readonly rightPreViewMatrix: Matrix;
  36036. /**
  36037. * Get the default VRMetrics based on the most generic setup.
  36038. * @returns the default vr metrics
  36039. */
  36040. static GetDefault(): VRCameraMetrics;
  36041. }
  36042. }
  36043. declare module BABYLON {
  36044. /** @hidden */
  36045. export var vrDistortionCorrectionPixelShader: {
  36046. name: string;
  36047. shader: string;
  36048. };
  36049. }
  36050. declare module BABYLON {
  36051. /**
  36052. * VRDistortionCorrectionPostProcess used for mobile VR
  36053. */
  36054. export class VRDistortionCorrectionPostProcess extends PostProcess {
  36055. private _isRightEye;
  36056. private _distortionFactors;
  36057. private _postProcessScaleFactor;
  36058. private _lensCenterOffset;
  36059. private _scaleIn;
  36060. private _scaleFactor;
  36061. private _lensCenter;
  36062. /**
  36063. * Initializes the VRDistortionCorrectionPostProcess
  36064. * @param name The name of the effect.
  36065. * @param camera The camera to apply the render pass to.
  36066. * @param isRightEye If this is for the right eye distortion
  36067. * @param vrMetrics All the required metrics for the VR camera
  36068. */
  36069. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  36070. }
  36071. }
  36072. declare module BABYLON {
  36073. /**
  36074. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  36075. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  36076. */
  36077. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  36078. /**
  36079. * Creates a new VRDeviceOrientationArcRotateCamera
  36080. * @param name defines camera name
  36081. * @param alpha defines the camera rotation along the logitudinal axis
  36082. * @param beta defines the camera rotation along the latitudinal axis
  36083. * @param radius defines the camera distance from its target
  36084. * @param target defines the camera target
  36085. * @param scene defines the scene the camera belongs to
  36086. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  36087. * @param vrCameraMetrics defines the vr metrics associated to the camera
  36088. */
  36089. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  36090. /**
  36091. * Gets camera class name
  36092. * @returns VRDeviceOrientationArcRotateCamera
  36093. */
  36094. getClassName(): string;
  36095. }
  36096. }
  36097. declare module BABYLON {
  36098. /**
  36099. * Camera used to simulate VR rendering (based on FreeCamera)
  36100. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  36101. */
  36102. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  36103. /**
  36104. * Creates a new VRDeviceOrientationFreeCamera
  36105. * @param name defines camera name
  36106. * @param position defines the start position of the camera
  36107. * @param scene defines the scene the camera belongs to
  36108. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  36109. * @param vrCameraMetrics defines the vr metrics associated to the camera
  36110. */
  36111. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  36112. /**
  36113. * Gets camera class name
  36114. * @returns VRDeviceOrientationFreeCamera
  36115. */
  36116. getClassName(): string;
  36117. }
  36118. }
  36119. declare module BABYLON {
  36120. /**
  36121. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  36122. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  36123. */
  36124. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  36125. /**
  36126. * Creates a new VRDeviceOrientationGamepadCamera
  36127. * @param name defines camera name
  36128. * @param position defines the start position of the camera
  36129. * @param scene defines the scene the camera belongs to
  36130. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  36131. * @param vrCameraMetrics defines the vr metrics associated to the camera
  36132. */
  36133. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  36134. /**
  36135. * Gets camera class name
  36136. * @returns VRDeviceOrientationGamepadCamera
  36137. */
  36138. getClassName(): string;
  36139. }
  36140. }
  36141. declare module BABYLON {
  36142. /**
  36143. * Defines supported buttons for XBox360 compatible gamepads
  36144. */
  36145. export enum Xbox360Button {
  36146. /** A */
  36147. A = 0,
  36148. /** B */
  36149. B = 1,
  36150. /** X */
  36151. X = 2,
  36152. /** Y */
  36153. Y = 3,
  36154. /** Start */
  36155. Start = 4,
  36156. /** Back */
  36157. Back = 5,
  36158. /** Left button */
  36159. LB = 6,
  36160. /** Right button */
  36161. RB = 7,
  36162. /** Left stick */
  36163. LeftStick = 8,
  36164. /** Right stick */
  36165. RightStick = 9
  36166. }
  36167. /** Defines values for XBox360 DPad */
  36168. export enum Xbox360Dpad {
  36169. /** Up */
  36170. Up = 0,
  36171. /** Down */
  36172. Down = 1,
  36173. /** Left */
  36174. Left = 2,
  36175. /** Right */
  36176. Right = 3
  36177. }
  36178. /**
  36179. * Defines a XBox360 gamepad
  36180. */
  36181. export class Xbox360Pad extends Gamepad {
  36182. private _leftTrigger;
  36183. private _rightTrigger;
  36184. private _onlefttriggerchanged;
  36185. private _onrighttriggerchanged;
  36186. private _onbuttondown;
  36187. private _onbuttonup;
  36188. private _ondpaddown;
  36189. private _ondpadup;
  36190. /** Observable raised when a button is pressed */
  36191. onButtonDownObservable: Observable<Xbox360Button>;
  36192. /** Observable raised when a button is released */
  36193. onButtonUpObservable: Observable<Xbox360Button>;
  36194. /** Observable raised when a pad is pressed */
  36195. onPadDownObservable: Observable<Xbox360Dpad>;
  36196. /** Observable raised when a pad is released */
  36197. onPadUpObservable: Observable<Xbox360Dpad>;
  36198. private _buttonA;
  36199. private _buttonB;
  36200. private _buttonX;
  36201. private _buttonY;
  36202. private _buttonBack;
  36203. private _buttonStart;
  36204. private _buttonLB;
  36205. private _buttonRB;
  36206. private _buttonLeftStick;
  36207. private _buttonRightStick;
  36208. private _dPadUp;
  36209. private _dPadDown;
  36210. private _dPadLeft;
  36211. private _dPadRight;
  36212. private _isXboxOnePad;
  36213. /**
  36214. * Creates a new XBox360 gamepad object
  36215. * @param id defines the id of this gamepad
  36216. * @param index defines its index
  36217. * @param gamepad defines the internal HTML gamepad object
  36218. * @param xboxOne defines if it is a XBox One gamepad
  36219. */
  36220. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  36221. /**
  36222. * Defines the callback to call when left trigger is pressed
  36223. * @param callback defines the callback to use
  36224. */
  36225. onlefttriggerchanged(callback: (value: number) => void): void;
  36226. /**
  36227. * Defines the callback to call when right trigger is pressed
  36228. * @param callback defines the callback to use
  36229. */
  36230. onrighttriggerchanged(callback: (value: number) => void): void;
  36231. /**
  36232. * Gets the left trigger value
  36233. */
  36234. /**
  36235. * Sets the left trigger value
  36236. */
  36237. leftTrigger: number;
  36238. /**
  36239. * Gets the right trigger value
  36240. */
  36241. /**
  36242. * Sets the right trigger value
  36243. */
  36244. rightTrigger: number;
  36245. /**
  36246. * Defines the callback to call when a button is pressed
  36247. * @param callback defines the callback to use
  36248. */
  36249. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  36250. /**
  36251. * Defines the callback to call when a button is released
  36252. * @param callback defines the callback to use
  36253. */
  36254. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  36255. /**
  36256. * Defines the callback to call when a pad is pressed
  36257. * @param callback defines the callback to use
  36258. */
  36259. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  36260. /**
  36261. * Defines the callback to call when a pad is released
  36262. * @param callback defines the callback to use
  36263. */
  36264. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  36265. private _setButtonValue;
  36266. private _setDPadValue;
  36267. /**
  36268. * Gets the value of the `A` button
  36269. */
  36270. /**
  36271. * Sets the value of the `A` button
  36272. */
  36273. buttonA: number;
  36274. /**
  36275. * Gets the value of the `B` button
  36276. */
  36277. /**
  36278. * Sets the value of the `B` button
  36279. */
  36280. buttonB: number;
  36281. /**
  36282. * Gets the value of the `X` button
  36283. */
  36284. /**
  36285. * Sets the value of the `X` button
  36286. */
  36287. buttonX: number;
  36288. /**
  36289. * Gets the value of the `Y` button
  36290. */
  36291. /**
  36292. * Sets the value of the `Y` button
  36293. */
  36294. buttonY: number;
  36295. /**
  36296. * Gets the value of the `Start` button
  36297. */
  36298. /**
  36299. * Sets the value of the `Start` button
  36300. */
  36301. buttonStart: number;
  36302. /**
  36303. * Gets the value of the `Back` button
  36304. */
  36305. /**
  36306. * Sets the value of the `Back` button
  36307. */
  36308. buttonBack: number;
  36309. /**
  36310. * Gets the value of the `Left` button
  36311. */
  36312. /**
  36313. * Sets the value of the `Left` button
  36314. */
  36315. buttonLB: number;
  36316. /**
  36317. * Gets the value of the `Right` button
  36318. */
  36319. /**
  36320. * Sets the value of the `Right` button
  36321. */
  36322. buttonRB: number;
  36323. /**
  36324. * Gets the value of the Left joystick
  36325. */
  36326. /**
  36327. * Sets the value of the Left joystick
  36328. */
  36329. buttonLeftStick: number;
  36330. /**
  36331. * Gets the value of the Right joystick
  36332. */
  36333. /**
  36334. * Sets the value of the Right joystick
  36335. */
  36336. buttonRightStick: number;
  36337. /**
  36338. * Gets the value of D-pad up
  36339. */
  36340. /**
  36341. * Sets the value of D-pad up
  36342. */
  36343. dPadUp: number;
  36344. /**
  36345. * Gets the value of D-pad down
  36346. */
  36347. /**
  36348. * Sets the value of D-pad down
  36349. */
  36350. dPadDown: number;
  36351. /**
  36352. * Gets the value of D-pad left
  36353. */
  36354. /**
  36355. * Sets the value of D-pad left
  36356. */
  36357. dPadLeft: number;
  36358. /**
  36359. * Gets the value of D-pad right
  36360. */
  36361. /**
  36362. * Sets the value of D-pad right
  36363. */
  36364. dPadRight: number;
  36365. /**
  36366. * Force the gamepad to synchronize with device values
  36367. */
  36368. update(): void;
  36369. /**
  36370. * Disposes the gamepad
  36371. */
  36372. dispose(): void;
  36373. }
  36374. }
  36375. declare module BABYLON {
  36376. /**
  36377. * Base class of materials working in push mode in babylon JS
  36378. * @hidden
  36379. */
  36380. export class PushMaterial extends Material {
  36381. protected _activeEffect: Effect;
  36382. protected _normalMatrix: Matrix;
  36383. /**
  36384. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  36385. * This means that the material can keep using a previous shader while a new one is being compiled.
  36386. * This is mostly used when shader parallel compilation is supported (true by default)
  36387. */
  36388. allowShaderHotSwapping: boolean;
  36389. constructor(name: string, scene: Scene);
  36390. getEffect(): Effect;
  36391. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  36392. /**
  36393. * Binds the given world matrix to the active effect
  36394. *
  36395. * @param world the matrix to bind
  36396. */
  36397. bindOnlyWorldMatrix(world: Matrix): void;
  36398. /**
  36399. * Binds the given normal matrix to the active effect
  36400. *
  36401. * @param normalMatrix the matrix to bind
  36402. */
  36403. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  36404. bind(world: Matrix, mesh?: Mesh): void;
  36405. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  36406. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  36407. }
  36408. }
  36409. declare module BABYLON {
  36410. /**
  36411. * This groups all the flags used to control the materials channel.
  36412. */
  36413. export class MaterialFlags {
  36414. private static _DiffuseTextureEnabled;
  36415. /**
  36416. * Are diffuse textures enabled in the application.
  36417. */
  36418. static DiffuseTextureEnabled: boolean;
  36419. private static _AmbientTextureEnabled;
  36420. /**
  36421. * Are ambient textures enabled in the application.
  36422. */
  36423. static AmbientTextureEnabled: boolean;
  36424. private static _OpacityTextureEnabled;
  36425. /**
  36426. * Are opacity textures enabled in the application.
  36427. */
  36428. static OpacityTextureEnabled: boolean;
  36429. private static _ReflectionTextureEnabled;
  36430. /**
  36431. * Are reflection textures enabled in the application.
  36432. */
  36433. static ReflectionTextureEnabled: boolean;
  36434. private static _EmissiveTextureEnabled;
  36435. /**
  36436. * Are emissive textures enabled in the application.
  36437. */
  36438. static EmissiveTextureEnabled: boolean;
  36439. private static _SpecularTextureEnabled;
  36440. /**
  36441. * Are specular textures enabled in the application.
  36442. */
  36443. static SpecularTextureEnabled: boolean;
  36444. private static _BumpTextureEnabled;
  36445. /**
  36446. * Are bump textures enabled in the application.
  36447. */
  36448. static BumpTextureEnabled: boolean;
  36449. private static _LightmapTextureEnabled;
  36450. /**
  36451. * Are lightmap textures enabled in the application.
  36452. */
  36453. static LightmapTextureEnabled: boolean;
  36454. private static _RefractionTextureEnabled;
  36455. /**
  36456. * Are refraction textures enabled in the application.
  36457. */
  36458. static RefractionTextureEnabled: boolean;
  36459. private static _ColorGradingTextureEnabled;
  36460. /**
  36461. * Are color grading textures enabled in the application.
  36462. */
  36463. static ColorGradingTextureEnabled: boolean;
  36464. private static _FresnelEnabled;
  36465. /**
  36466. * Are fresnels enabled in the application.
  36467. */
  36468. static FresnelEnabled: boolean;
  36469. }
  36470. }
  36471. declare module BABYLON {
  36472. /** @hidden */
  36473. export var defaultFragmentDeclaration: {
  36474. name: string;
  36475. shader: string;
  36476. };
  36477. }
  36478. declare module BABYLON {
  36479. /** @hidden */
  36480. export var defaultUboDeclaration: {
  36481. name: string;
  36482. shader: string;
  36483. };
  36484. }
  36485. declare module BABYLON {
  36486. /** @hidden */
  36487. export var lightFragmentDeclaration: {
  36488. name: string;
  36489. shader: string;
  36490. };
  36491. }
  36492. declare module BABYLON {
  36493. /** @hidden */
  36494. export var lightUboDeclaration: {
  36495. name: string;
  36496. shader: string;
  36497. };
  36498. }
  36499. declare module BABYLON {
  36500. /** @hidden */
  36501. export var lightsFragmentFunctions: {
  36502. name: string;
  36503. shader: string;
  36504. };
  36505. }
  36506. declare module BABYLON {
  36507. /** @hidden */
  36508. export var shadowsFragmentFunctions: {
  36509. name: string;
  36510. shader: string;
  36511. };
  36512. }
  36513. declare module BABYLON {
  36514. /** @hidden */
  36515. export var fresnelFunction: {
  36516. name: string;
  36517. shader: string;
  36518. };
  36519. }
  36520. declare module BABYLON {
  36521. /** @hidden */
  36522. export var reflectionFunction: {
  36523. name: string;
  36524. shader: string;
  36525. };
  36526. }
  36527. declare module BABYLON {
  36528. /** @hidden */
  36529. export var bumpFragmentFunctions: {
  36530. name: string;
  36531. shader: string;
  36532. };
  36533. }
  36534. declare module BABYLON {
  36535. /** @hidden */
  36536. export var logDepthDeclaration: {
  36537. name: string;
  36538. shader: string;
  36539. };
  36540. }
  36541. declare module BABYLON {
  36542. /** @hidden */
  36543. export var bumpFragment: {
  36544. name: string;
  36545. shader: string;
  36546. };
  36547. }
  36548. declare module BABYLON {
  36549. /** @hidden */
  36550. export var depthPrePass: {
  36551. name: string;
  36552. shader: string;
  36553. };
  36554. }
  36555. declare module BABYLON {
  36556. /** @hidden */
  36557. export var lightFragment: {
  36558. name: string;
  36559. shader: string;
  36560. };
  36561. }
  36562. declare module BABYLON {
  36563. /** @hidden */
  36564. export var logDepthFragment: {
  36565. name: string;
  36566. shader: string;
  36567. };
  36568. }
  36569. declare module BABYLON {
  36570. /** @hidden */
  36571. export var defaultPixelShader: {
  36572. name: string;
  36573. shader: string;
  36574. };
  36575. }
  36576. declare module BABYLON {
  36577. /** @hidden */
  36578. export var defaultVertexDeclaration: {
  36579. name: string;
  36580. shader: string;
  36581. };
  36582. }
  36583. declare module BABYLON {
  36584. /** @hidden */
  36585. export var bumpVertexDeclaration: {
  36586. name: string;
  36587. shader: string;
  36588. };
  36589. }
  36590. declare module BABYLON {
  36591. /** @hidden */
  36592. export var bumpVertex: {
  36593. name: string;
  36594. shader: string;
  36595. };
  36596. }
  36597. declare module BABYLON {
  36598. /** @hidden */
  36599. export var fogVertex: {
  36600. name: string;
  36601. shader: string;
  36602. };
  36603. }
  36604. declare module BABYLON {
  36605. /** @hidden */
  36606. export var shadowsVertex: {
  36607. name: string;
  36608. shader: string;
  36609. };
  36610. }
  36611. declare module BABYLON {
  36612. /** @hidden */
  36613. export var pointCloudVertex: {
  36614. name: string;
  36615. shader: string;
  36616. };
  36617. }
  36618. declare module BABYLON {
  36619. /** @hidden */
  36620. export var logDepthVertex: {
  36621. name: string;
  36622. shader: string;
  36623. };
  36624. }
  36625. declare module BABYLON {
  36626. /** @hidden */
  36627. export var defaultVertexShader: {
  36628. name: string;
  36629. shader: string;
  36630. };
  36631. }
  36632. declare module BABYLON {
  36633. /** @hidden */
  36634. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  36635. MAINUV1: boolean;
  36636. MAINUV2: boolean;
  36637. DIFFUSE: boolean;
  36638. DIFFUSEDIRECTUV: number;
  36639. AMBIENT: boolean;
  36640. AMBIENTDIRECTUV: number;
  36641. OPACITY: boolean;
  36642. OPACITYDIRECTUV: number;
  36643. OPACITYRGB: boolean;
  36644. REFLECTION: boolean;
  36645. EMISSIVE: boolean;
  36646. EMISSIVEDIRECTUV: number;
  36647. SPECULAR: boolean;
  36648. SPECULARDIRECTUV: number;
  36649. BUMP: boolean;
  36650. BUMPDIRECTUV: number;
  36651. PARALLAX: boolean;
  36652. PARALLAXOCCLUSION: boolean;
  36653. SPECULAROVERALPHA: boolean;
  36654. CLIPPLANE: boolean;
  36655. CLIPPLANE2: boolean;
  36656. CLIPPLANE3: boolean;
  36657. CLIPPLANE4: boolean;
  36658. ALPHATEST: boolean;
  36659. DEPTHPREPASS: boolean;
  36660. ALPHAFROMDIFFUSE: boolean;
  36661. POINTSIZE: boolean;
  36662. FOG: boolean;
  36663. SPECULARTERM: boolean;
  36664. DIFFUSEFRESNEL: boolean;
  36665. OPACITYFRESNEL: boolean;
  36666. REFLECTIONFRESNEL: boolean;
  36667. REFRACTIONFRESNEL: boolean;
  36668. EMISSIVEFRESNEL: boolean;
  36669. FRESNEL: boolean;
  36670. NORMAL: boolean;
  36671. UV1: boolean;
  36672. UV2: boolean;
  36673. VERTEXCOLOR: boolean;
  36674. VERTEXALPHA: boolean;
  36675. NUM_BONE_INFLUENCERS: number;
  36676. BonesPerMesh: number;
  36677. BONETEXTURE: boolean;
  36678. INSTANCES: boolean;
  36679. GLOSSINESS: boolean;
  36680. ROUGHNESS: boolean;
  36681. EMISSIVEASILLUMINATION: boolean;
  36682. LINKEMISSIVEWITHDIFFUSE: boolean;
  36683. REFLECTIONFRESNELFROMSPECULAR: boolean;
  36684. LIGHTMAP: boolean;
  36685. LIGHTMAPDIRECTUV: number;
  36686. OBJECTSPACE_NORMALMAP: boolean;
  36687. USELIGHTMAPASSHADOWMAP: boolean;
  36688. REFLECTIONMAP_3D: boolean;
  36689. REFLECTIONMAP_SPHERICAL: boolean;
  36690. REFLECTIONMAP_PLANAR: boolean;
  36691. REFLECTIONMAP_CUBIC: boolean;
  36692. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  36693. REFLECTIONMAP_PROJECTION: boolean;
  36694. REFLECTIONMAP_SKYBOX: boolean;
  36695. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  36696. REFLECTIONMAP_EXPLICIT: boolean;
  36697. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  36698. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  36699. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  36700. INVERTCUBICMAP: boolean;
  36701. LOGARITHMICDEPTH: boolean;
  36702. REFRACTION: boolean;
  36703. REFRACTIONMAP_3D: boolean;
  36704. REFLECTIONOVERALPHA: boolean;
  36705. TWOSIDEDLIGHTING: boolean;
  36706. SHADOWFLOAT: boolean;
  36707. MORPHTARGETS: boolean;
  36708. MORPHTARGETS_NORMAL: boolean;
  36709. MORPHTARGETS_TANGENT: boolean;
  36710. NUM_MORPH_INFLUENCERS: number;
  36711. NONUNIFORMSCALING: boolean;
  36712. PREMULTIPLYALPHA: boolean;
  36713. IMAGEPROCESSING: boolean;
  36714. VIGNETTE: boolean;
  36715. VIGNETTEBLENDMODEMULTIPLY: boolean;
  36716. VIGNETTEBLENDMODEOPAQUE: boolean;
  36717. TONEMAPPING: boolean;
  36718. TONEMAPPING_ACES: boolean;
  36719. CONTRAST: boolean;
  36720. COLORCURVES: boolean;
  36721. COLORGRADING: boolean;
  36722. COLORGRADING3D: boolean;
  36723. SAMPLER3DGREENDEPTH: boolean;
  36724. SAMPLER3DBGRMAP: boolean;
  36725. IMAGEPROCESSINGPOSTPROCESS: boolean;
  36726. /**
  36727. * If the reflection texture on this material is in linear color space
  36728. * @hidden
  36729. */
  36730. IS_REFLECTION_LINEAR: boolean;
  36731. /**
  36732. * If the refraction texture on this material is in linear color space
  36733. * @hidden
  36734. */
  36735. IS_REFRACTION_LINEAR: boolean;
  36736. EXPOSURE: boolean;
  36737. constructor();
  36738. setReflectionMode(modeToEnable: string): void;
  36739. }
  36740. /**
  36741. * This is the default material used in Babylon. It is the best trade off between quality
  36742. * and performances.
  36743. * @see http://doc.babylonjs.com/babylon101/materials
  36744. */
  36745. export class StandardMaterial extends PushMaterial {
  36746. private _diffuseTexture;
  36747. /**
  36748. * The basic texture of the material as viewed under a light.
  36749. */
  36750. diffuseTexture: Nullable<BaseTexture>;
  36751. private _ambientTexture;
  36752. /**
  36753. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  36754. */
  36755. ambientTexture: Nullable<BaseTexture>;
  36756. private _opacityTexture;
  36757. /**
  36758. * Define the transparency of the material from a texture.
  36759. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  36760. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  36761. */
  36762. opacityTexture: Nullable<BaseTexture>;
  36763. private _reflectionTexture;
  36764. /**
  36765. * Define the texture used to display the reflection.
  36766. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  36767. */
  36768. reflectionTexture: Nullable<BaseTexture>;
  36769. private _emissiveTexture;
  36770. /**
  36771. * Define texture of the material as if self lit.
  36772. * This will be mixed in the final result even in the absence of light.
  36773. */
  36774. emissiveTexture: Nullable<BaseTexture>;
  36775. private _specularTexture;
  36776. /**
  36777. * Define how the color and intensity of the highlight given by the light in the material.
  36778. */
  36779. specularTexture: Nullable<BaseTexture>;
  36780. private _bumpTexture;
  36781. /**
  36782. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  36783. * 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.
  36784. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  36785. */
  36786. bumpTexture: Nullable<BaseTexture>;
  36787. private _lightmapTexture;
  36788. /**
  36789. * Complex lighting can be computationally expensive to compute at runtime.
  36790. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  36791. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  36792. */
  36793. lightmapTexture: Nullable<BaseTexture>;
  36794. private _refractionTexture;
  36795. /**
  36796. * Define the texture used to display the refraction.
  36797. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  36798. */
  36799. refractionTexture: Nullable<BaseTexture>;
  36800. /**
  36801. * The color of the material lit by the environmental background lighting.
  36802. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  36803. */
  36804. ambientColor: Color3;
  36805. /**
  36806. * The basic color of the material as viewed under a light.
  36807. */
  36808. diffuseColor: Color3;
  36809. /**
  36810. * Define how the color and intensity of the highlight given by the light in the material.
  36811. */
  36812. specularColor: Color3;
  36813. /**
  36814. * Define the color of the material as if self lit.
  36815. * This will be mixed in the final result even in the absence of light.
  36816. */
  36817. emissiveColor: Color3;
  36818. /**
  36819. * Defines how sharp are the highlights in the material.
  36820. * The bigger the value the sharper giving a more glossy feeling to the result.
  36821. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  36822. */
  36823. specularPower: number;
  36824. private _useAlphaFromDiffuseTexture;
  36825. /**
  36826. * Does the transparency come from the diffuse texture alpha channel.
  36827. */
  36828. useAlphaFromDiffuseTexture: boolean;
  36829. private _useEmissiveAsIllumination;
  36830. /**
  36831. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  36832. */
  36833. useEmissiveAsIllumination: boolean;
  36834. private _linkEmissiveWithDiffuse;
  36835. /**
  36836. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  36837. * the emissive level when the final color is close to one.
  36838. */
  36839. linkEmissiveWithDiffuse: boolean;
  36840. private _useSpecularOverAlpha;
  36841. /**
  36842. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  36843. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  36844. */
  36845. useSpecularOverAlpha: boolean;
  36846. private _useReflectionOverAlpha;
  36847. /**
  36848. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  36849. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  36850. */
  36851. useReflectionOverAlpha: boolean;
  36852. private _disableLighting;
  36853. /**
  36854. * Does lights from the scene impacts this material.
  36855. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  36856. */
  36857. disableLighting: boolean;
  36858. private _useObjectSpaceNormalMap;
  36859. /**
  36860. * Allows using an object space normal map (instead of tangent space).
  36861. */
  36862. useObjectSpaceNormalMap: boolean;
  36863. private _useParallax;
  36864. /**
  36865. * Is parallax enabled or not.
  36866. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  36867. */
  36868. useParallax: boolean;
  36869. private _useParallaxOcclusion;
  36870. /**
  36871. * Is parallax occlusion enabled or not.
  36872. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  36873. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  36874. */
  36875. useParallaxOcclusion: boolean;
  36876. /**
  36877. * 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.
  36878. */
  36879. parallaxScaleBias: number;
  36880. private _roughness;
  36881. /**
  36882. * Helps to define how blurry the reflections should appears in the material.
  36883. */
  36884. roughness: number;
  36885. /**
  36886. * In case of refraction, define the value of the indice of refraction.
  36887. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  36888. */
  36889. indexOfRefraction: number;
  36890. /**
  36891. * Invert the refraction texture alongside the y axis.
  36892. * It can be useful with procedural textures or probe for instance.
  36893. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  36894. */
  36895. invertRefractionY: boolean;
  36896. /**
  36897. * Defines the alpha limits in alpha test mode.
  36898. */
  36899. alphaCutOff: number;
  36900. private _useLightmapAsShadowmap;
  36901. /**
  36902. * In case of light mapping, define whether the map contains light or shadow informations.
  36903. */
  36904. useLightmapAsShadowmap: boolean;
  36905. private _diffuseFresnelParameters;
  36906. /**
  36907. * Define the diffuse fresnel parameters of the material.
  36908. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  36909. */
  36910. diffuseFresnelParameters: FresnelParameters;
  36911. private _opacityFresnelParameters;
  36912. /**
  36913. * Define the opacity fresnel parameters of the material.
  36914. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  36915. */
  36916. opacityFresnelParameters: FresnelParameters;
  36917. private _reflectionFresnelParameters;
  36918. /**
  36919. * Define the reflection fresnel parameters of the material.
  36920. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  36921. */
  36922. reflectionFresnelParameters: FresnelParameters;
  36923. private _refractionFresnelParameters;
  36924. /**
  36925. * Define the refraction fresnel parameters of the material.
  36926. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  36927. */
  36928. refractionFresnelParameters: FresnelParameters;
  36929. private _emissiveFresnelParameters;
  36930. /**
  36931. * Define the emissive fresnel parameters of the material.
  36932. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  36933. */
  36934. emissiveFresnelParameters: FresnelParameters;
  36935. private _useReflectionFresnelFromSpecular;
  36936. /**
  36937. * If true automatically deducts the fresnels values from the material specularity.
  36938. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  36939. */
  36940. useReflectionFresnelFromSpecular: boolean;
  36941. private _useGlossinessFromSpecularMapAlpha;
  36942. /**
  36943. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  36944. */
  36945. useGlossinessFromSpecularMapAlpha: boolean;
  36946. private _maxSimultaneousLights;
  36947. /**
  36948. * Defines the maximum number of lights that can be used in the material
  36949. */
  36950. maxSimultaneousLights: number;
  36951. private _invertNormalMapX;
  36952. /**
  36953. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  36954. */
  36955. invertNormalMapX: boolean;
  36956. private _invertNormalMapY;
  36957. /**
  36958. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  36959. */
  36960. invertNormalMapY: boolean;
  36961. private _twoSidedLighting;
  36962. /**
  36963. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  36964. */
  36965. twoSidedLighting: boolean;
  36966. /**
  36967. * Default configuration related to image processing available in the standard Material.
  36968. */
  36969. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36970. /**
  36971. * Gets the image processing configuration used either in this material.
  36972. */
  36973. /**
  36974. * Sets the Default image processing configuration used either in the this material.
  36975. *
  36976. * If sets to null, the scene one is in use.
  36977. */
  36978. imageProcessingConfiguration: ImageProcessingConfiguration;
  36979. /**
  36980. * Keep track of the image processing observer to allow dispose and replace.
  36981. */
  36982. private _imageProcessingObserver;
  36983. /**
  36984. * Attaches a new image processing configuration to the Standard Material.
  36985. * @param configuration
  36986. */
  36987. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  36988. /**
  36989. * Gets wether the color curves effect is enabled.
  36990. */
  36991. /**
  36992. * Sets wether the color curves effect is enabled.
  36993. */
  36994. cameraColorCurvesEnabled: boolean;
  36995. /**
  36996. * Gets wether the color grading effect is enabled.
  36997. */
  36998. /**
  36999. * Gets wether the color grading effect is enabled.
  37000. */
  37001. cameraColorGradingEnabled: boolean;
  37002. /**
  37003. * Gets wether tonemapping is enabled or not.
  37004. */
  37005. /**
  37006. * Sets wether tonemapping is enabled or not
  37007. */
  37008. cameraToneMappingEnabled: boolean;
  37009. /**
  37010. * The camera exposure used on this material.
  37011. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  37012. * This corresponds to a photographic exposure.
  37013. */
  37014. /**
  37015. * The camera exposure used on this material.
  37016. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  37017. * This corresponds to a photographic exposure.
  37018. */
  37019. cameraExposure: number;
  37020. /**
  37021. * Gets The camera contrast used on this material.
  37022. */
  37023. /**
  37024. * Sets The camera contrast used on this material.
  37025. */
  37026. cameraContrast: number;
  37027. /**
  37028. * Gets the Color Grading 2D Lookup Texture.
  37029. */
  37030. /**
  37031. * Sets the Color Grading 2D Lookup Texture.
  37032. */
  37033. cameraColorGradingTexture: Nullable<BaseTexture>;
  37034. /**
  37035. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  37036. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  37037. * 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;
  37038. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  37039. */
  37040. /**
  37041. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  37042. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  37043. * 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;
  37044. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  37045. */
  37046. cameraColorCurves: Nullable<ColorCurves>;
  37047. /**
  37048. * Custom callback helping to override the default shader used in the material.
  37049. */
  37050. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  37051. protected _renderTargets: SmartArray<RenderTargetTexture>;
  37052. protected _worldViewProjectionMatrix: Matrix;
  37053. protected _globalAmbientColor: Color3;
  37054. protected _useLogarithmicDepth: boolean;
  37055. /**
  37056. * Instantiates a new standard material.
  37057. * This is the default material used in Babylon. It is the best trade off between quality
  37058. * and performances.
  37059. * @see http://doc.babylonjs.com/babylon101/materials
  37060. * @param name Define the name of the material in the scene
  37061. * @param scene Define the scene the material belong to
  37062. */
  37063. constructor(name: string, scene: Scene);
  37064. /**
  37065. * Gets a boolean indicating that current material needs to register RTT
  37066. */
  37067. readonly hasRenderTargetTextures: boolean;
  37068. /**
  37069. * Gets the current class name of the material e.g. "StandardMaterial"
  37070. * Mainly use in serialization.
  37071. * @returns the class name
  37072. */
  37073. getClassName(): string;
  37074. /**
  37075. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  37076. * You can try switching to logarithmic depth.
  37077. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  37078. */
  37079. useLogarithmicDepth: boolean;
  37080. /**
  37081. * Specifies if the material will require alpha blending
  37082. * @returns a boolean specifying if alpha blending is needed
  37083. */
  37084. needAlphaBlending(): boolean;
  37085. /**
  37086. * Specifies if this material should be rendered in alpha test mode
  37087. * @returns a boolean specifying if an alpha test is needed.
  37088. */
  37089. needAlphaTesting(): boolean;
  37090. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  37091. /**
  37092. * Get the texture used for alpha test purpose.
  37093. * @returns the diffuse texture in case of the standard material.
  37094. */
  37095. getAlphaTestTexture(): Nullable<BaseTexture>;
  37096. /**
  37097. * Get if the submesh is ready to be used and all its information available.
  37098. * Child classes can use it to update shaders
  37099. * @param mesh defines the mesh to check
  37100. * @param subMesh defines which submesh to check
  37101. * @param useInstances specifies that instances should be used
  37102. * @returns a boolean indicating that the submesh is ready or not
  37103. */
  37104. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  37105. /**
  37106. * Builds the material UBO layouts.
  37107. * Used internally during the effect preparation.
  37108. */
  37109. buildUniformLayout(): void;
  37110. /**
  37111. * Unbinds the material from the mesh
  37112. */
  37113. unbind(): void;
  37114. /**
  37115. * Binds the submesh to this material by preparing the effect and shader to draw
  37116. * @param world defines the world transformation matrix
  37117. * @param mesh defines the mesh containing the submesh
  37118. * @param subMesh defines the submesh to bind the material to
  37119. */
  37120. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  37121. /**
  37122. * Get the list of animatables in the material.
  37123. * @returns the list of animatables object used in the material
  37124. */
  37125. getAnimatables(): IAnimatable[];
  37126. /**
  37127. * Gets the active textures from the material
  37128. * @returns an array of textures
  37129. */
  37130. getActiveTextures(): BaseTexture[];
  37131. /**
  37132. * Specifies if the material uses a texture
  37133. * @param texture defines the texture to check against the material
  37134. * @returns a boolean specifying if the material uses the texture
  37135. */
  37136. hasTexture(texture: BaseTexture): boolean;
  37137. /**
  37138. * Disposes the material
  37139. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  37140. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  37141. */
  37142. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  37143. /**
  37144. * Makes a duplicate of the material, and gives it a new name
  37145. * @param name defines the new name for the duplicated material
  37146. * @returns the cloned material
  37147. */
  37148. clone(name: string): StandardMaterial;
  37149. /**
  37150. * Serializes this material in a JSON representation
  37151. * @returns the serialized material object
  37152. */
  37153. serialize(): any;
  37154. /**
  37155. * Creates a standard material from parsed material data
  37156. * @param source defines the JSON representation of the material
  37157. * @param scene defines the hosting scene
  37158. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  37159. * @returns a new standard material
  37160. */
  37161. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  37162. /**
  37163. * Are diffuse textures enabled in the application.
  37164. */
  37165. static DiffuseTextureEnabled: boolean;
  37166. /**
  37167. * Are ambient textures enabled in the application.
  37168. */
  37169. static AmbientTextureEnabled: boolean;
  37170. /**
  37171. * Are opacity textures enabled in the application.
  37172. */
  37173. static OpacityTextureEnabled: boolean;
  37174. /**
  37175. * Are reflection textures enabled in the application.
  37176. */
  37177. static ReflectionTextureEnabled: boolean;
  37178. /**
  37179. * Are emissive textures enabled in the application.
  37180. */
  37181. static EmissiveTextureEnabled: boolean;
  37182. /**
  37183. * Are specular textures enabled in the application.
  37184. */
  37185. static SpecularTextureEnabled: boolean;
  37186. /**
  37187. * Are bump textures enabled in the application.
  37188. */
  37189. static BumpTextureEnabled: boolean;
  37190. /**
  37191. * Are lightmap textures enabled in the application.
  37192. */
  37193. static LightmapTextureEnabled: boolean;
  37194. /**
  37195. * Are refraction textures enabled in the application.
  37196. */
  37197. static RefractionTextureEnabled: boolean;
  37198. /**
  37199. * Are color grading textures enabled in the application.
  37200. */
  37201. static ColorGradingTextureEnabled: boolean;
  37202. /**
  37203. * Are fresnels enabled in the application.
  37204. */
  37205. static FresnelEnabled: boolean;
  37206. }
  37207. }
  37208. declare module BABYLON {
  37209. /**
  37210. * A class extending Texture allowing drawing on a texture
  37211. * @see http://doc.babylonjs.com/how_to/dynamictexture
  37212. */
  37213. export class DynamicTexture extends Texture {
  37214. private _generateMipMaps;
  37215. private _canvas;
  37216. private _context;
  37217. private _engine;
  37218. /**
  37219. * Creates a DynamicTexture
  37220. * @param name defines the name of the texture
  37221. * @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
  37222. * @param scene defines the scene where you want the texture
  37223. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  37224. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  37225. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  37226. */
  37227. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  37228. /**
  37229. * Get the current class name of the texture useful for serialization or dynamic coding.
  37230. * @returns "DynamicTexture"
  37231. */
  37232. getClassName(): string;
  37233. /**
  37234. * Gets the current state of canRescale
  37235. */
  37236. readonly canRescale: boolean;
  37237. private _recreate;
  37238. /**
  37239. * Scales the texture
  37240. * @param ratio the scale factor to apply to both width and height
  37241. */
  37242. scale(ratio: number): void;
  37243. /**
  37244. * Resizes the texture
  37245. * @param width the new width
  37246. * @param height the new height
  37247. */
  37248. scaleTo(width: number, height: number): void;
  37249. /**
  37250. * Gets the context of the canvas used by the texture
  37251. * @returns the canvas context of the dynamic texture
  37252. */
  37253. getContext(): CanvasRenderingContext2D;
  37254. /**
  37255. * Clears the texture
  37256. */
  37257. clear(): void;
  37258. /**
  37259. * Updates the texture
  37260. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  37261. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  37262. */
  37263. update(invertY?: boolean, premulAlpha?: boolean): void;
  37264. /**
  37265. * Draws text onto the texture
  37266. * @param text defines the text to be drawn
  37267. * @param x defines the placement of the text from the left
  37268. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  37269. * @param font defines the font to be used with font-style, font-size, font-name
  37270. * @param color defines the color used for the text
  37271. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  37272. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  37273. * @param update defines whether texture is immediately update (default is true)
  37274. */
  37275. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  37276. /**
  37277. * Clones the texture
  37278. * @returns the clone of the texture.
  37279. */
  37280. clone(): DynamicTexture;
  37281. /**
  37282. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  37283. * @returns a serialized dynamic texture object
  37284. */
  37285. serialize(): any;
  37286. /** @hidden */ rebuild(): void;
  37287. }
  37288. }
  37289. declare module BABYLON {
  37290. /** @hidden */
  37291. export var imageProcessingPixelShader: {
  37292. name: string;
  37293. shader: string;
  37294. };
  37295. }
  37296. declare module BABYLON {
  37297. /**
  37298. * ImageProcessingPostProcess
  37299. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  37300. */
  37301. export class ImageProcessingPostProcess extends PostProcess {
  37302. /**
  37303. * Default configuration related to image processing available in the PBR Material.
  37304. */
  37305. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  37306. /**
  37307. * Gets the image processing configuration used either in this material.
  37308. */
  37309. /**
  37310. * Sets the Default image processing configuration used either in the this material.
  37311. *
  37312. * If sets to null, the scene one is in use.
  37313. */
  37314. imageProcessingConfiguration: ImageProcessingConfiguration;
  37315. /**
  37316. * Keep track of the image processing observer to allow dispose and replace.
  37317. */
  37318. private _imageProcessingObserver;
  37319. /**
  37320. * Attaches a new image processing configuration to the PBR Material.
  37321. * @param configuration
  37322. */
  37323. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  37324. /**
  37325. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  37326. */
  37327. /**
  37328. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  37329. */
  37330. colorCurves: Nullable<ColorCurves>;
  37331. /**
  37332. * Gets wether the color curves effect is enabled.
  37333. */
  37334. /**
  37335. * Sets wether the color curves effect is enabled.
  37336. */
  37337. colorCurvesEnabled: boolean;
  37338. /**
  37339. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  37340. */
  37341. /**
  37342. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  37343. */
  37344. colorGradingTexture: Nullable<BaseTexture>;
  37345. /**
  37346. * Gets wether the color grading effect is enabled.
  37347. */
  37348. /**
  37349. * Gets wether the color grading effect is enabled.
  37350. */
  37351. colorGradingEnabled: boolean;
  37352. /**
  37353. * Gets exposure used in the effect.
  37354. */
  37355. /**
  37356. * Sets exposure used in the effect.
  37357. */
  37358. exposure: number;
  37359. /**
  37360. * Gets wether tonemapping is enabled or not.
  37361. */
  37362. /**
  37363. * Sets wether tonemapping is enabled or not
  37364. */
  37365. toneMappingEnabled: boolean;
  37366. /**
  37367. * Gets contrast used in the effect.
  37368. */
  37369. /**
  37370. * Sets contrast used in the effect.
  37371. */
  37372. contrast: number;
  37373. /**
  37374. * Gets Vignette stretch size.
  37375. */
  37376. /**
  37377. * Sets Vignette stretch size.
  37378. */
  37379. vignetteStretch: number;
  37380. /**
  37381. * Gets Vignette centre X Offset.
  37382. */
  37383. /**
  37384. * Sets Vignette centre X Offset.
  37385. */
  37386. vignetteCentreX: number;
  37387. /**
  37388. * Gets Vignette centre Y Offset.
  37389. */
  37390. /**
  37391. * Sets Vignette centre Y Offset.
  37392. */
  37393. vignetteCentreY: number;
  37394. /**
  37395. * Gets Vignette weight or intensity of the vignette effect.
  37396. */
  37397. /**
  37398. * Sets Vignette weight or intensity of the vignette effect.
  37399. */
  37400. vignetteWeight: number;
  37401. /**
  37402. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  37403. * if vignetteEnabled is set to true.
  37404. */
  37405. /**
  37406. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  37407. * if vignetteEnabled is set to true.
  37408. */
  37409. vignetteColor: Color4;
  37410. /**
  37411. * Gets Camera field of view used by the Vignette effect.
  37412. */
  37413. /**
  37414. * Sets Camera field of view used by the Vignette effect.
  37415. */
  37416. vignetteCameraFov: number;
  37417. /**
  37418. * Gets the vignette blend mode allowing different kind of effect.
  37419. */
  37420. /**
  37421. * Sets the vignette blend mode allowing different kind of effect.
  37422. */
  37423. vignetteBlendMode: number;
  37424. /**
  37425. * Gets wether the vignette effect is enabled.
  37426. */
  37427. /**
  37428. * Sets wether the vignette effect is enabled.
  37429. */
  37430. vignetteEnabled: boolean;
  37431. private _fromLinearSpace;
  37432. /**
  37433. * Gets wether the input of the processing is in Gamma or Linear Space.
  37434. */
  37435. /**
  37436. * Sets wether the input of the processing is in Gamma or Linear Space.
  37437. */
  37438. fromLinearSpace: boolean;
  37439. /**
  37440. * Defines cache preventing GC.
  37441. */
  37442. private _defines;
  37443. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  37444. /**
  37445. * "ImageProcessingPostProcess"
  37446. * @returns "ImageProcessingPostProcess"
  37447. */
  37448. getClassName(): string;
  37449. protected _updateParameters(): void;
  37450. dispose(camera?: Camera): void;
  37451. }
  37452. }
  37453. declare module BABYLON {
  37454. /**
  37455. * Class containing static functions to help procedurally build meshes
  37456. */
  37457. export class GroundBuilder {
  37458. /**
  37459. * Creates a ground mesh
  37460. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  37461. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  37462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37463. * @param name defines the name of the mesh
  37464. * @param options defines the options used to create the mesh
  37465. * @param scene defines the hosting scene
  37466. * @returns the ground mesh
  37467. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  37468. */
  37469. static CreateGround(name: string, options: {
  37470. width?: number;
  37471. height?: number;
  37472. subdivisions?: number;
  37473. subdivisionsX?: number;
  37474. subdivisionsY?: number;
  37475. updatable?: boolean;
  37476. }, scene: any): Mesh;
  37477. /**
  37478. * Creates a tiled ground mesh
  37479. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  37480. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  37481. * * 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
  37482. * * 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
  37483. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  37484. * @param name defines the name of the mesh
  37485. * @param options defines the options used to create the mesh
  37486. * @param scene defines the hosting scene
  37487. * @returns the tiled ground mesh
  37488. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  37489. */
  37490. static CreateTiledGround(name: string, options: {
  37491. xmin: number;
  37492. zmin: number;
  37493. xmax: number;
  37494. zmax: number;
  37495. subdivisions?: {
  37496. w: number;
  37497. h: number;
  37498. };
  37499. precision?: {
  37500. w: number;
  37501. h: number;
  37502. };
  37503. updatable?: boolean;
  37504. }, scene: Scene): Mesh;
  37505. /**
  37506. * Creates a ground mesh from a height map
  37507. * * The parameter `url` sets the URL of the height map image resource.
  37508. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  37509. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  37510. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  37511. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  37512. * * 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.
  37513. * * 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).
  37514. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  37515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  37516. * @param name defines the name of the mesh
  37517. * @param url defines the url to the height map
  37518. * @param options defines the options used to create the mesh
  37519. * @param scene defines the hosting scene
  37520. * @returns the ground mesh
  37521. * @see https://doc.babylonjs.com/babylon101/height_map
  37522. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  37523. */
  37524. static CreateGroundFromHeightMap(name: string, url: string, options: {
  37525. width?: number;
  37526. height?: number;
  37527. subdivisions?: number;
  37528. minHeight?: number;
  37529. maxHeight?: number;
  37530. colorFilter?: Color3;
  37531. alphaFilter?: number;
  37532. updatable?: boolean;
  37533. onReady?: (mesh: GroundMesh) => void;
  37534. }, scene: Scene): GroundMesh;
  37535. }
  37536. }
  37537. declare module BABYLON {
  37538. /**
  37539. * Class containing static functions to help procedurally build meshes
  37540. */
  37541. export class TorusBuilder {
  37542. /**
  37543. * Creates a torus mesh
  37544. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  37545. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  37546. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  37547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37548. * * 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
  37549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  37550. * @param name defines the name of the mesh
  37551. * @param options defines the options used to create the mesh
  37552. * @param scene defines the hosting scene
  37553. * @returns the torus mesh
  37554. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  37555. */
  37556. static CreateTorus(name: string, options: {
  37557. diameter?: number;
  37558. thickness?: number;
  37559. tessellation?: number;
  37560. updatable?: boolean;
  37561. sideOrientation?: number;
  37562. frontUVs?: Vector4;
  37563. backUVs?: Vector4;
  37564. }, scene: any): Mesh;
  37565. }
  37566. }
  37567. declare module BABYLON {
  37568. /**
  37569. * Class containing static functions to help procedurally build meshes
  37570. */
  37571. export class CylinderBuilder {
  37572. /**
  37573. * Creates a cylinder or a cone mesh
  37574. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  37575. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  37576. * * 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.
  37577. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  37578. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  37579. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  37580. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  37581. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  37582. * * 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).
  37583. * * 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
  37584. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  37585. * * 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
  37586. * * 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.
  37587. * * If `enclose` is false, a ring surface is one element.
  37588. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  37589. * * 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
  37590. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37591. * * 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
  37592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  37593. * @param name defines the name of the mesh
  37594. * @param options defines the options used to create the mesh
  37595. * @param scene defines the hosting scene
  37596. * @returns the cylinder mesh
  37597. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  37598. */
  37599. static CreateCylinder(name: string, options: {
  37600. height?: number;
  37601. diameterTop?: number;
  37602. diameterBottom?: number;
  37603. diameter?: number;
  37604. tessellation?: number;
  37605. subdivisions?: number;
  37606. arc?: number;
  37607. faceColors?: Color4[];
  37608. faceUV?: Vector4[];
  37609. updatable?: boolean;
  37610. hasRings?: boolean;
  37611. enclose?: boolean;
  37612. sideOrientation?: number;
  37613. frontUVs?: Vector4;
  37614. backUVs?: Vector4;
  37615. }, scene: any): Mesh;
  37616. }
  37617. }
  37618. declare module BABYLON {
  37619. /**
  37620. * Manager for handling gamepads
  37621. */
  37622. export class GamepadManager {
  37623. private _scene?;
  37624. private _babylonGamepads;
  37625. private _oneGamepadConnected;
  37626. /** @hidden */ isMonitoring: boolean;
  37627. private _gamepadEventSupported;
  37628. private _gamepadSupport;
  37629. /**
  37630. * observable to be triggered when the gamepad controller has been connected
  37631. */
  37632. onGamepadConnectedObservable: Observable<Gamepad>;
  37633. /**
  37634. * observable to be triggered when the gamepad controller has been disconnected
  37635. */
  37636. onGamepadDisconnectedObservable: Observable<Gamepad>;
  37637. private _onGamepadConnectedEvent;
  37638. private _onGamepadDisconnectedEvent;
  37639. /**
  37640. * Initializes the gamepad manager
  37641. * @param _scene BabylonJS scene
  37642. */
  37643. constructor(_scene?: Scene | undefined);
  37644. /**
  37645. * The gamepads in the game pad manager
  37646. */
  37647. readonly gamepads: Gamepad[];
  37648. /**
  37649. * Get the gamepad controllers based on type
  37650. * @param type The type of gamepad controller
  37651. * @returns Nullable gamepad
  37652. */
  37653. getGamepadByType(type?: number): Nullable<Gamepad>;
  37654. /**
  37655. * Disposes the gamepad manager
  37656. */
  37657. dispose(): void;
  37658. private _addNewGamepad;
  37659. private _startMonitoringGamepads;
  37660. private _stopMonitoringGamepads;
  37661. /** @hidden */ checkGamepadsStatus(): void;
  37662. private _updateGamepadObjects;
  37663. }
  37664. }
  37665. declare module BABYLON {
  37666. interface Scene {
  37667. /** @hidden */ gamepadManager: Nullable<GamepadManager>;
  37668. /**
  37669. * Gets the gamepad manager associated with the scene
  37670. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  37671. */
  37672. gamepadManager: GamepadManager;
  37673. }
  37674. /**
  37675. * Interface representing a free camera inputs manager
  37676. */
  37677. interface FreeCameraInputsManager {
  37678. /**
  37679. * Adds gamepad input support to the FreeCameraInputsManager.
  37680. * @returns the FreeCameraInputsManager
  37681. */
  37682. addGamepad(): FreeCameraInputsManager;
  37683. }
  37684. /**
  37685. * Interface representing an arc rotate camera inputs manager
  37686. */
  37687. interface ArcRotateCameraInputsManager {
  37688. /**
  37689. * Adds gamepad input support to the ArcRotateCamera InputManager.
  37690. * @returns the camera inputs manager
  37691. */
  37692. addGamepad(): ArcRotateCameraInputsManager;
  37693. }
  37694. /**
  37695. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  37696. */
  37697. export class GamepadSystemSceneComponent implements ISceneComponent {
  37698. /**
  37699. * The component name helpfull to identify the component in the list of scene components.
  37700. */
  37701. readonly name: string;
  37702. /**
  37703. * The scene the component belongs to.
  37704. */
  37705. scene: Scene;
  37706. /**
  37707. * Creates a new instance of the component for the given scene
  37708. * @param scene Defines the scene to register the component in
  37709. */
  37710. constructor(scene: Scene);
  37711. /**
  37712. * Registers the component in a given scene
  37713. */
  37714. register(): void;
  37715. /**
  37716. * Rebuilds the elements related to this component in case of
  37717. * context lost for instance.
  37718. */
  37719. rebuild(): void;
  37720. /**
  37721. * Disposes the component and the associated ressources
  37722. */
  37723. dispose(): void;
  37724. private _beforeCameraUpdate;
  37725. }
  37726. }
  37727. declare module BABYLON {
  37728. /**
  37729. * Options to modify the vr teleportation behavior.
  37730. */
  37731. export interface VRTeleportationOptions {
  37732. /**
  37733. * The name of the mesh which should be used as the teleportation floor. (default: null)
  37734. */
  37735. floorMeshName?: string;
  37736. /**
  37737. * A list of meshes to be used as the teleportation floor. (default: empty)
  37738. */
  37739. floorMeshes?: Mesh[];
  37740. }
  37741. /**
  37742. * Options to modify the vr experience helper's behavior.
  37743. */
  37744. export interface VRExperienceHelperOptions extends WebVROptions {
  37745. /**
  37746. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  37747. */
  37748. createDeviceOrientationCamera?: boolean;
  37749. /**
  37750. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  37751. */
  37752. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  37753. /**
  37754. * Uses the main button on the controller to toggle the laser casted. (default: true)
  37755. */
  37756. laserToggle?: boolean;
  37757. /**
  37758. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  37759. */
  37760. floorMeshes?: Mesh[];
  37761. /**
  37762. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  37763. */
  37764. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  37765. }
  37766. /**
  37767. * Helps to quickly add VR support to an existing scene.
  37768. * See http://doc.babylonjs.com/how_to/webvr_helper
  37769. */
  37770. export class VRExperienceHelper {
  37771. /** Options to modify the vr experience helper's behavior. */
  37772. webVROptions: VRExperienceHelperOptions;
  37773. private _scene;
  37774. private _position;
  37775. private _btnVR;
  37776. private _btnVRDisplayed;
  37777. private _webVRsupported;
  37778. private _webVRready;
  37779. private _webVRrequesting;
  37780. private _webVRpresenting;
  37781. private _hasEnteredVR;
  37782. private _fullscreenVRpresenting;
  37783. private _canvas;
  37784. private _webVRCamera;
  37785. private _vrDeviceOrientationCamera;
  37786. private _deviceOrientationCamera;
  37787. private _existingCamera;
  37788. private _onKeyDown;
  37789. private _onVrDisplayPresentChange;
  37790. private _onVRDisplayChanged;
  37791. private _onVRRequestPresentStart;
  37792. private _onVRRequestPresentComplete;
  37793. /**
  37794. * Observable raised when entering VR.
  37795. */
  37796. onEnteringVRObservable: Observable<VRExperienceHelper>;
  37797. /**
  37798. * Observable raised when exiting VR.
  37799. */
  37800. onExitingVRObservable: Observable<VRExperienceHelper>;
  37801. /**
  37802. * Observable raised when controller mesh is loaded.
  37803. */
  37804. onControllerMeshLoadedObservable: Observable<WebVRController>;
  37805. /** Return this.onEnteringVRObservable
  37806. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  37807. */
  37808. readonly onEnteringVR: Observable<VRExperienceHelper>;
  37809. /** Return this.onExitingVRObservable
  37810. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  37811. */
  37812. readonly onExitingVR: Observable<VRExperienceHelper>;
  37813. /** Return this.onControllerMeshLoadedObservable
  37814. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  37815. */
  37816. readonly onControllerMeshLoaded: Observable<WebVRController>;
  37817. private _rayLength;
  37818. private _useCustomVRButton;
  37819. private _teleportationRequested;
  37820. private _teleportActive;
  37821. private _floorMeshName;
  37822. private _floorMeshesCollection;
  37823. private _rotationAllowed;
  37824. private _teleportBackwardsVector;
  37825. private _teleportationTarget;
  37826. private _isDefaultTeleportationTarget;
  37827. private _postProcessMove;
  37828. private _teleportationFillColor;
  37829. private _teleportationBorderColor;
  37830. private _rotationAngle;
  37831. private _haloCenter;
  37832. private _cameraGazer;
  37833. private _padSensibilityUp;
  37834. private _padSensibilityDown;
  37835. private _leftController;
  37836. private _rightController;
  37837. /**
  37838. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  37839. */
  37840. onNewMeshSelected: Observable<AbstractMesh>;
  37841. /**
  37842. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  37843. */
  37844. onNewMeshPicked: Observable<PickingInfo>;
  37845. private _circleEase;
  37846. /**
  37847. * Observable raised before camera teleportation
  37848. */
  37849. onBeforeCameraTeleport: Observable<Vector3>;
  37850. /**
  37851. * Observable raised after camera teleportation
  37852. */
  37853. onAfterCameraTeleport: Observable<Vector3>;
  37854. /**
  37855. * Observable raised when current selected mesh gets unselected
  37856. */
  37857. onSelectedMeshUnselected: Observable<AbstractMesh>;
  37858. private _raySelectionPredicate;
  37859. /**
  37860. * To be optionaly changed by user to define custom ray selection
  37861. */
  37862. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  37863. /**
  37864. * To be optionaly changed by user to define custom selection logic (after ray selection)
  37865. */
  37866. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  37867. /**
  37868. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  37869. */
  37870. teleportationEnabled: boolean;
  37871. private _defaultHeight;
  37872. private _teleportationInitialized;
  37873. private _interactionsEnabled;
  37874. private _interactionsRequested;
  37875. private _displayGaze;
  37876. private _displayLaserPointer;
  37877. /**
  37878. * The mesh used to display where the user is going to teleport.
  37879. */
  37880. /**
  37881. * Sets the mesh to be used to display where the user is going to teleport.
  37882. */
  37883. teleportationTarget: Mesh;
  37884. /**
  37885. * 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
  37886. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  37887. * See http://doc.babylonjs.com/resources/baking_transformations
  37888. */
  37889. gazeTrackerMesh: Mesh;
  37890. /**
  37891. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  37892. */
  37893. updateGazeTrackerScale: boolean;
  37894. /**
  37895. * If the gaze trackers color should be updated when selecting meshes
  37896. */
  37897. updateGazeTrackerColor: boolean;
  37898. /**
  37899. * The gaze tracking mesh corresponding to the left controller
  37900. */
  37901. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  37902. /**
  37903. * The gaze tracking mesh corresponding to the right controller
  37904. */
  37905. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  37906. /**
  37907. * If the ray of the gaze should be displayed.
  37908. */
  37909. /**
  37910. * Sets if the ray of the gaze should be displayed.
  37911. */
  37912. displayGaze: boolean;
  37913. /**
  37914. * If the ray of the LaserPointer should be displayed.
  37915. */
  37916. /**
  37917. * Sets if the ray of the LaserPointer should be displayed.
  37918. */
  37919. displayLaserPointer: boolean;
  37920. /**
  37921. * The deviceOrientationCamera used as the camera when not in VR.
  37922. */
  37923. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  37924. /**
  37925. * Based on the current WebVR support, returns the current VR camera used.
  37926. */
  37927. readonly currentVRCamera: Nullable<Camera>;
  37928. /**
  37929. * The webVRCamera which is used when in VR.
  37930. */
  37931. readonly webVRCamera: WebVRFreeCamera;
  37932. /**
  37933. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  37934. */
  37935. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  37936. private readonly _teleportationRequestInitiated;
  37937. /**
  37938. * Defines wether or not Pointer lock should be requested when switching to
  37939. * full screen.
  37940. */
  37941. requestPointerLockOnFullScreen: boolean;
  37942. /**
  37943. * Instantiates a VRExperienceHelper.
  37944. * Helps to quickly add VR support to an existing scene.
  37945. * @param scene The scene the VRExperienceHelper belongs to.
  37946. * @param webVROptions Options to modify the vr experience helper's behavior.
  37947. */
  37948. constructor(scene: Scene,
  37949. /** Options to modify the vr experience helper's behavior. */
  37950. webVROptions?: VRExperienceHelperOptions);
  37951. private _onDefaultMeshLoaded;
  37952. private _onResize;
  37953. private _onFullscreenChange;
  37954. /**
  37955. * Gets a value indicating if we are currently in VR mode.
  37956. */
  37957. readonly isInVRMode: boolean;
  37958. private onVrDisplayPresentChange;
  37959. private onVRDisplayChanged;
  37960. private moveButtonToBottomRight;
  37961. private displayVRButton;
  37962. private updateButtonVisibility;
  37963. private _cachedAngularSensibility;
  37964. /**
  37965. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  37966. * Otherwise, will use the fullscreen API.
  37967. */
  37968. enterVR(): void;
  37969. /**
  37970. * Attempt to exit VR, or fullscreen.
  37971. */
  37972. exitVR(): void;
  37973. /**
  37974. * The position of the vr experience helper.
  37975. */
  37976. /**
  37977. * Sets the position of the vr experience helper.
  37978. */
  37979. position: Vector3;
  37980. /**
  37981. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  37982. */
  37983. enableInteractions(): void;
  37984. private readonly _noControllerIsActive;
  37985. private beforeRender;
  37986. private _isTeleportationFloor;
  37987. /**
  37988. * Adds a floor mesh to be used for teleportation.
  37989. * @param floorMesh the mesh to be used for teleportation.
  37990. */
  37991. addFloorMesh(floorMesh: Mesh): void;
  37992. /**
  37993. * Removes a floor mesh from being used for teleportation.
  37994. * @param floorMesh the mesh to be removed.
  37995. */
  37996. removeFloorMesh(floorMesh: Mesh): void;
  37997. /**
  37998. * Enables interactions and teleportation using the VR controllers and gaze.
  37999. * @param vrTeleportationOptions options to modify teleportation behavior.
  38000. */
  38001. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  38002. private _onNewGamepadConnected;
  38003. private _tryEnableInteractionOnController;
  38004. private _onNewGamepadDisconnected;
  38005. private _enableInteractionOnController;
  38006. private _checkTeleportWithRay;
  38007. private _checkRotate;
  38008. private _checkTeleportBackwards;
  38009. private _enableTeleportationOnController;
  38010. private _createTeleportationCircles;
  38011. private _displayTeleportationTarget;
  38012. private _hideTeleportationTarget;
  38013. private _rotateCamera;
  38014. private _moveTeleportationSelectorTo;
  38015. private _workingVector;
  38016. private _workingQuaternion;
  38017. private _workingMatrix;
  38018. /**
  38019. * Teleports the users feet to the desired location
  38020. * @param location The location where the user's feet should be placed
  38021. */
  38022. teleportCamera(location: Vector3): void;
  38023. private _convertNormalToDirectionOfRay;
  38024. private _castRayAndSelectObject;
  38025. private _notifySelectedMeshUnselected;
  38026. /**
  38027. * Sets the color of the laser ray from the vr controllers.
  38028. * @param color new color for the ray.
  38029. */
  38030. changeLaserColor(color: Color3): void;
  38031. /**
  38032. * Sets the color of the ray from the vr headsets gaze.
  38033. * @param color new color for the ray.
  38034. */
  38035. changeGazeColor(color: Color3): void;
  38036. /**
  38037. * Exits VR and disposes of the vr experience helper
  38038. */
  38039. dispose(): void;
  38040. /**
  38041. * Gets the name of the VRExperienceHelper class
  38042. * @returns "VRExperienceHelper"
  38043. */
  38044. getClassName(): string;
  38045. }
  38046. }
  38047. declare module BABYLON {
  38048. /**
  38049. * Manages an XRSession
  38050. * @see https://doc.babylonjs.com/how_to/webxr
  38051. */
  38052. export class WebXRSessionManager implements IDisposable {
  38053. private scene;
  38054. /**
  38055. * Fires every time a new xrFrame arrives which can be used to update the camera
  38056. */
  38057. onXRFrameObservable: Observable<any>;
  38058. /**
  38059. * Fires when the xr session is ended either by the device or manually done
  38060. */
  38061. onXRSessionEnded: Observable<any>;
  38062. /** @hidden */ xrSession: XRSession;
  38063. /** @hidden */ frameOfReference: XRFrameOfReference;
  38064. /** @hidden */ sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  38065. /** @hidden */ currentXRFrame: Nullable<XRFrame>;
  38066. private _xrNavigator;
  38067. private _xrDevice;
  38068. private _tmpMatrix;
  38069. /**
  38070. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  38071. * @param scene The scene which the session should be created for
  38072. */
  38073. constructor(scene: Scene);
  38074. /**
  38075. * Initializes the manager
  38076. * After initialization enterXR can be called to start an XR session
  38077. * @returns Promise which resolves after it is initialized
  38078. */
  38079. initializeAsync(): Promise<void>;
  38080. /**
  38081. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  38082. * @param sessionCreationOptions xr options to create the session with
  38083. * @param frameOfReferenceType option to configure how the xr pose is expressed
  38084. * @returns Promise which resolves after it enters XR
  38085. */
  38086. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  38087. /**
  38088. * Stops the xrSession and restores the renderloop
  38089. * @returns Promise which resolves after it exits XR
  38090. */
  38091. exitXRAsync(): Promise<void>;
  38092. /**
  38093. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  38094. * @param ray ray to cast into the environment
  38095. * @returns Promise which resolves with a collision point in the environment if it exists
  38096. */
  38097. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  38098. /**
  38099. * Checks if a session would be supported for the creation options specified
  38100. * @param options creation options to check if they are supported
  38101. * @returns true if supported
  38102. */
  38103. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  38104. /**
  38105. * @hidden
  38106. * Converts the render layer of xrSession to a render target
  38107. * @param session session to create render target for
  38108. * @param scene scene the new render target should be created for
  38109. */ private static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  38110. /**
  38111. * Disposes of the session manager
  38112. */
  38113. dispose(): void;
  38114. }
  38115. }
  38116. declare module BABYLON {
  38117. /**
  38118. * WebXR Camera which holds the views for the xrSession
  38119. * @see https://doc.babylonjs.com/how_to/webxr
  38120. */
  38121. export class WebXRCamera extends FreeCamera {
  38122. private static _TmpMatrix;
  38123. /**
  38124. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  38125. * @param name the name of the camera
  38126. * @param scene the scene to add the camera to
  38127. */
  38128. constructor(name: string, scene: Scene);
  38129. private _updateNumberOfRigCameras;
  38130. /** @hidden */ updateForDualEyeDebugging(pupilDistance?: number): void;
  38131. /**
  38132. * Updates the cameras position from the current pose information of the XR session
  38133. * @param xrSessionManager the session containing pose information
  38134. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  38135. */
  38136. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  38137. }
  38138. }
  38139. declare module BABYLON {
  38140. /**
  38141. * States of the webXR experience
  38142. */
  38143. export enum WebXRState {
  38144. /**
  38145. * Transitioning to being in XR mode
  38146. */
  38147. ENTERING_XR = 0,
  38148. /**
  38149. * Transitioning to non XR mode
  38150. */
  38151. EXITING_XR = 1,
  38152. /**
  38153. * In XR mode and presenting
  38154. */
  38155. IN_XR = 2,
  38156. /**
  38157. * Not entered XR mode
  38158. */
  38159. NOT_IN_XR = 3
  38160. }
  38161. /**
  38162. * Helper class used to enable XR
  38163. * @see https://doc.babylonjs.com/how_to/webxr
  38164. */
  38165. export class WebXRExperienceHelper implements IDisposable {
  38166. private scene;
  38167. /**
  38168. * 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
  38169. */
  38170. container: AbstractMesh;
  38171. /**
  38172. * Camera used to render xr content
  38173. */
  38174. camera: WebXRCamera;
  38175. /**
  38176. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  38177. */
  38178. state: WebXRState;
  38179. private _setState;
  38180. private static _TmpVector;
  38181. /**
  38182. * Fires when the state of the experience helper has changed
  38183. */
  38184. onStateChangedObservable: Observable<WebXRState>;
  38185. /** @hidden */ sessionManager: WebXRSessionManager;
  38186. private _nonVRCamera;
  38187. private _originalSceneAutoClear;
  38188. private _supported;
  38189. /**
  38190. * Creates the experience helper
  38191. * @param scene the scene to attach the experience helper to
  38192. * @returns a promise for the experience helper
  38193. */
  38194. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  38195. /**
  38196. * Creates a WebXRExperienceHelper
  38197. * @param scene The scene the helper should be created in
  38198. */
  38199. private constructor();
  38200. /**
  38201. * Exits XR mode and returns the scene to its original state
  38202. * @returns promise that resolves after xr mode has exited
  38203. */
  38204. exitXRAsync(): Promise<void>;
  38205. /**
  38206. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  38207. * @param sessionCreationOptions options for the XR session
  38208. * @param frameOfReference frame of reference of the XR session
  38209. * @returns promise that resolves after xr mode has entered
  38210. */
  38211. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  38212. /**
  38213. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  38214. * @param ray ray to cast into the environment
  38215. * @returns Promise which resolves with a collision point in the environment if it exists
  38216. */
  38217. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  38218. /**
  38219. * Updates the global position of the camera by moving the camera's container
  38220. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  38221. * @param position The desired global position of the camera
  38222. */
  38223. setPositionOfCameraUsingContainer(position: Vector3): void;
  38224. /**
  38225. * Rotates the xr camera by rotating the camera's container around the camera's position
  38226. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  38227. * @param rotation the desired quaternion rotation to apply to the camera
  38228. */
  38229. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  38230. /**
  38231. * Checks if the creation options are supported by the xr session
  38232. * @param options creation options
  38233. * @returns true if supported
  38234. */
  38235. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  38236. /**
  38237. * Disposes of the experience helper
  38238. */
  38239. dispose(): void;
  38240. }
  38241. }
  38242. declare module BABYLON {
  38243. /**
  38244. * Button which can be used to enter a different mode of XR
  38245. */
  38246. export class WebXREnterExitUIButton {
  38247. /** button element */
  38248. element: HTMLElement;
  38249. /** XR initialization options for the button */
  38250. initializationOptions: XRSessionCreationOptions;
  38251. /**
  38252. * Creates a WebXREnterExitUIButton
  38253. * @param element button element
  38254. * @param initializationOptions XR initialization options for the button
  38255. */
  38256. constructor(
  38257. /** button element */
  38258. element: HTMLElement,
  38259. /** XR initialization options for the button */
  38260. initializationOptions: XRSessionCreationOptions);
  38261. /**
  38262. * Overwritable function which can be used to update the button's visuals when the state changes
  38263. * @param activeButton the current active button in the UI
  38264. */
  38265. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  38266. }
  38267. /**
  38268. * Options to create the webXR UI
  38269. */
  38270. export class WebXREnterExitUIOptions {
  38271. /**
  38272. * Context to enter xr with
  38273. */
  38274. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  38275. /**
  38276. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  38277. */
  38278. customButtons?: Array<WebXREnterExitUIButton>;
  38279. }
  38280. /**
  38281. * UI to allow the user to enter/exit XR mode
  38282. */
  38283. export class WebXREnterExitUI implements IDisposable {
  38284. private scene;
  38285. private _overlay;
  38286. private _buttons;
  38287. private _activeButton;
  38288. /**
  38289. * Fired every time the active button is changed.
  38290. *
  38291. * When xr is entered via a button that launches xr that button will be the callback parameter
  38292. *
  38293. * When exiting xr the callback parameter will be null)
  38294. */
  38295. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  38296. /**
  38297. * Creates UI to allow the user to enter/exit XR mode
  38298. * @param scene the scene to add the ui to
  38299. * @param helper the xr experience helper to enter/exit xr with
  38300. * @param options options to configure the UI
  38301. * @returns the created ui
  38302. */
  38303. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  38304. private constructor();
  38305. private _updateButtons;
  38306. /**
  38307. * Disposes of the object
  38308. */
  38309. dispose(): void;
  38310. }
  38311. }
  38312. declare module BABYLON {
  38313. /**
  38314. * Represents an XR input
  38315. */
  38316. export class WebXRController {
  38317. /**
  38318. * 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
  38319. */
  38320. grip?: AbstractMesh;
  38321. /**
  38322. * Pointer which can be used to select objects or attach a visible laser to
  38323. */
  38324. pointer: AbstractMesh;
  38325. /**
  38326. * Creates the controller
  38327. * @see https://doc.babylonjs.com/how_to/webxr
  38328. * @param scene the scene which the controller should be associated to
  38329. */
  38330. constructor(scene: Scene);
  38331. /**
  38332. * Disposes of the object
  38333. */
  38334. dispose(): void;
  38335. }
  38336. /**
  38337. * XR input used to track XR inputs such as controllers/rays
  38338. */
  38339. export class WebXRInput implements IDisposable {
  38340. private helper;
  38341. /**
  38342. * XR controllers being tracked
  38343. */
  38344. controllers: Array<WebXRController>;
  38345. private _tmpMatrix;
  38346. private _frameObserver;
  38347. /**
  38348. * Initializes the WebXRInput
  38349. * @param helper experience helper which the input should be created for
  38350. */
  38351. constructor(helper: WebXRExperienceHelper);
  38352. /**
  38353. * Disposes of the object
  38354. */
  38355. dispose(): void;
  38356. }
  38357. }
  38358. declare module BABYLON {
  38359. /**
  38360. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  38361. */
  38362. export class WebXRManagedOutputCanvas implements IDisposable {
  38363. private _canvas;
  38364. /**
  38365. * xrpresent context of the canvas which can be used to display/mirror xr content
  38366. */
  38367. canvasContext: Nullable<WebGLRenderingContext>;
  38368. /**
  38369. * Initializes the canvas to be added/removed upon entering/exiting xr
  38370. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  38371. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  38372. */
  38373. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  38374. /**
  38375. * Disposes of the object
  38376. */
  38377. dispose(): void;
  38378. private _setManagedOutputCanvas;
  38379. private _addCanvas;
  38380. private _removeCanvas;
  38381. }
  38382. }
  38383. declare module BABYLON {
  38384. /**
  38385. * Contains an array of blocks representing the octree
  38386. */
  38387. export interface IOctreeContainer<T> {
  38388. /**
  38389. * Blocks within the octree
  38390. */
  38391. blocks: Array<OctreeBlock<T>>;
  38392. }
  38393. /**
  38394. * Class used to store a cell in an octree
  38395. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  38396. */
  38397. export class OctreeBlock<T> {
  38398. /**
  38399. * Gets the content of the current block
  38400. */
  38401. entries: T[];
  38402. /**
  38403. * Gets the list of block children
  38404. */
  38405. blocks: Array<OctreeBlock<T>>;
  38406. private _depth;
  38407. private _maxDepth;
  38408. private _capacity;
  38409. private _minPoint;
  38410. private _maxPoint;
  38411. private _boundingVectors;
  38412. private _creationFunc;
  38413. /**
  38414. * Creates a new block
  38415. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  38416. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  38417. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  38418. * @param depth defines the current depth of this block in the octree
  38419. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  38420. * @param creationFunc defines a callback to call when an element is added to the block
  38421. */
  38422. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  38423. /**
  38424. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  38425. */
  38426. readonly capacity: number;
  38427. /**
  38428. * Gets the minimum vector (in world space) of the block's bounding box
  38429. */
  38430. readonly minPoint: Vector3;
  38431. /**
  38432. * Gets the maximum vector (in world space) of the block's bounding box
  38433. */
  38434. readonly maxPoint: Vector3;
  38435. /**
  38436. * Add a new element to this block
  38437. * @param entry defines the element to add
  38438. */
  38439. addEntry(entry: T): void;
  38440. /**
  38441. * Remove an element from this block
  38442. * @param entry defines the element to remove
  38443. */
  38444. removeEntry(entry: T): void;
  38445. /**
  38446. * Add an array of elements to this block
  38447. * @param entries defines the array of elements to add
  38448. */
  38449. addEntries(entries: T[]): void;
  38450. /**
  38451. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  38452. * @param frustumPlanes defines the frustum planes to test
  38453. * @param selection defines the array to store current content if selection is positive
  38454. * @param allowDuplicate defines if the selection array can contains duplicated entries
  38455. */
  38456. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  38457. /**
  38458. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  38459. * @param sphereCenter defines the bounding sphere center
  38460. * @param sphereRadius defines the bounding sphere radius
  38461. * @param selection defines the array to store current content if selection is positive
  38462. * @param allowDuplicate defines if the selection array can contains duplicated entries
  38463. */
  38464. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  38465. /**
  38466. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  38467. * @param ray defines the ray to test with
  38468. * @param selection defines the array to store current content if selection is positive
  38469. */
  38470. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  38471. /**
  38472. * Subdivide the content into child blocks (this block will then be empty)
  38473. */
  38474. createInnerBlocks(): void;
  38475. /**
  38476. * @hidden
  38477. */ 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;
  38478. }
  38479. }
  38480. declare module BABYLON {
  38481. /**
  38482. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  38483. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  38484. */
  38485. export class Octree<T> {
  38486. /** 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.) */
  38487. maxDepth: number;
  38488. /**
  38489. * Blocks within the octree containing objects
  38490. */
  38491. blocks: Array<OctreeBlock<T>>;
  38492. /**
  38493. * Content stored in the octree
  38494. */
  38495. dynamicContent: T[];
  38496. private _maxBlockCapacity;
  38497. private _selectionContent;
  38498. private _creationFunc;
  38499. /**
  38500. * Creates a octree
  38501. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  38502. * @param creationFunc function to be used to instatiate the octree
  38503. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  38504. * @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.)
  38505. */
  38506. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  38507. /** 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.) */
  38508. maxDepth?: number);
  38509. /**
  38510. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  38511. * @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);
  38512. * @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);
  38513. * @param entries meshes to be added to the octree blocks
  38514. */
  38515. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  38516. /**
  38517. * Adds a mesh to the octree
  38518. * @param entry Mesh to add to the octree
  38519. */
  38520. addMesh(entry: T): void;
  38521. /**
  38522. * Remove an element from the octree
  38523. * @param entry defines the element to remove
  38524. */
  38525. removeMesh(entry: T): void;
  38526. /**
  38527. * Selects an array of meshes within the frustum
  38528. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  38529. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  38530. * @returns array of meshes within the frustum
  38531. */
  38532. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  38533. /**
  38534. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  38535. * @param sphereCenter defines the bounding sphere center
  38536. * @param sphereRadius defines the bounding sphere radius
  38537. * @param allowDuplicate defines if the selection array can contains duplicated entries
  38538. * @returns an array of objects that intersect the sphere
  38539. */
  38540. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  38541. /**
  38542. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  38543. * @param ray defines the ray to test with
  38544. * @returns array of intersected objects
  38545. */
  38546. intersectsRay(ray: Ray): SmartArray<T>;
  38547. /**
  38548. * Adds a mesh into the octree block if it intersects the block
  38549. */
  38550. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  38551. /**
  38552. * Adds a submesh into the octree block if it intersects the block
  38553. */
  38554. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  38555. }
  38556. }
  38557. declare module BABYLON {
  38558. interface Scene {
  38559. /**
  38560. * @hidden
  38561. * Backing Filed
  38562. */ selectionOctree: Octree<AbstractMesh>;
  38563. /**
  38564. * Gets the octree used to boost mesh selection (picking)
  38565. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  38566. */
  38567. selectionOctree: Octree<AbstractMesh>;
  38568. /**
  38569. * Creates or updates the octree used to boost selection (picking)
  38570. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  38571. * @param maxCapacity defines the maximum capacity per leaf
  38572. * @param maxDepth defines the maximum depth of the octree
  38573. * @returns an octree of AbstractMesh
  38574. */
  38575. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  38576. }
  38577. interface AbstractMesh {
  38578. /**
  38579. * @hidden
  38580. * Backing Field
  38581. */ submeshesOctree: Octree<SubMesh>;
  38582. /**
  38583. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  38584. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  38585. * @param maxCapacity defines the maximum size of each block (64 by default)
  38586. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  38587. * @returns the new octree
  38588. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  38589. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  38590. */
  38591. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  38592. }
  38593. /**
  38594. * Defines the octree scene component responsible to manage any octrees
  38595. * in a given scene.
  38596. */
  38597. export class OctreeSceneComponent {
  38598. /**
  38599. * The component name helpfull to identify the component in the list of scene components.
  38600. */
  38601. readonly name: string;
  38602. /**
  38603. * The scene the component belongs to.
  38604. */
  38605. scene: Scene;
  38606. /**
  38607. * Indicates if the meshes have been checked to make sure they are isEnabled()
  38608. */
  38609. readonly checksIsEnabled: boolean;
  38610. /**
  38611. * Creates a new instance of the component for the given scene
  38612. * @param scene Defines the scene to register the component in
  38613. */
  38614. constructor(scene: Scene);
  38615. /**
  38616. * Registers the component in a given scene
  38617. */
  38618. register(): void;
  38619. /**
  38620. * Return the list of active meshes
  38621. * @returns the list of active meshes
  38622. */
  38623. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  38624. /**
  38625. * Return the list of active sub meshes
  38626. * @param mesh The mesh to get the candidates sub meshes from
  38627. * @returns the list of active sub meshes
  38628. */
  38629. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  38630. private _tempRay;
  38631. /**
  38632. * Return the list of sub meshes intersecting with a given local ray
  38633. * @param mesh defines the mesh to find the submesh for
  38634. * @param localRay defines the ray in local space
  38635. * @returns the list of intersecting sub meshes
  38636. */
  38637. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  38638. /**
  38639. * Return the list of sub meshes colliding with a collider
  38640. * @param mesh defines the mesh to find the submesh for
  38641. * @param collider defines the collider to evaluate the collision against
  38642. * @returns the list of colliding sub meshes
  38643. */
  38644. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  38645. /**
  38646. * Rebuilds the elements related to this component in case of
  38647. * context lost for instance.
  38648. */
  38649. rebuild(): void;
  38650. /**
  38651. * Disposes the component and the associated ressources.
  38652. */
  38653. dispose(): void;
  38654. }
  38655. }
  38656. declare module BABYLON {
  38657. /**
  38658. * Class containing static functions to help procedurally build meshes
  38659. */
  38660. export class LinesBuilder {
  38661. /**
  38662. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  38663. * * 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
  38664. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  38665. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  38666. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  38667. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  38668. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  38669. * * 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
  38670. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  38671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38672. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  38673. * @param name defines the name of the new line system
  38674. * @param options defines the options used to create the line system
  38675. * @param scene defines the hosting scene
  38676. * @returns a new line system mesh
  38677. */
  38678. static CreateLineSystem(name: string, options: {
  38679. lines: Vector3[][];
  38680. updatable?: boolean;
  38681. instance?: Nullable<LinesMesh>;
  38682. colors?: Nullable<Color4[][]>;
  38683. useVertexAlpha?: boolean;
  38684. }, scene: Nullable<Scene>): LinesMesh;
  38685. /**
  38686. * Creates a line mesh
  38687. * 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
  38688. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  38689. * * The parameter `points` is an array successive Vector3
  38690. * * 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
  38691. * * The optional parameter `colors` is an array of successive Color4, one per line point
  38692. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  38693. * * When updating an instance, remember that only point positions can change, not the number of points
  38694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38695. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  38696. * @param name defines the name of the new line system
  38697. * @param options defines the options used to create the line system
  38698. * @param scene defines the hosting scene
  38699. * @returns a new line mesh
  38700. */
  38701. static CreateLines(name: string, options: {
  38702. points: Vector3[];
  38703. updatable?: boolean;
  38704. instance?: Nullable<LinesMesh>;
  38705. colors?: Color4[];
  38706. useVertexAlpha?: boolean;
  38707. }, scene?: Nullable<Scene>): LinesMesh;
  38708. /**
  38709. * Creates a dashed line mesh
  38710. * * 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
  38711. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  38712. * * The parameter `points` is an array successive Vector3
  38713. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  38714. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  38715. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  38716. * * 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
  38717. * * When updating an instance, remember that only point positions can change, not the number of points
  38718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38719. * @param name defines the name of the mesh
  38720. * @param options defines the options used to create the mesh
  38721. * @param scene defines the hosting scene
  38722. * @returns the dashed line mesh
  38723. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  38724. */
  38725. static CreateDashedLines(name: string, options: {
  38726. points: Vector3[];
  38727. dashSize?: number;
  38728. gapSize?: number;
  38729. dashNb?: number;
  38730. updatable?: boolean;
  38731. instance?: LinesMesh;
  38732. }, scene?: Nullable<Scene>): LinesMesh;
  38733. }
  38734. }
  38735. declare module BABYLON {
  38736. /**
  38737. * Renders a layer on top of an existing scene
  38738. */
  38739. export class UtilityLayerRenderer implements IDisposable {
  38740. /** the original scene that will be rendered on top of */
  38741. originalScene: Scene;
  38742. private _pointerCaptures;
  38743. private _lastPointerEvents;
  38744. private static _DefaultUtilityLayer;
  38745. private static _DefaultKeepDepthUtilityLayer;
  38746. /**
  38747. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  38748. */
  38749. pickUtilitySceneFirst: boolean;
  38750. /**
  38751. * 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)
  38752. */
  38753. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  38754. /**
  38755. * 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)
  38756. */
  38757. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  38758. /**
  38759. * The scene that is rendered on top of the original scene
  38760. */
  38761. utilityLayerScene: Scene;
  38762. /**
  38763. * If the utility layer should automatically be rendered on top of existing scene
  38764. */
  38765. shouldRender: boolean;
  38766. /**
  38767. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  38768. */
  38769. onlyCheckPointerDownEvents: boolean;
  38770. /**
  38771. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  38772. */
  38773. processAllEvents: boolean;
  38774. /**
  38775. * Observable raised when the pointer move from the utility layer scene to the main scene
  38776. */
  38777. onPointerOutObservable: Observable<number>;
  38778. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  38779. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  38780. private _afterRenderObserver;
  38781. private _sceneDisposeObserver;
  38782. private _originalPointerObserver;
  38783. /**
  38784. * Instantiates a UtilityLayerRenderer
  38785. * @param originalScene the original scene that will be rendered on top of
  38786. * @param handleEvents boolean indicating if the utility layer should handle events
  38787. */
  38788. constructor(
  38789. /** the original scene that will be rendered on top of */
  38790. originalScene: Scene, handleEvents?: boolean);
  38791. private _notifyObservers;
  38792. /**
  38793. * Renders the utility layers scene on top of the original scene
  38794. */
  38795. render(): void;
  38796. /**
  38797. * Disposes of the renderer
  38798. */
  38799. dispose(): void;
  38800. private _updateCamera;
  38801. }
  38802. }
  38803. declare module BABYLON {
  38804. /**
  38805. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  38806. */
  38807. export class Gizmo implements IDisposable {
  38808. /** The utility layer the gizmo will be added to */
  38809. gizmoLayer: UtilityLayerRenderer;
  38810. /**
  38811. * The root mesh of the gizmo
  38812. */
  38813. protected _rootMesh: Mesh;
  38814. private _attachedMesh;
  38815. /**
  38816. * Ratio for the scale of the gizmo (Default: 1)
  38817. */
  38818. scaleRatio: number;
  38819. private _tmpMatrix;
  38820. /**
  38821. * If a custom mesh has been set (Default: false)
  38822. */
  38823. protected _customMeshSet: boolean;
  38824. /**
  38825. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  38826. * * When set, interactions will be enabled
  38827. */
  38828. attachedMesh: Nullable<AbstractMesh>;
  38829. /**
  38830. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  38831. * @param mesh The mesh to replace the default mesh of the gizmo
  38832. */
  38833. setCustomMesh(mesh: Mesh): void;
  38834. /**
  38835. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  38836. */
  38837. updateGizmoRotationToMatchAttachedMesh: boolean;
  38838. /**
  38839. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  38840. */
  38841. updateGizmoPositionToMatchAttachedMesh: boolean;
  38842. /**
  38843. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  38844. */
  38845. protected _updateScale: boolean;
  38846. protected _interactionsEnabled: boolean;
  38847. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  38848. private _beforeRenderObserver;
  38849. /**
  38850. * Creates a gizmo
  38851. * @param gizmoLayer The utility layer the gizmo will be added to
  38852. */
  38853. constructor(
  38854. /** The utility layer the gizmo will be added to */
  38855. gizmoLayer?: UtilityLayerRenderer);
  38856. private _tempVector;
  38857. /**
  38858. * @hidden
  38859. * Updates the gizmo to match the attached mesh's position/rotation
  38860. */
  38861. protected _update(): void;
  38862. /**
  38863. * Disposes of the gizmo
  38864. */
  38865. dispose(): void;
  38866. }
  38867. }
  38868. declare module BABYLON {
  38869. /**
  38870. * Single axis drag gizmo
  38871. */
  38872. export class AxisDragGizmo extends Gizmo {
  38873. /**
  38874. * Drag behavior responsible for the gizmos dragging interactions
  38875. */
  38876. dragBehavior: PointerDragBehavior;
  38877. private _pointerObserver;
  38878. /**
  38879. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  38880. */
  38881. snapDistance: number;
  38882. /**
  38883. * Event that fires each time the gizmo snaps to a new location.
  38884. * * snapDistance is the the change in distance
  38885. */
  38886. onSnapObservable: Observable<{
  38887. snapDistance: number;
  38888. }>;
  38889. /** @hidden */ private static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  38890. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  38891. /**
  38892. * Creates an AxisDragGizmo
  38893. * @param gizmoLayer The utility layer the gizmo will be added to
  38894. * @param dragAxis The axis which the gizmo will be able to drag on
  38895. * @param color The color of the gizmo
  38896. */
  38897. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  38898. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  38899. /**
  38900. * Disposes of the gizmo
  38901. */
  38902. dispose(): void;
  38903. }
  38904. }
  38905. declare module BABYLON.Debug {
  38906. /**
  38907. * The Axes viewer will show 3 axes in a specific point in space
  38908. */
  38909. export class AxesViewer {
  38910. private _xAxis;
  38911. private _yAxis;
  38912. private _zAxis;
  38913. private _scaleLinesFactor;
  38914. private _instanced;
  38915. /**
  38916. * Gets the hosting scene
  38917. */
  38918. scene: Scene;
  38919. /**
  38920. * Gets or sets a number used to scale line length
  38921. */
  38922. scaleLines: number;
  38923. /** Gets the node hierarchy used to render x-axis */
  38924. readonly xAxis: TransformNode;
  38925. /** Gets the node hierarchy used to render y-axis */
  38926. readonly yAxis: TransformNode;
  38927. /** Gets the node hierarchy used to render z-axis */
  38928. readonly zAxis: TransformNode;
  38929. /**
  38930. * Creates a new AxesViewer
  38931. * @param scene defines the hosting scene
  38932. * @param scaleLines defines a number used to scale line length (1 by default)
  38933. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  38934. * @param xAxis defines the node hierarchy used to render the x-axis
  38935. * @param yAxis defines the node hierarchy used to render the y-axis
  38936. * @param zAxis defines the node hierarchy used to render the z-axis
  38937. */
  38938. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  38939. /**
  38940. * Force the viewer to update
  38941. * @param position defines the position of the viewer
  38942. * @param xaxis defines the x axis of the viewer
  38943. * @param yaxis defines the y axis of the viewer
  38944. * @param zaxis defines the z axis of the viewer
  38945. */
  38946. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  38947. /**
  38948. * Creates an instance of this axes viewer.
  38949. * @returns a new axes viewer with instanced meshes
  38950. */
  38951. createInstance(): AxesViewer;
  38952. /** Releases resources */
  38953. dispose(): void;
  38954. private static _SetRenderingGroupId;
  38955. }
  38956. }
  38957. declare module BABYLON.Debug {
  38958. /**
  38959. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  38960. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  38961. */
  38962. export class BoneAxesViewer extends AxesViewer {
  38963. /**
  38964. * Gets or sets the target mesh where to display the axes viewer
  38965. */
  38966. mesh: Nullable<Mesh>;
  38967. /**
  38968. * Gets or sets the target bone where to display the axes viewer
  38969. */
  38970. bone: Nullable<Bone>;
  38971. /** Gets current position */
  38972. pos: Vector3;
  38973. /** Gets direction of X axis */
  38974. xaxis: Vector3;
  38975. /** Gets direction of Y axis */
  38976. yaxis: Vector3;
  38977. /** Gets direction of Z axis */
  38978. zaxis: Vector3;
  38979. /**
  38980. * Creates a new BoneAxesViewer
  38981. * @param scene defines the hosting scene
  38982. * @param bone defines the target bone
  38983. * @param mesh defines the target mesh
  38984. * @param scaleLines defines a scaling factor for line length (1 by default)
  38985. */
  38986. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  38987. /**
  38988. * Force the viewer to update
  38989. */
  38990. update(): void;
  38991. /** Releases resources */
  38992. dispose(): void;
  38993. }
  38994. }
  38995. declare module BABYLON {
  38996. /**
  38997. * Interface used to define scene explorer extensibility option
  38998. */
  38999. export interface IExplorerExtensibilityOption {
  39000. /**
  39001. * Define the option label
  39002. */
  39003. label: string;
  39004. /**
  39005. * Defines the action to execute on click
  39006. */
  39007. action: (entity: any) => void;
  39008. }
  39009. /**
  39010. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  39011. */
  39012. export interface IExplorerExtensibilityGroup {
  39013. /**
  39014. * Defines a predicate to test if a given type mut be extended
  39015. */
  39016. predicate: (entity: any) => boolean;
  39017. /**
  39018. * Gets the list of options added to a type
  39019. */
  39020. entries: IExplorerExtensibilityOption[];
  39021. }
  39022. /**
  39023. * Interface used to define the options to use to create the Inspector
  39024. */
  39025. export interface IInspectorOptions {
  39026. /**
  39027. * Display in overlay mode (default: false)
  39028. */
  39029. overlay?: boolean;
  39030. /**
  39031. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  39032. */
  39033. globalRoot?: HTMLElement;
  39034. /**
  39035. * Display the Scene explorer
  39036. */
  39037. showExplorer?: boolean;
  39038. /**
  39039. * Display the property inspector
  39040. */
  39041. showInspector?: boolean;
  39042. /**
  39043. * Display in embed mode (both panes on the right)
  39044. */
  39045. embedMode?: boolean;
  39046. /**
  39047. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  39048. */
  39049. handleResize?: boolean;
  39050. /**
  39051. * Allow the panes to popup (default: true)
  39052. */
  39053. enablePopup?: boolean;
  39054. /**
  39055. * Allow the panes to be closed by users (default: true)
  39056. */
  39057. enableClose?: boolean;
  39058. /**
  39059. * Optional list of extensibility entries
  39060. */
  39061. explorerExtensibility?: IExplorerExtensibilityGroup[];
  39062. }
  39063. interface Scene {
  39064. /**
  39065. * @hidden
  39066. * Backing field
  39067. */ debugLayer: DebugLayer;
  39068. /**
  39069. * Gets the debug layer (aka Inspector) associated with the scene
  39070. * @see http://doc.babylonjs.com/features/playground_debuglayer
  39071. */
  39072. debugLayer: DebugLayer;
  39073. }
  39074. /**
  39075. * The debug layer (aka Inspector) is the go to tool in order to better understand
  39076. * what is happening in your scene
  39077. * @see http://doc.babylonjs.com/features/playground_debuglayer
  39078. */
  39079. export class DebugLayer {
  39080. /**
  39081. * Define the url to get the inspector script from.
  39082. * By default it uses the babylonjs CDN.
  39083. * @ignoreNaming
  39084. */
  39085. static InspectorURL: string;
  39086. private _scene;
  39087. private BJSINSPECTOR;
  39088. /**
  39089. * Observable triggered when a property is changed through the inspector.
  39090. */
  39091. onPropertyChangedObservable: Observable<{
  39092. object: any;
  39093. property: string;
  39094. value: any;
  39095. initialValue: any;
  39096. }>;
  39097. /**
  39098. * Instantiates a new debug layer.
  39099. * The debug layer (aka Inspector) is the go to tool in order to better understand
  39100. * what is happening in your scene
  39101. * @see http://doc.babylonjs.com/features/playground_debuglayer
  39102. * @param scene Defines the scene to inspect
  39103. */
  39104. constructor(scene: Scene);
  39105. /** Creates the inspector window. */
  39106. private _createInspector;
  39107. /** Get the inspector from bundle or global */
  39108. private _getGlobalInspector;
  39109. /**
  39110. * Get if the inspector is visible or not.
  39111. * @returns true if visible otherwise, false
  39112. */
  39113. isVisible(): boolean;
  39114. /**
  39115. * Hide the inspector and close its window.
  39116. */
  39117. hide(): void;
  39118. /**
  39119. * Launch the debugLayer.
  39120. * @param config Define the configuration of the inspector
  39121. */
  39122. show(config?: IInspectorOptions): void;
  39123. }
  39124. }
  39125. declare module BABYLON {
  39126. /**
  39127. * Class containing static functions to help procedurally build meshes
  39128. */
  39129. export class BoxBuilder {
  39130. /**
  39131. * Creates a box mesh
  39132. * * The parameter `size` sets the size (float) of each box side (default 1)
  39133. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  39134. * * 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)
  39135. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  39136. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39137. * * 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
  39138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39139. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  39140. * @param name defines the name of the mesh
  39141. * @param options defines the options used to create the mesh
  39142. * @param scene defines the hosting scene
  39143. * @returns the box mesh
  39144. */
  39145. static CreateBox(name: string, options: {
  39146. size?: number;
  39147. width?: number;
  39148. height?: number;
  39149. depth?: number;
  39150. faceUV?: Vector4[];
  39151. faceColors?: Color4[];
  39152. sideOrientation?: number;
  39153. frontUVs?: Vector4;
  39154. backUVs?: Vector4;
  39155. updatable?: boolean;
  39156. }, scene?: Nullable<Scene>): Mesh;
  39157. }
  39158. }
  39159. declare module BABYLON {
  39160. /**
  39161. * Class containing static functions to help procedurally build meshes
  39162. */
  39163. export class SphereBuilder {
  39164. /**
  39165. * Creates a sphere mesh
  39166. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  39167. * * 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`)
  39168. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  39169. * * 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
  39170. * * 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)
  39171. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39172. * * 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
  39173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39174. * @param name defines the name of the mesh
  39175. * @param options defines the options used to create the mesh
  39176. * @param scene defines the hosting scene
  39177. * @returns the sphere mesh
  39178. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  39179. */
  39180. static CreateSphere(name: string, options: {
  39181. segments?: number;
  39182. diameter?: number;
  39183. diameterX?: number;
  39184. diameterY?: number;
  39185. diameterZ?: number;
  39186. arc?: number;
  39187. slice?: number;
  39188. sideOrientation?: number;
  39189. frontUVs?: Vector4;
  39190. backUVs?: Vector4;
  39191. updatable?: boolean;
  39192. }, scene: any): Mesh;
  39193. }
  39194. }
  39195. declare module BABYLON.Debug {
  39196. /**
  39197. * Used to show the physics impostor around the specific mesh
  39198. */
  39199. export class PhysicsViewer {
  39200. /** @hidden */
  39201. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  39202. /** @hidden */
  39203. protected _meshes: Array<Nullable<AbstractMesh>>;
  39204. /** @hidden */
  39205. protected _scene: Nullable<Scene>;
  39206. /** @hidden */
  39207. protected _numMeshes: number;
  39208. /** @hidden */
  39209. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  39210. private _renderFunction;
  39211. private _utilityLayer;
  39212. private _debugBoxMesh;
  39213. private _debugSphereMesh;
  39214. private _debugMaterial;
  39215. /**
  39216. * Creates a new PhysicsViewer
  39217. * @param scene defines the hosting scene
  39218. */
  39219. constructor(scene: Scene);
  39220. /** @hidden */
  39221. protected _updateDebugMeshes(): void;
  39222. /**
  39223. * Renders a specified physic impostor
  39224. * @param impostor defines the impostor to render
  39225. * @returns the new debug mesh used to render the impostor
  39226. */
  39227. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  39228. /**
  39229. * Hides a specified physic impostor
  39230. * @param impostor defines the impostor to hide
  39231. */
  39232. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  39233. private _getDebugMaterial;
  39234. private _getDebugBoxMesh;
  39235. private _getDebugSphereMesh;
  39236. private _getDebugMesh;
  39237. /** Releases all resources */
  39238. dispose(): void;
  39239. }
  39240. }
  39241. declare module BABYLON {
  39242. /**
  39243. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  39244. * in order to better appreciate the issue one might have.
  39245. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  39246. */
  39247. export class RayHelper {
  39248. /**
  39249. * Defines the ray we are currently tryin to visualize.
  39250. */
  39251. ray: Nullable<Ray>;
  39252. private _renderPoints;
  39253. private _renderLine;
  39254. private _renderFunction;
  39255. private _scene;
  39256. private _updateToMeshFunction;
  39257. private _attachedToMesh;
  39258. private _meshSpaceDirection;
  39259. private _meshSpaceOrigin;
  39260. /**
  39261. * Helper function to create a colored helper in a scene in one line.
  39262. * @param ray Defines the ray we are currently tryin to visualize
  39263. * @param scene Defines the scene the ray is used in
  39264. * @param color Defines the color we want to see the ray in
  39265. * @returns The newly created ray helper.
  39266. */
  39267. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  39268. /**
  39269. * Instantiate a new ray helper.
  39270. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  39271. * in order to better appreciate the issue one might have.
  39272. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  39273. * @param ray Defines the ray we are currently tryin to visualize
  39274. */
  39275. constructor(ray: Ray);
  39276. /**
  39277. * Shows the ray we are willing to debug.
  39278. * @param scene Defines the scene the ray needs to be rendered in
  39279. * @param color Defines the color the ray needs to be rendered in
  39280. */
  39281. show(scene: Scene, color?: Color3): void;
  39282. /**
  39283. * Hides the ray we are debugging.
  39284. */
  39285. hide(): void;
  39286. private _render;
  39287. /**
  39288. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  39289. * @param mesh Defines the mesh we want the helper attached to
  39290. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  39291. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  39292. * @param length Defines the length of the ray
  39293. */
  39294. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  39295. /**
  39296. * Detach the ray helper from the mesh it has previously been attached to.
  39297. */
  39298. detachFromMesh(): void;
  39299. private _updateToMesh;
  39300. /**
  39301. * Dispose the helper and release its associated resources.
  39302. */
  39303. dispose(): void;
  39304. }
  39305. }
  39306. declare module BABYLON.Debug {
  39307. /**
  39308. * Class used to render a debug view of a given skeleton
  39309. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  39310. */
  39311. export class SkeletonViewer {
  39312. /** defines the skeleton to render */
  39313. skeleton: Skeleton;
  39314. /** defines the mesh attached to the skeleton */
  39315. mesh: AbstractMesh;
  39316. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  39317. autoUpdateBonesMatrices: boolean;
  39318. /** defines the rendering group id to use with the viewer */
  39319. renderingGroupId: number;
  39320. /** Gets or sets the color used to render the skeleton */
  39321. color: Color3;
  39322. private _scene;
  39323. private _debugLines;
  39324. private _debugMesh;
  39325. private _isEnabled;
  39326. private _renderFunction;
  39327. private _utilityLayer;
  39328. /**
  39329. * Returns the mesh used to render the bones
  39330. */
  39331. readonly debugMesh: Nullable<LinesMesh>;
  39332. /**
  39333. * Creates a new SkeletonViewer
  39334. * @param skeleton defines the skeleton to render
  39335. * @param mesh defines the mesh attached to the skeleton
  39336. * @param scene defines the hosting scene
  39337. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  39338. * @param renderingGroupId defines the rendering group id to use with the viewer
  39339. */
  39340. constructor(
  39341. /** defines the skeleton to render */
  39342. skeleton: Skeleton,
  39343. /** defines the mesh attached to the skeleton */
  39344. mesh: AbstractMesh, scene: Scene,
  39345. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  39346. autoUpdateBonesMatrices?: boolean,
  39347. /** defines the rendering group id to use with the viewer */
  39348. renderingGroupId?: number);
  39349. /** Gets or sets a boolean indicating if the viewer is enabled */
  39350. isEnabled: boolean;
  39351. private _getBonePosition;
  39352. private _getLinesForBonesWithLength;
  39353. private _getLinesForBonesNoLength;
  39354. /** Update the viewer to sync with current skeleton state */
  39355. update(): void;
  39356. /** Release associated resources */
  39357. dispose(): void;
  39358. }
  39359. }
  39360. declare module BABYLON {
  39361. /**
  39362. * Options to create the null engine
  39363. */
  39364. export class NullEngineOptions {
  39365. /**
  39366. * Render width (Default: 512)
  39367. */
  39368. renderWidth: number;
  39369. /**
  39370. * Render height (Default: 256)
  39371. */
  39372. renderHeight: number;
  39373. /**
  39374. * Texture size (Default: 512)
  39375. */
  39376. textureSize: number;
  39377. /**
  39378. * If delta time between frames should be constant
  39379. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39380. */
  39381. deterministicLockstep: boolean;
  39382. /**
  39383. * Maximum about of steps between frames (Default: 4)
  39384. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39385. */
  39386. lockstepMaxSteps: number;
  39387. }
  39388. /**
  39389. * The null engine class provides support for headless version of babylon.js.
  39390. * This can be used in server side scenario or for testing purposes
  39391. */
  39392. export class NullEngine extends Engine {
  39393. private _options;
  39394. /**
  39395. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39396. */
  39397. isDeterministicLockStep(): boolean;
  39398. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  39399. getLockstepMaxSteps(): number;
  39400. /**
  39401. * Sets hardware scaling, used to save performance if needed
  39402. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  39403. */
  39404. getHardwareScalingLevel(): number;
  39405. constructor(options?: NullEngineOptions);
  39406. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  39407. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  39408. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  39409. getRenderWidth(useScreen?: boolean): number;
  39410. getRenderHeight(useScreen?: boolean): number;
  39411. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  39412. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  39413. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  39414. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  39415. bindSamplers(effect: Effect): void;
  39416. enableEffect(effect: Effect): void;
  39417. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  39418. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  39419. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  39420. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  39421. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  39422. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  39423. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  39424. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  39425. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  39426. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  39427. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  39428. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  39429. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  39430. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  39431. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  39432. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  39433. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  39434. setFloat(uniform: WebGLUniformLocation, value: number): void;
  39435. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  39436. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  39437. setBool(uniform: WebGLUniformLocation, bool: number): void;
  39438. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  39439. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  39440. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  39441. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  39442. bindBuffers(vertexBuffers: {
  39443. [key: string]: VertexBuffer;
  39444. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  39445. wipeCaches(bruteForce?: boolean): void;
  39446. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  39447. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  39448. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39449. /** @hidden */ createTexture(): WebGLTexture;
  39450. /** @hidden */ releaseTexture(texture: InternalTexture): void;
  39451. 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;
  39452. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  39453. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  39454. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  39455. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  39456. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  39457. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  39458. areAllEffectsReady(): boolean;
  39459. /**
  39460. * @hidden
  39461. * Get the current error code of the webGL context
  39462. * @returns the error code
  39463. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  39464. */
  39465. getError(): number;
  39466. /** @hidden */ getUnpackAlignement(): number;
  39467. /** @hidden */ unpackFlipY(value: boolean): void;
  39468. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  39469. /**
  39470. * Updates a dynamic vertex buffer.
  39471. * @param vertexBuffer the vertex buffer to update
  39472. * @param data the data used to update the vertex buffer
  39473. * @param byteOffset the byte offset of the data (optional)
  39474. * @param byteLength the byte length of the data (optional)
  39475. */
  39476. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void; bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  39477. /** @hidden */ bindTexture(channel: number, texture: InternalTexture): void;
  39478. /** @hidden */ releaseBuffer(buffer: WebGLBuffer): boolean;
  39479. releaseEffects(): void;
  39480. displayLoadingUI(): void;
  39481. hideLoadingUI(): void;
  39482. /** @hidden */ uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39483. /** @hidden */ uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39484. /** @hidden */ uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39485. /** @hidden */ uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  39486. }
  39487. }
  39488. declare module BABYLON {
  39489. /** @hidden */
  39490. export class _OcclusionDataStorage {
  39491. /** @hidden */
  39492. occlusionInternalRetryCounter: number;
  39493. /** @hidden */
  39494. isOcclusionQueryInProgress: boolean;
  39495. /** @hidden */
  39496. isOccluded: boolean;
  39497. /** @hidden */
  39498. occlusionRetryCount: number;
  39499. /** @hidden */
  39500. occlusionType: number;
  39501. /** @hidden */
  39502. occlusionQueryAlgorithmType: number;
  39503. }
  39504. interface Engine {
  39505. /**
  39506. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  39507. * @return the new query
  39508. */
  39509. createQuery(): WebGLQuery;
  39510. /**
  39511. * Delete and release a webGL query
  39512. * @param query defines the query to delete
  39513. * @return the current engine
  39514. */
  39515. deleteQuery(query: WebGLQuery): Engine;
  39516. /**
  39517. * Check if a given query has resolved and got its value
  39518. * @param query defines the query to check
  39519. * @returns true if the query got its value
  39520. */
  39521. isQueryResultAvailable(query: WebGLQuery): boolean;
  39522. /**
  39523. * Gets the value of a given query
  39524. * @param query defines the query to check
  39525. * @returns the value of the query
  39526. */
  39527. getQueryResult(query: WebGLQuery): number;
  39528. /**
  39529. * Initiates an occlusion query
  39530. * @param algorithmType defines the algorithm to use
  39531. * @param query defines the query to use
  39532. * @returns the current engine
  39533. * @see http://doc.babylonjs.com/features/occlusionquery
  39534. */
  39535. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  39536. /**
  39537. * Ends an occlusion query
  39538. * @see http://doc.babylonjs.com/features/occlusionquery
  39539. * @param algorithmType defines the algorithm to use
  39540. * @returns the current engine
  39541. */
  39542. endOcclusionQuery(algorithmType: number): Engine;
  39543. /**
  39544. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  39545. * Please note that only one query can be issued at a time
  39546. * @returns a time token used to track the time span
  39547. */
  39548. startTimeQuery(): Nullable<_TimeToken>;
  39549. /**
  39550. * Ends a time query
  39551. * @param token defines the token used to measure the time span
  39552. * @returns the time spent (in ns)
  39553. */
  39554. endTimeQuery(token: _TimeToken): int;
  39555. /** @hidden */ currentNonTimestampToken: Nullable<_TimeToken>;
  39556. /** @hidden */ createTimeQuery(): WebGLQuery;
  39557. /** @hidden */ deleteTimeQuery(query: WebGLQuery): void;
  39558. /** @hidden */ getGlAlgorithmType(algorithmType: number): number;
  39559. /** @hidden */ getTimeQueryResult(query: WebGLQuery): any;
  39560. /** @hidden */ getTimeQueryAvailability(query: WebGLQuery): any;
  39561. }
  39562. interface AbstractMesh {
  39563. /**
  39564. * Backing filed
  39565. * @hidden
  39566. */ private _occlusionDataStorage: _OcclusionDataStorage;
  39567. /**
  39568. * Access property
  39569. * @hidden
  39570. */ occlusionDataStorage: _OcclusionDataStorage;
  39571. /**
  39572. * 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.
  39573. * The default value is -1 which means don't break the query and wait till the result
  39574. * @see http://doc.babylonjs.com/features/occlusionquery
  39575. */
  39576. occlusionRetryCount: number;
  39577. /**
  39578. * 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:
  39579. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  39580. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  39581. * * 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.
  39582. * @see http://doc.babylonjs.com/features/occlusionquery
  39583. */
  39584. occlusionType: number;
  39585. /**
  39586. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  39587. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  39588. * * 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.
  39589. * @see http://doc.babylonjs.com/features/occlusionquery
  39590. */
  39591. occlusionQueryAlgorithmType: number;
  39592. /**
  39593. * 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
  39594. * @see http://doc.babylonjs.com/features/occlusionquery
  39595. */
  39596. isOccluded: boolean;
  39597. /**
  39598. * Flag to check the progress status of the query
  39599. * @see http://doc.babylonjs.com/features/occlusionquery
  39600. */
  39601. isOcclusionQueryInProgress: boolean;
  39602. }
  39603. }
  39604. declare module BABYLON {
  39605. /** @hidden */
  39606. export var _forceTransformFeedbackToBundle: boolean;
  39607. interface Engine {
  39608. /**
  39609. * Creates a webGL transform feedback object
  39610. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  39611. * @returns the webGL transform feedback object
  39612. */
  39613. createTransformFeedback(): WebGLTransformFeedback;
  39614. /**
  39615. * Delete a webGL transform feedback object
  39616. * @param value defines the webGL transform feedback object to delete
  39617. */
  39618. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  39619. /**
  39620. * Bind a webGL transform feedback object to the webgl context
  39621. * @param value defines the webGL transform feedback object to bind
  39622. */
  39623. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  39624. /**
  39625. * Begins a transform feedback operation
  39626. * @param usePoints defines if points or triangles must be used
  39627. */
  39628. beginTransformFeedback(usePoints: boolean): void;
  39629. /**
  39630. * Ends a transform feedback operation
  39631. */
  39632. endTransformFeedback(): void;
  39633. /**
  39634. * Specify the varyings to use with transform feedback
  39635. * @param program defines the associated webGL program
  39636. * @param value defines the list of strings representing the varying names
  39637. */
  39638. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  39639. /**
  39640. * Bind a webGL buffer for a transform feedback operation
  39641. * @param value defines the webGL buffer to bind
  39642. */
  39643. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  39644. }
  39645. }
  39646. declare module BABYLON {
  39647. /**
  39648. * Gather the list of clipboard event types as constants.
  39649. */
  39650. export class ClipboardEventTypes {
  39651. /**
  39652. * The clipboard event is fired when a copy command is active (pressed).
  39653. */
  39654. static readonly COPY: number;
  39655. /**
  39656. * The clipboard event is fired when a cut command is active (pressed).
  39657. */
  39658. static readonly CUT: number;
  39659. /**
  39660. * The clipboard event is fired when a paste command is active (pressed).
  39661. */
  39662. static readonly PASTE: number;
  39663. }
  39664. /**
  39665. * This class is used to store clipboard related info for the onClipboardObservable event.
  39666. */
  39667. export class ClipboardInfo {
  39668. /**
  39669. * Defines the type of event (BABYLON.ClipboardEventTypes)
  39670. */
  39671. type: number;
  39672. /**
  39673. * Defines the related dom event
  39674. */
  39675. event: ClipboardEvent;
  39676. /**
  39677. *Creates an instance of ClipboardInfo.
  39678. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  39679. * @param event Defines the related dom event
  39680. */
  39681. constructor(
  39682. /**
  39683. * Defines the type of event (BABYLON.ClipboardEventTypes)
  39684. */
  39685. type: number,
  39686. /**
  39687. * Defines the related dom event
  39688. */
  39689. event: ClipboardEvent);
  39690. /**
  39691. * Get the clipboard event's type from the keycode.
  39692. * @param keyCode Defines the keyCode for the current keyboard event.
  39693. * @return {number}
  39694. */
  39695. static GetTypeFromCharacter(keyCode: number): number;
  39696. }
  39697. }
  39698. declare module BABYLON {
  39699. /**
  39700. * Class used to represent data loading progression
  39701. */
  39702. export class SceneLoaderProgressEvent {
  39703. /** defines if data length to load can be evaluated */
  39704. readonly lengthComputable: boolean;
  39705. /** defines the loaded data length */
  39706. readonly loaded: number;
  39707. /** defines the data length to load */
  39708. readonly total: number;
  39709. /**
  39710. * Create a new progress event
  39711. * @param lengthComputable defines if data length to load can be evaluated
  39712. * @param loaded defines the loaded data length
  39713. * @param total defines the data length to load
  39714. */
  39715. constructor(
  39716. /** defines if data length to load can be evaluated */
  39717. lengthComputable: boolean,
  39718. /** defines the loaded data length */
  39719. loaded: number,
  39720. /** defines the data length to load */
  39721. total: number);
  39722. /**
  39723. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  39724. * @param event defines the source event
  39725. * @returns a new SceneLoaderProgressEvent
  39726. */
  39727. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  39728. }
  39729. /**
  39730. * Interface used by SceneLoader plugins to define supported file extensions
  39731. */
  39732. export interface ISceneLoaderPluginExtensions {
  39733. /**
  39734. * Defines the list of supported extensions
  39735. */
  39736. [extension: string]: {
  39737. isBinary: boolean;
  39738. };
  39739. }
  39740. /**
  39741. * Interface used by SceneLoader plugin factory
  39742. */
  39743. export interface ISceneLoaderPluginFactory {
  39744. /**
  39745. * Defines the name of the factory
  39746. */
  39747. name: string;
  39748. /**
  39749. * Function called to create a new plugin
  39750. * @return the new plugin
  39751. */
  39752. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  39753. /**
  39754. * Boolean indicating if the plugin can direct load specific data
  39755. */
  39756. canDirectLoad?: (data: string) => boolean;
  39757. }
  39758. /**
  39759. * Interface used to define a SceneLoader plugin
  39760. */
  39761. export interface ISceneLoaderPlugin {
  39762. /**
  39763. * The friendly name of this plugin.
  39764. */
  39765. name: string;
  39766. /**
  39767. * The file extensions supported by this plugin.
  39768. */
  39769. extensions: string | ISceneLoaderPluginExtensions;
  39770. /**
  39771. * Import meshes into a scene.
  39772. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  39773. * @param scene The scene to import into
  39774. * @param data The data to import
  39775. * @param rootUrl The root url for scene and resources
  39776. * @param meshes The meshes array to import into
  39777. * @param particleSystems The particle systems array to import into
  39778. * @param skeletons The skeletons array to import into
  39779. * @param onError The callback when import fails
  39780. * @returns True if successful or false otherwise
  39781. */
  39782. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  39783. /**
  39784. * Load into a scene.
  39785. * @param scene The scene to load into
  39786. * @param data The data to import
  39787. * @param rootUrl The root url for scene and resources
  39788. * @param onError The callback when import fails
  39789. * @returns true if successful or false otherwise
  39790. */
  39791. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  39792. /**
  39793. * The callback that returns true if the data can be directly loaded.
  39794. */
  39795. canDirectLoad?: (data: string) => boolean;
  39796. /**
  39797. * The callback that allows custom handling of the root url based on the response url.
  39798. */
  39799. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  39800. /**
  39801. * Load into an asset container.
  39802. * @param scene The scene to load into
  39803. * @param data The data to import
  39804. * @param rootUrl The root url for scene and resources
  39805. * @param onError The callback when import fails
  39806. * @returns The loaded asset container
  39807. */
  39808. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  39809. }
  39810. /**
  39811. * Interface used to define an async SceneLoader plugin
  39812. */
  39813. export interface ISceneLoaderPluginAsync {
  39814. /**
  39815. * The friendly name of this plugin.
  39816. */
  39817. name: string;
  39818. /**
  39819. * The file extensions supported by this plugin.
  39820. */
  39821. extensions: string | ISceneLoaderPluginExtensions;
  39822. /**
  39823. * Import meshes into a scene.
  39824. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  39825. * @param scene The scene to import into
  39826. * @param data The data to import
  39827. * @param rootUrl The root url for scene and resources
  39828. * @param onProgress The callback when the load progresses
  39829. * @param fileName Defines the name of the file to load
  39830. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  39831. */
  39832. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  39833. meshes: AbstractMesh[];
  39834. particleSystems: IParticleSystem[];
  39835. skeletons: Skeleton[];
  39836. animationGroups: AnimationGroup[];
  39837. }>;
  39838. /**
  39839. * Load into a scene.
  39840. * @param scene The scene to load into
  39841. * @param data The data to import
  39842. * @param rootUrl The root url for scene and resources
  39843. * @param onProgress The callback when the load progresses
  39844. * @param fileName Defines the name of the file to load
  39845. * @returns Nothing
  39846. */
  39847. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  39848. /**
  39849. * The callback that returns true if the data can be directly loaded.
  39850. */
  39851. canDirectLoad?: (data: string) => boolean;
  39852. /**
  39853. * The callback that allows custom handling of the root url based on the response url.
  39854. */
  39855. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  39856. /**
  39857. * Load into an asset container.
  39858. * @param scene The scene to load into
  39859. * @param data The data to import
  39860. * @param rootUrl The root url for scene and resources
  39861. * @param onProgress The callback when the load progresses
  39862. * @param fileName Defines the name of the file to load
  39863. * @returns The loaded asset container
  39864. */
  39865. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  39866. }
  39867. /**
  39868. * Class used to load scene from various file formats using registered plugins
  39869. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  39870. */
  39871. export class SceneLoader {
  39872. /**
  39873. * No logging while loading
  39874. */
  39875. static readonly NO_LOGGING: number;
  39876. /**
  39877. * Minimal logging while loading
  39878. */
  39879. static readonly MINIMAL_LOGGING: number;
  39880. /**
  39881. * Summary logging while loading
  39882. */
  39883. static readonly SUMMARY_LOGGING: number;
  39884. /**
  39885. * Detailled logging while loading
  39886. */
  39887. static readonly DETAILED_LOGGING: number;
  39888. /**
  39889. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  39890. */
  39891. static ForceFullSceneLoadingForIncremental: boolean;
  39892. /**
  39893. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  39894. */
  39895. static ShowLoadingScreen: boolean;
  39896. /**
  39897. * Defines the current logging level (while loading the scene)
  39898. * @ignorenaming
  39899. */
  39900. static loggingLevel: number;
  39901. /**
  39902. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  39903. */
  39904. static CleanBoneMatrixWeights: boolean;
  39905. /**
  39906. * Event raised when a plugin is used to load a scene
  39907. */
  39908. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  39909. private static _registeredPlugins;
  39910. private static _getDefaultPlugin;
  39911. private static _getPluginForExtension;
  39912. private static _getPluginForDirectLoad;
  39913. private static _getPluginForFilename;
  39914. private static _getDirectLoad;
  39915. private static _loadData;
  39916. private static _getFileInfo;
  39917. /**
  39918. * Gets a plugin that can load the given extension
  39919. * @param extension defines the extension to load
  39920. * @returns a plugin or null if none works
  39921. */
  39922. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  39923. /**
  39924. * Gets a boolean indicating that the given extension can be loaded
  39925. * @param extension defines the extension to load
  39926. * @returns true if the extension is supported
  39927. */
  39928. static IsPluginForExtensionAvailable(extension: string): boolean;
  39929. /**
  39930. * Adds a new plugin to the list of registered plugins
  39931. * @param plugin defines the plugin to add
  39932. */
  39933. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  39934. /**
  39935. * Import meshes into a scene
  39936. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  39937. * @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)
  39938. * @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)
  39939. * @param scene the instance of BABYLON.Scene to append to
  39940. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  39941. * @param onProgress a callback with a progress event for each file being loaded
  39942. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  39943. * @param pluginExtension the extension used to determine the plugin
  39944. * @returns The loaded plugin
  39945. */
  39946. 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>;
  39947. /**
  39948. * Import meshes into a scene
  39949. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  39950. * @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)
  39951. * @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)
  39952. * @param scene the instance of BABYLON.Scene to append to
  39953. * @param onProgress a callback with a progress event for each file being loaded
  39954. * @param pluginExtension the extension used to determine the plugin
  39955. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  39956. */
  39957. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  39958. meshes: AbstractMesh[];
  39959. particleSystems: IParticleSystem[];
  39960. skeletons: Skeleton[];
  39961. animationGroups: AnimationGroup[];
  39962. }>;
  39963. /**
  39964. * Load a scene
  39965. * @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)
  39966. * @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)
  39967. * @param engine is the instance of BABYLON.Engine to use to create the scene
  39968. * @param onSuccess a callback with the scene when import succeeds
  39969. * @param onProgress a callback with a progress event for each file being loaded
  39970. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  39971. * @param pluginExtension the extension used to determine the plugin
  39972. * @returns The loaded plugin
  39973. */
  39974. 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>;
  39975. /**
  39976. * Load a scene
  39977. * @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)
  39978. * @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)
  39979. * @param engine is the instance of BABYLON.Engine to use to create the scene
  39980. * @param onProgress a callback with a progress event for each file being loaded
  39981. * @param pluginExtension the extension used to determine the plugin
  39982. * @returns The loaded scene
  39983. */
  39984. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  39985. /**
  39986. * Append a scene
  39987. * @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)
  39988. * @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)
  39989. * @param scene is the instance of BABYLON.Scene to append to
  39990. * @param onSuccess a callback with the scene when import succeeds
  39991. * @param onProgress a callback with a progress event for each file being loaded
  39992. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  39993. * @param pluginExtension the extension used to determine the plugin
  39994. * @returns The loaded plugin
  39995. */
  39996. 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>;
  39997. /**
  39998. * Append a scene
  39999. * @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)
  40000. * @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)
  40001. * @param scene is the instance of BABYLON.Scene to append to
  40002. * @param onProgress a callback with a progress event for each file being loaded
  40003. * @param pluginExtension the extension used to determine the plugin
  40004. * @returns The given scene
  40005. */
  40006. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  40007. /**
  40008. * Load a scene into an asset container
  40009. * @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)
  40010. * @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)
  40011. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  40012. * @param onSuccess a callback with the scene when import succeeds
  40013. * @param onProgress a callback with a progress event for each file being loaded
  40014. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  40015. * @param pluginExtension the extension used to determine the plugin
  40016. * @returns The loaded plugin
  40017. */
  40018. 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>;
  40019. /**
  40020. * Load a scene into an asset container
  40021. * @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)
  40022. * @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)
  40023. * @param scene is the instance of Scene to append to
  40024. * @param onProgress a callback with a progress event for each file being loaded
  40025. * @param pluginExtension the extension used to determine the plugin
  40026. * @returns The loaded asset container
  40027. */
  40028. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  40029. }
  40030. }
  40031. declare module BABYLON {
  40032. /**
  40033. * Google Daydream controller
  40034. */
  40035. export class DaydreamController extends WebVRController {
  40036. /**
  40037. * Base Url for the controller model.
  40038. */
  40039. static MODEL_BASE_URL: string;
  40040. /**
  40041. * File name for the controller model.
  40042. */
  40043. static MODEL_FILENAME: string;
  40044. /**
  40045. * Gamepad Id prefix used to identify Daydream Controller.
  40046. */
  40047. static readonly GAMEPAD_ID_PREFIX: string;
  40048. /**
  40049. * Creates a new DaydreamController from a gamepad
  40050. * @param vrGamepad the gamepad that the controller should be created from
  40051. */
  40052. constructor(vrGamepad: any);
  40053. /**
  40054. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40055. * @param scene scene in which to add meshes
  40056. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40057. */
  40058. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40059. /**
  40060. * Called once for each button that changed state since the last frame
  40061. * @param buttonIdx Which button index changed
  40062. * @param state New state of the button
  40063. * @param changes Which properties on the state changed since last frame
  40064. */
  40065. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40066. }
  40067. }
  40068. declare module BABYLON {
  40069. /**
  40070. * Gear VR Controller
  40071. */
  40072. export class GearVRController extends WebVRController {
  40073. /**
  40074. * Base Url for the controller model.
  40075. */
  40076. static MODEL_BASE_URL: string;
  40077. /**
  40078. * File name for the controller model.
  40079. */
  40080. static MODEL_FILENAME: string;
  40081. /**
  40082. * Gamepad Id prefix used to identify this controller.
  40083. */
  40084. static readonly GAMEPAD_ID_PREFIX: string;
  40085. private readonly _buttonIndexToObservableNameMap;
  40086. /**
  40087. * Creates a new GearVRController from a gamepad
  40088. * @param vrGamepad the gamepad that the controller should be created from
  40089. */
  40090. constructor(vrGamepad: any);
  40091. /**
  40092. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40093. * @param scene scene in which to add meshes
  40094. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40095. */
  40096. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40097. /**
  40098. * Called once for each button that changed state since the last frame
  40099. * @param buttonIdx Which button index changed
  40100. * @param state New state of the button
  40101. * @param changes Which properties on the state changed since last frame
  40102. */
  40103. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40104. }
  40105. }
  40106. declare module BABYLON {
  40107. /**
  40108. * Generic Controller
  40109. */
  40110. export class GenericController extends WebVRController {
  40111. /**
  40112. * Base Url for the controller model.
  40113. */
  40114. static readonly MODEL_BASE_URL: string;
  40115. /**
  40116. * File name for the controller model.
  40117. */
  40118. static readonly MODEL_FILENAME: string;
  40119. /**
  40120. * Creates a new GenericController from a gamepad
  40121. * @param vrGamepad the gamepad that the controller should be created from
  40122. */
  40123. constructor(vrGamepad: any);
  40124. /**
  40125. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40126. * @param scene scene in which to add meshes
  40127. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40128. */
  40129. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40130. /**
  40131. * Called once for each button that changed state since the last frame
  40132. * @param buttonIdx Which button index changed
  40133. * @param state New state of the button
  40134. * @param changes Which properties on the state changed since last frame
  40135. */
  40136. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40137. }
  40138. }
  40139. declare module BABYLON {
  40140. /**
  40141. * Oculus Touch Controller
  40142. */
  40143. export class OculusTouchController extends WebVRController {
  40144. /**
  40145. * Base Url for the controller model.
  40146. */
  40147. static MODEL_BASE_URL: string;
  40148. /**
  40149. * File name for the left controller model.
  40150. */
  40151. static MODEL_LEFT_FILENAME: string;
  40152. /**
  40153. * File name for the right controller model.
  40154. */
  40155. static MODEL_RIGHT_FILENAME: string;
  40156. /**
  40157. * Fired when the secondary trigger on this controller is modified
  40158. */
  40159. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  40160. /**
  40161. * Fired when the thumb rest on this controller is modified
  40162. */
  40163. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  40164. /**
  40165. * Creates a new OculusTouchController from a gamepad
  40166. * @param vrGamepad the gamepad that the controller should be created from
  40167. */
  40168. constructor(vrGamepad: any);
  40169. /**
  40170. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40171. * @param scene scene in which to add meshes
  40172. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40173. */
  40174. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40175. /**
  40176. * Fired when the A button on this controller is modified
  40177. */
  40178. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40179. /**
  40180. * Fired when the B button on this controller is modified
  40181. */
  40182. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40183. /**
  40184. * Fired when the X button on this controller is modified
  40185. */
  40186. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40187. /**
  40188. * Fired when the Y button on this controller is modified
  40189. */
  40190. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40191. /**
  40192. * Called once for each button that changed state since the last frame
  40193. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  40194. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  40195. * 2) secondary trigger (same)
  40196. * 3) A (right) X (left), touch, pressed = value
  40197. * 4) B / Y
  40198. * 5) thumb rest
  40199. * @param buttonIdx Which button index changed
  40200. * @param state New state of the button
  40201. * @param changes Which properties on the state changed since last frame
  40202. */
  40203. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40204. }
  40205. }
  40206. declare module BABYLON {
  40207. /**
  40208. * Vive Controller
  40209. */
  40210. export class ViveController extends WebVRController {
  40211. /**
  40212. * Base Url for the controller model.
  40213. */
  40214. static MODEL_BASE_URL: string;
  40215. /**
  40216. * File name for the controller model.
  40217. */
  40218. static MODEL_FILENAME: string;
  40219. /**
  40220. * Creates a new ViveController from a gamepad
  40221. * @param vrGamepad the gamepad that the controller should be created from
  40222. */
  40223. constructor(vrGamepad: any);
  40224. /**
  40225. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40226. * @param scene scene in which to add meshes
  40227. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40228. */
  40229. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40230. /**
  40231. * Fired when the left button on this controller is modified
  40232. */
  40233. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40234. /**
  40235. * Fired when the right button on this controller is modified
  40236. */
  40237. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40238. /**
  40239. * Fired when the menu button on this controller is modified
  40240. */
  40241. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40242. /**
  40243. * Called once for each button that changed state since the last frame
  40244. * Vive mapping:
  40245. * 0: touchpad
  40246. * 1: trigger
  40247. * 2: left AND right buttons
  40248. * 3: menu button
  40249. * @param buttonIdx Which button index changed
  40250. * @param state New state of the button
  40251. * @param changes Which properties on the state changed since last frame
  40252. */
  40253. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40254. }
  40255. }
  40256. declare module BABYLON {
  40257. /**
  40258. * Defines the WindowsMotionController object that the state of the windows motion controller
  40259. */
  40260. export class WindowsMotionController extends WebVRController {
  40261. /**
  40262. * The base url used to load the left and right controller models
  40263. */
  40264. static MODEL_BASE_URL: string;
  40265. /**
  40266. * The name of the left controller model file
  40267. */
  40268. static MODEL_LEFT_FILENAME: string;
  40269. /**
  40270. * The name of the right controller model file
  40271. */
  40272. static MODEL_RIGHT_FILENAME: string;
  40273. /**
  40274. * The controller name prefix for this controller type
  40275. */
  40276. static readonly GAMEPAD_ID_PREFIX: string;
  40277. /**
  40278. * The controller id pattern for this controller type
  40279. */
  40280. private static readonly GAMEPAD_ID_PATTERN;
  40281. private _loadedMeshInfo;
  40282. private readonly _mapping;
  40283. /**
  40284. * Fired when the trackpad on this controller is clicked
  40285. */
  40286. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  40287. /**
  40288. * Fired when the trackpad on this controller is modified
  40289. */
  40290. onTrackpadValuesChangedObservable: Observable<StickValues>;
  40291. /**
  40292. * The current x and y values of this controller's trackpad
  40293. */
  40294. trackpad: StickValues;
  40295. /**
  40296. * Creates a new WindowsMotionController from a gamepad
  40297. * @param vrGamepad the gamepad that the controller should be created from
  40298. */
  40299. constructor(vrGamepad: any);
  40300. /**
  40301. * Fired when the trigger on this controller is modified
  40302. */
  40303. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40304. /**
  40305. * Fired when the menu button on this controller is modified
  40306. */
  40307. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40308. /**
  40309. * Fired when the grip button on this controller is modified
  40310. */
  40311. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40312. /**
  40313. * Fired when the thumbstick button on this controller is modified
  40314. */
  40315. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40316. /**
  40317. * Fired when the touchpad button on this controller is modified
  40318. */
  40319. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40320. /**
  40321. * Fired when the touchpad values on this controller are modified
  40322. */
  40323. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  40324. private _updateTrackpad;
  40325. /**
  40326. * Called once per frame by the engine.
  40327. */
  40328. update(): void;
  40329. /**
  40330. * Called once for each button that changed state since the last frame
  40331. * @param buttonIdx Which button index changed
  40332. * @param state New state of the button
  40333. * @param changes Which properties on the state changed since last frame
  40334. */
  40335. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40336. /**
  40337. * Moves the buttons on the controller mesh based on their current state
  40338. * @param buttonName the name of the button to move
  40339. * @param buttonValue the value of the button which determines the buttons new position
  40340. */
  40341. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  40342. /**
  40343. * Moves the axis on the controller mesh based on its current state
  40344. * @param axis the index of the axis
  40345. * @param axisValue the value of the axis which determines the meshes new position
  40346. * @hidden
  40347. */
  40348. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  40349. /**
  40350. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40351. * @param scene scene in which to add meshes
  40352. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40353. */
  40354. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  40355. /**
  40356. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  40357. * can be transformed by button presses and axes values, based on this._mapping.
  40358. *
  40359. * @param scene scene in which the meshes exist
  40360. * @param meshes list of meshes that make up the controller model to process
  40361. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  40362. */
  40363. private processModel;
  40364. private createMeshInfo;
  40365. /**
  40366. * Gets the ray of the controller in the direction the controller is pointing
  40367. * @param length the length the resulting ray should be
  40368. * @returns a ray in the direction the controller is pointing
  40369. */
  40370. getForwardRay(length?: number): Ray;
  40371. /**
  40372. * Disposes of the controller
  40373. */
  40374. dispose(): void;
  40375. }
  40376. }
  40377. declare module BABYLON {
  40378. /**
  40379. * Single axis scale gizmo
  40380. */
  40381. export class AxisScaleGizmo extends Gizmo {
  40382. private _coloredMaterial;
  40383. /**
  40384. * Drag behavior responsible for the gizmos dragging interactions
  40385. */
  40386. dragBehavior: PointerDragBehavior;
  40387. private _pointerObserver;
  40388. /**
  40389. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40390. */
  40391. snapDistance: number;
  40392. /**
  40393. * Event that fires each time the gizmo snaps to a new location.
  40394. * * snapDistance is the the change in distance
  40395. */
  40396. onSnapObservable: Observable<{
  40397. snapDistance: number;
  40398. }>;
  40399. /**
  40400. * If the scaling operation should be done on all axis (default: false)
  40401. */
  40402. uniformScaling: boolean;
  40403. /**
  40404. * Creates an AxisScaleGizmo
  40405. * @param gizmoLayer The utility layer the gizmo will be added to
  40406. * @param dragAxis The axis which the gizmo will be able to scale on
  40407. * @param color The color of the gizmo
  40408. */
  40409. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40410. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40411. /**
  40412. * Disposes of the gizmo
  40413. */
  40414. dispose(): void;
  40415. /**
  40416. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40417. * @param mesh The mesh to replace the default mesh of the gizmo
  40418. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  40419. */
  40420. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  40421. }
  40422. }
  40423. declare module BABYLON {
  40424. /**
  40425. * Bounding box gizmo
  40426. */
  40427. export class BoundingBoxGizmo extends Gizmo {
  40428. private _lineBoundingBox;
  40429. private _rotateSpheresParent;
  40430. private _scaleBoxesParent;
  40431. private _boundingDimensions;
  40432. private _renderObserver;
  40433. private _pointerObserver;
  40434. private _scaleDragSpeed;
  40435. private _tmpQuaternion;
  40436. private _tmpVector;
  40437. private _tmpRotationMatrix;
  40438. /**
  40439. * 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)
  40440. */
  40441. ignoreChildren: boolean;
  40442. /**
  40443. * 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)
  40444. */
  40445. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  40446. /**
  40447. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  40448. */
  40449. rotationSphereSize: number;
  40450. /**
  40451. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  40452. */
  40453. scaleBoxSize: number;
  40454. /**
  40455. * 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)
  40456. */
  40457. fixedDragMeshScreenSize: boolean;
  40458. /**
  40459. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  40460. */
  40461. fixedDragMeshScreenSizeDistanceFactor: number;
  40462. /**
  40463. * Fired when a rotation sphere or scale box is dragged
  40464. */
  40465. onDragStartObservable: Observable<{}>;
  40466. /**
  40467. * Fired when a scale box is dragged
  40468. */
  40469. onScaleBoxDragObservable: Observable<{}>;
  40470. /**
  40471. * Fired when a scale box drag is ended
  40472. */
  40473. onScaleBoxDragEndObservable: Observable<{}>;
  40474. /**
  40475. * Fired when a rotation sphere is dragged
  40476. */
  40477. onRotationSphereDragObservable: Observable<{}>;
  40478. /**
  40479. * Fired when a rotation sphere drag is ended
  40480. */
  40481. onRotationSphereDragEndObservable: Observable<{}>;
  40482. /**
  40483. * 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)
  40484. */
  40485. scalePivot: Nullable<Vector3>;
  40486. private _anchorMesh;
  40487. private _existingMeshScale;
  40488. private _dragMesh;
  40489. private pointerDragBehavior;
  40490. /**
  40491. * Creates an BoundingBoxGizmo
  40492. * @param gizmoLayer The utility layer the gizmo will be added to
  40493. * @param color The color of the gizmo
  40494. */
  40495. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40496. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40497. private _selectNode;
  40498. /**
  40499. * Updates the bounding box information for the Gizmo
  40500. */
  40501. updateBoundingBox(): void;
  40502. private _updateRotationSpheres;
  40503. private _updateScaleBoxes;
  40504. /**
  40505. * Enables rotation on the specified axis and disables rotation on the others
  40506. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  40507. */
  40508. setEnabledRotationAxis(axis: string): void;
  40509. /**
  40510. * Enables/disables scaling
  40511. * @param enable if scaling should be enabled
  40512. */
  40513. setEnabledScaling(enable: boolean): void;
  40514. private _updateDummy;
  40515. /**
  40516. * Enables a pointer drag behavior on the bounding box of the gizmo
  40517. */
  40518. enableDragBehavior(): void;
  40519. /**
  40520. * Disposes of the gizmo
  40521. */
  40522. dispose(): void;
  40523. /**
  40524. * 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)
  40525. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  40526. * @returns the bounding box mesh with the passed in mesh as a child
  40527. */
  40528. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  40529. /**
  40530. * CustomMeshes are not supported by this gizmo
  40531. * @param mesh The mesh to replace the default mesh of the gizmo
  40532. */
  40533. setCustomMesh(mesh: Mesh): void;
  40534. }
  40535. }
  40536. declare module BABYLON {
  40537. /**
  40538. * Single plane rotation gizmo
  40539. */
  40540. export class PlaneRotationGizmo extends Gizmo {
  40541. /**
  40542. * Drag behavior responsible for the gizmos dragging interactions
  40543. */
  40544. dragBehavior: PointerDragBehavior;
  40545. private _pointerObserver;
  40546. /**
  40547. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  40548. */
  40549. snapDistance: number;
  40550. /**
  40551. * Event that fires each time the gizmo snaps to a new location.
  40552. * * snapDistance is the the change in distance
  40553. */
  40554. onSnapObservable: Observable<{
  40555. snapDistance: number;
  40556. }>;
  40557. /**
  40558. * Creates a PlaneRotationGizmo
  40559. * @param gizmoLayer The utility layer the gizmo will be added to
  40560. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  40561. * @param color The color of the gizmo
  40562. * @param tessellation Amount of tessellation to be used when creating rotation circles
  40563. */
  40564. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  40565. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40566. /**
  40567. * Disposes of the gizmo
  40568. */
  40569. dispose(): void;
  40570. }
  40571. }
  40572. declare module BABYLON {
  40573. /**
  40574. * Gizmo that enables rotating a mesh along 3 axis
  40575. */
  40576. export class RotationGizmo extends Gizmo {
  40577. /**
  40578. * Internal gizmo used for interactions on the x axis
  40579. */
  40580. xGizmo: PlaneRotationGizmo;
  40581. /**
  40582. * Internal gizmo used for interactions on the y axis
  40583. */
  40584. yGizmo: PlaneRotationGizmo;
  40585. /**
  40586. * Internal gizmo used for interactions on the z axis
  40587. */
  40588. zGizmo: PlaneRotationGizmo;
  40589. /** Fires an event when any of it's sub gizmos are dragged */
  40590. onDragStartObservable: Observable<{}>;
  40591. /** Fires an event when any of it's sub gizmos are released from dragging */
  40592. onDragEndObservable: Observable<{}>;
  40593. attachedMesh: Nullable<AbstractMesh>;
  40594. /**
  40595. * Creates a RotationGizmo
  40596. * @param gizmoLayer The utility layer the gizmo will be added to
  40597. * @param tessellation Amount of tessellation to be used when creating rotation circles
  40598. */
  40599. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  40600. updateGizmoRotationToMatchAttachedMesh: boolean;
  40601. /**
  40602. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40603. */
  40604. snapDistance: number;
  40605. /**
  40606. * Ratio for the scale of the gizmo (Default: 1)
  40607. */
  40608. scaleRatio: number;
  40609. /**
  40610. * Disposes of the gizmo
  40611. */
  40612. dispose(): void;
  40613. /**
  40614. * CustomMeshes are not supported by this gizmo
  40615. * @param mesh The mesh to replace the default mesh of the gizmo
  40616. */
  40617. setCustomMesh(mesh: Mesh): void;
  40618. }
  40619. }
  40620. declare module BABYLON {
  40621. /**
  40622. * Gizmo that enables dragging a mesh along 3 axis
  40623. */
  40624. export class PositionGizmo extends Gizmo {
  40625. /**
  40626. * Internal gizmo used for interactions on the x axis
  40627. */
  40628. xGizmo: AxisDragGizmo;
  40629. /**
  40630. * Internal gizmo used for interactions on the y axis
  40631. */
  40632. yGizmo: AxisDragGizmo;
  40633. /**
  40634. * Internal gizmo used for interactions on the z axis
  40635. */
  40636. zGizmo: AxisDragGizmo;
  40637. /** Fires an event when any of it's sub gizmos are dragged */
  40638. onDragStartObservable: Observable<{}>;
  40639. /** Fires an event when any of it's sub gizmos are released from dragging */
  40640. onDragEndObservable: Observable<{}>;
  40641. attachedMesh: Nullable<AbstractMesh>;
  40642. /**
  40643. * Creates a PositionGizmo
  40644. * @param gizmoLayer The utility layer the gizmo will be added to
  40645. */
  40646. constructor(gizmoLayer?: UtilityLayerRenderer);
  40647. updateGizmoRotationToMatchAttachedMesh: boolean;
  40648. /**
  40649. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40650. */
  40651. snapDistance: number;
  40652. /**
  40653. * Ratio for the scale of the gizmo (Default: 1)
  40654. */
  40655. scaleRatio: number;
  40656. /**
  40657. * Disposes of the gizmo
  40658. */
  40659. dispose(): void;
  40660. /**
  40661. * CustomMeshes are not supported by this gizmo
  40662. * @param mesh The mesh to replace the default mesh of the gizmo
  40663. */
  40664. setCustomMesh(mesh: Mesh): void;
  40665. }
  40666. }
  40667. declare module BABYLON {
  40668. /**
  40669. * Class containing static functions to help procedurally build meshes
  40670. */
  40671. export class PolyhedronBuilder {
  40672. /**
  40673. * Creates a polyhedron mesh
  40674. * * 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
  40675. * * The parameter `size` (positive float, default 1) sets the polygon size
  40676. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  40677. * * 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`
  40678. * * 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
  40679. * * 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)`)
  40680. * * 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
  40681. * * 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
  40682. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40683. * * 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
  40684. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40685. * @param name defines the name of the mesh
  40686. * @param options defines the options used to create the mesh
  40687. * @param scene defines the hosting scene
  40688. * @returns the polyhedron mesh
  40689. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  40690. */
  40691. static CreatePolyhedron(name: string, options: {
  40692. type?: number;
  40693. size?: number;
  40694. sizeX?: number;
  40695. sizeY?: number;
  40696. sizeZ?: number;
  40697. custom?: any;
  40698. faceUV?: Vector4[];
  40699. faceColors?: Color4[];
  40700. flat?: boolean;
  40701. updatable?: boolean;
  40702. sideOrientation?: number;
  40703. frontUVs?: Vector4;
  40704. backUVs?: Vector4;
  40705. }, scene: Scene): Mesh;
  40706. }
  40707. }
  40708. declare module BABYLON {
  40709. /**
  40710. * Gizmo that enables scaling a mesh along 3 axis
  40711. */
  40712. export class ScaleGizmo extends Gizmo {
  40713. /**
  40714. * Internal gizmo used for interactions on the x axis
  40715. */
  40716. xGizmo: AxisScaleGizmo;
  40717. /**
  40718. * Internal gizmo used for interactions on the y axis
  40719. */
  40720. yGizmo: AxisScaleGizmo;
  40721. /**
  40722. * Internal gizmo used for interactions on the z axis
  40723. */
  40724. zGizmo: AxisScaleGizmo;
  40725. /**
  40726. * Internal gizmo used to scale all axis equally
  40727. */
  40728. uniformScaleGizmo: AxisScaleGizmo;
  40729. /** Fires an event when any of it's sub gizmos are dragged */
  40730. onDragStartObservable: Observable<{}>;
  40731. /** Fires an event when any of it's sub gizmos are released from dragging */
  40732. onDragEndObservable: Observable<{}>;
  40733. attachedMesh: Nullable<AbstractMesh>;
  40734. /**
  40735. * Creates a ScaleGizmo
  40736. * @param gizmoLayer The utility layer the gizmo will be added to
  40737. */
  40738. constructor(gizmoLayer?: UtilityLayerRenderer);
  40739. updateGizmoRotationToMatchAttachedMesh: boolean;
  40740. /**
  40741. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40742. */
  40743. snapDistance: number;
  40744. /**
  40745. * Ratio for the scale of the gizmo (Default: 1)
  40746. */
  40747. scaleRatio: number;
  40748. /**
  40749. * Disposes of the gizmo
  40750. */
  40751. dispose(): void;
  40752. }
  40753. }
  40754. declare module BABYLON {
  40755. /**
  40756. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  40757. */
  40758. export class GizmoManager implements IDisposable {
  40759. private scene;
  40760. /**
  40761. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  40762. */
  40763. gizmos: {
  40764. positionGizmo: Nullable<PositionGizmo>;
  40765. rotationGizmo: Nullable<RotationGizmo>;
  40766. scaleGizmo: Nullable<ScaleGizmo>;
  40767. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  40768. };
  40769. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  40770. clearGizmoOnEmptyPointerEvent: boolean;
  40771. /** Fires an event when the manager is attached to a mesh */
  40772. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  40773. private _gizmosEnabled;
  40774. private _pointerObserver;
  40775. private _attachedMesh;
  40776. private _boundingBoxColor;
  40777. private _defaultUtilityLayer;
  40778. private _defaultKeepDepthUtilityLayer;
  40779. /**
  40780. * When bounding box gizmo is enabled, this can be used to track drag/end events
  40781. */
  40782. boundingBoxDragBehavior: SixDofDragBehavior;
  40783. /**
  40784. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  40785. */
  40786. attachableMeshes: Nullable<Array<AbstractMesh>>;
  40787. /**
  40788. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  40789. */
  40790. usePointerToAttachGizmos: boolean;
  40791. /**
  40792. * Instatiates a gizmo manager
  40793. * @param scene the scene to overlay the gizmos on top of
  40794. */
  40795. constructor(scene: Scene);
  40796. /**
  40797. * Attaches a set of gizmos to the specified mesh
  40798. * @param mesh The mesh the gizmo's should be attached to
  40799. */
  40800. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  40801. /**
  40802. * If the position gizmo is enabled
  40803. */
  40804. positionGizmoEnabled: boolean;
  40805. /**
  40806. * If the rotation gizmo is enabled
  40807. */
  40808. rotationGizmoEnabled: boolean;
  40809. /**
  40810. * If the scale gizmo is enabled
  40811. */
  40812. scaleGizmoEnabled: boolean;
  40813. /**
  40814. * If the boundingBox gizmo is enabled
  40815. */
  40816. boundingBoxGizmoEnabled: boolean;
  40817. /**
  40818. * Disposes of the gizmo manager
  40819. */
  40820. dispose(): void;
  40821. }
  40822. }
  40823. declare module BABYLON {
  40824. /** @hidden */
  40825. export var backgroundFragmentDeclaration: {
  40826. name: string;
  40827. shader: string;
  40828. };
  40829. }
  40830. declare module BABYLON {
  40831. /** @hidden */
  40832. export var backgroundUboDeclaration: {
  40833. name: string;
  40834. shader: string;
  40835. };
  40836. }
  40837. declare module BABYLON {
  40838. /** @hidden */
  40839. export var backgroundPixelShader: {
  40840. name: string;
  40841. shader: string;
  40842. };
  40843. }
  40844. declare module BABYLON {
  40845. /** @hidden */
  40846. export var backgroundVertexDeclaration: {
  40847. name: string;
  40848. shader: string;
  40849. };
  40850. }
  40851. declare module BABYLON {
  40852. /** @hidden */
  40853. export var backgroundVertexShader: {
  40854. name: string;
  40855. shader: string;
  40856. };
  40857. }
  40858. declare module BABYLON {
  40859. /**
  40860. * Background material used to create an efficient environement around your scene.
  40861. */
  40862. export class BackgroundMaterial extends PushMaterial {
  40863. /**
  40864. * Standard reflectance value at parallel view angle.
  40865. */
  40866. static StandardReflectance0: number;
  40867. /**
  40868. * Standard reflectance value at grazing angle.
  40869. */
  40870. static StandardReflectance90: number;
  40871. protected _primaryColor: Color3;
  40872. /**
  40873. * Key light Color (multiply against the environement texture)
  40874. */
  40875. primaryColor: Color3;
  40876. protected __perceptualColor: Nullable<Color3>;
  40877. /**
  40878. * Experimental Internal Use Only.
  40879. *
  40880. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  40881. * This acts as a helper to set the primary color to a more "human friendly" value.
  40882. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  40883. * output color as close as possible from the chosen value.
  40884. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  40885. * part of lighting setup.)
  40886. */ perceptualColor: Nullable<Color3>;
  40887. protected _primaryColorShadowLevel: float;
  40888. /**
  40889. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  40890. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  40891. */
  40892. primaryColorShadowLevel: float;
  40893. protected _primaryColorHighlightLevel: float;
  40894. /**
  40895. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  40896. * The primary color is used at the level chosen to define what the white area would look.
  40897. */
  40898. primaryColorHighlightLevel: float;
  40899. protected _reflectionTexture: Nullable<BaseTexture>;
  40900. /**
  40901. * Reflection Texture used in the material.
  40902. * Should be author in a specific way for the best result (refer to the documentation).
  40903. */
  40904. reflectionTexture: Nullable<BaseTexture>;
  40905. protected _reflectionBlur: float;
  40906. /**
  40907. * Reflection Texture level of blur.
  40908. *
  40909. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  40910. * texture twice.
  40911. */
  40912. reflectionBlur: float;
  40913. protected _diffuseTexture: Nullable<BaseTexture>;
  40914. /**
  40915. * Diffuse Texture used in the material.
  40916. * Should be author in a specific way for the best result (refer to the documentation).
  40917. */
  40918. diffuseTexture: Nullable<BaseTexture>;
  40919. protected _shadowLights: Nullable<IShadowLight[]>;
  40920. /**
  40921. * Specify the list of lights casting shadow on the material.
  40922. * All scene shadow lights will be included if null.
  40923. */
  40924. shadowLights: Nullable<IShadowLight[]>;
  40925. protected _shadowLevel: float;
  40926. /**
  40927. * Helps adjusting the shadow to a softer level if required.
  40928. * 0 means black shadows and 1 means no shadows.
  40929. */
  40930. shadowLevel: float;
  40931. protected _sceneCenter: Vector3;
  40932. /**
  40933. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  40934. * It is usually zero but might be interesting to modify according to your setup.
  40935. */
  40936. sceneCenter: Vector3;
  40937. protected _opacityFresnel: boolean;
  40938. /**
  40939. * This helps specifying that the material is falling off to the sky box at grazing angle.
  40940. * This helps ensuring a nice transition when the camera goes under the ground.
  40941. */
  40942. opacityFresnel: boolean;
  40943. protected _reflectionFresnel: boolean;
  40944. /**
  40945. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  40946. * This helps adding a mirror texture on the ground.
  40947. */
  40948. reflectionFresnel: boolean;
  40949. protected _reflectionFalloffDistance: number;
  40950. /**
  40951. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  40952. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  40953. */
  40954. reflectionFalloffDistance: number;
  40955. protected _reflectionAmount: number;
  40956. /**
  40957. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  40958. */
  40959. reflectionAmount: number;
  40960. protected _reflectionReflectance0: number;
  40961. /**
  40962. * This specifies the weight of the reflection at grazing angle.
  40963. */
  40964. reflectionReflectance0: number;
  40965. protected _reflectionReflectance90: number;
  40966. /**
  40967. * This specifies the weight of the reflection at a perpendicular point of view.
  40968. */
  40969. reflectionReflectance90: number;
  40970. /**
  40971. * Sets the reflection reflectance fresnel values according to the default standard
  40972. * empirically know to work well :-)
  40973. */
  40974. reflectionStandardFresnelWeight: number;
  40975. protected _useRGBColor: boolean;
  40976. /**
  40977. * Helps to directly use the maps channels instead of their level.
  40978. */
  40979. useRGBColor: boolean;
  40980. protected _enableNoise: boolean;
  40981. /**
  40982. * This helps reducing the banding effect that could occur on the background.
  40983. */
  40984. enableNoise: boolean;
  40985. /**
  40986. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  40987. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  40988. * Recommended to be keep at 1.0 except for special cases.
  40989. */
  40990. fovMultiplier: number;
  40991. private _fovMultiplier;
  40992. /**
  40993. * Enable the FOV adjustment feature controlled by fovMultiplier.
  40994. */
  40995. useEquirectangularFOV: boolean;
  40996. private _maxSimultaneousLights;
  40997. /**
  40998. * Number of Simultaneous lights allowed on the material.
  40999. */
  41000. maxSimultaneousLights: int;
  41001. /**
  41002. * Default configuration related to image processing available in the Background Material.
  41003. */
  41004. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41005. /**
  41006. * Keep track of the image processing observer to allow dispose and replace.
  41007. */
  41008. private _imageProcessingObserver;
  41009. /**
  41010. * Attaches a new image processing configuration to the PBR Material.
  41011. * @param configuration (if null the scene configuration will be use)
  41012. */
  41013. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41014. /**
  41015. * Gets the image processing configuration used either in this material.
  41016. */
  41017. /**
  41018. * Sets the Default image processing configuration used either in the this material.
  41019. *
  41020. * If sets to null, the scene one is in use.
  41021. */
  41022. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  41023. /**
  41024. * Gets wether the color curves effect is enabled.
  41025. */
  41026. /**
  41027. * Sets wether the color curves effect is enabled.
  41028. */
  41029. cameraColorCurvesEnabled: boolean;
  41030. /**
  41031. * Gets wether the color grading effect is enabled.
  41032. */
  41033. /**
  41034. * Gets wether the color grading effect is enabled.
  41035. */
  41036. cameraColorGradingEnabled: boolean;
  41037. /**
  41038. * Gets wether tonemapping is enabled or not.
  41039. */
  41040. /**
  41041. * Sets wether tonemapping is enabled or not
  41042. */
  41043. cameraToneMappingEnabled: boolean;
  41044. /**
  41045. * The camera exposure used on this material.
  41046. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41047. * This corresponds to a photographic exposure.
  41048. */
  41049. /**
  41050. * The camera exposure used on this material.
  41051. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41052. * This corresponds to a photographic exposure.
  41053. */
  41054. cameraExposure: float;
  41055. /**
  41056. * Gets The camera contrast used on this material.
  41057. */
  41058. /**
  41059. * Sets The camera contrast used on this material.
  41060. */
  41061. cameraContrast: float;
  41062. /**
  41063. * Gets the Color Grading 2D Lookup Texture.
  41064. */
  41065. /**
  41066. * Sets the Color Grading 2D Lookup Texture.
  41067. */
  41068. cameraColorGradingTexture: Nullable<BaseTexture>;
  41069. /**
  41070. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41071. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41072. * 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;
  41073. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41074. */
  41075. /**
  41076. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41077. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41078. * 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;
  41079. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41080. */
  41081. cameraColorCurves: Nullable<ColorCurves>;
  41082. /**
  41083. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  41084. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  41085. */
  41086. switchToBGR: boolean;
  41087. private _renderTargets;
  41088. private _reflectionControls;
  41089. private _white;
  41090. private _primaryShadowColor;
  41091. private _primaryHighlightColor;
  41092. /**
  41093. * Instantiates a Background Material in the given scene
  41094. * @param name The friendly name of the material
  41095. * @param scene The scene to add the material to
  41096. */
  41097. constructor(name: string, scene: Scene);
  41098. /**
  41099. * Gets a boolean indicating that current material needs to register RTT
  41100. */
  41101. readonly hasRenderTargetTextures: boolean;
  41102. /**
  41103. * The entire material has been created in order to prevent overdraw.
  41104. * @returns false
  41105. */
  41106. needAlphaTesting(): boolean;
  41107. /**
  41108. * The entire material has been created in order to prevent overdraw.
  41109. * @returns true if blending is enable
  41110. */
  41111. needAlphaBlending(): boolean;
  41112. /**
  41113. * Checks wether the material is ready to be rendered for a given mesh.
  41114. * @param mesh The mesh to render
  41115. * @param subMesh The submesh to check against
  41116. * @param useInstances Specify wether or not the material is used with instances
  41117. * @returns true if all the dependencies are ready (Textures, Effects...)
  41118. */
  41119. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41120. /**
  41121. * Compute the primary color according to the chosen perceptual color.
  41122. */
  41123. private _computePrimaryColorFromPerceptualColor;
  41124. /**
  41125. * Compute the highlights and shadow colors according to their chosen levels.
  41126. */
  41127. private _computePrimaryColors;
  41128. /**
  41129. * Build the uniform buffer used in the material.
  41130. */
  41131. buildUniformLayout(): void;
  41132. /**
  41133. * Unbind the material.
  41134. */
  41135. unbind(): void;
  41136. /**
  41137. * Bind only the world matrix to the material.
  41138. * @param world The world matrix to bind.
  41139. */
  41140. bindOnlyWorldMatrix(world: Matrix): void;
  41141. /**
  41142. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  41143. * @param world The world matrix to bind.
  41144. * @param subMesh The submesh to bind for.
  41145. */
  41146. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41147. /**
  41148. * Dispose the material.
  41149. * @param forceDisposeEffect Force disposal of the associated effect.
  41150. * @param forceDisposeTextures Force disposal of the associated textures.
  41151. */
  41152. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41153. /**
  41154. * Clones the material.
  41155. * @param name The cloned name.
  41156. * @returns The cloned material.
  41157. */
  41158. clone(name: string): BackgroundMaterial;
  41159. /**
  41160. * Serializes the current material to its JSON representation.
  41161. * @returns The JSON representation.
  41162. */
  41163. serialize(): any;
  41164. /**
  41165. * Gets the class name of the material
  41166. * @returns "BackgroundMaterial"
  41167. */
  41168. getClassName(): string;
  41169. /**
  41170. * Parse a JSON input to create back a background material.
  41171. * @param source The JSON data to parse
  41172. * @param scene The scene to create the parsed material in
  41173. * @param rootUrl The root url of the assets the material depends upon
  41174. * @returns the instantiated BackgroundMaterial.
  41175. */
  41176. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  41177. }
  41178. }
  41179. declare module BABYLON {
  41180. /**
  41181. * Represents the different options available during the creation of
  41182. * a Environment helper.
  41183. *
  41184. * This can control the default ground, skybox and image processing setup of your scene.
  41185. */
  41186. export interface IEnvironmentHelperOptions {
  41187. /**
  41188. * Specifies wether or not to create a ground.
  41189. * True by default.
  41190. */
  41191. createGround: boolean;
  41192. /**
  41193. * Specifies the ground size.
  41194. * 15 by default.
  41195. */
  41196. groundSize: number;
  41197. /**
  41198. * The texture used on the ground for the main color.
  41199. * Comes from the BabylonJS CDN by default.
  41200. *
  41201. * Remarks: Can be either a texture or a url.
  41202. */
  41203. groundTexture: string | BaseTexture;
  41204. /**
  41205. * The color mixed in the ground texture by default.
  41206. * BabylonJS clearColor by default.
  41207. */
  41208. groundColor: Color3;
  41209. /**
  41210. * Specifies the ground opacity.
  41211. * 1 by default.
  41212. */
  41213. groundOpacity: number;
  41214. /**
  41215. * Enables the ground to receive shadows.
  41216. * True by default.
  41217. */
  41218. enableGroundShadow: boolean;
  41219. /**
  41220. * Helps preventing the shadow to be fully black on the ground.
  41221. * 0.5 by default.
  41222. */
  41223. groundShadowLevel: number;
  41224. /**
  41225. * Creates a mirror texture attach to the ground.
  41226. * false by default.
  41227. */
  41228. enableGroundMirror: boolean;
  41229. /**
  41230. * Specifies the ground mirror size ratio.
  41231. * 0.3 by default as the default kernel is 64.
  41232. */
  41233. groundMirrorSizeRatio: number;
  41234. /**
  41235. * Specifies the ground mirror blur kernel size.
  41236. * 64 by default.
  41237. */
  41238. groundMirrorBlurKernel: number;
  41239. /**
  41240. * Specifies the ground mirror visibility amount.
  41241. * 1 by default
  41242. */
  41243. groundMirrorAmount: number;
  41244. /**
  41245. * Specifies the ground mirror reflectance weight.
  41246. * This uses the standard weight of the background material to setup the fresnel effect
  41247. * of the mirror.
  41248. * 1 by default.
  41249. */
  41250. groundMirrorFresnelWeight: number;
  41251. /**
  41252. * Specifies the ground mirror Falloff distance.
  41253. * This can helps reducing the size of the reflection.
  41254. * 0 by Default.
  41255. */
  41256. groundMirrorFallOffDistance: number;
  41257. /**
  41258. * Specifies the ground mirror texture type.
  41259. * Unsigned Int by Default.
  41260. */
  41261. groundMirrorTextureType: number;
  41262. /**
  41263. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  41264. * the shown objects.
  41265. */
  41266. groundYBias: number;
  41267. /**
  41268. * Specifies wether or not to create a skybox.
  41269. * True by default.
  41270. */
  41271. createSkybox: boolean;
  41272. /**
  41273. * Specifies the skybox size.
  41274. * 20 by default.
  41275. */
  41276. skyboxSize: number;
  41277. /**
  41278. * The texture used on the skybox for the main color.
  41279. * Comes from the BabylonJS CDN by default.
  41280. *
  41281. * Remarks: Can be either a texture or a url.
  41282. */
  41283. skyboxTexture: string | BaseTexture;
  41284. /**
  41285. * The color mixed in the skybox texture by default.
  41286. * BabylonJS clearColor by default.
  41287. */
  41288. skyboxColor: Color3;
  41289. /**
  41290. * The background rotation around the Y axis of the scene.
  41291. * This helps aligning the key lights of your scene with the background.
  41292. * 0 by default.
  41293. */
  41294. backgroundYRotation: number;
  41295. /**
  41296. * Compute automatically the size of the elements to best fit with the scene.
  41297. */
  41298. sizeAuto: boolean;
  41299. /**
  41300. * Default position of the rootMesh if autoSize is not true.
  41301. */
  41302. rootPosition: Vector3;
  41303. /**
  41304. * Sets up the image processing in the scene.
  41305. * true by default.
  41306. */
  41307. setupImageProcessing: boolean;
  41308. /**
  41309. * The texture used as your environment texture in the scene.
  41310. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  41311. *
  41312. * Remarks: Can be either a texture or a url.
  41313. */
  41314. environmentTexture: string | BaseTexture;
  41315. /**
  41316. * The value of the exposure to apply to the scene.
  41317. * 0.6 by default if setupImageProcessing is true.
  41318. */
  41319. cameraExposure: number;
  41320. /**
  41321. * The value of the contrast to apply to the scene.
  41322. * 1.6 by default if setupImageProcessing is true.
  41323. */
  41324. cameraContrast: number;
  41325. /**
  41326. * Specifies wether or not tonemapping should be enabled in the scene.
  41327. * true by default if setupImageProcessing is true.
  41328. */
  41329. toneMappingEnabled: boolean;
  41330. }
  41331. /**
  41332. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  41333. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  41334. * It also helps with the default setup of your imageProcessing configuration.
  41335. */
  41336. export class EnvironmentHelper {
  41337. /**
  41338. * Default ground texture URL.
  41339. */
  41340. private static _groundTextureCDNUrl;
  41341. /**
  41342. * Default skybox texture URL.
  41343. */
  41344. private static _skyboxTextureCDNUrl;
  41345. /**
  41346. * Default environment texture URL.
  41347. */
  41348. private static _environmentTextureCDNUrl;
  41349. /**
  41350. * Creates the default options for the helper.
  41351. */
  41352. private static _getDefaultOptions;
  41353. private _rootMesh;
  41354. /**
  41355. * Gets the root mesh created by the helper.
  41356. */
  41357. readonly rootMesh: Mesh;
  41358. private _skybox;
  41359. /**
  41360. * Gets the skybox created by the helper.
  41361. */
  41362. readonly skybox: Nullable<Mesh>;
  41363. private _skyboxTexture;
  41364. /**
  41365. * Gets the skybox texture created by the helper.
  41366. */
  41367. readonly skyboxTexture: Nullable<BaseTexture>;
  41368. private _skyboxMaterial;
  41369. /**
  41370. * Gets the skybox material created by the helper.
  41371. */
  41372. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  41373. private _ground;
  41374. /**
  41375. * Gets the ground mesh created by the helper.
  41376. */
  41377. readonly ground: Nullable<Mesh>;
  41378. private _groundTexture;
  41379. /**
  41380. * Gets the ground texture created by the helper.
  41381. */
  41382. readonly groundTexture: Nullable<BaseTexture>;
  41383. private _groundMirror;
  41384. /**
  41385. * Gets the ground mirror created by the helper.
  41386. */
  41387. readonly groundMirror: Nullable<MirrorTexture>;
  41388. /**
  41389. * Gets the ground mirror render list to helps pushing the meshes
  41390. * you wish in the ground reflection.
  41391. */
  41392. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  41393. private _groundMaterial;
  41394. /**
  41395. * Gets the ground material created by the helper.
  41396. */
  41397. readonly groundMaterial: Nullable<BackgroundMaterial>;
  41398. /**
  41399. * Stores the creation options.
  41400. */
  41401. private readonly _scene;
  41402. private _options;
  41403. /**
  41404. * This observable will be notified with any error during the creation of the environment,
  41405. * mainly texture creation errors.
  41406. */
  41407. onErrorObservable: Observable<{
  41408. message?: string;
  41409. exception?: any;
  41410. }>;
  41411. /**
  41412. * constructor
  41413. * @param options Defines the options we want to customize the helper
  41414. * @param scene The scene to add the material to
  41415. */
  41416. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  41417. /**
  41418. * Updates the background according to the new options
  41419. * @param options
  41420. */
  41421. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  41422. /**
  41423. * Sets the primary color of all the available elements.
  41424. * @param color the main color to affect to the ground and the background
  41425. */
  41426. setMainColor(color: Color3): void;
  41427. /**
  41428. * Setup the image processing according to the specified options.
  41429. */
  41430. private _setupImageProcessing;
  41431. /**
  41432. * Setup the environment texture according to the specified options.
  41433. */
  41434. private _setupEnvironmentTexture;
  41435. /**
  41436. * Setup the background according to the specified options.
  41437. */
  41438. private _setupBackground;
  41439. /**
  41440. * Get the scene sizes according to the setup.
  41441. */
  41442. private _getSceneSize;
  41443. /**
  41444. * Setup the ground according to the specified options.
  41445. */
  41446. private _setupGround;
  41447. /**
  41448. * Setup the ground material according to the specified options.
  41449. */
  41450. private _setupGroundMaterial;
  41451. /**
  41452. * Setup the ground diffuse texture according to the specified options.
  41453. */
  41454. private _setupGroundDiffuseTexture;
  41455. /**
  41456. * Setup the ground mirror texture according to the specified options.
  41457. */
  41458. private _setupGroundMirrorTexture;
  41459. /**
  41460. * Setup the ground to receive the mirror texture.
  41461. */
  41462. private _setupMirrorInGroundMaterial;
  41463. /**
  41464. * Setup the skybox according to the specified options.
  41465. */
  41466. private _setupSkybox;
  41467. /**
  41468. * Setup the skybox material according to the specified options.
  41469. */
  41470. private _setupSkyboxMaterial;
  41471. /**
  41472. * Setup the skybox reflection texture according to the specified options.
  41473. */
  41474. private _setupSkyboxReflectionTexture;
  41475. private _errorHandler;
  41476. /**
  41477. * Dispose all the elements created by the Helper.
  41478. */
  41479. dispose(): void;
  41480. }
  41481. }
  41482. declare module BABYLON {
  41483. /**
  41484. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  41485. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  41486. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  41487. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  41488. */
  41489. export class PhotoDome extends TransformNode {
  41490. private _useDirectMapping;
  41491. /**
  41492. * The texture being displayed on the sphere
  41493. */
  41494. protected _photoTexture: Texture;
  41495. /**
  41496. * Gets or sets the texture being displayed on the sphere
  41497. */
  41498. photoTexture: Texture;
  41499. /**
  41500. * Observable raised when an error occured while loading the 360 image
  41501. */
  41502. onLoadErrorObservable: Observable<string>;
  41503. /**
  41504. * The skybox material
  41505. */
  41506. protected _material: BackgroundMaterial;
  41507. /**
  41508. * The surface used for the skybox
  41509. */
  41510. protected _mesh: Mesh;
  41511. /**
  41512. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  41513. * Also see the options.resolution property.
  41514. */
  41515. fovMultiplier: number;
  41516. /**
  41517. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  41518. * @param name Element's name, child elements will append suffixes for their own names.
  41519. * @param urlsOfPhoto defines the url of the photo to display
  41520. * @param options defines an object containing optional or exposed sub element properties
  41521. * @param onError defines a callback called when an error occured while loading the texture
  41522. */
  41523. constructor(name: string, urlOfPhoto: string, options: {
  41524. resolution?: number;
  41525. size?: number;
  41526. useDirectMapping?: boolean;
  41527. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  41528. /**
  41529. * Releases resources associated with this node.
  41530. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  41531. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  41532. */
  41533. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  41534. }
  41535. }
  41536. declare module BABYLON {
  41537. /**
  41538. * Class used to host texture specific utilities
  41539. */
  41540. export class TextureTools {
  41541. /**
  41542. * Uses the GPU to create a copy texture rescaled at a given size
  41543. * @param texture Texture to copy from
  41544. * @param width defines the desired width
  41545. * @param height defines the desired height
  41546. * @param useBilinearMode defines if bilinear mode has to be used
  41547. * @return the generated texture
  41548. */
  41549. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  41550. /**
  41551. * Gets an environment BRDF texture for a given scene
  41552. * @param scene defines the hosting scene
  41553. * @returns the environment BRDF texture
  41554. */
  41555. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  41556. private static _environmentBRDFBase64Texture;
  41557. }
  41558. }
  41559. declare module BABYLON {
  41560. /** @hidden */
  41561. export var pbrFragmentDeclaration: {
  41562. name: string;
  41563. shader: string;
  41564. };
  41565. }
  41566. declare module BABYLON {
  41567. /** @hidden */
  41568. export var pbrUboDeclaration: {
  41569. name: string;
  41570. shader: string;
  41571. };
  41572. }
  41573. declare module BABYLON {
  41574. /** @hidden */
  41575. export var pbrFunctions: {
  41576. name: string;
  41577. shader: string;
  41578. };
  41579. }
  41580. declare module BABYLON {
  41581. /** @hidden */
  41582. export var harmonicsFunctions: {
  41583. name: string;
  41584. shader: string;
  41585. };
  41586. }
  41587. declare module BABYLON {
  41588. /** @hidden */
  41589. export var pbrLightFunctions: {
  41590. name: string;
  41591. shader: string;
  41592. };
  41593. }
  41594. declare module BABYLON {
  41595. /** @hidden */
  41596. export var pbrPixelShader: {
  41597. name: string;
  41598. shader: string;
  41599. };
  41600. }
  41601. declare module BABYLON {
  41602. /** @hidden */
  41603. export var pbrVertexDeclaration: {
  41604. name: string;
  41605. shader: string;
  41606. };
  41607. }
  41608. declare module BABYLON {
  41609. /** @hidden */
  41610. export var pbrVertexShader: {
  41611. name: string;
  41612. shader: string;
  41613. };
  41614. }
  41615. declare module BABYLON {
  41616. /**
  41617. * The Physically based material base class of BJS.
  41618. *
  41619. * This offers the main features of a standard PBR material.
  41620. * For more information, please refer to the documentation :
  41621. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  41622. */
  41623. export abstract class PBRBaseMaterial extends PushMaterial {
  41624. /**
  41625. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  41626. */
  41627. static readonly PBRMATERIAL_OPAQUE: number;
  41628. /**
  41629. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  41630. */
  41631. static readonly PBRMATERIAL_ALPHATEST: number;
  41632. /**
  41633. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  41634. */
  41635. static readonly PBRMATERIAL_ALPHABLEND: number;
  41636. /**
  41637. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  41638. * They are also discarded below the alpha cutoff threshold to improve performances.
  41639. */
  41640. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  41641. /**
  41642. * Defines the default value of how much AO map is occluding the analytical lights
  41643. * (point spot...).
  41644. */
  41645. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  41646. /**
  41647. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  41648. */
  41649. static readonly LIGHTFALLOFF_PHYSICAL: number;
  41650. /**
  41651. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  41652. * to enhance interoperability with other engines.
  41653. */
  41654. static readonly LIGHTFALLOFF_GLTF: number;
  41655. /**
  41656. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  41657. * to enhance interoperability with other materials.
  41658. */
  41659. static readonly LIGHTFALLOFF_STANDARD: number;
  41660. /**
  41661. * Intensity of the direct lights e.g. the four lights available in your scene.
  41662. * This impacts both the direct diffuse and specular highlights.
  41663. */
  41664. protected _directIntensity: number;
  41665. /**
  41666. * Intensity of the emissive part of the material.
  41667. * This helps controlling the emissive effect without modifying the emissive color.
  41668. */
  41669. protected _emissiveIntensity: number;
  41670. /**
  41671. * Intensity of the environment e.g. how much the environment will light the object
  41672. * either through harmonics for rough material or through the refelction for shiny ones.
  41673. */
  41674. protected _environmentIntensity: number;
  41675. /**
  41676. * This is a special control allowing the reduction of the specular highlights coming from the
  41677. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  41678. */
  41679. protected _specularIntensity: number;
  41680. /**
  41681. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  41682. */
  41683. private _lightingInfos;
  41684. /**
  41685. * Debug Control allowing disabling the bump map on this material.
  41686. */
  41687. protected _disableBumpMap: boolean;
  41688. /**
  41689. * AKA Diffuse Texture in standard nomenclature.
  41690. */
  41691. protected _albedoTexture: BaseTexture;
  41692. /**
  41693. * AKA Occlusion Texture in other nomenclature.
  41694. */
  41695. protected _ambientTexture: BaseTexture;
  41696. /**
  41697. * AKA Occlusion Texture Intensity in other nomenclature.
  41698. */
  41699. protected _ambientTextureStrength: number;
  41700. /**
  41701. * Defines how much the AO map is occluding the analytical lights (point spot...).
  41702. * 1 means it completely occludes it
  41703. * 0 mean it has no impact
  41704. */
  41705. protected _ambientTextureImpactOnAnalyticalLights: number;
  41706. /**
  41707. * Stores the alpha values in a texture.
  41708. */
  41709. protected _opacityTexture: BaseTexture;
  41710. /**
  41711. * Stores the reflection values in a texture.
  41712. */
  41713. protected _reflectionTexture: BaseTexture;
  41714. /**
  41715. * Stores the refraction values in a texture.
  41716. */
  41717. protected _refractionTexture: BaseTexture;
  41718. /**
  41719. * Stores the emissive values in a texture.
  41720. */
  41721. protected _emissiveTexture: BaseTexture;
  41722. /**
  41723. * AKA Specular texture in other nomenclature.
  41724. */
  41725. protected _reflectivityTexture: BaseTexture;
  41726. /**
  41727. * Used to switch from specular/glossiness to metallic/roughness workflow.
  41728. */
  41729. protected _metallicTexture: BaseTexture;
  41730. /**
  41731. * Specifies the metallic scalar of the metallic/roughness workflow.
  41732. * Can also be used to scale the metalness values of the metallic texture.
  41733. */
  41734. protected _metallic: Nullable<number>;
  41735. /**
  41736. * Specifies the roughness scalar of the metallic/roughness workflow.
  41737. * Can also be used to scale the roughness values of the metallic texture.
  41738. */
  41739. protected _roughness: Nullable<number>;
  41740. /**
  41741. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  41742. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  41743. */
  41744. protected _microSurfaceTexture: BaseTexture;
  41745. /**
  41746. * Stores surface normal data used to displace a mesh in a texture.
  41747. */
  41748. protected _bumpTexture: BaseTexture;
  41749. /**
  41750. * Stores the pre-calculated light information of a mesh in a texture.
  41751. */
  41752. protected _lightmapTexture: BaseTexture;
  41753. /**
  41754. * The color of a material in ambient lighting.
  41755. */
  41756. protected _ambientColor: Color3;
  41757. /**
  41758. * AKA Diffuse Color in other nomenclature.
  41759. */
  41760. protected _albedoColor: Color3;
  41761. /**
  41762. * AKA Specular Color in other nomenclature.
  41763. */
  41764. protected _reflectivityColor: Color3;
  41765. /**
  41766. * The color applied when light is reflected from a material.
  41767. */
  41768. protected _reflectionColor: Color3;
  41769. /**
  41770. * The color applied when light is emitted from a material.
  41771. */
  41772. protected _emissiveColor: Color3;
  41773. /**
  41774. * AKA Glossiness in other nomenclature.
  41775. */
  41776. protected _microSurface: number;
  41777. /**
  41778. * source material index of refraction (IOR)' / 'destination material IOR.
  41779. */
  41780. protected _indexOfRefraction: number;
  41781. /**
  41782. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  41783. */
  41784. protected _invertRefractionY: boolean;
  41785. /**
  41786. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  41787. * Materials half opaque for instance using refraction could benefit from this control.
  41788. */
  41789. protected _linkRefractionWithTransparency: boolean;
  41790. /**
  41791. * Specifies that the material will use the light map as a show map.
  41792. */
  41793. protected _useLightmapAsShadowmap: boolean;
  41794. /**
  41795. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  41796. * makes the reflect vector face the model (under horizon).
  41797. */
  41798. protected _useHorizonOcclusion: boolean;
  41799. /**
  41800. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  41801. * too much the area relying on ambient texture to define their ambient occlusion.
  41802. */
  41803. protected _useRadianceOcclusion: boolean;
  41804. /**
  41805. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  41806. */
  41807. protected _useAlphaFromAlbedoTexture: boolean;
  41808. /**
  41809. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  41810. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41811. */
  41812. protected _useSpecularOverAlpha: boolean;
  41813. /**
  41814. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  41815. */
  41816. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  41817. /**
  41818. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  41819. */
  41820. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  41821. /**
  41822. * Specifies if the metallic texture contains the roughness information in its green channel.
  41823. */
  41824. protected _useRoughnessFromMetallicTextureGreen: boolean;
  41825. /**
  41826. * Specifies if the metallic texture contains the metallness information in its blue channel.
  41827. */
  41828. protected _useMetallnessFromMetallicTextureBlue: boolean;
  41829. /**
  41830. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  41831. */
  41832. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  41833. /**
  41834. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  41835. */
  41836. protected _useAmbientInGrayScale: boolean;
  41837. /**
  41838. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  41839. * The material will try to infer what glossiness each pixel should be.
  41840. */
  41841. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  41842. /**
  41843. * Defines the falloff type used in this material.
  41844. * It by default is Physical.
  41845. */
  41846. protected _lightFalloff: number;
  41847. /**
  41848. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41849. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41850. */
  41851. protected _useRadianceOverAlpha: boolean;
  41852. /**
  41853. * Allows using an object space normal map (instead of tangent space).
  41854. */
  41855. protected _useObjectSpaceNormalMap: boolean;
  41856. /**
  41857. * Allows using the bump map in parallax mode.
  41858. */
  41859. protected _useParallax: boolean;
  41860. /**
  41861. * Allows using the bump map in parallax occlusion mode.
  41862. */
  41863. protected _useParallaxOcclusion: boolean;
  41864. /**
  41865. * Controls the scale bias of the parallax mode.
  41866. */
  41867. protected _parallaxScaleBias: number;
  41868. /**
  41869. * If sets to true, disables all the lights affecting the material.
  41870. */
  41871. protected _disableLighting: boolean;
  41872. /**
  41873. * Number of Simultaneous lights allowed on the material.
  41874. */
  41875. protected _maxSimultaneousLights: number;
  41876. /**
  41877. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  41878. */
  41879. protected _invertNormalMapX: boolean;
  41880. /**
  41881. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  41882. */
  41883. protected _invertNormalMapY: boolean;
  41884. /**
  41885. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41886. */
  41887. protected _twoSidedLighting: boolean;
  41888. /**
  41889. * Defines the alpha limits in alpha test mode.
  41890. */
  41891. protected _alphaCutOff: number;
  41892. /**
  41893. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  41894. */
  41895. protected _forceAlphaTest: boolean;
  41896. /**
  41897. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  41898. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  41899. */
  41900. protected _useAlphaFresnel: boolean;
  41901. /**
  41902. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  41903. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  41904. */
  41905. protected _useLinearAlphaFresnel: boolean;
  41906. /**
  41907. * The transparency mode of the material.
  41908. */
  41909. protected _transparencyMode: Nullable<number>;
  41910. /**
  41911. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  41912. * from cos thetav and roughness:
  41913. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  41914. */
  41915. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  41916. /**
  41917. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  41918. */
  41919. protected _forceIrradianceInFragment: boolean;
  41920. /**
  41921. * Force normal to face away from face.
  41922. */
  41923. protected _forceNormalForward: boolean;
  41924. /**
  41925. * Enables specular anti aliasing in the PBR shader.
  41926. * It will both interacts on the Geometry for analytical and IBL lighting.
  41927. * It also prefilter the roughness map based on the bump values.
  41928. */
  41929. protected _enableSpecularAntiAliasing: boolean;
  41930. /**
  41931. * Default configuration related to image processing available in the PBR Material.
  41932. */
  41933. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41934. /**
  41935. * Keep track of the image processing observer to allow dispose and replace.
  41936. */
  41937. private _imageProcessingObserver;
  41938. /**
  41939. * Attaches a new image processing configuration to the PBR Material.
  41940. * @param configuration
  41941. */
  41942. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41943. /**
  41944. * Stores the available render targets.
  41945. */
  41946. private _renderTargets;
  41947. /**
  41948. * Sets the global ambient color for the material used in lighting calculations.
  41949. */
  41950. private _globalAmbientColor;
  41951. /**
  41952. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  41953. */
  41954. private _useLogarithmicDepth;
  41955. /**
  41956. * If set to true, no lighting calculations will be applied.
  41957. */
  41958. private _unlit;
  41959. /**
  41960. * Instantiates a new PBRMaterial instance.
  41961. *
  41962. * @param name The material name
  41963. * @param scene The scene the material will be use in.
  41964. */
  41965. constructor(name: string, scene: Scene);
  41966. /**
  41967. * Gets a boolean indicating that current material needs to register RTT
  41968. */
  41969. readonly hasRenderTargetTextures: boolean;
  41970. /**
  41971. * Gets the name of the material class.
  41972. */
  41973. getClassName(): string;
  41974. /**
  41975. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  41976. */
  41977. /**
  41978. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  41979. */
  41980. useLogarithmicDepth: boolean;
  41981. /**
  41982. * Gets the current transparency mode.
  41983. */
  41984. /**
  41985. * Sets the transparency mode of the material.
  41986. *
  41987. * | Value | Type | Description |
  41988. * | ----- | ----------------------------------- | ----------- |
  41989. * | 0 | OPAQUE | |
  41990. * | 1 | ALPHATEST | |
  41991. * | 2 | ALPHABLEND | |
  41992. * | 3 | ALPHATESTANDBLEND | |
  41993. *
  41994. */
  41995. transparencyMode: Nullable<number>;
  41996. /**
  41997. * Returns true if alpha blending should be disabled.
  41998. */
  41999. private readonly _disableAlphaBlending;
  42000. /**
  42001. * Specifies whether or not this material should be rendered in alpha blend mode.
  42002. */
  42003. needAlphaBlending(): boolean;
  42004. /**
  42005. * Specifies if the mesh will require alpha blending.
  42006. * @param mesh - BJS mesh.
  42007. */
  42008. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  42009. /**
  42010. * Specifies whether or not this material should be rendered in alpha test mode.
  42011. */
  42012. needAlphaTesting(): boolean;
  42013. /**
  42014. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  42015. */
  42016. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  42017. /**
  42018. * Gets the texture used for the alpha test.
  42019. */
  42020. getAlphaTestTexture(): BaseTexture;
  42021. /**
  42022. * Specifies that the submesh is ready to be used.
  42023. * @param mesh - BJS mesh.
  42024. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  42025. * @param useInstances - Specifies that instances should be used.
  42026. * @returns - boolean indicating that the submesh is ready or not.
  42027. */
  42028. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42029. /**
  42030. * Specifies if the material uses metallic roughness workflow.
  42031. * @returns boolean specifiying if the material uses metallic roughness workflow.
  42032. */
  42033. isMetallicWorkflow(): boolean;
  42034. private _prepareEffect;
  42035. private _prepareDefines;
  42036. /**
  42037. * Force shader compilation
  42038. */
  42039. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  42040. clipPlane: boolean;
  42041. }>): void;
  42042. /**
  42043. * Initializes the uniform buffer layout for the shader.
  42044. */
  42045. buildUniformLayout(): void;
  42046. /**
  42047. * Unbinds the textures.
  42048. */
  42049. unbind(): void;
  42050. /**
  42051. * Binds the submesh data.
  42052. * @param world - The world matrix.
  42053. * @param mesh - The BJS mesh.
  42054. * @param subMesh - A submesh of the BJS mesh.
  42055. */
  42056. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42057. /**
  42058. * Returns the animatable textures.
  42059. * @returns - Array of animatable textures.
  42060. */
  42061. getAnimatables(): IAnimatable[];
  42062. /**
  42063. * Returns the texture used for reflections.
  42064. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  42065. */
  42066. private _getReflectionTexture;
  42067. /**
  42068. * Returns the texture used for refraction or null if none is used.
  42069. * @returns - Refection texture if present. If no refraction texture and refraction
  42070. * is linked with transparency, returns environment texture. Otherwise, returns null.
  42071. */
  42072. private _getRefractionTexture;
  42073. /**
  42074. * Disposes the resources of the material.
  42075. * @param forceDisposeEffect - Forces the disposal of effects.
  42076. * @param forceDisposeTextures - Forces the disposal of all textures.
  42077. */
  42078. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42079. }
  42080. }
  42081. declare module BABYLON {
  42082. /**
  42083. * The Physically based material of BJS.
  42084. *
  42085. * This offers the main features of a standard PBR material.
  42086. * For more information, please refer to the documentation :
  42087. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  42088. */
  42089. export class PBRMaterial extends PBRBaseMaterial {
  42090. /**
  42091. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  42092. */
  42093. static readonly PBRMATERIAL_OPAQUE: number;
  42094. /**
  42095. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  42096. */
  42097. static readonly PBRMATERIAL_ALPHATEST: number;
  42098. /**
  42099. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  42100. */
  42101. static readonly PBRMATERIAL_ALPHABLEND: number;
  42102. /**
  42103. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  42104. * They are also discarded below the alpha cutoff threshold to improve performances.
  42105. */
  42106. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  42107. /**
  42108. * Defines the default value of how much AO map is occluding the analytical lights
  42109. * (point spot...).
  42110. */
  42111. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  42112. /**
  42113. * Intensity of the direct lights e.g. the four lights available in your scene.
  42114. * This impacts both the direct diffuse and specular highlights.
  42115. */
  42116. directIntensity: number;
  42117. /**
  42118. * Intensity of the emissive part of the material.
  42119. * This helps controlling the emissive effect without modifying the emissive color.
  42120. */
  42121. emissiveIntensity: number;
  42122. /**
  42123. * Intensity of the environment e.g. how much the environment will light the object
  42124. * either through harmonics for rough material or through the refelction for shiny ones.
  42125. */
  42126. environmentIntensity: number;
  42127. /**
  42128. * This is a special control allowing the reduction of the specular highlights coming from the
  42129. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  42130. */
  42131. specularIntensity: number;
  42132. /**
  42133. * Debug Control allowing disabling the bump map on this material.
  42134. */
  42135. disableBumpMap: boolean;
  42136. /**
  42137. * AKA Diffuse Texture in standard nomenclature.
  42138. */
  42139. albedoTexture: BaseTexture;
  42140. /**
  42141. * AKA Occlusion Texture in other nomenclature.
  42142. */
  42143. ambientTexture: BaseTexture;
  42144. /**
  42145. * AKA Occlusion Texture Intensity in other nomenclature.
  42146. */
  42147. ambientTextureStrength: number;
  42148. /**
  42149. * Defines how much the AO map is occluding the analytical lights (point spot...).
  42150. * 1 means it completely occludes it
  42151. * 0 mean it has no impact
  42152. */
  42153. ambientTextureImpactOnAnalyticalLights: number;
  42154. /**
  42155. * Stores the alpha values in a texture.
  42156. */
  42157. opacityTexture: BaseTexture;
  42158. /**
  42159. * Stores the reflection values in a texture.
  42160. */
  42161. reflectionTexture: Nullable<BaseTexture>;
  42162. /**
  42163. * Stores the emissive values in a texture.
  42164. */
  42165. emissiveTexture: BaseTexture;
  42166. /**
  42167. * AKA Specular texture in other nomenclature.
  42168. */
  42169. reflectivityTexture: BaseTexture;
  42170. /**
  42171. * Used to switch from specular/glossiness to metallic/roughness workflow.
  42172. */
  42173. metallicTexture: BaseTexture;
  42174. /**
  42175. * Specifies the metallic scalar of the metallic/roughness workflow.
  42176. * Can also be used to scale the metalness values of the metallic texture.
  42177. */
  42178. metallic: Nullable<number>;
  42179. /**
  42180. * Specifies the roughness scalar of the metallic/roughness workflow.
  42181. * Can also be used to scale the roughness values of the metallic texture.
  42182. */
  42183. roughness: Nullable<number>;
  42184. /**
  42185. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  42186. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  42187. */
  42188. microSurfaceTexture: BaseTexture;
  42189. /**
  42190. * Stores surface normal data used to displace a mesh in a texture.
  42191. */
  42192. bumpTexture: BaseTexture;
  42193. /**
  42194. * Stores the pre-calculated light information of a mesh in a texture.
  42195. */
  42196. lightmapTexture: BaseTexture;
  42197. /**
  42198. * Stores the refracted light information in a texture.
  42199. */
  42200. refractionTexture: BaseTexture;
  42201. /**
  42202. * The color of a material in ambient lighting.
  42203. */
  42204. ambientColor: Color3;
  42205. /**
  42206. * AKA Diffuse Color in other nomenclature.
  42207. */
  42208. albedoColor: Color3;
  42209. /**
  42210. * AKA Specular Color in other nomenclature.
  42211. */
  42212. reflectivityColor: Color3;
  42213. /**
  42214. * The color reflected from the material.
  42215. */
  42216. reflectionColor: Color3;
  42217. /**
  42218. * The color emitted from the material.
  42219. */
  42220. emissiveColor: Color3;
  42221. /**
  42222. * AKA Glossiness in other nomenclature.
  42223. */
  42224. microSurface: number;
  42225. /**
  42226. * source material index of refraction (IOR)' / 'destination material IOR.
  42227. */
  42228. indexOfRefraction: number;
  42229. /**
  42230. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  42231. */
  42232. invertRefractionY: boolean;
  42233. /**
  42234. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  42235. * Materials half opaque for instance using refraction could benefit from this control.
  42236. */
  42237. linkRefractionWithTransparency: boolean;
  42238. /**
  42239. * If true, the light map contains occlusion information instead of lighting info.
  42240. */
  42241. useLightmapAsShadowmap: boolean;
  42242. /**
  42243. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  42244. */
  42245. useAlphaFromAlbedoTexture: boolean;
  42246. /**
  42247. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  42248. */
  42249. forceAlphaTest: boolean;
  42250. /**
  42251. * Defines the alpha limits in alpha test mode.
  42252. */
  42253. alphaCutOff: number;
  42254. /**
  42255. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  42256. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  42257. */
  42258. useSpecularOverAlpha: boolean;
  42259. /**
  42260. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  42261. */
  42262. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  42263. /**
  42264. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  42265. */
  42266. useRoughnessFromMetallicTextureAlpha: boolean;
  42267. /**
  42268. * Specifies if the metallic texture contains the roughness information in its green channel.
  42269. */
  42270. useRoughnessFromMetallicTextureGreen: boolean;
  42271. /**
  42272. * Specifies if the metallic texture contains the metallness information in its blue channel.
  42273. */
  42274. useMetallnessFromMetallicTextureBlue: boolean;
  42275. /**
  42276. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  42277. */
  42278. useAmbientOcclusionFromMetallicTextureRed: boolean;
  42279. /**
  42280. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  42281. */
  42282. useAmbientInGrayScale: boolean;
  42283. /**
  42284. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  42285. * The material will try to infer what glossiness each pixel should be.
  42286. */
  42287. useAutoMicroSurfaceFromReflectivityMap: boolean;
  42288. /**
  42289. * BJS is using an harcoded light falloff based on a manually sets up range.
  42290. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  42291. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  42292. */
  42293. /**
  42294. * BJS is using an harcoded light falloff based on a manually sets up range.
  42295. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  42296. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  42297. */
  42298. usePhysicalLightFalloff: boolean;
  42299. /**
  42300. * In order to support the falloff compatibility with gltf, a special mode has been added
  42301. * to reproduce the gltf light falloff.
  42302. */
  42303. /**
  42304. * In order to support the falloff compatibility with gltf, a special mode has been added
  42305. * to reproduce the gltf light falloff.
  42306. */
  42307. useGLTFLightFalloff: boolean;
  42308. /**
  42309. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  42310. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  42311. */
  42312. useRadianceOverAlpha: boolean;
  42313. /**
  42314. * Allows using an object space normal map (instead of tangent space).
  42315. */
  42316. useObjectSpaceNormalMap: boolean;
  42317. /**
  42318. * Allows using the bump map in parallax mode.
  42319. */
  42320. useParallax: boolean;
  42321. /**
  42322. * Allows using the bump map in parallax occlusion mode.
  42323. */
  42324. useParallaxOcclusion: boolean;
  42325. /**
  42326. * Controls the scale bias of the parallax mode.
  42327. */
  42328. parallaxScaleBias: number;
  42329. /**
  42330. * If sets to true, disables all the lights affecting the material.
  42331. */
  42332. disableLighting: boolean;
  42333. /**
  42334. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  42335. */
  42336. forceIrradianceInFragment: boolean;
  42337. /**
  42338. * Number of Simultaneous lights allowed on the material.
  42339. */
  42340. maxSimultaneousLights: number;
  42341. /**
  42342. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  42343. */
  42344. invertNormalMapX: boolean;
  42345. /**
  42346. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  42347. */
  42348. invertNormalMapY: boolean;
  42349. /**
  42350. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  42351. */
  42352. twoSidedLighting: boolean;
  42353. /**
  42354. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  42355. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  42356. */
  42357. useAlphaFresnel: boolean;
  42358. /**
  42359. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  42360. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  42361. */
  42362. useLinearAlphaFresnel: boolean;
  42363. /**
  42364. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  42365. * And/Or occlude the blended part.
  42366. */
  42367. environmentBRDFTexture: Nullable<BaseTexture>;
  42368. /**
  42369. * Force normal to face away from face.
  42370. */
  42371. forceNormalForward: boolean;
  42372. /**
  42373. * Enables specular anti aliasing in the PBR shader.
  42374. * It will both interacts on the Geometry for analytical and IBL lighting.
  42375. * It also prefilter the roughness map based on the bump values.
  42376. */
  42377. enableSpecularAntiAliasing: boolean;
  42378. /**
  42379. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  42380. * makes the reflect vector face the model (under horizon).
  42381. */
  42382. useHorizonOcclusion: boolean;
  42383. /**
  42384. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  42385. * too much the area relying on ambient texture to define their ambient occlusion.
  42386. */
  42387. useRadianceOcclusion: boolean;
  42388. /**
  42389. * If set to true, no lighting calculations will be applied.
  42390. */
  42391. unlit: boolean;
  42392. /**
  42393. * Gets the image processing configuration used either in this material.
  42394. */
  42395. /**
  42396. * Sets the Default image processing configuration used either in the this material.
  42397. *
  42398. * If sets to null, the scene one is in use.
  42399. */
  42400. imageProcessingConfiguration: ImageProcessingConfiguration;
  42401. /**
  42402. * Gets wether the color curves effect is enabled.
  42403. */
  42404. /**
  42405. * Sets wether the color curves effect is enabled.
  42406. */
  42407. cameraColorCurvesEnabled: boolean;
  42408. /**
  42409. * Gets wether the color grading effect is enabled.
  42410. */
  42411. /**
  42412. * Gets wether the color grading effect is enabled.
  42413. */
  42414. cameraColorGradingEnabled: boolean;
  42415. /**
  42416. * Gets wether tonemapping is enabled or not.
  42417. */
  42418. /**
  42419. * Sets wether tonemapping is enabled or not
  42420. */
  42421. cameraToneMappingEnabled: boolean;
  42422. /**
  42423. * The camera exposure used on this material.
  42424. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42425. * This corresponds to a photographic exposure.
  42426. */
  42427. /**
  42428. * The camera exposure used on this material.
  42429. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42430. * This corresponds to a photographic exposure.
  42431. */
  42432. cameraExposure: number;
  42433. /**
  42434. * Gets The camera contrast used on this material.
  42435. */
  42436. /**
  42437. * Sets The camera contrast used on this material.
  42438. */
  42439. cameraContrast: number;
  42440. /**
  42441. * Gets the Color Grading 2D Lookup Texture.
  42442. */
  42443. /**
  42444. * Sets the Color Grading 2D Lookup Texture.
  42445. */
  42446. cameraColorGradingTexture: Nullable<BaseTexture>;
  42447. /**
  42448. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42449. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42450. * 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;
  42451. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42452. */
  42453. /**
  42454. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42455. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42456. * 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;
  42457. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42458. */
  42459. cameraColorCurves: Nullable<ColorCurves>;
  42460. /**
  42461. * Instantiates a new PBRMaterial instance.
  42462. *
  42463. * @param name The material name
  42464. * @param scene The scene the material will be use in.
  42465. */
  42466. constructor(name: string, scene: Scene);
  42467. /**
  42468. * Returns the name of this material class.
  42469. */
  42470. getClassName(): string;
  42471. /**
  42472. * Returns an array of the actively used textures.
  42473. * @returns - Array of BaseTextures
  42474. */
  42475. getActiveTextures(): BaseTexture[];
  42476. /**
  42477. * Checks to see if a texture is used in the material.
  42478. * @param texture - Base texture to use.
  42479. * @returns - Boolean specifying if a texture is used in the material.
  42480. */
  42481. hasTexture(texture: BaseTexture): boolean;
  42482. /**
  42483. * Makes a duplicate of the current material.
  42484. * @param name - name to use for the new material.
  42485. */
  42486. clone(name: string): PBRMaterial;
  42487. /**
  42488. * Serializes this PBR Material.
  42489. * @returns - An object with the serialized material.
  42490. */
  42491. serialize(): any;
  42492. /**
  42493. * Parses a PBR Material from a serialized object.
  42494. * @param source - Serialized object.
  42495. * @param scene - BJS scene instance.
  42496. * @param rootUrl - url for the scene object
  42497. * @returns - PBRMaterial
  42498. */
  42499. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  42500. }
  42501. }
  42502. declare module BABYLON {
  42503. /** @hidden */
  42504. export var _forceSceneHelpersToBundle: boolean;
  42505. interface Scene {
  42506. /**
  42507. * Creates a default light for the scene.
  42508. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  42509. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  42510. */
  42511. createDefaultLight(replace?: boolean): void;
  42512. /**
  42513. * Creates a default camera for the scene.
  42514. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  42515. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  42516. * @param replace has default false, when true replaces the active camera in the scene
  42517. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  42518. */
  42519. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  42520. /**
  42521. * Creates a default camera and a default light.
  42522. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  42523. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  42524. * @param replace has the default false, when true replaces the active camera/light in the scene
  42525. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  42526. */
  42527. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  42528. /**
  42529. * Creates a new sky box
  42530. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  42531. * @param environmentTexture defines the texture to use as environment texture
  42532. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  42533. * @param scale defines the overall scale of the skybox
  42534. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  42535. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  42536. * @returns a new mesh holding the sky box
  42537. */
  42538. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  42539. /**
  42540. * Creates a new environment
  42541. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  42542. * @param options defines the options you can use to configure the environment
  42543. * @returns the new EnvironmentHelper
  42544. */
  42545. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  42546. /**
  42547. * Creates a new VREXperienceHelper
  42548. * @see http://doc.babylonjs.com/how_to/webvr_helper
  42549. * @param webVROptions defines the options used to create the new VREXperienceHelper
  42550. * @returns a new VREXperienceHelper
  42551. */
  42552. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  42553. /**
  42554. * Creates a new XREXperienceHelper
  42555. * @see http://doc.babylonjs.com/how_to/webxr
  42556. * @returns a promise for a new XREXperienceHelper
  42557. */
  42558. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  42559. }
  42560. }
  42561. declare module BABYLON {
  42562. /**
  42563. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  42564. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  42565. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  42566. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  42567. */
  42568. export class VideoDome extends TransformNode {
  42569. private _useDirectMapping;
  42570. /**
  42571. * The video texture being displayed on the sphere
  42572. */
  42573. protected _videoTexture: VideoTexture;
  42574. /**
  42575. * Gets the video texture being displayed on the sphere
  42576. */
  42577. readonly videoTexture: VideoTexture;
  42578. /**
  42579. * The skybox material
  42580. */
  42581. protected _material: BackgroundMaterial;
  42582. /**
  42583. * The surface used for the skybox
  42584. */
  42585. protected _mesh: Mesh;
  42586. /**
  42587. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  42588. * Also see the options.resolution property.
  42589. */
  42590. fovMultiplier: number;
  42591. /**
  42592. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  42593. * @param name Element's name, child elements will append suffixes for their own names.
  42594. * @param urlsOrVideo defines the url(s) or the video element to use
  42595. * @param options An object containing optional or exposed sub element properties
  42596. */
  42597. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  42598. resolution?: number;
  42599. clickToPlay?: boolean;
  42600. autoPlay?: boolean;
  42601. loop?: boolean;
  42602. size?: number;
  42603. poster?: string;
  42604. useDirectMapping?: boolean;
  42605. }, scene: Scene);
  42606. /**
  42607. * Releases resources associated with this node.
  42608. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  42609. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  42610. */
  42611. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  42612. }
  42613. }
  42614. declare module BABYLON {
  42615. /**
  42616. * This class can be used to get instrumentation data from a Babylon engine
  42617. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42618. */
  42619. export class EngineInstrumentation implements IDisposable {
  42620. /**
  42621. * Define the instrumented engine.
  42622. */
  42623. engine: Engine;
  42624. private _captureGPUFrameTime;
  42625. private _gpuFrameTimeToken;
  42626. private _gpuFrameTime;
  42627. private _captureShaderCompilationTime;
  42628. private _shaderCompilationTime;
  42629. private _onBeginFrameObserver;
  42630. private _onEndFrameObserver;
  42631. private _onBeforeShaderCompilationObserver;
  42632. private _onAfterShaderCompilationObserver;
  42633. /**
  42634. * Gets the perf counter used for GPU frame time
  42635. */
  42636. readonly gpuFrameTimeCounter: PerfCounter;
  42637. /**
  42638. * Gets the GPU frame time capture status
  42639. */
  42640. /**
  42641. * Enable or disable the GPU frame time capture
  42642. */
  42643. captureGPUFrameTime: boolean;
  42644. /**
  42645. * Gets the perf counter used for shader compilation time
  42646. */
  42647. readonly shaderCompilationTimeCounter: PerfCounter;
  42648. /**
  42649. * Gets the shader compilation time capture status
  42650. */
  42651. /**
  42652. * Enable or disable the shader compilation time capture
  42653. */
  42654. captureShaderCompilationTime: boolean;
  42655. /**
  42656. * Instantiates a new engine instrumentation.
  42657. * This class can be used to get instrumentation data from a Babylon engine
  42658. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42659. * @param engine Defines the engine to instrument
  42660. */
  42661. constructor(
  42662. /**
  42663. * Define the instrumented engine.
  42664. */
  42665. engine: Engine);
  42666. /**
  42667. * Dispose and release associated resources.
  42668. */
  42669. dispose(): void;
  42670. }
  42671. }
  42672. declare module BABYLON {
  42673. /**
  42674. * This class can be used to get instrumentation data from a Babylon engine
  42675. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  42676. */
  42677. export class SceneInstrumentation implements IDisposable {
  42678. /**
  42679. * Defines the scene to instrument
  42680. */
  42681. scene: Scene;
  42682. private _captureActiveMeshesEvaluationTime;
  42683. private _activeMeshesEvaluationTime;
  42684. private _captureRenderTargetsRenderTime;
  42685. private _renderTargetsRenderTime;
  42686. private _captureFrameTime;
  42687. private _frameTime;
  42688. private _captureRenderTime;
  42689. private _renderTime;
  42690. private _captureInterFrameTime;
  42691. private _interFrameTime;
  42692. private _captureParticlesRenderTime;
  42693. private _particlesRenderTime;
  42694. private _captureSpritesRenderTime;
  42695. private _spritesRenderTime;
  42696. private _capturePhysicsTime;
  42697. private _physicsTime;
  42698. private _captureAnimationsTime;
  42699. private _animationsTime;
  42700. private _captureCameraRenderTime;
  42701. private _cameraRenderTime;
  42702. private _onBeforeActiveMeshesEvaluationObserver;
  42703. private _onAfterActiveMeshesEvaluationObserver;
  42704. private _onBeforeRenderTargetsRenderObserver;
  42705. private _onAfterRenderTargetsRenderObserver;
  42706. private _onAfterRenderObserver;
  42707. private _onBeforeDrawPhaseObserver;
  42708. private _onAfterDrawPhaseObserver;
  42709. private _onBeforeAnimationsObserver;
  42710. private _onBeforeParticlesRenderingObserver;
  42711. private _onAfterParticlesRenderingObserver;
  42712. private _onBeforeSpritesRenderingObserver;
  42713. private _onAfterSpritesRenderingObserver;
  42714. private _onBeforePhysicsObserver;
  42715. private _onAfterPhysicsObserver;
  42716. private _onAfterAnimationsObserver;
  42717. private _onBeforeCameraRenderObserver;
  42718. private _onAfterCameraRenderObserver;
  42719. /**
  42720. * Gets the perf counter used for active meshes evaluation time
  42721. */
  42722. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  42723. /**
  42724. * Gets the active meshes evaluation time capture status
  42725. */
  42726. /**
  42727. * Enable or disable the active meshes evaluation time capture
  42728. */
  42729. captureActiveMeshesEvaluationTime: boolean;
  42730. /**
  42731. * Gets the perf counter used for render targets render time
  42732. */
  42733. readonly renderTargetsRenderTimeCounter: PerfCounter;
  42734. /**
  42735. * Gets the render targets render time capture status
  42736. */
  42737. /**
  42738. * Enable or disable the render targets render time capture
  42739. */
  42740. captureRenderTargetsRenderTime: boolean;
  42741. /**
  42742. * Gets the perf counter used for particles render time
  42743. */
  42744. readonly particlesRenderTimeCounter: PerfCounter;
  42745. /**
  42746. * Gets the particles render time capture status
  42747. */
  42748. /**
  42749. * Enable or disable the particles render time capture
  42750. */
  42751. captureParticlesRenderTime: boolean;
  42752. /**
  42753. * Gets the perf counter used for sprites render time
  42754. */
  42755. readonly spritesRenderTimeCounter: PerfCounter;
  42756. /**
  42757. * Gets the sprites render time capture status
  42758. */
  42759. /**
  42760. * Enable or disable the sprites render time capture
  42761. */
  42762. captureSpritesRenderTime: boolean;
  42763. /**
  42764. * Gets the perf counter used for physics time
  42765. */
  42766. readonly physicsTimeCounter: PerfCounter;
  42767. /**
  42768. * Gets the physics time capture status
  42769. */
  42770. /**
  42771. * Enable or disable the physics time capture
  42772. */
  42773. capturePhysicsTime: boolean;
  42774. /**
  42775. * Gets the perf counter used for animations time
  42776. */
  42777. readonly animationsTimeCounter: PerfCounter;
  42778. /**
  42779. * Gets the animations time capture status
  42780. */
  42781. /**
  42782. * Enable or disable the animations time capture
  42783. */
  42784. captureAnimationsTime: boolean;
  42785. /**
  42786. * Gets the perf counter used for frame time capture
  42787. */
  42788. readonly frameTimeCounter: PerfCounter;
  42789. /**
  42790. * Gets the frame time capture status
  42791. */
  42792. /**
  42793. * Enable or disable the frame time capture
  42794. */
  42795. captureFrameTime: boolean;
  42796. /**
  42797. * Gets the perf counter used for inter-frames time capture
  42798. */
  42799. readonly interFrameTimeCounter: PerfCounter;
  42800. /**
  42801. * Gets the inter-frames time capture status
  42802. */
  42803. /**
  42804. * Enable or disable the inter-frames time capture
  42805. */
  42806. captureInterFrameTime: boolean;
  42807. /**
  42808. * Gets the perf counter used for render time capture
  42809. */
  42810. readonly renderTimeCounter: PerfCounter;
  42811. /**
  42812. * Gets the render time capture status
  42813. */
  42814. /**
  42815. * Enable or disable the render time capture
  42816. */
  42817. captureRenderTime: boolean;
  42818. /**
  42819. * Gets the perf counter used for camera render time capture
  42820. */
  42821. readonly cameraRenderTimeCounter: PerfCounter;
  42822. /**
  42823. * Gets the camera render time capture status
  42824. */
  42825. /**
  42826. * Enable or disable the camera render time capture
  42827. */
  42828. captureCameraRenderTime: boolean;
  42829. /**
  42830. * Gets the perf counter used for draw calls
  42831. */
  42832. readonly drawCallsCounter: PerfCounter;
  42833. /**
  42834. * Gets the perf counter used for texture collisions
  42835. */
  42836. readonly textureCollisionsCounter: PerfCounter;
  42837. /**
  42838. * Instantiates a new scene instrumentation.
  42839. * This class can be used to get instrumentation data from a Babylon engine
  42840. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  42841. * @param scene Defines the scene to instrument
  42842. */
  42843. constructor(
  42844. /**
  42845. * Defines the scene to instrument
  42846. */
  42847. scene: Scene);
  42848. /**
  42849. * Dispose and release associated resources.
  42850. */
  42851. dispose(): void;
  42852. }
  42853. }
  42854. declare module BABYLON {
  42855. /** @hidden */
  42856. export var glowMapGenerationPixelShader: {
  42857. name: string;
  42858. shader: string;
  42859. };
  42860. }
  42861. declare module BABYLON {
  42862. /** @hidden */
  42863. export var glowMapGenerationVertexShader: {
  42864. name: string;
  42865. shader: string;
  42866. };
  42867. }
  42868. declare module BABYLON {
  42869. /**
  42870. * Effect layer options. This helps customizing the behaviour
  42871. * of the effect layer.
  42872. */
  42873. export interface IEffectLayerOptions {
  42874. /**
  42875. * Multiplication factor apply to the canvas size to compute the render target size
  42876. * used to generated the objects (the smaller the faster).
  42877. */
  42878. mainTextureRatio: number;
  42879. /**
  42880. * Enforces a fixed size texture to ensure effect stability across devices.
  42881. */
  42882. mainTextureFixedSize?: number;
  42883. /**
  42884. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  42885. */
  42886. alphaBlendingMode: number;
  42887. /**
  42888. * The camera attached to the layer.
  42889. */
  42890. camera: Nullable<Camera>;
  42891. /**
  42892. * The rendering group to draw the layer in.
  42893. */
  42894. renderingGroupId: number;
  42895. }
  42896. /**
  42897. * The effect layer Helps adding post process effect blended with the main pass.
  42898. *
  42899. * This can be for instance use to generate glow or higlight effects on the scene.
  42900. *
  42901. * The effect layer class can not be used directly and is intented to inherited from to be
  42902. * customized per effects.
  42903. */
  42904. export abstract class EffectLayer {
  42905. private _vertexBuffers;
  42906. private _indexBuffer;
  42907. private _cachedDefines;
  42908. private _effectLayerMapGenerationEffect;
  42909. private _effectLayerOptions;
  42910. private _mergeEffect;
  42911. protected _scene: Scene;
  42912. protected _engine: Engine;
  42913. protected _maxSize: number;
  42914. protected _mainTextureDesiredSize: ISize;
  42915. protected _mainTexture: RenderTargetTexture;
  42916. protected _shouldRender: boolean;
  42917. protected _postProcesses: PostProcess[];
  42918. protected _textures: BaseTexture[];
  42919. protected _emissiveTextureAndColor: {
  42920. texture: Nullable<BaseTexture>;
  42921. color: Color4;
  42922. };
  42923. /**
  42924. * The name of the layer
  42925. */
  42926. name: string;
  42927. /**
  42928. * The clear color of the texture used to generate the glow map.
  42929. */
  42930. neutralColor: Color4;
  42931. /**
  42932. * Specifies wether the highlight layer is enabled or not.
  42933. */
  42934. isEnabled: boolean;
  42935. /**
  42936. * Gets the camera attached to the layer.
  42937. */
  42938. readonly camera: Nullable<Camera>;
  42939. /**
  42940. * Gets the rendering group id the layer should render in.
  42941. */
  42942. readonly renderingGroupId: number;
  42943. /**
  42944. * An event triggered when the effect layer has been disposed.
  42945. */
  42946. onDisposeObservable: Observable<EffectLayer>;
  42947. /**
  42948. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  42949. */
  42950. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  42951. /**
  42952. * An event triggered when the generated texture is being merged in the scene.
  42953. */
  42954. onBeforeComposeObservable: Observable<EffectLayer>;
  42955. /**
  42956. * An event triggered when the generated texture has been merged in the scene.
  42957. */
  42958. onAfterComposeObservable: Observable<EffectLayer>;
  42959. /**
  42960. * An event triggered when the efffect layer changes its size.
  42961. */
  42962. onSizeChangedObservable: Observable<EffectLayer>;
  42963. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  42964. /**
  42965. * Instantiates a new effect Layer and references it in the scene.
  42966. * @param name The name of the layer
  42967. * @param scene The scene to use the layer in
  42968. */
  42969. constructor(
  42970. /** The Friendly of the effect in the scene */
  42971. name: string, scene: Scene);
  42972. /**
  42973. * Get the effect name of the layer.
  42974. * @return The effect name
  42975. */
  42976. abstract getEffectName(): string;
  42977. /**
  42978. * Checks for the readiness of the element composing the layer.
  42979. * @param subMesh the mesh to check for
  42980. * @param useInstances specify wether or not to use instances to render the mesh
  42981. * @return true if ready otherwise, false
  42982. */
  42983. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  42984. /**
  42985. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  42986. * @returns true if the effect requires stencil during the main canvas render pass.
  42987. */
  42988. abstract needStencil(): boolean;
  42989. /**
  42990. * Create the merge effect. This is the shader use to blit the information back
  42991. * to the main canvas at the end of the scene rendering.
  42992. * @returns The effect containing the shader used to merge the effect on the main canvas
  42993. */
  42994. protected abstract _createMergeEffect(): Effect;
  42995. /**
  42996. * Creates the render target textures and post processes used in the effect layer.
  42997. */
  42998. protected abstract _createTextureAndPostProcesses(): void;
  42999. /**
  43000. * Implementation specific of rendering the generating effect on the main canvas.
  43001. * @param effect The effect used to render through
  43002. */
  43003. protected abstract _internalRender(effect: Effect): void;
  43004. /**
  43005. * Sets the required values for both the emissive texture and and the main color.
  43006. */
  43007. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  43008. /**
  43009. * Free any resources and references associated to a mesh.
  43010. * Internal use
  43011. * @param mesh The mesh to free.
  43012. */
  43013. abstract _disposeMesh(mesh: Mesh): void;
  43014. /**
  43015. * Serializes this layer (Glow or Highlight for example)
  43016. * @returns a serialized layer object
  43017. */
  43018. abstract serialize?(): any;
  43019. /**
  43020. * Initializes the effect layer with the required options.
  43021. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  43022. */
  43023. protected _init(options: Partial<IEffectLayerOptions>): void;
  43024. /**
  43025. * Generates the index buffer of the full screen quad blending to the main canvas.
  43026. */
  43027. private _generateIndexBuffer;
  43028. /**
  43029. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  43030. */
  43031. private _genrateVertexBuffer;
  43032. /**
  43033. * Sets the main texture desired size which is the closest power of two
  43034. * of the engine canvas size.
  43035. */
  43036. private _setMainTextureSize;
  43037. /**
  43038. * Creates the main texture for the effect layer.
  43039. */
  43040. protected _createMainTexture(): void;
  43041. /**
  43042. * Adds specific effects defines.
  43043. * @param defines The defines to add specifics to.
  43044. */
  43045. protected _addCustomEffectDefines(defines: string[]): void;
  43046. /**
  43047. * Checks for the readiness of the element composing the layer.
  43048. * @param subMesh the mesh to check for
  43049. * @param useInstances specify wether or not to use instances to render the mesh
  43050. * @param emissiveTexture the associated emissive texture used to generate the glow
  43051. * @return true if ready otherwise, false
  43052. */
  43053. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  43054. /**
  43055. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  43056. */
  43057. render(): void;
  43058. /**
  43059. * Determine if a given mesh will be used in the current effect.
  43060. * @param mesh mesh to test
  43061. * @returns true if the mesh will be used
  43062. */
  43063. hasMesh(mesh: AbstractMesh): boolean;
  43064. /**
  43065. * Returns true if the layer contains information to display, otherwise false.
  43066. * @returns true if the glow layer should be rendered
  43067. */
  43068. shouldRender(): boolean;
  43069. /**
  43070. * Returns true if the mesh should render, otherwise false.
  43071. * @param mesh The mesh to render
  43072. * @returns true if it should render otherwise false
  43073. */
  43074. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  43075. /**
  43076. * Returns true if the mesh can be rendered, otherwise false.
  43077. * @param mesh The mesh to render
  43078. * @param material The material used on the mesh
  43079. * @returns true if it can be rendered otherwise false
  43080. */
  43081. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  43082. /**
  43083. * Returns true if the mesh should render, otherwise false.
  43084. * @param mesh The mesh to render
  43085. * @returns true if it should render otherwise false
  43086. */
  43087. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  43088. /**
  43089. * Renders the submesh passed in parameter to the generation map.
  43090. */
  43091. protected _renderSubMesh(subMesh: SubMesh): void;
  43092. /**
  43093. * Rebuild the required buffers.
  43094. * @hidden Internal use only.
  43095. */ rebuild(): void;
  43096. /**
  43097. * Dispose only the render target textures and post process.
  43098. */
  43099. private _disposeTextureAndPostProcesses;
  43100. /**
  43101. * Dispose the highlight layer and free resources.
  43102. */
  43103. dispose(): void;
  43104. /**
  43105. * Gets the class name of the effect layer
  43106. * @returns the string with the class name of the effect layer
  43107. */
  43108. getClassName(): string;
  43109. /**
  43110. * Creates an effect layer from parsed effect layer data
  43111. * @param parsedEffectLayer defines effect layer data
  43112. * @param scene defines the current scene
  43113. * @param rootUrl defines the root URL containing the effect layer information
  43114. * @returns a parsed effect Layer
  43115. */
  43116. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  43117. }
  43118. }
  43119. declare module BABYLON {
  43120. interface AbstractScene {
  43121. /**
  43122. * The list of effect layers (highlights/glow) added to the scene
  43123. * @see http://doc.babylonjs.com/how_to/highlight_layer
  43124. * @see http://doc.babylonjs.com/how_to/glow_layer
  43125. */
  43126. effectLayers: Array<EffectLayer>;
  43127. /**
  43128. * Removes the given effect layer from this scene.
  43129. * @param toRemove defines the effect layer to remove
  43130. * @returns the index of the removed effect layer
  43131. */
  43132. removeEffectLayer(toRemove: EffectLayer): number;
  43133. /**
  43134. * Adds the given effect layer to this scene
  43135. * @param newEffectLayer defines the effect layer to add
  43136. */
  43137. addEffectLayer(newEffectLayer: EffectLayer): void;
  43138. }
  43139. /**
  43140. * Defines the layer scene component responsible to manage any effect layers
  43141. * in a given scene.
  43142. */
  43143. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  43144. /**
  43145. * The component name helpfull to identify the component in the list of scene components.
  43146. */
  43147. readonly name: string;
  43148. /**
  43149. * The scene the component belongs to.
  43150. */
  43151. scene: Scene;
  43152. private _engine;
  43153. private _renderEffects;
  43154. private _needStencil;
  43155. private _previousStencilState;
  43156. /**
  43157. * Creates a new instance of the component for the given scene
  43158. * @param scene Defines the scene to register the component in
  43159. */
  43160. constructor(scene: Scene);
  43161. /**
  43162. * Registers the component in a given scene
  43163. */
  43164. register(): void;
  43165. /**
  43166. * Rebuilds the elements related to this component in case of
  43167. * context lost for instance.
  43168. */
  43169. rebuild(): void;
  43170. /**
  43171. * Serializes the component data to the specified json object
  43172. * @param serializationObject The object to serialize to
  43173. */
  43174. serialize(serializationObject: any): void;
  43175. /**
  43176. * Adds all the element from the container to the scene
  43177. * @param container the container holding the elements
  43178. */
  43179. addFromContainer(container: AbstractScene): void;
  43180. /**
  43181. * Removes all the elements in the container from the scene
  43182. * @param container contains the elements to remove
  43183. */
  43184. removeFromContainer(container: AbstractScene): void;
  43185. /**
  43186. * Disposes the component and the associated ressources.
  43187. */
  43188. dispose(): void;
  43189. private _isReadyForMesh;
  43190. private _renderMainTexture;
  43191. private _setStencil;
  43192. private _setStencilBack;
  43193. private _draw;
  43194. private _drawCamera;
  43195. private _drawRenderingGroup;
  43196. }
  43197. }
  43198. declare module BABYLON {
  43199. /** @hidden */
  43200. export var glowMapMergePixelShader: {
  43201. name: string;
  43202. shader: string;
  43203. };
  43204. }
  43205. declare module BABYLON {
  43206. /** @hidden */
  43207. export var glowMapMergeVertexShader: {
  43208. name: string;
  43209. shader: string;
  43210. };
  43211. }
  43212. declare module BABYLON {
  43213. interface AbstractScene {
  43214. /**
  43215. * Return a the first highlight layer of the scene with a given name.
  43216. * @param name The name of the highlight layer to look for.
  43217. * @return The highlight layer if found otherwise null.
  43218. */
  43219. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  43220. }
  43221. /**
  43222. * Glow layer options. This helps customizing the behaviour
  43223. * of the glow layer.
  43224. */
  43225. export interface IGlowLayerOptions {
  43226. /**
  43227. * Multiplication factor apply to the canvas size to compute the render target size
  43228. * used to generated the glowing objects (the smaller the faster).
  43229. */
  43230. mainTextureRatio: number;
  43231. /**
  43232. * Enforces a fixed size texture to ensure resize independant blur.
  43233. */
  43234. mainTextureFixedSize?: number;
  43235. /**
  43236. * How big is the kernel of the blur texture.
  43237. */
  43238. blurKernelSize: number;
  43239. /**
  43240. * The camera attached to the layer.
  43241. */
  43242. camera: Nullable<Camera>;
  43243. /**
  43244. * Enable MSAA by chosing the number of samples.
  43245. */
  43246. mainTextureSamples?: number;
  43247. /**
  43248. * The rendering group to draw the layer in.
  43249. */
  43250. renderingGroupId: number;
  43251. }
  43252. /**
  43253. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  43254. *
  43255. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  43256. * glowy meshes to your scene.
  43257. *
  43258. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  43259. */
  43260. export class GlowLayer extends EffectLayer {
  43261. /**
  43262. * Effect Name of the layer.
  43263. */
  43264. static readonly EffectName: string;
  43265. /**
  43266. * The default blur kernel size used for the glow.
  43267. */
  43268. static DefaultBlurKernelSize: number;
  43269. /**
  43270. * The default texture size ratio used for the glow.
  43271. */
  43272. static DefaultTextureRatio: number;
  43273. /**
  43274. * Sets the kernel size of the blur.
  43275. */
  43276. /**
  43277. * Gets the kernel size of the blur.
  43278. */
  43279. blurKernelSize: number;
  43280. /**
  43281. * Sets the glow intensity.
  43282. */
  43283. /**
  43284. * Gets the glow intensity.
  43285. */
  43286. intensity: number;
  43287. private _options;
  43288. private _intensity;
  43289. private _horizontalBlurPostprocess1;
  43290. private _verticalBlurPostprocess1;
  43291. private _horizontalBlurPostprocess2;
  43292. private _verticalBlurPostprocess2;
  43293. private _blurTexture1;
  43294. private _blurTexture2;
  43295. private _postProcesses1;
  43296. private _postProcesses2;
  43297. private _includedOnlyMeshes;
  43298. private _excludedMeshes;
  43299. /**
  43300. * Callback used to let the user override the color selection on a per mesh basis
  43301. */
  43302. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  43303. /**
  43304. * Callback used to let the user override the texture selection on a per mesh basis
  43305. */
  43306. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  43307. /**
  43308. * Instantiates a new glow Layer and references it to the scene.
  43309. * @param name The name of the layer
  43310. * @param scene The scene to use the layer in
  43311. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  43312. */
  43313. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  43314. /**
  43315. * Get the effect name of the layer.
  43316. * @return The effect name
  43317. */
  43318. getEffectName(): string;
  43319. /**
  43320. * Create the merge effect. This is the shader use to blit the information back
  43321. * to the main canvas at the end of the scene rendering.
  43322. */
  43323. protected _createMergeEffect(): Effect;
  43324. /**
  43325. * Creates the render target textures and post processes used in the glow layer.
  43326. */
  43327. protected _createTextureAndPostProcesses(): void;
  43328. /**
  43329. * Checks for the readiness of the element composing the layer.
  43330. * @param subMesh the mesh to check for
  43331. * @param useInstances specify wether or not to use instances to render the mesh
  43332. * @param emissiveTexture the associated emissive texture used to generate the glow
  43333. * @return true if ready otherwise, false
  43334. */
  43335. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  43336. /**
  43337. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  43338. */
  43339. needStencil(): boolean;
  43340. /**
  43341. * Returns true if the mesh can be rendered, otherwise false.
  43342. * @param mesh The mesh to render
  43343. * @param material The material used on the mesh
  43344. * @returns true if it can be rendered otherwise false
  43345. */
  43346. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  43347. /**
  43348. * Implementation specific of rendering the generating effect on the main canvas.
  43349. * @param effect The effect used to render through
  43350. */
  43351. protected _internalRender(effect: Effect): void;
  43352. /**
  43353. * Sets the required values for both the emissive texture and and the main color.
  43354. */
  43355. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  43356. /**
  43357. * Returns true if the mesh should render, otherwise false.
  43358. * @param mesh The mesh to render
  43359. * @returns true if it should render otherwise false
  43360. */
  43361. protected _shouldRenderMesh(mesh: Mesh): boolean;
  43362. /**
  43363. * Adds specific effects defines.
  43364. * @param defines The defines to add specifics to.
  43365. */
  43366. protected _addCustomEffectDefines(defines: string[]): void;
  43367. /**
  43368. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  43369. * @param mesh The mesh to exclude from the glow layer
  43370. */
  43371. addExcludedMesh(mesh: Mesh): void;
  43372. /**
  43373. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  43374. * @param mesh The mesh to remove
  43375. */
  43376. removeExcludedMesh(mesh: Mesh): void;
  43377. /**
  43378. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  43379. * @param mesh The mesh to include in the glow layer
  43380. */
  43381. addIncludedOnlyMesh(mesh: Mesh): void;
  43382. /**
  43383. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  43384. * @param mesh The mesh to remove
  43385. */
  43386. removeIncludedOnlyMesh(mesh: Mesh): void;
  43387. /**
  43388. * Determine if a given mesh will be used in the glow layer
  43389. * @param mesh The mesh to test
  43390. * @returns true if the mesh will be highlighted by the current glow layer
  43391. */
  43392. hasMesh(mesh: AbstractMesh): boolean;
  43393. /**
  43394. * Free any resources and references associated to a mesh.
  43395. * Internal use
  43396. * @param mesh The mesh to free.
  43397. * @hidden
  43398. */ disposeMesh(mesh: Mesh): void;
  43399. /**
  43400. * Gets the class name of the effect layer
  43401. * @returns the string with the class name of the effect layer
  43402. */
  43403. getClassName(): string;
  43404. /**
  43405. * Serializes this glow layer
  43406. * @returns a serialized glow layer object
  43407. */
  43408. serialize(): any;
  43409. /**
  43410. * Creates a Glow Layer from parsed glow layer data
  43411. * @param parsedGlowLayer defines glow layer data
  43412. * @param scene defines the current scene
  43413. * @param rootUrl defines the root URL containing the glow layer information
  43414. * @returns a parsed Glow Layer
  43415. */
  43416. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  43417. }
  43418. }
  43419. declare module BABYLON {
  43420. /** @hidden */
  43421. export var glowBlurPostProcessPixelShader: {
  43422. name: string;
  43423. shader: string;
  43424. };
  43425. }
  43426. declare module BABYLON {
  43427. interface AbstractScene {
  43428. /**
  43429. * Return a the first highlight layer of the scene with a given name.
  43430. * @param name The name of the highlight layer to look for.
  43431. * @return The highlight layer if found otherwise null.
  43432. */
  43433. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  43434. }
  43435. /**
  43436. * Highlight layer options. This helps customizing the behaviour
  43437. * of the highlight layer.
  43438. */
  43439. export interface IHighlightLayerOptions {
  43440. /**
  43441. * Multiplication factor apply to the canvas size to compute the render target size
  43442. * used to generated the glowing objects (the smaller the faster).
  43443. */
  43444. mainTextureRatio: number;
  43445. /**
  43446. * Enforces a fixed size texture to ensure resize independant blur.
  43447. */
  43448. mainTextureFixedSize?: number;
  43449. /**
  43450. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  43451. * of the picture to blur (the smaller the faster).
  43452. */
  43453. blurTextureSizeRatio: number;
  43454. /**
  43455. * How big in texel of the blur texture is the vertical blur.
  43456. */
  43457. blurVerticalSize: number;
  43458. /**
  43459. * How big in texel of the blur texture is the horizontal blur.
  43460. */
  43461. blurHorizontalSize: number;
  43462. /**
  43463. * Alpha blending mode used to apply the blur. Default is combine.
  43464. */
  43465. alphaBlendingMode: number;
  43466. /**
  43467. * The camera attached to the layer.
  43468. */
  43469. camera: Nullable<Camera>;
  43470. /**
  43471. * Should we display highlight as a solid stroke?
  43472. */
  43473. isStroke?: boolean;
  43474. /**
  43475. * The rendering group to draw the layer in.
  43476. */
  43477. renderingGroupId: number;
  43478. }
  43479. /**
  43480. * The highlight layer Helps adding a glow effect around a mesh.
  43481. *
  43482. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  43483. * glowy meshes to your scene.
  43484. *
  43485. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  43486. */
  43487. export class HighlightLayer extends EffectLayer {
  43488. name: string;
  43489. /**
  43490. * Effect Name of the highlight layer.
  43491. */
  43492. static readonly EffectName: string;
  43493. /**
  43494. * The neutral color used during the preparation of the glow effect.
  43495. * This is black by default as the blend operation is a blend operation.
  43496. */
  43497. static NeutralColor: Color4;
  43498. /**
  43499. * Stencil value used for glowing meshes.
  43500. */
  43501. static GlowingMeshStencilReference: number;
  43502. /**
  43503. * Stencil value used for the other meshes in the scene.
  43504. */
  43505. static NormalMeshStencilReference: number;
  43506. /**
  43507. * Specifies whether or not the inner glow is ACTIVE in the layer.
  43508. */
  43509. innerGlow: boolean;
  43510. /**
  43511. * Specifies whether or not the outer glow is ACTIVE in the layer.
  43512. */
  43513. outerGlow: boolean;
  43514. /**
  43515. * Specifies the horizontal size of the blur.
  43516. */
  43517. /**
  43518. * Gets the horizontal size of the blur.
  43519. */
  43520. blurHorizontalSize: number;
  43521. /**
  43522. * Specifies the vertical size of the blur.
  43523. */
  43524. /**
  43525. * Gets the vertical size of the blur.
  43526. */
  43527. blurVerticalSize: number;
  43528. /**
  43529. * An event triggered when the highlight layer is being blurred.
  43530. */
  43531. onBeforeBlurObservable: Observable<HighlightLayer>;
  43532. /**
  43533. * An event triggered when the highlight layer has been blurred.
  43534. */
  43535. onAfterBlurObservable: Observable<HighlightLayer>;
  43536. private _instanceGlowingMeshStencilReference;
  43537. private _options;
  43538. private _downSamplePostprocess;
  43539. private _horizontalBlurPostprocess;
  43540. private _verticalBlurPostprocess;
  43541. private _blurTexture;
  43542. private _meshes;
  43543. private _excludedMeshes;
  43544. /**
  43545. * Instantiates a new highlight Layer and references it to the scene..
  43546. * @param name The name of the layer
  43547. * @param scene The scene to use the layer in
  43548. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  43549. */
  43550. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  43551. /**
  43552. * Get the effect name of the layer.
  43553. * @return The effect name
  43554. */
  43555. getEffectName(): string;
  43556. /**
  43557. * Create the merge effect. This is the shader use to blit the information back
  43558. * to the main canvas at the end of the scene rendering.
  43559. */
  43560. protected _createMergeEffect(): Effect;
  43561. /**
  43562. * Creates the render target textures and post processes used in the highlight layer.
  43563. */
  43564. protected _createTextureAndPostProcesses(): void;
  43565. /**
  43566. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  43567. */
  43568. needStencil(): boolean;
  43569. /**
  43570. * Checks for the readiness of the element composing the layer.
  43571. * @param subMesh the mesh to check for
  43572. * @param useInstances specify wether or not to use instances to render the mesh
  43573. * @param emissiveTexture the associated emissive texture used to generate the glow
  43574. * @return true if ready otherwise, false
  43575. */
  43576. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  43577. /**
  43578. * Implementation specific of rendering the generating effect on the main canvas.
  43579. * @param effect The effect used to render through
  43580. */
  43581. protected _internalRender(effect: Effect): void;
  43582. /**
  43583. * Returns true if the layer contains information to display, otherwise false.
  43584. */
  43585. shouldRender(): boolean;
  43586. /**
  43587. * Returns true if the mesh should render, otherwise false.
  43588. * @param mesh The mesh to render
  43589. * @returns true if it should render otherwise false
  43590. */
  43591. protected _shouldRenderMesh(mesh: Mesh): boolean;
  43592. /**
  43593. * Sets the required values for both the emissive texture and and the main color.
  43594. */
  43595. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  43596. /**
  43597. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  43598. * @param mesh The mesh to exclude from the highlight layer
  43599. */
  43600. addExcludedMesh(mesh: Mesh): void;
  43601. /**
  43602. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  43603. * @param mesh The mesh to highlight
  43604. */
  43605. removeExcludedMesh(mesh: Mesh): void;
  43606. /**
  43607. * Determine if a given mesh will be highlighted by the current HighlightLayer
  43608. * @param mesh mesh to test
  43609. * @returns true if the mesh will be highlighted by the current HighlightLayer
  43610. */
  43611. hasMesh(mesh: AbstractMesh): boolean;
  43612. /**
  43613. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  43614. * @param mesh The mesh to highlight
  43615. * @param color The color of the highlight
  43616. * @param glowEmissiveOnly Extract the glow from the emissive texture
  43617. */
  43618. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  43619. /**
  43620. * Remove a mesh from the highlight layer in order to make it stop glowing.
  43621. * @param mesh The mesh to highlight
  43622. */
  43623. removeMesh(mesh: Mesh): void;
  43624. /**
  43625. * Force the stencil to the normal expected value for none glowing parts
  43626. */
  43627. private _defaultStencilReference;
  43628. /**
  43629. * Free any resources and references associated to a mesh.
  43630. * Internal use
  43631. * @param mesh The mesh to free.
  43632. * @hidden
  43633. */ disposeMesh(mesh: Mesh): void;
  43634. /**
  43635. * Dispose the highlight layer and free resources.
  43636. */
  43637. dispose(): void;
  43638. /**
  43639. * Gets the class name of the effect layer
  43640. * @returns the string with the class name of the effect layer
  43641. */
  43642. getClassName(): string;
  43643. /**
  43644. * Serializes this Highlight layer
  43645. * @returns a serialized Highlight layer object
  43646. */
  43647. serialize(): any;
  43648. /**
  43649. * Creates a Highlight layer from parsed Highlight layer data
  43650. * @param parsedHightlightLayer defines the Highlight layer data
  43651. * @param scene defines the current scene
  43652. * @param rootUrl defines the root URL containing the Highlight layer information
  43653. * @returns a parsed Highlight layer
  43654. */
  43655. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  43656. }
  43657. }
  43658. declare module BABYLON {
  43659. /** @hidden */
  43660. export var lensFlarePixelShader: {
  43661. name: string;
  43662. shader: string;
  43663. };
  43664. }
  43665. declare module BABYLON {
  43666. /** @hidden */
  43667. export var lensFlareVertexShader: {
  43668. name: string;
  43669. shader: string;
  43670. };
  43671. }
  43672. declare module BABYLON {
  43673. /**
  43674. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  43675. * It is usually composed of several `lensFlare`.
  43676. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43677. */
  43678. export class LensFlareSystem {
  43679. /**
  43680. * Define the name of the lens flare system
  43681. */
  43682. name: string;
  43683. /**
  43684. * List of lens flares used in this system.
  43685. */
  43686. lensFlares: LensFlare[];
  43687. /**
  43688. * Define a limit from the border the lens flare can be visible.
  43689. */
  43690. borderLimit: number;
  43691. /**
  43692. * Define a viewport border we do not want to see the lens flare in.
  43693. */
  43694. viewportBorder: number;
  43695. /**
  43696. * Define a predicate which could limit the list of meshes able to occlude the effect.
  43697. */
  43698. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  43699. /**
  43700. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  43701. */
  43702. layerMask: number;
  43703. /**
  43704. * Define the id of the lens flare system in the scene.
  43705. * (equal to name by default)
  43706. */
  43707. id: string;
  43708. private _scene;
  43709. private _emitter;
  43710. private _vertexBuffers;
  43711. private _indexBuffer;
  43712. private _effect;
  43713. private _positionX;
  43714. private _positionY;
  43715. private _isEnabled;
  43716. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  43717. /**
  43718. * Instantiates a lens flare system.
  43719. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  43720. * It is usually composed of several `lensFlare`.
  43721. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43722. * @param name Define the name of the lens flare system in the scene
  43723. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  43724. * @param scene Define the scene the lens flare system belongs to
  43725. */
  43726. constructor(
  43727. /**
  43728. * Define the name of the lens flare system
  43729. */
  43730. name: string, emitter: any, scene: Scene);
  43731. /**
  43732. * Define if the lens flare system is enabled.
  43733. */
  43734. isEnabled: boolean;
  43735. /**
  43736. * Get the scene the effects belongs to.
  43737. * @returns the scene holding the lens flare system
  43738. */
  43739. getScene(): Scene;
  43740. /**
  43741. * Get the emitter of the lens flare system.
  43742. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  43743. * @returns the emitter of the lens flare system
  43744. */
  43745. getEmitter(): any;
  43746. /**
  43747. * Set the emitter of the lens flare system.
  43748. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  43749. * @param newEmitter Define the new emitter of the system
  43750. */
  43751. setEmitter(newEmitter: any): void;
  43752. /**
  43753. * Get the lens flare system emitter position.
  43754. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  43755. * @returns the position
  43756. */
  43757. getEmitterPosition(): Vector3;
  43758. /**
  43759. * @hidden
  43760. */
  43761. computeEffectivePosition(globalViewport: Viewport): boolean;
  43762. /** @hidden */ isVisible(): boolean;
  43763. /**
  43764. * @hidden
  43765. */
  43766. render(): boolean;
  43767. /**
  43768. * Dispose and release the lens flare with its associated resources.
  43769. */
  43770. dispose(): void;
  43771. /**
  43772. * Parse a lens flare system from a JSON repressentation
  43773. * @param parsedLensFlareSystem Define the JSON to parse
  43774. * @param scene Define the scene the parsed system should be instantiated in
  43775. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  43776. * @returns the parsed system
  43777. */
  43778. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  43779. /**
  43780. * Serialize the current Lens Flare System into a JSON representation.
  43781. * @returns the serialized JSON
  43782. */
  43783. serialize(): any;
  43784. }
  43785. }
  43786. declare module BABYLON {
  43787. /**
  43788. * This represents one of the lens effect in a `lensFlareSystem`.
  43789. * It controls one of the indiviual texture used in the effect.
  43790. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43791. */
  43792. export class LensFlare {
  43793. /**
  43794. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  43795. */
  43796. size: number;
  43797. /**
  43798. * 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.
  43799. */
  43800. position: number;
  43801. /**
  43802. * Define the lens color.
  43803. */
  43804. color: Color3;
  43805. /**
  43806. * Define the lens texture.
  43807. */
  43808. texture: Nullable<Texture>;
  43809. /**
  43810. * Define the alpha mode to render this particular lens.
  43811. */
  43812. alphaMode: number;
  43813. private _system;
  43814. /**
  43815. * Creates a new Lens Flare.
  43816. * This represents one of the lens effect in a `lensFlareSystem`.
  43817. * It controls one of the indiviual texture used in the effect.
  43818. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43819. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  43820. * @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.
  43821. * @param color Define the lens color
  43822. * @param imgUrl Define the lens texture url
  43823. * @param system Define the `lensFlareSystem` this flare is part of
  43824. * @returns The newly created Lens Flare
  43825. */
  43826. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  43827. /**
  43828. * Instantiates a new Lens Flare.
  43829. * This represents one of the lens effect in a `lensFlareSystem`.
  43830. * It controls one of the indiviual texture used in the effect.
  43831. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43832. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  43833. * @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.
  43834. * @param color Define the lens color
  43835. * @param imgUrl Define the lens texture url
  43836. * @param system Define the `lensFlareSystem` this flare is part of
  43837. */
  43838. constructor(
  43839. /**
  43840. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  43841. */
  43842. size: number,
  43843. /**
  43844. * 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.
  43845. */
  43846. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  43847. /**
  43848. * Dispose and release the lens flare with its associated resources.
  43849. */
  43850. dispose(): void;
  43851. }
  43852. }
  43853. declare module BABYLON {
  43854. interface AbstractScene {
  43855. /**
  43856. * The list of lens flare system added to the scene
  43857. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43858. */
  43859. lensFlareSystems: Array<LensFlareSystem>;
  43860. /**
  43861. * Removes the given lens flare system from this scene.
  43862. * @param toRemove The lens flare system to remove
  43863. * @returns The index of the removed lens flare system
  43864. */
  43865. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  43866. /**
  43867. * Adds the given lens flare system to this scene
  43868. * @param newLensFlareSystem The lens flare system to add
  43869. */
  43870. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  43871. /**
  43872. * Gets a lens flare system using its name
  43873. * @param name defines the name to look for
  43874. * @returns the lens flare system or null if not found
  43875. */
  43876. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  43877. /**
  43878. * Gets a lens flare system using its id
  43879. * @param id defines the id to look for
  43880. * @returns the lens flare system or null if not found
  43881. */
  43882. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  43883. }
  43884. /**
  43885. * Defines the lens flare scene component responsible to manage any lens flares
  43886. * in a given scene.
  43887. */
  43888. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  43889. /**
  43890. * The component name helpfull to identify the component in the list of scene components.
  43891. */
  43892. readonly name: string;
  43893. /**
  43894. * The scene the component belongs to.
  43895. */
  43896. scene: Scene;
  43897. /**
  43898. * Creates a new instance of the component for the given scene
  43899. * @param scene Defines the scene to register the component in
  43900. */
  43901. constructor(scene: Scene);
  43902. /**
  43903. * Registers the component in a given scene
  43904. */
  43905. register(): void;
  43906. /**
  43907. * Rebuilds the elements related to this component in case of
  43908. * context lost for instance.
  43909. */
  43910. rebuild(): void;
  43911. /**
  43912. * Adds all the element from the container to the scene
  43913. * @param container the container holding the elements
  43914. */
  43915. addFromContainer(container: AbstractScene): void;
  43916. /**
  43917. * Removes all the elements in the container from the scene
  43918. * @param container contains the elements to remove
  43919. */
  43920. removeFromContainer(container: AbstractScene): void;
  43921. /**
  43922. * Serializes the component data to the specified json object
  43923. * @param serializationObject The object to serialize to
  43924. */
  43925. serialize(serializationObject: any): void;
  43926. /**
  43927. * Disposes the component and the associated ressources.
  43928. */
  43929. dispose(): void;
  43930. private _draw;
  43931. }
  43932. }
  43933. declare module BABYLON {
  43934. /**
  43935. * Defines the shadow generator component responsible to manage any shadow generators
  43936. * in a given scene.
  43937. */
  43938. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  43939. /**
  43940. * The component name helpfull to identify the component in the list of scene components.
  43941. */
  43942. readonly name: string;
  43943. /**
  43944. * The scene the component belongs to.
  43945. */
  43946. scene: Scene;
  43947. /**
  43948. * Creates a new instance of the component for the given scene
  43949. * @param scene Defines the scene to register the component in
  43950. */
  43951. constructor(scene: Scene);
  43952. /**
  43953. * Registers the component in a given scene
  43954. */
  43955. register(): void;
  43956. /**
  43957. * Rebuilds the elements related to this component in case of
  43958. * context lost for instance.
  43959. */
  43960. rebuild(): void;
  43961. /**
  43962. * Serializes the component data to the specified json object
  43963. * @param serializationObject The object to serialize to
  43964. */
  43965. serialize(serializationObject: any): void;
  43966. /**
  43967. * Adds all the element from the container to the scene
  43968. * @param container the container holding the elements
  43969. */
  43970. addFromContainer(container: AbstractScene): void;
  43971. /**
  43972. * Removes all the elements in the container from the scene
  43973. * @param container contains the elements to remove
  43974. */
  43975. removeFromContainer(container: AbstractScene): void;
  43976. /**
  43977. * Rebuilds the elements related to this component in case of
  43978. * context lost for instance.
  43979. */
  43980. dispose(): void;
  43981. private _gatherRenderTargets;
  43982. }
  43983. }
  43984. declare module BABYLON {
  43985. /**
  43986. * A directional light is defined by a direction (what a surprise!).
  43987. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  43988. * 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.
  43989. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43990. */
  43991. export class DirectionalLight extends ShadowLight {
  43992. private _shadowFrustumSize;
  43993. /**
  43994. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  43995. */
  43996. /**
  43997. * Specifies a fix frustum size for the shadow generation.
  43998. */
  43999. shadowFrustumSize: number;
  44000. private _shadowOrthoScale;
  44001. /**
  44002. * Gets the shadow projection scale against the optimal computed one.
  44003. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44004. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44005. */
  44006. /**
  44007. * Sets the shadow projection scale against the optimal computed one.
  44008. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44009. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44010. */
  44011. shadowOrthoScale: number;
  44012. /**
  44013. * Automatically compute the projection matrix to best fit (including all the casters)
  44014. * on each frame.
  44015. */
  44016. autoUpdateExtends: boolean;
  44017. private _orthoLeft;
  44018. private _orthoRight;
  44019. private _orthoTop;
  44020. private _orthoBottom;
  44021. /**
  44022. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44023. * The directional light is emitted from everywhere in the given direction.
  44024. * It can cast shadows.
  44025. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44026. * @param name The friendly name of the light
  44027. * @param direction The direction of the light
  44028. * @param scene The scene the light belongs to
  44029. */
  44030. constructor(name: string, direction: Vector3, scene: Scene);
  44031. /**
  44032. * Returns the string "DirectionalLight".
  44033. * @return The class name
  44034. */
  44035. getClassName(): string;
  44036. /**
  44037. * Returns the integer 1.
  44038. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44039. */
  44040. getTypeID(): number;
  44041. /**
  44042. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44043. * Returns the DirectionalLight Shadow projection matrix.
  44044. */
  44045. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44046. /**
  44047. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44048. * Returns the DirectionalLight Shadow projection matrix.
  44049. */
  44050. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44051. /**
  44052. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44053. * Returns the DirectionalLight Shadow projection matrix.
  44054. */
  44055. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44056. protected _buildUniformLayout(): void;
  44057. /**
  44058. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44059. * @param effect The effect to update
  44060. * @param lightIndex The index of the light in the effect to update
  44061. * @returns The directional light
  44062. */
  44063. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44064. /**
  44065. * Gets the minZ used for shadow according to both the scene and the light.
  44066. *
  44067. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44068. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44069. * @param activeCamera The camera we are returning the min for
  44070. * @returns the depth min z
  44071. */
  44072. getDepthMinZ(activeCamera: Camera): number;
  44073. /**
  44074. * Gets the maxZ used for shadow according to both the scene and the light.
  44075. *
  44076. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44077. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44078. * @param activeCamera The camera we are returning the max for
  44079. * @returns the depth max z
  44080. */
  44081. getDepthMaxZ(activeCamera: Camera): number;
  44082. /**
  44083. * Prepares the list of defines specific to the light type.
  44084. * @param defines the list of defines
  44085. * @param lightIndex defines the index of the light for the effect
  44086. */
  44087. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44088. }
  44089. }
  44090. declare module BABYLON {
  44091. /**
  44092. * A point light is a light defined by an unique point in world space.
  44093. * The light is emitted in every direction from this point.
  44094. * A good example of a point light is a standard light bulb.
  44095. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44096. */
  44097. export class PointLight extends ShadowLight {
  44098. private _shadowAngle;
  44099. /**
  44100. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  44101. * This specifies what angle the shadow will use to be created.
  44102. *
  44103. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  44104. */
  44105. /**
  44106. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  44107. * This specifies what angle the shadow will use to be created.
  44108. *
  44109. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  44110. */
  44111. shadowAngle: number;
  44112. /**
  44113. * Gets the direction if it has been set.
  44114. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  44115. */
  44116. /**
  44117. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  44118. */
  44119. direction: Vector3;
  44120. /**
  44121. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  44122. * A PointLight emits the light in every direction.
  44123. * It can cast shadows.
  44124. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  44125. * ```javascript
  44126. * var pointLight = new PointLight("pl", camera.position, scene);
  44127. * ```
  44128. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44129. * @param name The light friendly name
  44130. * @param position The position of the point light in the scene
  44131. * @param scene The scene the lights belongs to
  44132. */
  44133. constructor(name: string, position: Vector3, scene: Scene);
  44134. /**
  44135. * Returns the string "PointLight"
  44136. * @returns the class name
  44137. */
  44138. getClassName(): string;
  44139. /**
  44140. * Returns the integer 0.
  44141. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44142. */
  44143. getTypeID(): number;
  44144. /**
  44145. * Specifies wether or not the shadowmap should be a cube texture.
  44146. * @returns true if the shadowmap needs to be a cube texture.
  44147. */
  44148. needCube(): boolean;
  44149. /**
  44150. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  44151. * @param faceIndex The index of the face we are computed the direction to generate shadow
  44152. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  44153. */
  44154. getShadowDirection(faceIndex?: number): Vector3;
  44155. /**
  44156. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  44157. * - fov = PI / 2
  44158. * - aspect ratio : 1.0
  44159. * - z-near and far equal to the active camera minZ and maxZ.
  44160. * Returns the PointLight.
  44161. */
  44162. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44163. protected _buildUniformLayout(): void;
  44164. /**
  44165. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  44166. * @param effect The effect to update
  44167. * @param lightIndex The index of the light in the effect to update
  44168. * @returns The point light
  44169. */
  44170. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  44171. /**
  44172. * Prepares the list of defines specific to the light type.
  44173. * @param defines the list of defines
  44174. * @param lightIndex defines the index of the light for the effect
  44175. */
  44176. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44177. }
  44178. }
  44179. declare module BABYLON {
  44180. /**
  44181. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44182. * These values define a cone of light starting from the position, emitting toward the direction.
  44183. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44184. * and the exponent defines the speed of the decay of the light with distance (reach).
  44185. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44186. */
  44187. export class SpotLight extends ShadowLight {
  44188. private _angle;
  44189. private _innerAngle;
  44190. private _cosHalfAngle;
  44191. private _lightAngleScale;
  44192. private _lightAngleOffset;
  44193. /**
  44194. * Gets the cone angle of the spot light in Radians.
  44195. */
  44196. /**
  44197. * Sets the cone angle of the spot light in Radians.
  44198. */
  44199. angle: number;
  44200. /**
  44201. * Only used in gltf falloff mode, this defines the angle where
  44202. * the directional falloff will start before cutting at angle which could be seen
  44203. * as outer angle.
  44204. */
  44205. /**
  44206. * Only used in gltf falloff mode, this defines the angle where
  44207. * the directional falloff will start before cutting at angle which could be seen
  44208. * as outer angle.
  44209. */
  44210. innerAngle: number;
  44211. private _shadowAngleScale;
  44212. /**
  44213. * Allows scaling the angle of the light for shadow generation only.
  44214. */
  44215. /**
  44216. * Allows scaling the angle of the light for shadow generation only.
  44217. */
  44218. shadowAngleScale: number;
  44219. /**
  44220. * The light decay speed with the distance from the emission spot.
  44221. */
  44222. exponent: number;
  44223. private _projectionTextureMatrix;
  44224. /**
  44225. * Allows reading the projecton texture
  44226. */
  44227. readonly projectionTextureMatrix: Matrix;
  44228. protected _projectionTextureLightNear: number;
  44229. /**
  44230. * Gets the near clip of the Spotlight for texture projection.
  44231. */
  44232. /**
  44233. * Sets the near clip of the Spotlight for texture projection.
  44234. */
  44235. projectionTextureLightNear: number;
  44236. protected _projectionTextureLightFar: number;
  44237. /**
  44238. * Gets the far clip of the Spotlight for texture projection.
  44239. */
  44240. /**
  44241. * Sets the far clip of the Spotlight for texture projection.
  44242. */
  44243. projectionTextureLightFar: number;
  44244. protected _projectionTextureUpDirection: Vector3;
  44245. /**
  44246. * Gets the Up vector of the Spotlight for texture projection.
  44247. */
  44248. /**
  44249. * Sets the Up vector of the Spotlight for texture projection.
  44250. */
  44251. projectionTextureUpDirection: Vector3;
  44252. private _projectionTexture;
  44253. /**
  44254. * Gets the projection texture of the light.
  44255. */
  44256. /**
  44257. * Sets the projection texture of the light.
  44258. */
  44259. projectionTexture: Nullable<BaseTexture>;
  44260. private _projectionTextureViewLightDirty;
  44261. private _projectionTextureProjectionLightDirty;
  44262. private _projectionTextureDirty;
  44263. private _projectionTextureViewTargetVector;
  44264. private _projectionTextureViewLightMatrix;
  44265. private _projectionTextureProjectionLightMatrix;
  44266. private _projectionTextureScalingMatrix;
  44267. /**
  44268. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44269. * It can cast shadows.
  44270. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44271. * @param name The light friendly name
  44272. * @param position The position of the spot light in the scene
  44273. * @param direction The direction of the light in the scene
  44274. * @param angle The cone angle of the light in Radians
  44275. * @param exponent The light decay speed with the distance from the emission spot
  44276. * @param scene The scene the lights belongs to
  44277. */
  44278. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44279. /**
  44280. * Returns the string "SpotLight".
  44281. * @returns the class name
  44282. */
  44283. getClassName(): string;
  44284. /**
  44285. * Returns the integer 2.
  44286. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44287. */
  44288. getTypeID(): number;
  44289. /**
  44290. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44291. */
  44292. protected _setDirection(value: Vector3): void;
  44293. /**
  44294. * Overrides the position setter to recompute the projection texture view light Matrix.
  44295. */
  44296. protected _setPosition(value: Vector3): void;
  44297. /**
  44298. * 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.
  44299. * Returns the SpotLight.
  44300. */
  44301. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44302. protected _computeProjectionTextureViewLightMatrix(): void;
  44303. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44304. /**
  44305. * Main function for light texture projection matrix computing.
  44306. */
  44307. protected _computeProjectionTextureMatrix(): void;
  44308. protected _buildUniformLayout(): void;
  44309. private _computeAngleValues;
  44310. /**
  44311. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44312. * @param effect The effect to update
  44313. * @param lightIndex The index of the light in the effect to update
  44314. * @returns The spot light
  44315. */
  44316. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44317. /**
  44318. * Disposes the light and the associated resources.
  44319. */
  44320. dispose(): void;
  44321. /**
  44322. * Prepares the list of defines specific to the light type.
  44323. * @param defines the list of defines
  44324. * @param lightIndex defines the index of the light for the effect
  44325. */
  44326. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44327. }
  44328. }
  44329. declare module BABYLON {
  44330. /**
  44331. * Header information of HDR texture files.
  44332. */
  44333. export interface HDRInfo {
  44334. /**
  44335. * The height of the texture in pixels.
  44336. */
  44337. height: number;
  44338. /**
  44339. * The width of the texture in pixels.
  44340. */
  44341. width: number;
  44342. /**
  44343. * The index of the beginning of the data in the binary file.
  44344. */
  44345. dataPosition: number;
  44346. }
  44347. /**
  44348. * This groups tools to convert HDR texture to native colors array.
  44349. */
  44350. export class HDRTools {
  44351. private static Ldexp;
  44352. private static Rgbe2float;
  44353. private static readStringLine;
  44354. /**
  44355. * Reads header information from an RGBE texture stored in a native array.
  44356. * More information on this format are available here:
  44357. * https://en.wikipedia.org/wiki/RGBE_image_format
  44358. *
  44359. * @param uint8array The binary file stored in native array.
  44360. * @return The header information.
  44361. */
  44362. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  44363. /**
  44364. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  44365. * This RGBE texture needs to store the information as a panorama.
  44366. *
  44367. * More information on this format are available here:
  44368. * https://en.wikipedia.org/wiki/RGBE_image_format
  44369. *
  44370. * @param buffer The binary file stored in an array buffer.
  44371. * @param size The expected size of the extracted cubemap.
  44372. * @return The Cube Map information.
  44373. */
  44374. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  44375. /**
  44376. * Returns the pixels data extracted from an RGBE texture.
  44377. * This pixels will be stored left to right up to down in the R G B order in one array.
  44378. *
  44379. * More information on this format are available here:
  44380. * https://en.wikipedia.org/wiki/RGBE_image_format
  44381. *
  44382. * @param uint8array The binary file stored in an array buffer.
  44383. * @param hdrInfo The header information of the file.
  44384. * @return The pixels data in RGB right to left up to down order.
  44385. */
  44386. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  44387. private static RGBE_ReadPixels_RLE;
  44388. }
  44389. }
  44390. declare module BABYLON {
  44391. /**
  44392. * This represents a texture coming from an HDR input.
  44393. *
  44394. * The only supported format is currently panorama picture stored in RGBE format.
  44395. * Example of such files can be found on HDRLib: http://hdrlib.com/
  44396. */
  44397. export class HDRCubeTexture extends BaseTexture {
  44398. private static _facesMapping;
  44399. private _generateHarmonics;
  44400. private _noMipmap;
  44401. private _textureMatrix;
  44402. private _size;
  44403. private _onLoad;
  44404. private _onError;
  44405. /**
  44406. * The texture URL.
  44407. */
  44408. url: string;
  44409. /**
  44410. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  44411. */
  44412. coordinatesMode: number;
  44413. protected _isBlocking: boolean;
  44414. /**
  44415. * Sets wether or not the texture is blocking during loading.
  44416. */
  44417. /**
  44418. * Gets wether or not the texture is blocking during loading.
  44419. */
  44420. isBlocking: boolean;
  44421. protected _rotationY: number;
  44422. /**
  44423. * Sets texture matrix rotation angle around Y axis in radians.
  44424. */
  44425. /**
  44426. * Gets texture matrix rotation angle around Y axis radians.
  44427. */
  44428. rotationY: number;
  44429. /**
  44430. * Gets or sets the center of the bounding box associated with the cube texture
  44431. * It must define where the camera used to render the texture was set
  44432. */
  44433. boundingBoxPosition: Vector3;
  44434. private _boundingBoxSize;
  44435. /**
  44436. * Gets or sets the size of the bounding box associated with the cube texture
  44437. * When defined, the cubemap will switch to local mode
  44438. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  44439. * @example https://www.babylonjs-playground.com/#RNASML
  44440. */
  44441. boundingBoxSize: Vector3;
  44442. /**
  44443. * Instantiates an HDRTexture from the following parameters.
  44444. *
  44445. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  44446. * @param scene The scene the texture will be used in
  44447. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  44448. * @param noMipmap Forces to not generate the mipmap if true
  44449. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  44450. * @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)
  44451. * @param reserved Reserved flag for internal use.
  44452. */
  44453. 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>);
  44454. /**
  44455. * Get the current class name of the texture useful for serialization or dynamic coding.
  44456. * @returns "HDRCubeTexture"
  44457. */
  44458. getClassName(): string;
  44459. /**
  44460. * Occurs when the file is raw .hdr file.
  44461. */
  44462. private loadTexture;
  44463. clone(): HDRCubeTexture;
  44464. delayLoad(): void;
  44465. /**
  44466. * Get the texture reflection matrix used to rotate/transform the reflection.
  44467. * @returns the reflection matrix
  44468. */
  44469. getReflectionTextureMatrix(): Matrix;
  44470. /**
  44471. * Set the texture reflection matrix used to rotate/transform the reflection.
  44472. * @param value Define the reflection matrix to set
  44473. */
  44474. setReflectionTextureMatrix(value: Matrix): void;
  44475. /**
  44476. * Parses a JSON representation of an HDR Texture in order to create the texture
  44477. * @param parsedTexture Define the JSON representation
  44478. * @param scene Define the scene the texture should be created in
  44479. * @param rootUrl Define the root url in case we need to load relative dependencies
  44480. * @returns the newly created texture after parsing
  44481. */
  44482. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  44483. serialize(): any;
  44484. }
  44485. }
  44486. declare module BABYLON {
  44487. /**
  44488. * Class used to control physics engine
  44489. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  44490. */
  44491. export class PhysicsEngine implements IPhysicsEngine {
  44492. private _physicsPlugin;
  44493. /**
  44494. * Global value used to control the smallest number supported by the simulation
  44495. */
  44496. static Epsilon: number;
  44497. private _impostors;
  44498. private _joints;
  44499. /**
  44500. * Gets the gravity vector used by the simulation
  44501. */
  44502. gravity: Vector3;
  44503. /**
  44504. * Factory used to create the default physics plugin.
  44505. * @returns The default physics plugin
  44506. */
  44507. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  44508. /**
  44509. * Creates a new Physics Engine
  44510. * @param gravity defines the gravity vector used by the simulation
  44511. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  44512. */
  44513. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  44514. /**
  44515. * Sets the gravity vector used by the simulation
  44516. * @param gravity defines the gravity vector to use
  44517. */
  44518. setGravity(gravity: Vector3): void;
  44519. /**
  44520. * Set the time step of the physics engine.
  44521. * Default is 1/60.
  44522. * To slow it down, enter 1/600 for example.
  44523. * To speed it up, 1/30
  44524. * @param newTimeStep defines the new timestep to apply to this world.
  44525. */
  44526. setTimeStep(newTimeStep?: number): void;
  44527. /**
  44528. * Get the time step of the physics engine.
  44529. * @returns the current time step
  44530. */
  44531. getTimeStep(): number;
  44532. /**
  44533. * Release all resources
  44534. */
  44535. dispose(): void;
  44536. /**
  44537. * Gets the name of the current physics plugin
  44538. * @returns the name of the plugin
  44539. */
  44540. getPhysicsPluginName(): string;
  44541. /**
  44542. * Adding a new impostor for the impostor tracking.
  44543. * This will be done by the impostor itself.
  44544. * @param impostor the impostor to add
  44545. */
  44546. addImpostor(impostor: PhysicsImpostor): void;
  44547. /**
  44548. * Remove an impostor from the engine.
  44549. * This impostor and its mesh will not longer be updated by the physics engine.
  44550. * @param impostor the impostor to remove
  44551. */
  44552. removeImpostor(impostor: PhysicsImpostor): void;
  44553. /**
  44554. * Add a joint to the physics engine
  44555. * @param mainImpostor defines the main impostor to which the joint is added.
  44556. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  44557. * @param joint defines the joint that will connect both impostors.
  44558. */
  44559. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  44560. /**
  44561. * Removes a joint from the simulation
  44562. * @param mainImpostor defines the impostor used with the joint
  44563. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  44564. * @param joint defines the joint to remove
  44565. */
  44566. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  44567. /**
  44568. * Called by the scene. No need to call it.
  44569. * @param delta defines the timespam between frames
  44570. */ step(delta: number): void;
  44571. /**
  44572. * Gets the current plugin used to run the simulation
  44573. * @returns current plugin
  44574. */
  44575. getPhysicsPlugin(): IPhysicsEnginePlugin;
  44576. /**
  44577. * Gets the list of physic impostors
  44578. * @returns an array of PhysicsImpostor
  44579. */
  44580. getImpostors(): Array<PhysicsImpostor>;
  44581. /**
  44582. * Gets the impostor for a physics enabled object
  44583. * @param object defines the object impersonated by the impostor
  44584. * @returns the PhysicsImpostor or null if not found
  44585. */
  44586. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  44587. /**
  44588. * Gets the impostor for a physics body object
  44589. * @param body defines physics body used by the impostor
  44590. * @returns the PhysicsImpostor or null if not found
  44591. */
  44592. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  44593. }
  44594. }
  44595. declare module BABYLON {
  44596. /** @hidden */
  44597. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  44598. private _useDeltaForWorldStep;
  44599. world: any;
  44600. name: string;
  44601. private _physicsMaterials;
  44602. private _fixedTimeStep;
  44603. BJSCANNON: any;
  44604. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  44605. setGravity(gravity: Vector3): void;
  44606. setTimeStep(timeStep: number): void;
  44607. getTimeStep(): number;
  44608. executeStep(delta: number): void;
  44609. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  44610. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  44611. generatePhysicsBody(impostor: PhysicsImpostor): void;
  44612. private _processChildMeshes;
  44613. removePhysicsBody(impostor: PhysicsImpostor): void;
  44614. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  44615. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  44616. private _addMaterial;
  44617. private _checkWithEpsilon;
  44618. private _createShape;
  44619. private _createHeightmap;
  44620. private _minus90X;
  44621. private _plus90X;
  44622. private _tmpPosition;
  44623. private _tmpDeltaPosition;
  44624. private _tmpUnityRotation;
  44625. private _updatePhysicsBodyTransformation;
  44626. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  44627. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  44628. isSupported(): boolean;
  44629. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  44630. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  44631. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  44632. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  44633. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  44634. getBodyMass(impostor: PhysicsImpostor): number;
  44635. getBodyFriction(impostor: PhysicsImpostor): number;
  44636. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  44637. getBodyRestitution(impostor: PhysicsImpostor): number;
  44638. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  44639. sleepBody(impostor: PhysicsImpostor): void;
  44640. wakeUpBody(impostor: PhysicsImpostor): void;
  44641. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  44642. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  44643. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  44644. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  44645. getRadius(impostor: PhysicsImpostor): number;
  44646. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  44647. dispose(): void;
  44648. private _extendNamespace;
  44649. }
  44650. }
  44651. declare module BABYLON {
  44652. /** @hidden */
  44653. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  44654. world: any;
  44655. name: string;
  44656. BJSOIMO: any;
  44657. constructor(iterations?: number, oimoInjection?: any);
  44658. setGravity(gravity: Vector3): void;
  44659. setTimeStep(timeStep: number): void;
  44660. getTimeStep(): number;
  44661. private _tmpImpostorsArray;
  44662. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  44663. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  44664. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  44665. generatePhysicsBody(impostor: PhysicsImpostor): void;
  44666. private _tmpPositionVector;
  44667. removePhysicsBody(impostor: PhysicsImpostor): void;
  44668. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  44669. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  44670. isSupported(): boolean;
  44671. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  44672. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  44673. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  44674. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  44675. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  44676. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  44677. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  44678. getBodyMass(impostor: PhysicsImpostor): number;
  44679. getBodyFriction(impostor: PhysicsImpostor): number;
  44680. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  44681. getBodyRestitution(impostor: PhysicsImpostor): number;
  44682. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  44683. sleepBody(impostor: PhysicsImpostor): void;
  44684. wakeUpBody(impostor: PhysicsImpostor): void;
  44685. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  44686. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  44687. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  44688. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  44689. getRadius(impostor: PhysicsImpostor): number;
  44690. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  44691. dispose(): void;
  44692. }
  44693. }
  44694. declare module BABYLON {
  44695. interface AbstractScene {
  44696. /**
  44697. * The list of reflection probes added to the scene
  44698. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  44699. */
  44700. reflectionProbes: Array<ReflectionProbe>;
  44701. /**
  44702. * Removes the given reflection probe from this scene.
  44703. * @param toRemove The reflection probe to remove
  44704. * @returns The index of the removed reflection probe
  44705. */
  44706. removeReflectionProbe(toRemove: ReflectionProbe): number;
  44707. /**
  44708. * Adds the given reflection probe to this scene.
  44709. * @param newReflectionProbe The reflection probe to add
  44710. */
  44711. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  44712. }
  44713. /**
  44714. * Class used to generate realtime reflection / refraction cube textures
  44715. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  44716. */
  44717. export class ReflectionProbe {
  44718. /** defines the name of the probe */
  44719. name: string;
  44720. private _scene;
  44721. private _renderTargetTexture;
  44722. private _projectionMatrix;
  44723. private _viewMatrix;
  44724. private _target;
  44725. private _add;
  44726. private _attachedMesh;
  44727. private _invertYAxis;
  44728. /** Gets or sets probe position (center of the cube map) */
  44729. position: Vector3;
  44730. /**
  44731. * Creates a new reflection probe
  44732. * @param name defines the name of the probe
  44733. * @param size defines the texture resolution (for each face)
  44734. * @param scene defines the hosting scene
  44735. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  44736. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  44737. */
  44738. constructor(
  44739. /** defines the name of the probe */
  44740. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  44741. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  44742. samples: number;
  44743. /** Gets or sets the refresh rate to use (on every frame by default) */
  44744. refreshRate: number;
  44745. /**
  44746. * Gets the hosting scene
  44747. * @returns a Scene
  44748. */
  44749. getScene(): Scene;
  44750. /** Gets the internal CubeTexture used to render to */
  44751. readonly cubeTexture: RenderTargetTexture;
  44752. /** Gets the list of meshes to render */
  44753. readonly renderList: Nullable<AbstractMesh[]>;
  44754. /**
  44755. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  44756. * @param mesh defines the mesh to attach to
  44757. */
  44758. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44759. /**
  44760. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  44761. * @param renderingGroupId The rendering group id corresponding to its index
  44762. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  44763. */
  44764. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  44765. /**
  44766. * Clean all associated resources
  44767. */
  44768. dispose(): void;
  44769. /**
  44770. * Converts the reflection probe information to a readable string for debug purpose.
  44771. * @param fullDetails Supports for multiple levels of logging within scene loading
  44772. * @returns the human readable reflection probe info
  44773. */
  44774. toString(fullDetails?: boolean): string;
  44775. /**
  44776. * Get the class name of the relfection probe.
  44777. * @returns "ReflectionProbe"
  44778. */
  44779. getClassName(): string;
  44780. /**
  44781. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  44782. * @returns The JSON representation of the texture
  44783. */
  44784. serialize(): any;
  44785. /**
  44786. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  44787. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  44788. * @param scene Define the scene the parsed reflection probe should be instantiated in
  44789. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  44790. * @returns The parsed reflection probe if successful
  44791. */
  44792. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  44793. }
  44794. }
  44795. declare module BABYLON {
  44796. /** @hidden */
  44797. export var _BabylonLoaderRegistered: boolean;
  44798. }
  44799. declare module BABYLON {
  44800. /**
  44801. * The Physically based simple base material of BJS.
  44802. *
  44803. * This enables better naming and convention enforcements on top of the pbrMaterial.
  44804. * It is used as the base class for both the specGloss and metalRough conventions.
  44805. */
  44806. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  44807. /**
  44808. * Number of Simultaneous lights allowed on the material.
  44809. */
  44810. maxSimultaneousLights: number;
  44811. /**
  44812. * If sets to true, disables all the lights affecting the material.
  44813. */
  44814. disableLighting: boolean;
  44815. /**
  44816. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  44817. */
  44818. environmentTexture: BaseTexture;
  44819. /**
  44820. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  44821. */
  44822. invertNormalMapX: boolean;
  44823. /**
  44824. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  44825. */
  44826. invertNormalMapY: boolean;
  44827. /**
  44828. * Normal map used in the model.
  44829. */
  44830. normalTexture: BaseTexture;
  44831. /**
  44832. * Emissivie color used to self-illuminate the model.
  44833. */
  44834. emissiveColor: Color3;
  44835. /**
  44836. * Emissivie texture used to self-illuminate the model.
  44837. */
  44838. emissiveTexture: BaseTexture;
  44839. /**
  44840. * Occlusion Channel Strenght.
  44841. */
  44842. occlusionStrength: number;
  44843. /**
  44844. * Occlusion Texture of the material (adding extra occlusion effects).
  44845. */
  44846. occlusionTexture: BaseTexture;
  44847. /**
  44848. * Defines the alpha limits in alpha test mode.
  44849. */
  44850. alphaCutOff: number;
  44851. /**
  44852. * Gets the current double sided mode.
  44853. */
  44854. /**
  44855. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44856. */
  44857. doubleSided: boolean;
  44858. /**
  44859. * Stores the pre-calculated light information of a mesh in a texture.
  44860. */
  44861. lightmapTexture: BaseTexture;
  44862. /**
  44863. * If true, the light map contains occlusion information instead of lighting info.
  44864. */
  44865. useLightmapAsShadowmap: boolean;
  44866. /**
  44867. * Return the active textures of the material.
  44868. */
  44869. getActiveTextures(): BaseTexture[];
  44870. hasTexture(texture: BaseTexture): boolean;
  44871. /**
  44872. * Instantiates a new PBRMaterial instance.
  44873. *
  44874. * @param name The material name
  44875. * @param scene The scene the material will be use in.
  44876. */
  44877. constructor(name: string, scene: Scene);
  44878. getClassName(): string;
  44879. }
  44880. }
  44881. declare module BABYLON {
  44882. /**
  44883. * The PBR material of BJS following the metal roughness convention.
  44884. *
  44885. * This fits to the PBR convention in the GLTF definition:
  44886. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  44887. */
  44888. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  44889. /**
  44890. * The base color has two different interpretations depending on the value of metalness.
  44891. * When the material is a metal, the base color is the specific measured reflectance value
  44892. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  44893. * of the material.
  44894. */
  44895. baseColor: Color3;
  44896. /**
  44897. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  44898. * well as opacity information in the alpha channel.
  44899. */
  44900. baseTexture: BaseTexture;
  44901. /**
  44902. * Specifies the metallic scalar value of the material.
  44903. * Can also be used to scale the metalness values of the metallic texture.
  44904. */
  44905. metallic: number;
  44906. /**
  44907. * Specifies the roughness scalar value of the material.
  44908. * Can also be used to scale the roughness values of the metallic texture.
  44909. */
  44910. roughness: number;
  44911. /**
  44912. * Texture containing both the metallic value in the B channel and the
  44913. * roughness value in the G channel to keep better precision.
  44914. */
  44915. metallicRoughnessTexture: BaseTexture;
  44916. /**
  44917. * Instantiates a new PBRMetalRoughnessMaterial instance.
  44918. *
  44919. * @param name The material name
  44920. * @param scene The scene the material will be use in.
  44921. */
  44922. constructor(name: string, scene: Scene);
  44923. /**
  44924. * Return the currrent class name of the material.
  44925. */
  44926. getClassName(): string;
  44927. /**
  44928. * Return the active textures of the material.
  44929. */
  44930. getActiveTextures(): BaseTexture[];
  44931. /**
  44932. * Checks to see if a texture is used in the material.
  44933. * @param texture - Base texture to use.
  44934. * @returns - Boolean specifying if a texture is used in the material.
  44935. */
  44936. hasTexture(texture: BaseTexture): boolean;
  44937. /**
  44938. * Makes a duplicate of the current material.
  44939. * @param name - name to use for the new material.
  44940. */
  44941. clone(name: string): PBRMetallicRoughnessMaterial;
  44942. /**
  44943. * Serialize the material to a parsable JSON object.
  44944. */
  44945. serialize(): any;
  44946. /**
  44947. * Parses a JSON object correponding to the serialize function.
  44948. */
  44949. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  44950. }
  44951. }
  44952. declare module BABYLON {
  44953. /**
  44954. * The PBR material of BJS following the specular glossiness convention.
  44955. *
  44956. * This fits to the PBR convention in the GLTF definition:
  44957. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  44958. */
  44959. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  44960. /**
  44961. * Specifies the diffuse color of the material.
  44962. */
  44963. diffuseColor: Color3;
  44964. /**
  44965. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  44966. * channel.
  44967. */
  44968. diffuseTexture: BaseTexture;
  44969. /**
  44970. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  44971. */
  44972. specularColor: Color3;
  44973. /**
  44974. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  44975. */
  44976. glossiness: number;
  44977. /**
  44978. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  44979. */
  44980. specularGlossinessTexture: BaseTexture;
  44981. /**
  44982. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  44983. *
  44984. * @param name The material name
  44985. * @param scene The scene the material will be use in.
  44986. */
  44987. constructor(name: string, scene: Scene);
  44988. /**
  44989. * Return the currrent class name of the material.
  44990. */
  44991. getClassName(): string;
  44992. /**
  44993. * Return the active textures of the material.
  44994. */
  44995. getActiveTextures(): BaseTexture[];
  44996. /**
  44997. * Checks to see if a texture is used in the material.
  44998. * @param texture - Base texture to use.
  44999. * @returns - Boolean specifying if a texture is used in the material.
  45000. */
  45001. hasTexture(texture: BaseTexture): boolean;
  45002. /**
  45003. * Makes a duplicate of the current material.
  45004. * @param name - name to use for the new material.
  45005. */
  45006. clone(name: string): PBRSpecularGlossinessMaterial;
  45007. /**
  45008. * Serialize the material to a parsable JSON object.
  45009. */
  45010. serialize(): any;
  45011. /**
  45012. * Parses a JSON object correponding to the serialize function.
  45013. */
  45014. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  45015. }
  45016. }
  45017. declare module BABYLON {
  45018. /**
  45019. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  45020. * It can help converting any input color in a desired output one. This can then be used to create effects
  45021. * from sepia, black and white to sixties or futuristic rendering...
  45022. *
  45023. * The only supported format is currently 3dl.
  45024. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  45025. */
  45026. export class ColorGradingTexture extends BaseTexture {
  45027. /**
  45028. * The current texture matrix. (will always be identity in color grading texture)
  45029. */
  45030. private _textureMatrix;
  45031. /**
  45032. * The texture URL.
  45033. */
  45034. url: string;
  45035. /**
  45036. * Empty line regex stored for GC.
  45037. */
  45038. private static _noneEmptyLineRegex;
  45039. private _engine;
  45040. /**
  45041. * Instantiates a ColorGradingTexture from the following parameters.
  45042. *
  45043. * @param url The location of the color gradind data (currently only supporting 3dl)
  45044. * @param scene The scene the texture will be used in
  45045. */
  45046. constructor(url: string, scene: Scene);
  45047. /**
  45048. * Returns the texture matrix used in most of the material.
  45049. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  45050. */
  45051. getTextureMatrix(): Matrix;
  45052. /**
  45053. * Occurs when the file being loaded is a .3dl LUT file.
  45054. */
  45055. private load3dlTexture;
  45056. /**
  45057. * Starts the loading process of the texture.
  45058. */
  45059. private loadTexture;
  45060. /**
  45061. * Clones the color gradind texture.
  45062. */
  45063. clone(): ColorGradingTexture;
  45064. /**
  45065. * Called during delayed load for textures.
  45066. */
  45067. delayLoad(): void;
  45068. /**
  45069. * Parses a color grading texture serialized by Babylon.
  45070. * @param parsedTexture The texture information being parsedTexture
  45071. * @param scene The scene to load the texture in
  45072. * @param rootUrl The root url of the data assets to load
  45073. * @return A color gradind texture
  45074. */
  45075. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  45076. /**
  45077. * Serializes the LUT texture to json format.
  45078. */
  45079. serialize(): any;
  45080. }
  45081. }
  45082. declare module BABYLON {
  45083. /**
  45084. * Direct draw surface info
  45085. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  45086. */
  45087. export interface DDSInfo {
  45088. /**
  45089. * Width of the texture
  45090. */
  45091. width: number;
  45092. /**
  45093. * Width of the texture
  45094. */
  45095. height: number;
  45096. /**
  45097. * Number of Mipmaps for the texture
  45098. * @see https://en.wikipedia.org/wiki/Mipmap
  45099. */
  45100. mipmapCount: number;
  45101. /**
  45102. * If the textures format is a known fourCC format
  45103. * @see https://www.fourcc.org/
  45104. */
  45105. isFourCC: boolean;
  45106. /**
  45107. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  45108. */
  45109. isRGB: boolean;
  45110. /**
  45111. * If the texture is a lumincance format
  45112. */
  45113. isLuminance: boolean;
  45114. /**
  45115. * If this is a cube texture
  45116. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  45117. */
  45118. isCube: boolean;
  45119. /**
  45120. * If the texture is a compressed format eg. FOURCC_DXT1
  45121. */
  45122. isCompressed: boolean;
  45123. /**
  45124. * The dxgiFormat of the texture
  45125. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  45126. */
  45127. dxgiFormat: number;
  45128. /**
  45129. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  45130. */
  45131. textureType: number;
  45132. /**
  45133. * Sphericle polynomial created for the dds texture
  45134. */
  45135. sphericalPolynomial?: SphericalPolynomial;
  45136. }
  45137. /**
  45138. * Class used to provide DDS decompression tools
  45139. */
  45140. export class DDSTools {
  45141. /**
  45142. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  45143. */
  45144. static StoreLODInAlphaChannel: boolean;
  45145. /**
  45146. * Gets DDS information from an array buffer
  45147. * @param arrayBuffer defines the array buffer to read data from
  45148. * @returns the DDS information
  45149. */
  45150. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  45151. private static _FloatView;
  45152. private static _Int32View;
  45153. private static _ToHalfFloat;
  45154. private static _FromHalfFloat;
  45155. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  45156. private static _GetHalfFloatRGBAArrayBuffer;
  45157. private static _GetFloatRGBAArrayBuffer;
  45158. private static _GetFloatAsUIntRGBAArrayBuffer;
  45159. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  45160. private static _GetRGBAArrayBuffer;
  45161. private static _ExtractLongWordOrder;
  45162. private static _GetRGBArrayBuffer;
  45163. private static _GetLuminanceArrayBuffer;
  45164. /**
  45165. * Uploads DDS Levels to a Babylon Texture
  45166. * @hidden
  45167. */
  45168. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  45169. }
  45170. interface Engine {
  45171. /**
  45172. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  45173. * @param rootUrl defines the url where the file to load is located
  45174. * @param scene defines the current scene
  45175. * @param lodScale defines scale to apply to the mip map selection
  45176. * @param lodOffset defines offset to apply to the mip map selection
  45177. * @param onLoad defines an optional callback raised when the texture is loaded
  45178. * @param onError defines an optional callback raised if there is an issue to load the texture
  45179. * @param format defines the format of the data
  45180. * @param forcedExtension defines the extension to use to pick the right loader
  45181. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  45182. * @returns the cube texture as an InternalTexture
  45183. */
  45184. 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;
  45185. }
  45186. }
  45187. declare module BABYLON {
  45188. /**
  45189. * Implementation of the DDS Texture Loader.
  45190. * @hidden
  45191. */
  45192. export class _DDSTextureLoader implements IInternalTextureLoader {
  45193. /**
  45194. * Defines wether the loader supports cascade loading the different faces.
  45195. */
  45196. readonly supportCascades: boolean;
  45197. /**
  45198. * This returns if the loader support the current file information.
  45199. * @param extension defines the file extension of the file being loaded
  45200. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45201. * @param fallback defines the fallback internal texture if any
  45202. * @param isBase64 defines whether the texture is encoded as a base64
  45203. * @param isBuffer defines whether the texture data are stored as a buffer
  45204. * @returns true if the loader can load the specified file
  45205. */
  45206. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45207. /**
  45208. * Transform the url before loading if required.
  45209. * @param rootUrl the url of the texture
  45210. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45211. * @returns the transformed texture
  45212. */
  45213. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45214. /**
  45215. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45216. * @param rootUrl the url of the texture
  45217. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45218. * @returns the fallback texture
  45219. */
  45220. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45221. /**
  45222. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45223. * @param data contains the texture data
  45224. * @param texture defines the BabylonJS internal texture
  45225. * @param createPolynomials will be true if polynomials have been requested
  45226. * @param onLoad defines the callback to trigger once the texture is ready
  45227. * @param onError defines the callback to trigger in case of error
  45228. */
  45229. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45230. /**
  45231. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45232. * @param data contains the texture data
  45233. * @param texture defines the BabylonJS internal texture
  45234. * @param callback defines the method to call once ready to upload
  45235. */
  45236. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45237. }
  45238. }
  45239. declare module BABYLON {
  45240. /** @hidden */
  45241. export var rgbdEncodePixelShader: {
  45242. name: string;
  45243. shader: string;
  45244. };
  45245. }
  45246. declare module BABYLON {
  45247. /** @hidden */
  45248. export var rgbdDecodePixelShader: {
  45249. name: string;
  45250. shader: string;
  45251. };
  45252. }
  45253. declare module BABYLON {
  45254. /**
  45255. * Raw texture data and descriptor sufficient for WebGL texture upload
  45256. */
  45257. export interface EnvironmentTextureInfo {
  45258. /**
  45259. * Version of the environment map
  45260. */
  45261. version: number;
  45262. /**
  45263. * Width of image
  45264. */
  45265. width: number;
  45266. /**
  45267. * Irradiance information stored in the file.
  45268. */
  45269. irradiance: any;
  45270. /**
  45271. * Specular information stored in the file.
  45272. */
  45273. specular: any;
  45274. }
  45275. /**
  45276. * Sets of helpers addressing the serialization and deserialization of environment texture
  45277. * stored in a BabylonJS env file.
  45278. * Those files are usually stored as .env files.
  45279. */
  45280. export class EnvironmentTextureTools {
  45281. /**
  45282. * Magic number identifying the env file.
  45283. */
  45284. private static _MagicBytes;
  45285. /**
  45286. * Gets the environment info from an env file.
  45287. * @param data The array buffer containing the .env bytes.
  45288. * @returns the environment file info (the json header) if successfully parsed.
  45289. */
  45290. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45291. /**
  45292. * Creates an environment texture from a loaded cube texture.
  45293. * @param texture defines the cube texture to convert in env file
  45294. * @return a promise containing the environment data if succesfull.
  45295. */
  45296. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45297. /**
  45298. * Creates a JSON representation of the spherical data.
  45299. * @param texture defines the texture containing the polynomials
  45300. * @return the JSON representation of the spherical info
  45301. */
  45302. private static _CreateEnvTextureIrradiance;
  45303. /**
  45304. * Uploads the texture info contained in the env file to the GPU.
  45305. * @param texture defines the internal texture to upload to
  45306. * @param arrayBuffer defines the buffer cotaining the data to load
  45307. * @param info defines the texture info retrieved through the GetEnvInfo method
  45308. * @returns a promise
  45309. */
  45310. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45311. /**
  45312. * Uploads the levels of image data to the GPU.
  45313. * @param texture defines the internal texture to upload to
  45314. * @param imageData defines the array buffer views of image data [mipmap][face]
  45315. * @returns a promise
  45316. */
  45317. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45318. /**
  45319. * Uploads spherical polynomials information to the texture.
  45320. * @param texture defines the texture we are trying to upload the information to
  45321. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45322. */
  45323. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45324. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45325. }
  45326. }
  45327. declare module BABYLON {
  45328. /**
  45329. * Implementation of the ENV Texture Loader.
  45330. * @hidden
  45331. */
  45332. export class _ENVTextureLoader implements IInternalTextureLoader {
  45333. /**
  45334. * Defines wether the loader supports cascade loading the different faces.
  45335. */
  45336. readonly supportCascades: boolean;
  45337. /**
  45338. * This returns if the loader support the current file information.
  45339. * @param extension defines the file extension of the file being loaded
  45340. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45341. * @param fallback defines the fallback internal texture if any
  45342. * @param isBase64 defines whether the texture is encoded as a base64
  45343. * @param isBuffer defines whether the texture data are stored as a buffer
  45344. * @returns true if the loader can load the specified file
  45345. */
  45346. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45347. /**
  45348. * Transform the url before loading if required.
  45349. * @param rootUrl the url of the texture
  45350. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45351. * @returns the transformed texture
  45352. */
  45353. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45354. /**
  45355. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45356. * @param rootUrl the url of the texture
  45357. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45358. * @returns the fallback texture
  45359. */
  45360. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45361. /**
  45362. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45363. * @param data contains the texture data
  45364. * @param texture defines the BabylonJS internal texture
  45365. * @param createPolynomials will be true if polynomials have been requested
  45366. * @param onLoad defines the callback to trigger once the texture is ready
  45367. * @param onError defines the callback to trigger in case of error
  45368. */
  45369. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45370. /**
  45371. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45372. * @param data contains the texture data
  45373. * @param texture defines the BabylonJS internal texture
  45374. * @param callback defines the method to call once ready to upload
  45375. */
  45376. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45377. }
  45378. }
  45379. declare module BABYLON {
  45380. /**
  45381. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  45382. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  45383. */
  45384. export class KhronosTextureContainer {
  45385. /** contents of the KTX container file */
  45386. arrayBuffer: any;
  45387. private static HEADER_LEN;
  45388. private static COMPRESSED_2D;
  45389. private static COMPRESSED_3D;
  45390. private static TEX_2D;
  45391. private static TEX_3D;
  45392. /**
  45393. * Gets the openGL type
  45394. */
  45395. glType: number;
  45396. /**
  45397. * Gets the openGL type size
  45398. */
  45399. glTypeSize: number;
  45400. /**
  45401. * Gets the openGL format
  45402. */
  45403. glFormat: number;
  45404. /**
  45405. * Gets the openGL internal format
  45406. */
  45407. glInternalFormat: number;
  45408. /**
  45409. * Gets the base internal format
  45410. */
  45411. glBaseInternalFormat: number;
  45412. /**
  45413. * Gets image width in pixel
  45414. */
  45415. pixelWidth: number;
  45416. /**
  45417. * Gets image height in pixel
  45418. */
  45419. pixelHeight: number;
  45420. /**
  45421. * Gets image depth in pixels
  45422. */
  45423. pixelDepth: number;
  45424. /**
  45425. * Gets the number of array elements
  45426. */
  45427. numberOfArrayElements: number;
  45428. /**
  45429. * Gets the number of faces
  45430. */
  45431. numberOfFaces: number;
  45432. /**
  45433. * Gets the number of mipmap levels
  45434. */
  45435. numberOfMipmapLevels: number;
  45436. /**
  45437. * Gets the bytes of key value data
  45438. */
  45439. bytesOfKeyValueData: number;
  45440. /**
  45441. * Gets the load type
  45442. */
  45443. loadType: number;
  45444. /**
  45445. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  45446. */
  45447. isInvalid: boolean;
  45448. /**
  45449. * Creates a new KhronosTextureContainer
  45450. * @param arrayBuffer contents of the KTX container file
  45451. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  45452. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  45453. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  45454. */
  45455. constructor(
  45456. /** contents of the KTX container file */
  45457. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  45458. /**
  45459. * Uploads KTX content to a Babylon Texture.
  45460. * It is assumed that the texture has already been created & is currently bound
  45461. * @hidden
  45462. */
  45463. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  45464. private _upload2DCompressedLevels;
  45465. }
  45466. }
  45467. declare module BABYLON {
  45468. /**
  45469. * Implementation of the KTX Texture Loader.
  45470. * @hidden
  45471. */
  45472. export class _KTXTextureLoader implements IInternalTextureLoader {
  45473. /**
  45474. * Defines wether the loader supports cascade loading the different faces.
  45475. */
  45476. readonly supportCascades: boolean;
  45477. /**
  45478. * This returns if the loader support the current file information.
  45479. * @param extension defines the file extension of the file being loaded
  45480. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45481. * @param fallback defines the fallback internal texture if any
  45482. * @param isBase64 defines whether the texture is encoded as a base64
  45483. * @param isBuffer defines whether the texture data are stored as a buffer
  45484. * @returns true if the loader can load the specified file
  45485. */
  45486. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45487. /**
  45488. * Transform the url before loading if required.
  45489. * @param rootUrl the url of the texture
  45490. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45491. * @returns the transformed texture
  45492. */
  45493. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45494. /**
  45495. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45496. * @param rootUrl the url of the texture
  45497. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45498. * @returns the fallback texture
  45499. */
  45500. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45501. /**
  45502. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45503. * @param data contains the texture data
  45504. * @param texture defines the BabylonJS internal texture
  45505. * @param createPolynomials will be true if polynomials have been requested
  45506. * @param onLoad defines the callback to trigger once the texture is ready
  45507. * @param onError defines the callback to trigger in case of error
  45508. */
  45509. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45510. /**
  45511. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45512. * @param data contains the texture data
  45513. * @param texture defines the BabylonJS internal texture
  45514. * @param callback defines the method to call once ready to upload
  45515. */
  45516. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  45517. }
  45518. }
  45519. declare module BABYLON {
  45520. /**
  45521. * Based on jsTGALoader - Javascript loader for TGA file
  45522. * By Vincent Thibault
  45523. * @see http://blog.robrowser.com/javascript-tga-loader.html
  45524. */
  45525. export class TGATools {
  45526. private static _TYPE_INDEXED;
  45527. private static _TYPE_RGB;
  45528. private static _TYPE_GREY;
  45529. private static _TYPE_RLE_INDEXED;
  45530. private static _TYPE_RLE_RGB;
  45531. private static _TYPE_RLE_GREY;
  45532. private static _ORIGIN_MASK;
  45533. private static _ORIGIN_SHIFT;
  45534. private static _ORIGIN_BL;
  45535. private static _ORIGIN_BR;
  45536. private static _ORIGIN_UL;
  45537. private static _ORIGIN_UR;
  45538. /**
  45539. * Gets the header of a TGA file
  45540. * @param data defines the TGA data
  45541. * @returns the header
  45542. */
  45543. static GetTGAHeader(data: Uint8Array): any;
  45544. /**
  45545. * Uploads TGA content to a Babylon Texture
  45546. * @hidden
  45547. */
  45548. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  45549. /** @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;
  45550. /** @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;
  45551. /** @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;
  45552. /** @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;
  45553. /** @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;
  45554. /** @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;
  45555. }
  45556. }
  45557. declare module BABYLON {
  45558. /**
  45559. * Implementation of the TGA Texture Loader.
  45560. * @hidden
  45561. */
  45562. export class _TGATextureLoader implements IInternalTextureLoader {
  45563. /**
  45564. * Defines wether the loader supports cascade loading the different faces.
  45565. */
  45566. readonly supportCascades: boolean;
  45567. /**
  45568. * This returns if the loader support the current file information.
  45569. * @param extension defines the file extension of the file being loaded
  45570. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45571. * @param fallback defines the fallback internal texture if any
  45572. * @param isBase64 defines whether the texture is encoded as a base64
  45573. * @param isBuffer defines whether the texture data are stored as a buffer
  45574. * @returns true if the loader can load the specified file
  45575. */
  45576. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45577. /**
  45578. * Transform the url before loading if required.
  45579. * @param rootUrl the url of the texture
  45580. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45581. * @returns the transformed texture
  45582. */
  45583. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45584. /**
  45585. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45586. * @param rootUrl the url of the texture
  45587. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45588. * @returns the fallback texture
  45589. */
  45590. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45591. /**
  45592. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45593. * @param data contains the texture data
  45594. * @param texture defines the BabylonJS internal texture
  45595. * @param createPolynomials will be true if polynomials have been requested
  45596. * @param onLoad defines the callback to trigger once the texture is ready
  45597. * @param onError defines the callback to trigger in case of error
  45598. */
  45599. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45600. /**
  45601. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45602. * @param data contains the texture data
  45603. * @param texture defines the BabylonJS internal texture
  45604. * @param callback defines the method to call once ready to upload
  45605. */
  45606. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45607. }
  45608. }
  45609. declare module BABYLON {
  45610. /**
  45611. * 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.
  45612. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  45613. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  45614. */
  45615. export class CustomProceduralTexture extends ProceduralTexture {
  45616. private _animate;
  45617. private _time;
  45618. private _config;
  45619. private _texturePath;
  45620. /**
  45621. * Instantiates a new Custom Procedural Texture.
  45622. * 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.
  45623. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  45624. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  45625. * @param name Define the name of the texture
  45626. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  45627. * @param size Define the size of the texture to create
  45628. * @param scene Define the scene the texture belongs to
  45629. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  45630. * @param generateMipMaps Define if the texture should creates mip maps or not
  45631. */
  45632. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  45633. private _loadJson;
  45634. /**
  45635. * Is the texture ready to be used ? (rendered at least once)
  45636. * @returns true if ready, otherwise, false.
  45637. */
  45638. isReady(): boolean;
  45639. /**
  45640. * Render the texture to its associated render target.
  45641. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  45642. */
  45643. render(useCameraPostProcess?: boolean): void;
  45644. /**
  45645. * Update the list of dependant textures samplers in the shader.
  45646. */
  45647. updateTextures(): void;
  45648. /**
  45649. * Update the uniform values of the procedural texture in the shader.
  45650. */
  45651. updateShaderUniforms(): void;
  45652. /**
  45653. * Define if the texture animates or not.
  45654. */
  45655. animate: boolean;
  45656. }
  45657. }
  45658. declare module BABYLON {
  45659. /** @hidden */
  45660. export var noisePixelShader: {
  45661. name: string;
  45662. shader: string;
  45663. };
  45664. }
  45665. declare module BABYLON {
  45666. /**
  45667. * Class used to generate noise procedural textures
  45668. */
  45669. export class NoiseProceduralTexture extends ProceduralTexture {
  45670. private _time;
  45671. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  45672. brightness: number;
  45673. /** Defines the number of octaves to process */
  45674. octaves: number;
  45675. /** Defines the level of persistence (0.8 by default) */
  45676. persistence: number;
  45677. /** Gets or sets animation speed factor (default is 1) */
  45678. animationSpeedFactor: number;
  45679. /**
  45680. * Creates a new NoiseProceduralTexture
  45681. * @param name defines the name fo the texture
  45682. * @param size defines the size of the texture (default is 256)
  45683. * @param scene defines the hosting scene
  45684. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  45685. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  45686. */
  45687. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  45688. private _updateShaderUniforms;
  45689. protected _getDefines(): string;
  45690. /** Generate the current state of the procedural texture */
  45691. render(useCameraPostProcess?: boolean): void;
  45692. /**
  45693. * Serializes this noise procedural texture
  45694. * @returns a serialized noise procedural texture object
  45695. */
  45696. serialize(): any;
  45697. /**
  45698. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  45699. * @param parsedTexture defines parsed texture data
  45700. * @param scene defines the current scene
  45701. * @param rootUrl defines the root URL containing noise procedural texture information
  45702. * @returns a parsed NoiseProceduralTexture
  45703. */
  45704. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  45705. }
  45706. }
  45707. declare module BABYLON {
  45708. /**
  45709. * Raw cube texture where the raw buffers are passed in
  45710. */
  45711. export class RawCubeTexture extends CubeTexture {
  45712. /**
  45713. * Creates a cube texture where the raw buffers are passed in.
  45714. * @param scene defines the scene the texture is attached to
  45715. * @param data defines the array of data to use to create each face
  45716. * @param size defines the size of the textures
  45717. * @param format defines the format of the data
  45718. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  45719. * @param generateMipMaps defines if the engine should generate the mip levels
  45720. * @param invertY defines if data must be stored with Y axis inverted
  45721. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45722. * @param compression defines the compression used (null by default)
  45723. */
  45724. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  45725. /**
  45726. * Updates the raw cube texture.
  45727. * @param data defines the data to store
  45728. * @param format defines the data format
  45729. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45730. * @param invertY defines if data must be stored with Y axis inverted
  45731. * @param compression defines the compression used (null by default)
  45732. * @param level defines which level of the texture to update
  45733. */
  45734. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  45735. /**
  45736. * Updates a raw cube texture with RGBD encoded data.
  45737. * @param data defines the array of data [mipmap][face] to use to create each face
  45738. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  45739. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45740. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45741. * @returns a promsie that resolves when the operation is complete
  45742. */
  45743. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  45744. /**
  45745. * Clones the raw cube texture.
  45746. * @return a new cube texture
  45747. */
  45748. clone(): CubeTexture;
  45749. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45750. }
  45751. }
  45752. declare module BABYLON {
  45753. /**
  45754. * Class used to store 3D textures containing user data
  45755. */
  45756. export class RawTexture3D extends Texture {
  45757. /** Gets or sets the texture format to use */
  45758. format: number;
  45759. private _engine;
  45760. /**
  45761. * Create a new RawTexture3D
  45762. * @param data defines the data of the texture
  45763. * @param width defines the width of the texture
  45764. * @param height defines the height of the texture
  45765. * @param depth defines the depth of the texture
  45766. * @param format defines the texture format to use
  45767. * @param scene defines the hosting scene
  45768. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  45769. * @param invertY defines if texture must be stored with Y axis inverted
  45770. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  45771. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  45772. */
  45773. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  45774. /** Gets or sets the texture format to use */
  45775. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  45776. /**
  45777. * Update the texture with new data
  45778. * @param data defines the data to store in the texture
  45779. */
  45780. update(data: ArrayBufferView): void;
  45781. }
  45782. }
  45783. declare module BABYLON {
  45784. /**
  45785. * Creates a refraction texture used by refraction channel of the standard material.
  45786. * It is like a mirror but to see through a material.
  45787. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  45788. */
  45789. export class RefractionTexture extends RenderTargetTexture {
  45790. /**
  45791. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  45792. * 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.
  45793. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  45794. */
  45795. refractionPlane: Plane;
  45796. /**
  45797. * Define how deep under the surface we should see.
  45798. */
  45799. depth: number;
  45800. /**
  45801. * Creates a refraction texture used by refraction channel of the standard material.
  45802. * It is like a mirror but to see through a material.
  45803. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  45804. * @param name Define the texture name
  45805. * @param size Define the size of the underlying texture
  45806. * @param scene Define the scene the refraction belongs to
  45807. * @param generateMipMaps Define if we need to generate mips level for the refraction
  45808. */
  45809. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  45810. /**
  45811. * Clone the refraction texture.
  45812. * @returns the cloned texture
  45813. */
  45814. clone(): RefractionTexture;
  45815. /**
  45816. * Serialize the texture to a JSON representation you could use in Parse later on
  45817. * @returns the serialized JSON representation
  45818. */
  45819. serialize(): any;
  45820. }
  45821. }
  45822. declare module BABYLON {
  45823. /**
  45824. * Configuration for Draco compression
  45825. */
  45826. export interface IDracoCompressionConfiguration {
  45827. /**
  45828. * Configuration for the decoder.
  45829. */
  45830. decoder?: {
  45831. /**
  45832. * The url to the WebAssembly module.
  45833. */
  45834. wasmUrl?: string;
  45835. /**
  45836. * The url to the WebAssembly binary.
  45837. */
  45838. wasmBinaryUrl?: string;
  45839. /**
  45840. * The url to the fallback JavaScript module.
  45841. */
  45842. fallbackUrl?: string;
  45843. };
  45844. }
  45845. /**
  45846. * Draco compression (https://google.github.io/draco/)
  45847. *
  45848. * This class wraps the Draco module.
  45849. *
  45850. * **Encoder**
  45851. *
  45852. * The encoder is not currently implemented.
  45853. *
  45854. * **Decoder**
  45855. *
  45856. * 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.
  45857. *
  45858. * To update the configuration, use the following code:
  45859. * ```javascript
  45860. * DracoCompression.Configuration = {
  45861. * decoder: {
  45862. * wasmUrl: "<url to the WebAssembly library>",
  45863. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  45864. * fallbackUrl: "<url to the fallback JavaScript library>",
  45865. * }
  45866. * };
  45867. * ```
  45868. *
  45869. * 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.
  45870. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  45871. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  45872. *
  45873. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  45874. * ```javascript
  45875. * var dracoCompression = new DracoCompression();
  45876. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  45877. * [VertexBuffer.PositionKind]: 0
  45878. * });
  45879. * ```
  45880. *
  45881. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  45882. */
  45883. export class DracoCompression implements IDisposable {
  45884. private static _DecoderModulePromise;
  45885. /**
  45886. * The configuration. Defaults to the following urls:
  45887. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  45888. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  45889. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  45890. */
  45891. static Configuration: IDracoCompressionConfiguration;
  45892. /**
  45893. * Returns true if the decoder is available.
  45894. */
  45895. static readonly DecoderAvailable: boolean;
  45896. /**
  45897. * Constructor
  45898. */
  45899. constructor();
  45900. /**
  45901. * Stop all async operations and release resources.
  45902. */
  45903. dispose(): void;
  45904. /**
  45905. * Decode Draco compressed mesh data to vertex data.
  45906. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  45907. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  45908. * @returns A promise that resolves with the decoded vertex data
  45909. */
  45910. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  45911. [kind: string]: number;
  45912. }): Promise<VertexData>;
  45913. private static _GetDecoderModule;
  45914. private static _LoadScriptAsync;
  45915. private static _LoadFileAsync;
  45916. }
  45917. }
  45918. declare module BABYLON {
  45919. /**
  45920. * Class for building Constructive Solid Geometry
  45921. */
  45922. export class CSG {
  45923. private polygons;
  45924. /**
  45925. * The world matrix
  45926. */
  45927. matrix: Matrix;
  45928. /**
  45929. * Stores the position
  45930. */
  45931. position: Vector3;
  45932. /**
  45933. * Stores the rotation
  45934. */
  45935. rotation: Vector3;
  45936. /**
  45937. * Stores the rotation quaternion
  45938. */
  45939. rotationQuaternion: Nullable<Quaternion>;
  45940. /**
  45941. * Stores the scaling vector
  45942. */
  45943. scaling: Vector3;
  45944. /**
  45945. * Convert the Mesh to CSG
  45946. * @param mesh The Mesh to convert to CSG
  45947. * @returns A new CSG from the Mesh
  45948. */
  45949. static FromMesh(mesh: Mesh): CSG;
  45950. /**
  45951. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  45952. * @param polygons Polygons used to construct a CSG solid
  45953. */
  45954. private static FromPolygons;
  45955. /**
  45956. * Clones, or makes a deep copy, of the CSG
  45957. * @returns A new CSG
  45958. */
  45959. clone(): CSG;
  45960. /**
  45961. * Unions this CSG with another CSG
  45962. * @param csg The CSG to union against this CSG
  45963. * @returns The unioned CSG
  45964. */
  45965. union(csg: CSG): CSG;
  45966. /**
  45967. * Unions this CSG with another CSG in place
  45968. * @param csg The CSG to union against this CSG
  45969. */
  45970. unionInPlace(csg: CSG): void;
  45971. /**
  45972. * Subtracts this CSG with another CSG
  45973. * @param csg The CSG to subtract against this CSG
  45974. * @returns A new CSG
  45975. */
  45976. subtract(csg: CSG): CSG;
  45977. /**
  45978. * Subtracts this CSG with another CSG in place
  45979. * @param csg The CSG to subtact against this CSG
  45980. */
  45981. subtractInPlace(csg: CSG): void;
  45982. /**
  45983. * Intersect this CSG with another CSG
  45984. * @param csg The CSG to intersect against this CSG
  45985. * @returns A new CSG
  45986. */
  45987. intersect(csg: CSG): CSG;
  45988. /**
  45989. * Intersects this CSG with another CSG in place
  45990. * @param csg The CSG to intersect against this CSG
  45991. */
  45992. intersectInPlace(csg: CSG): void;
  45993. /**
  45994. * Return a new CSG solid with solid and empty space switched. This solid is
  45995. * not modified.
  45996. * @returns A new CSG solid with solid and empty space switched
  45997. */
  45998. inverse(): CSG;
  45999. /**
  46000. * Inverses the CSG in place
  46001. */
  46002. inverseInPlace(): void;
  46003. /**
  46004. * This is used to keep meshes transformations so they can be restored
  46005. * when we build back a Babylon Mesh
  46006. * NB : All CSG operations are performed in world coordinates
  46007. * @param csg The CSG to copy the transform attributes from
  46008. * @returns This CSG
  46009. */
  46010. copyTransformAttributes(csg: CSG): CSG;
  46011. /**
  46012. * Build Raw mesh from CSG
  46013. * Coordinates here are in world space
  46014. * @param name The name of the mesh geometry
  46015. * @param scene The Scene
  46016. * @param keepSubMeshes Specifies if the submeshes should be kept
  46017. * @returns A new Mesh
  46018. */
  46019. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  46020. /**
  46021. * Build Mesh from CSG taking material and transforms into account
  46022. * @param name The name of the Mesh
  46023. * @param material The material of the Mesh
  46024. * @param scene The Scene
  46025. * @param keepSubMeshes Specifies if submeshes should be kept
  46026. * @returns The new Mesh
  46027. */
  46028. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  46029. }
  46030. }
  46031. declare module BABYLON {
  46032. /**
  46033. * Class containing static functions to help procedurally build meshes
  46034. */
  46035. export class RibbonBuilder {
  46036. /**
  46037. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  46038. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  46039. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  46040. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  46041. * * 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
  46042. * * 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
  46043. * * 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
  46044. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46045. * * 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
  46046. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  46047. * * 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
  46048. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  46049. * * 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
  46050. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  46051. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46052. * @param name defines the name of the mesh
  46053. * @param options defines the options used to create the mesh
  46054. * @param scene defines the hosting scene
  46055. * @returns the ribbon mesh
  46056. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  46057. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  46058. */
  46059. static CreateRibbon(name: string, options: {
  46060. pathArray: Vector3[][];
  46061. closeArray?: boolean;
  46062. closePath?: boolean;
  46063. offset?: number;
  46064. updatable?: boolean;
  46065. sideOrientation?: number;
  46066. frontUVs?: Vector4;
  46067. backUVs?: Vector4;
  46068. instance?: Mesh;
  46069. invertUV?: boolean;
  46070. uvs?: Vector2[];
  46071. colors?: Color4[];
  46072. }, scene?: Nullable<Scene>): Mesh;
  46073. }
  46074. }
  46075. declare module BABYLON {
  46076. /**
  46077. * Class containing static functions to help procedurally build meshes
  46078. */
  46079. export class TorusKnotBuilder {
  46080. /**
  46081. * Creates a torus knot mesh
  46082. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  46083. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  46084. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  46085. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  46086. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46087. * * 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
  46088. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46089. * @param name defines the name of the mesh
  46090. * @param options defines the options used to create the mesh
  46091. * @param scene defines the hosting scene
  46092. * @returns the torus knot mesh
  46093. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  46094. */
  46095. static CreateTorusKnot(name: string, options: {
  46096. radius?: number;
  46097. tube?: number;
  46098. radialSegments?: number;
  46099. tubularSegments?: number;
  46100. p?: number;
  46101. q?: number;
  46102. updatable?: boolean;
  46103. sideOrientation?: number;
  46104. frontUVs?: Vector4;
  46105. backUVs?: Vector4;
  46106. }, scene: any): Mesh;
  46107. }
  46108. }
  46109. declare module BABYLON {
  46110. /**
  46111. * Polygon
  46112. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  46113. */
  46114. export class Polygon {
  46115. /**
  46116. * Creates a rectangle
  46117. * @param xmin bottom X coord
  46118. * @param ymin bottom Y coord
  46119. * @param xmax top X coord
  46120. * @param ymax top Y coord
  46121. * @returns points that make the resulting rectation
  46122. */
  46123. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  46124. /**
  46125. * Creates a circle
  46126. * @param radius radius of circle
  46127. * @param cx scale in x
  46128. * @param cy scale in y
  46129. * @param numberOfSides number of sides that make up the circle
  46130. * @returns points that make the resulting circle
  46131. */
  46132. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  46133. /**
  46134. * Creates a polygon from input string
  46135. * @param input Input polygon data
  46136. * @returns the parsed points
  46137. */
  46138. static Parse(input: string): Vector2[];
  46139. /**
  46140. * Starts building a polygon from x and y coordinates
  46141. * @param x x coordinate
  46142. * @param y y coordinate
  46143. * @returns the started path2
  46144. */
  46145. static StartingAt(x: number, y: number): Path2;
  46146. }
  46147. /**
  46148. * Builds a polygon
  46149. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  46150. */
  46151. export class PolygonMeshBuilder {
  46152. private _points;
  46153. private _outlinepoints;
  46154. private _holes;
  46155. private _name;
  46156. private _scene;
  46157. private _epoints;
  46158. private _eholes;
  46159. private _addToepoint;
  46160. /**
  46161. * Babylon reference to the earcut plugin.
  46162. */
  46163. bjsEarcut: any;
  46164. /**
  46165. * Creates a PolygonMeshBuilder
  46166. * @param name name of the builder
  46167. * @param contours Path of the polygon
  46168. * @param scene scene to add to
  46169. * @param earcutInjection can be used to inject your own earcut reference
  46170. */
  46171. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  46172. /**
  46173. * Adds a whole within the polygon
  46174. * @param hole Array of points defining the hole
  46175. * @returns this
  46176. */
  46177. addHole(hole: Vector2[]): PolygonMeshBuilder;
  46178. /**
  46179. * Creates the polygon
  46180. * @param updatable If the mesh should be updatable
  46181. * @param depth The depth of the mesh created
  46182. * @returns the created mesh
  46183. */
  46184. build(updatable?: boolean, depth?: number): Mesh;
  46185. /**
  46186. * Adds a side to the polygon
  46187. * @param positions points that make the polygon
  46188. * @param normals normals of the polygon
  46189. * @param uvs uvs of the polygon
  46190. * @param indices indices of the polygon
  46191. * @param bounds bounds of the polygon
  46192. * @param points points of the polygon
  46193. * @param depth depth of the polygon
  46194. * @param flip flip of the polygon
  46195. */
  46196. private addSide;
  46197. }
  46198. }
  46199. declare module BABYLON {
  46200. /**
  46201. * Class containing static functions to help procedurally build meshes
  46202. */
  46203. export class PolygonBuilder {
  46204. /**
  46205. * Creates a polygon mesh
  46206. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  46207. * * 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
  46208. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  46209. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46210. * * 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)
  46211. * * Remember you can only change the shape positions, not their number when updating a polygon
  46212. * @param name defines the name of the mesh
  46213. * @param options defines the options used to create the mesh
  46214. * @param scene defines the hosting scene
  46215. * @param earcutInjection can be used to inject your own earcut reference
  46216. * @returns the polygon mesh
  46217. */
  46218. static CreatePolygon(name: string, options: {
  46219. shape: Vector3[];
  46220. holes?: Vector3[][];
  46221. depth?: number;
  46222. faceUV?: Vector4[];
  46223. faceColors?: Color4[];
  46224. updatable?: boolean;
  46225. sideOrientation?: number;
  46226. frontUVs?: Vector4;
  46227. backUVs?: Vector4;
  46228. }, scene: Scene, earcutInjection?: any): Mesh;
  46229. /**
  46230. * Creates an extruded polygon mesh, with depth in the Y direction.
  46231. * * 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)
  46232. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46233. * @param name defines the name of the mesh
  46234. * @param options defines the options used to create the mesh
  46235. * @param scene defines the hosting scene
  46236. * @param earcutInjection can be used to inject your own earcut reference
  46237. * @returns the polygon mesh
  46238. */
  46239. static ExtrudePolygon(name: string, options: {
  46240. shape: Vector3[];
  46241. holes?: Vector3[][];
  46242. depth?: number;
  46243. faceUV?: Vector4[];
  46244. faceColors?: Color4[];
  46245. updatable?: boolean;
  46246. sideOrientation?: number;
  46247. frontUVs?: Vector4;
  46248. backUVs?: Vector4;
  46249. }, scene: Scene, earcutInjection?: any): Mesh;
  46250. }
  46251. }
  46252. declare module BABYLON {
  46253. /**
  46254. * Class containing static functions to help procedurally build meshes
  46255. */
  46256. export class ShapeBuilder {
  46257. /**
  46258. * 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.
  46259. * * 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.
  46260. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  46261. * * 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.
  46262. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  46263. * * 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
  46264. * * 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
  46265. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  46266. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46267. * * 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
  46268. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  46269. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46270. * @param name defines the name of the mesh
  46271. * @param options defines the options used to create the mesh
  46272. * @param scene defines the hosting scene
  46273. * @returns the extruded shape mesh
  46274. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  46275. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  46276. */
  46277. static ExtrudeShape(name: string, options: {
  46278. shape: Vector3[];
  46279. path: Vector3[];
  46280. scale?: number;
  46281. rotation?: number;
  46282. cap?: number;
  46283. updatable?: boolean;
  46284. sideOrientation?: number;
  46285. frontUVs?: Vector4;
  46286. backUVs?: Vector4;
  46287. instance?: Mesh;
  46288. invertUV?: boolean;
  46289. }, scene?: Nullable<Scene>): Mesh;
  46290. /**
  46291. * Creates an custom extruded shape mesh.
  46292. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  46293. * * 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.
  46294. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  46295. * * 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
  46296. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  46297. * * 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
  46298. * * It must returns a float value that will be the scale value applied to the shape on each path point
  46299. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  46300. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  46301. * * 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
  46302. * * 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
  46303. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  46304. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46305. * * 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
  46306. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  46307. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46308. * @param name defines the name of the mesh
  46309. * @param options defines the options used to create the mesh
  46310. * @param scene defines the hosting scene
  46311. * @returns the custom extruded shape mesh
  46312. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  46313. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  46314. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  46315. */
  46316. static ExtrudeShapeCustom(name: string, options: {
  46317. shape: Vector3[];
  46318. path: Vector3[];
  46319. scaleFunction?: any;
  46320. rotationFunction?: any;
  46321. ribbonCloseArray?: boolean;
  46322. ribbonClosePath?: boolean;
  46323. cap?: number;
  46324. updatable?: boolean;
  46325. sideOrientation?: number;
  46326. frontUVs?: Vector4;
  46327. backUVs?: Vector4;
  46328. instance?: Mesh;
  46329. invertUV?: boolean;
  46330. }, scene: Scene): Mesh;
  46331. private static _ExtrudeShapeGeneric;
  46332. }
  46333. }
  46334. declare module BABYLON {
  46335. /**
  46336. * Class containing static functions to help procedurally build meshes
  46337. */
  46338. export class LatheBuilder {
  46339. /**
  46340. * Creates lathe mesh.
  46341. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  46342. * * 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
  46343. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  46344. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  46345. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  46346. * * 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
  46347. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  46348. * * 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
  46349. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46350. * * 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
  46351. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  46352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46353. * @param name defines the name of the mesh
  46354. * @param options defines the options used to create the mesh
  46355. * @param scene defines the hosting scene
  46356. * @returns the lathe mesh
  46357. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  46358. */
  46359. static CreateLathe(name: string, options: {
  46360. shape: Vector3[];
  46361. radius?: number;
  46362. tessellation?: number;
  46363. clip?: number;
  46364. arc?: number;
  46365. closed?: boolean;
  46366. updatable?: boolean;
  46367. sideOrientation?: number;
  46368. frontUVs?: Vector4;
  46369. backUVs?: Vector4;
  46370. cap?: number;
  46371. invertUV?: boolean;
  46372. }, scene: Scene): Mesh;
  46373. }
  46374. }
  46375. declare module BABYLON {
  46376. /**
  46377. * Class containing static functions to help procedurally build meshes
  46378. */
  46379. export class TubeBuilder {
  46380. /**
  46381. * Creates a tube mesh.
  46382. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  46383. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  46384. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  46385. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  46386. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  46387. * * 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)
  46388. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  46389. * * 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
  46390. * * 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
  46391. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46392. * * 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
  46393. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  46394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46395. * @param name defines the name of the mesh
  46396. * @param options defines the options used to create the mesh
  46397. * @param scene defines the hosting scene
  46398. * @returns the tube mesh
  46399. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  46400. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  46401. */
  46402. static CreateTube(name: string, options: {
  46403. path: Vector3[];
  46404. radius?: number;
  46405. tessellation?: number;
  46406. radiusFunction?: {
  46407. (i: number, distance: number): number;
  46408. };
  46409. cap?: number;
  46410. arc?: number;
  46411. updatable?: boolean;
  46412. sideOrientation?: number;
  46413. frontUVs?: Vector4;
  46414. backUVs?: Vector4;
  46415. instance?: Mesh;
  46416. invertUV?: boolean;
  46417. }, scene: Scene): Mesh;
  46418. }
  46419. }
  46420. declare module BABYLON {
  46421. /**
  46422. * Class containing static functions to help procedurally build meshes
  46423. */
  46424. export class IcoSphereBuilder {
  46425. /**
  46426. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  46427. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  46428. * * 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`)
  46429. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  46430. * * 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
  46431. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46432. * * 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
  46433. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46434. * @param name defines the name of the mesh
  46435. * @param options defines the options used to create the mesh
  46436. * @param scene defines the hosting scene
  46437. * @returns the icosahedron mesh
  46438. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  46439. */
  46440. static CreateIcoSphere(name: string, options: {
  46441. radius?: number;
  46442. radiusX?: number;
  46443. radiusY?: number;
  46444. radiusZ?: number;
  46445. flat?: boolean;
  46446. subdivisions?: number;
  46447. sideOrientation?: number;
  46448. frontUVs?: Vector4;
  46449. backUVs?: Vector4;
  46450. updatable?: boolean;
  46451. }, scene: Scene): Mesh;
  46452. }
  46453. }
  46454. declare module BABYLON {
  46455. /**
  46456. * Class containing static functions to help procedurally build meshes
  46457. */
  46458. export class DecalBuilder {
  46459. /**
  46460. * Creates a decal mesh.
  46461. * 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
  46462. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  46463. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  46464. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  46465. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  46466. * @param name defines the name of the mesh
  46467. * @param sourceMesh defines the mesh where the decal must be applied
  46468. * @param options defines the options used to create the mesh
  46469. * @param scene defines the hosting scene
  46470. * @returns the decal mesh
  46471. * @see https://doc.babylonjs.com/how_to/decals
  46472. */
  46473. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  46474. position?: Vector3;
  46475. normal?: Vector3;
  46476. size?: Vector3;
  46477. angle?: number;
  46478. }): Mesh;
  46479. }
  46480. }
  46481. declare module BABYLON {
  46482. /**
  46483. * Class containing static functions to help procedurally build meshes
  46484. */
  46485. export class MeshBuilder {
  46486. /**
  46487. * Creates a box mesh
  46488. * * The parameter `size` sets the size (float) of each box side (default 1)
  46489. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46490. * * 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)
  46491. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46492. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46493. * * 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
  46494. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46495. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46496. * @param name defines the name of the mesh
  46497. * @param options defines the options used to create the mesh
  46498. * @param scene defines the hosting scene
  46499. * @returns the box mesh
  46500. */
  46501. static CreateBox(name: string, options: {
  46502. size?: number;
  46503. width?: number;
  46504. height?: number;
  46505. depth?: number;
  46506. faceUV?: Vector4[];
  46507. faceColors?: Color4[];
  46508. sideOrientation?: number;
  46509. frontUVs?: Vector4;
  46510. backUVs?: Vector4;
  46511. updatable?: boolean;
  46512. }, scene?: Nullable<Scene>): Mesh;
  46513. /**
  46514. * Creates a sphere mesh
  46515. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  46516. * * 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`)
  46517. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  46518. * * 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
  46519. * * 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)
  46520. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46521. * * 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
  46522. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46523. * @param name defines the name of the mesh
  46524. * @param options defines the options used to create the mesh
  46525. * @param scene defines the hosting scene
  46526. * @returns the sphere mesh
  46527. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  46528. */
  46529. static CreateSphere(name: string, options: {
  46530. segments?: number;
  46531. diameter?: number;
  46532. diameterX?: number;
  46533. diameterY?: number;
  46534. diameterZ?: number;
  46535. arc?: number;
  46536. slice?: number;
  46537. sideOrientation?: number;
  46538. frontUVs?: Vector4;
  46539. backUVs?: Vector4;
  46540. updatable?: boolean;
  46541. }, scene: any): Mesh;
  46542. /**
  46543. * Creates a plane polygonal mesh. By default, this is a disc
  46544. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  46545. * * 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
  46546. * * 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
  46547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46548. * * 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
  46549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46550. * @param name defines the name of the mesh
  46551. * @param options defines the options used to create the mesh
  46552. * @param scene defines the hosting scene
  46553. * @returns the plane polygonal mesh
  46554. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  46555. */
  46556. static CreateDisc(name: string, options: {
  46557. radius?: number;
  46558. tessellation?: number;
  46559. arc?: number;
  46560. updatable?: boolean;
  46561. sideOrientation?: number;
  46562. frontUVs?: Vector4;
  46563. backUVs?: Vector4;
  46564. }, scene?: Nullable<Scene>): Mesh;
  46565. /**
  46566. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  46567. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  46568. * * 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`)
  46569. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  46570. * * 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
  46571. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46572. * * 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
  46573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46574. * @param name defines the name of the mesh
  46575. * @param options defines the options used to create the mesh
  46576. * @param scene defines the hosting scene
  46577. * @returns the icosahedron mesh
  46578. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  46579. */
  46580. static CreateIcoSphere(name: string, options: {
  46581. radius?: number;
  46582. radiusX?: number;
  46583. radiusY?: number;
  46584. radiusZ?: number;
  46585. flat?: boolean;
  46586. subdivisions?: number;
  46587. sideOrientation?: number;
  46588. frontUVs?: Vector4;
  46589. backUVs?: Vector4;
  46590. updatable?: boolean;
  46591. }, scene: Scene): Mesh;
  46592. /**
  46593. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  46594. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  46595. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  46596. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  46597. * * 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
  46598. * * 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
  46599. * * 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
  46600. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46601. * * 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
  46602. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  46603. * * 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
  46604. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  46605. * * 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
  46606. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  46607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46608. * @param name defines the name of the mesh
  46609. * @param options defines the options used to create the mesh
  46610. * @param scene defines the hosting scene
  46611. * @returns the ribbon mesh
  46612. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  46613. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  46614. */
  46615. static CreateRibbon(name: string, options: {
  46616. pathArray: Vector3[][];
  46617. closeArray?: boolean;
  46618. closePath?: boolean;
  46619. offset?: number;
  46620. updatable?: boolean;
  46621. sideOrientation?: number;
  46622. frontUVs?: Vector4;
  46623. backUVs?: Vector4;
  46624. instance?: Mesh;
  46625. invertUV?: boolean;
  46626. uvs?: Vector2[];
  46627. colors?: Color4[];
  46628. }, scene?: Nullable<Scene>): Mesh;
  46629. /**
  46630. * Creates a cylinder or a cone mesh
  46631. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  46632. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  46633. * * 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.
  46634. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  46635. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  46636. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  46637. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  46638. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  46639. * * 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).
  46640. * * 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
  46641. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  46642. * * 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
  46643. * * 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.
  46644. * * If `enclose` is false, a ring surface is one element.
  46645. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  46646. * * 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
  46647. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46648. * * 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
  46649. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46650. * @param name defines the name of the mesh
  46651. * @param options defines the options used to create the mesh
  46652. * @param scene defines the hosting scene
  46653. * @returns the cylinder mesh
  46654. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  46655. */
  46656. static CreateCylinder(name: string, options: {
  46657. height?: number;
  46658. diameterTop?: number;
  46659. diameterBottom?: number;
  46660. diameter?: number;
  46661. tessellation?: number;
  46662. subdivisions?: number;
  46663. arc?: number;
  46664. faceColors?: Color4[];
  46665. faceUV?: Vector4[];
  46666. updatable?: boolean;
  46667. hasRings?: boolean;
  46668. enclose?: boolean;
  46669. sideOrientation?: number;
  46670. frontUVs?: Vector4;
  46671. backUVs?: Vector4;
  46672. }, scene: any): Mesh;
  46673. /**
  46674. * Creates a torus mesh
  46675. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  46676. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  46677. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  46678. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46679. * * 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
  46680. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46681. * @param name defines the name of the mesh
  46682. * @param options defines the options used to create the mesh
  46683. * @param scene defines the hosting scene
  46684. * @returns the torus mesh
  46685. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  46686. */
  46687. static CreateTorus(name: string, options: {
  46688. diameter?: number;
  46689. thickness?: number;
  46690. tessellation?: number;
  46691. updatable?: boolean;
  46692. sideOrientation?: number;
  46693. frontUVs?: Vector4;
  46694. backUVs?: Vector4;
  46695. }, scene: any): Mesh;
  46696. /**
  46697. * Creates a torus knot mesh
  46698. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  46699. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  46700. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  46701. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  46702. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46703. * * 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
  46704. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46705. * @param name defines the name of the mesh
  46706. * @param options defines the options used to create the mesh
  46707. * @param scene defines the hosting scene
  46708. * @returns the torus knot mesh
  46709. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  46710. */
  46711. static CreateTorusKnot(name: string, options: {
  46712. radius?: number;
  46713. tube?: number;
  46714. radialSegments?: number;
  46715. tubularSegments?: number;
  46716. p?: number;
  46717. q?: number;
  46718. updatable?: boolean;
  46719. sideOrientation?: number;
  46720. frontUVs?: Vector4;
  46721. backUVs?: Vector4;
  46722. }, scene: any): Mesh;
  46723. /**
  46724. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46725. * * 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
  46726. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46727. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46728. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46729. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46730. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46731. * * 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
  46732. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46734. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46735. * @param name defines the name of the new line system
  46736. * @param options defines the options used to create the line system
  46737. * @param scene defines the hosting scene
  46738. * @returns a new line system mesh
  46739. */
  46740. static CreateLineSystem(name: string, options: {
  46741. lines: Vector3[][];
  46742. updatable?: boolean;
  46743. instance?: Nullable<LinesMesh>;
  46744. colors?: Nullable<Color4[][]>;
  46745. useVertexAlpha?: boolean;
  46746. }, scene: Nullable<Scene>): LinesMesh;
  46747. /**
  46748. * Creates a line mesh
  46749. * 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
  46750. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46751. * * The parameter `points` is an array successive Vector3
  46752. * * 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
  46753. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46754. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46755. * * When updating an instance, remember that only point positions can change, not the number of points
  46756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46757. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46758. * @param name defines the name of the new line system
  46759. * @param options defines the options used to create the line system
  46760. * @param scene defines the hosting scene
  46761. * @returns a new line mesh
  46762. */
  46763. static CreateLines(name: string, options: {
  46764. points: Vector3[];
  46765. updatable?: boolean;
  46766. instance?: Nullable<LinesMesh>;
  46767. colors?: Color4[];
  46768. useVertexAlpha?: boolean;
  46769. }, scene?: Nullable<Scene>): LinesMesh;
  46770. /**
  46771. * Creates a dashed line mesh
  46772. * * 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
  46773. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46774. * * The parameter `points` is an array successive Vector3
  46775. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46776. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46777. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46778. * * 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
  46779. * * When updating an instance, remember that only point positions can change, not the number of points
  46780. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46781. * @param name defines the name of the mesh
  46782. * @param options defines the options used to create the mesh
  46783. * @param scene defines the hosting scene
  46784. * @returns the dashed line mesh
  46785. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46786. */
  46787. static CreateDashedLines(name: string, options: {
  46788. points: Vector3[];
  46789. dashSize?: number;
  46790. gapSize?: number;
  46791. dashNb?: number;
  46792. updatable?: boolean;
  46793. instance?: LinesMesh;
  46794. }, scene?: Nullable<Scene>): LinesMesh;
  46795. /**
  46796. * 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.
  46797. * * 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.
  46798. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  46799. * * 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.
  46800. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  46801. * * 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
  46802. * * 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
  46803. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  46804. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46805. * * 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
  46806. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  46807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46808. * @param name defines the name of the mesh
  46809. * @param options defines the options used to create the mesh
  46810. * @param scene defines the hosting scene
  46811. * @returns the extruded shape mesh
  46812. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  46813. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  46814. */
  46815. static ExtrudeShape(name: string, options: {
  46816. shape: Vector3[];
  46817. path: Vector3[];
  46818. scale?: number;
  46819. rotation?: number;
  46820. cap?: number;
  46821. updatable?: boolean;
  46822. sideOrientation?: number;
  46823. frontUVs?: Vector4;
  46824. backUVs?: Vector4;
  46825. instance?: Mesh;
  46826. invertUV?: boolean;
  46827. }, scene?: Nullable<Scene>): Mesh;
  46828. /**
  46829. * Creates an custom extruded shape mesh.
  46830. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  46831. * * 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.
  46832. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  46833. * * 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
  46834. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  46835. * * 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
  46836. * * It must returns a float value that will be the scale value applied to the shape on each path point
  46837. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  46838. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  46839. * * 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
  46840. * * 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
  46841. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  46842. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46843. * * 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
  46844. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  46845. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46846. * @param name defines the name of the mesh
  46847. * @param options defines the options used to create the mesh
  46848. * @param scene defines the hosting scene
  46849. * @returns the custom extruded shape mesh
  46850. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  46851. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  46852. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  46853. */
  46854. static ExtrudeShapeCustom(name: string, options: {
  46855. shape: Vector3[];
  46856. path: Vector3[];
  46857. scaleFunction?: any;
  46858. rotationFunction?: any;
  46859. ribbonCloseArray?: boolean;
  46860. ribbonClosePath?: boolean;
  46861. cap?: number;
  46862. updatable?: boolean;
  46863. sideOrientation?: number;
  46864. frontUVs?: Vector4;
  46865. backUVs?: Vector4;
  46866. instance?: Mesh;
  46867. invertUV?: boolean;
  46868. }, scene: Scene): Mesh;
  46869. /**
  46870. * Creates lathe mesh.
  46871. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  46872. * * 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
  46873. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  46874. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  46875. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  46876. * * 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
  46877. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  46878. * * 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
  46879. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46880. * * 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
  46881. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  46882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46883. * @param name defines the name of the mesh
  46884. * @param options defines the options used to create the mesh
  46885. * @param scene defines the hosting scene
  46886. * @returns the lathe mesh
  46887. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  46888. */
  46889. static CreateLathe(name: string, options: {
  46890. shape: Vector3[];
  46891. radius?: number;
  46892. tessellation?: number;
  46893. clip?: number;
  46894. arc?: number;
  46895. closed?: boolean;
  46896. updatable?: boolean;
  46897. sideOrientation?: number;
  46898. frontUVs?: Vector4;
  46899. backUVs?: Vector4;
  46900. cap?: number;
  46901. invertUV?: boolean;
  46902. }, scene: Scene): Mesh;
  46903. /**
  46904. * Creates a plane mesh
  46905. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  46906. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  46907. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  46908. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46909. * * 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
  46910. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46911. * @param name defines the name of the mesh
  46912. * @param options defines the options used to create the mesh
  46913. * @param scene defines the hosting scene
  46914. * @returns the plane mesh
  46915. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  46916. */
  46917. static CreatePlane(name: string, options: {
  46918. size?: number;
  46919. width?: number;
  46920. height?: number;
  46921. sideOrientation?: number;
  46922. frontUVs?: Vector4;
  46923. backUVs?: Vector4;
  46924. updatable?: boolean;
  46925. sourcePlane?: Plane;
  46926. }, scene: Scene): Mesh;
  46927. /**
  46928. * Creates a ground mesh
  46929. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  46930. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  46931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46932. * @param name defines the name of the mesh
  46933. * @param options defines the options used to create the mesh
  46934. * @param scene defines the hosting scene
  46935. * @returns the ground mesh
  46936. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  46937. */
  46938. static CreateGround(name: string, options: {
  46939. width?: number;
  46940. height?: number;
  46941. subdivisions?: number;
  46942. subdivisionsX?: number;
  46943. subdivisionsY?: number;
  46944. updatable?: boolean;
  46945. }, scene: any): Mesh;
  46946. /**
  46947. * Creates a tiled ground mesh
  46948. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  46949. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  46950. * * 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
  46951. * * 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
  46952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46953. * @param name defines the name of the mesh
  46954. * @param options defines the options used to create the mesh
  46955. * @param scene defines the hosting scene
  46956. * @returns the tiled ground mesh
  46957. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  46958. */
  46959. static CreateTiledGround(name: string, options: {
  46960. xmin: number;
  46961. zmin: number;
  46962. xmax: number;
  46963. zmax: number;
  46964. subdivisions?: {
  46965. w: number;
  46966. h: number;
  46967. };
  46968. precision?: {
  46969. w: number;
  46970. h: number;
  46971. };
  46972. updatable?: boolean;
  46973. }, scene: Scene): Mesh;
  46974. /**
  46975. * Creates a ground mesh from a height map
  46976. * * The parameter `url` sets the URL of the height map image resource.
  46977. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  46978. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  46979. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  46980. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  46981. * * 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.
  46982. * * 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).
  46983. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  46984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46985. * @param name defines the name of the mesh
  46986. * @param url defines the url to the height map
  46987. * @param options defines the options used to create the mesh
  46988. * @param scene defines the hosting scene
  46989. * @returns the ground mesh
  46990. * @see https://doc.babylonjs.com/babylon101/height_map
  46991. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  46992. */
  46993. static CreateGroundFromHeightMap(name: string, url: string, options: {
  46994. width?: number;
  46995. height?: number;
  46996. subdivisions?: number;
  46997. minHeight?: number;
  46998. maxHeight?: number;
  46999. colorFilter?: Color3;
  47000. alphaFilter?: number;
  47001. updatable?: boolean;
  47002. onReady?: (mesh: GroundMesh) => void;
  47003. }, scene: Scene): GroundMesh;
  47004. /**
  47005. * Creates a polygon mesh
  47006. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  47007. * * 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
  47008. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  47009. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47010. * * 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)
  47011. * * Remember you can only change the shape positions, not their number when updating a polygon
  47012. * @param name defines the name of the mesh
  47013. * @param options defines the options used to create the mesh
  47014. * @param scene defines the hosting scene
  47015. * @param earcutInjection can be used to inject your own earcut reference
  47016. * @returns the polygon mesh
  47017. */
  47018. static CreatePolygon(name: string, options: {
  47019. shape: Vector3[];
  47020. holes?: Vector3[][];
  47021. depth?: number;
  47022. faceUV?: Vector4[];
  47023. faceColors?: Color4[];
  47024. updatable?: boolean;
  47025. sideOrientation?: number;
  47026. frontUVs?: Vector4;
  47027. backUVs?: Vector4;
  47028. }, scene: Scene, earcutInjection?: any): Mesh;
  47029. /**
  47030. * Creates an extruded polygon mesh, with depth in the Y direction.
  47031. * * 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)
  47032. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47033. * @param name defines the name of the mesh
  47034. * @param options defines the options used to create the mesh
  47035. * @param scene defines the hosting scene
  47036. * @param earcutInjection can be used to inject your own earcut reference
  47037. * @returns the polygon mesh
  47038. */
  47039. static ExtrudePolygon(name: string, options: {
  47040. shape: Vector3[];
  47041. holes?: Vector3[][];
  47042. depth?: number;
  47043. faceUV?: Vector4[];
  47044. faceColors?: Color4[];
  47045. updatable?: boolean;
  47046. sideOrientation?: number;
  47047. frontUVs?: Vector4;
  47048. backUVs?: Vector4;
  47049. }, scene: Scene, earcutInjection?: any): Mesh;
  47050. /**
  47051. * Creates a tube mesh.
  47052. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  47053. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  47054. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  47055. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  47056. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  47057. * * 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)
  47058. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  47059. * * 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
  47060. * * 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
  47061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47062. * * 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
  47063. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47065. * @param name defines the name of the mesh
  47066. * @param options defines the options used to create the mesh
  47067. * @param scene defines the hosting scene
  47068. * @returns the tube mesh
  47069. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47070. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  47071. */
  47072. static CreateTube(name: string, options: {
  47073. path: Vector3[];
  47074. radius?: number;
  47075. tessellation?: number;
  47076. radiusFunction?: {
  47077. (i: number, distance: number): number;
  47078. };
  47079. cap?: number;
  47080. arc?: number;
  47081. updatable?: boolean;
  47082. sideOrientation?: number;
  47083. frontUVs?: Vector4;
  47084. backUVs?: Vector4;
  47085. instance?: Mesh;
  47086. invertUV?: boolean;
  47087. }, scene: Scene): Mesh;
  47088. /**
  47089. * Creates a polyhedron mesh
  47090. * * 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
  47091. * * The parameter `size` (positive float, default 1) sets the polygon size
  47092. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  47093. * * 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`
  47094. * * 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
  47095. * * 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)`)
  47096. * * 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
  47097. * * 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
  47098. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47099. * * 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
  47100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47101. * @param name defines the name of the mesh
  47102. * @param options defines the options used to create the mesh
  47103. * @param scene defines the hosting scene
  47104. * @returns the polyhedron mesh
  47105. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  47106. */
  47107. static CreatePolyhedron(name: string, options: {
  47108. type?: number;
  47109. size?: number;
  47110. sizeX?: number;
  47111. sizeY?: number;
  47112. sizeZ?: number;
  47113. custom?: any;
  47114. faceUV?: Vector4[];
  47115. faceColors?: Color4[];
  47116. flat?: boolean;
  47117. updatable?: boolean;
  47118. sideOrientation?: number;
  47119. frontUVs?: Vector4;
  47120. backUVs?: Vector4;
  47121. }, scene: Scene): Mesh;
  47122. /**
  47123. * Creates a decal mesh.
  47124. * 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
  47125. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  47126. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  47127. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  47128. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  47129. * @param name defines the name of the mesh
  47130. * @param sourceMesh defines the mesh where the decal must be applied
  47131. * @param options defines the options used to create the mesh
  47132. * @param scene defines the hosting scene
  47133. * @returns the decal mesh
  47134. * @see https://doc.babylonjs.com/how_to/decals
  47135. */
  47136. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  47137. position?: Vector3;
  47138. normal?: Vector3;
  47139. size?: Vector3;
  47140. angle?: number;
  47141. }): Mesh;
  47142. }
  47143. }
  47144. declare module BABYLON {
  47145. /**
  47146. * A simplifier interface for future simplification implementations
  47147. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47148. */
  47149. export interface ISimplifier {
  47150. /**
  47151. * Simplification of a given mesh according to the given settings.
  47152. * Since this requires computation, it is assumed that the function runs async.
  47153. * @param settings The settings of the simplification, including quality and distance
  47154. * @param successCallback A callback that will be called after the mesh was simplified.
  47155. * @param errorCallback in case of an error, this callback will be called. optional.
  47156. */
  47157. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  47158. }
  47159. /**
  47160. * Expected simplification settings.
  47161. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  47162. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47163. */
  47164. export interface ISimplificationSettings {
  47165. /**
  47166. * Gets or sets the expected quality
  47167. */
  47168. quality: number;
  47169. /**
  47170. * Gets or sets the distance when this optimized version should be used
  47171. */
  47172. distance: number;
  47173. /**
  47174. * Gets an already optimized mesh
  47175. */
  47176. optimizeMesh?: boolean;
  47177. }
  47178. /**
  47179. * Class used to specify simplification options
  47180. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47181. */
  47182. export class SimplificationSettings implements ISimplificationSettings {
  47183. /** expected quality */
  47184. quality: number;
  47185. /** distance when this optimized version should be used */
  47186. distance: number;
  47187. /** already optimized mesh */
  47188. optimizeMesh?: boolean | undefined;
  47189. /**
  47190. * Creates a SimplificationSettings
  47191. * @param quality expected quality
  47192. * @param distance distance when this optimized version should be used
  47193. * @param optimizeMesh already optimized mesh
  47194. */
  47195. constructor(
  47196. /** expected quality */
  47197. quality: number,
  47198. /** distance when this optimized version should be used */
  47199. distance: number,
  47200. /** already optimized mesh */
  47201. optimizeMesh?: boolean | undefined);
  47202. }
  47203. /**
  47204. * Interface used to define a simplification task
  47205. */
  47206. export interface ISimplificationTask {
  47207. /**
  47208. * Array of settings
  47209. */
  47210. settings: Array<ISimplificationSettings>;
  47211. /**
  47212. * Simplification type
  47213. */
  47214. simplificationType: SimplificationType;
  47215. /**
  47216. * Mesh to simplify
  47217. */
  47218. mesh: Mesh;
  47219. /**
  47220. * Callback called on success
  47221. */
  47222. successCallback?: () => void;
  47223. /**
  47224. * Defines if parallel processing can be used
  47225. */
  47226. parallelProcessing: boolean;
  47227. }
  47228. /**
  47229. * Queue used to order the simplification tasks
  47230. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47231. */
  47232. export class SimplificationQueue {
  47233. private _simplificationArray;
  47234. /**
  47235. * Gets a boolean indicating that the process is still running
  47236. */
  47237. running: boolean;
  47238. /**
  47239. * Creates a new queue
  47240. */
  47241. constructor();
  47242. /**
  47243. * Adds a new simplification task
  47244. * @param task defines a task to add
  47245. */
  47246. addTask(task: ISimplificationTask): void;
  47247. /**
  47248. * Execute next task
  47249. */
  47250. executeNext(): void;
  47251. /**
  47252. * Execute a simplification task
  47253. * @param task defines the task to run
  47254. */
  47255. runSimplification(task: ISimplificationTask): void;
  47256. private getSimplifier;
  47257. }
  47258. /**
  47259. * The implemented types of simplification
  47260. * At the moment only Quadratic Error Decimation is implemented
  47261. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47262. */
  47263. export enum SimplificationType {
  47264. /** Quadratic error decimation */
  47265. QUADRATIC = 0
  47266. }
  47267. }
  47268. declare module BABYLON {
  47269. interface Scene {
  47270. /** @hidden (Backing field) */ simplificationQueue: SimplificationQueue;
  47271. /**
  47272. * Gets or sets the simplification queue attached to the scene
  47273. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47274. */
  47275. simplificationQueue: SimplificationQueue;
  47276. }
  47277. interface Mesh {
  47278. /**
  47279. * Simplify the mesh according to the given array of settings.
  47280. * Function will return immediately and will simplify async
  47281. * @param settings a collection of simplification settings
  47282. * @param parallelProcessing should all levels calculate parallel or one after the other
  47283. * @param simplificationType the type of simplification to run
  47284. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  47285. * @returns the current mesh
  47286. */
  47287. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  47288. }
  47289. /**
  47290. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  47291. * created in a scene
  47292. */
  47293. export class SimplicationQueueSceneComponent implements ISceneComponent {
  47294. /**
  47295. * The component name helpfull to identify the component in the list of scene components.
  47296. */
  47297. readonly name: string;
  47298. /**
  47299. * The scene the component belongs to.
  47300. */
  47301. scene: Scene;
  47302. /**
  47303. * Creates a new instance of the component for the given scene
  47304. * @param scene Defines the scene to register the component in
  47305. */
  47306. constructor(scene: Scene);
  47307. /**
  47308. * Registers the component in a given scene
  47309. */
  47310. register(): void;
  47311. /**
  47312. * Rebuilds the elements related to this component in case of
  47313. * context lost for instance.
  47314. */
  47315. rebuild(): void;
  47316. /**
  47317. * Disposes the component and the associated ressources
  47318. */
  47319. dispose(): void;
  47320. private _beforeCameraUpdate;
  47321. }
  47322. }
  47323. declare module BABYLON {
  47324. /**
  47325. * Class used to enable access to IndexedDB
  47326. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  47327. */
  47328. export class Database implements IOfflineProvider {
  47329. private _callbackManifestChecked;
  47330. private _currentSceneUrl;
  47331. private _db;
  47332. private _enableSceneOffline;
  47333. private _enableTexturesOffline;
  47334. private _manifestVersionFound;
  47335. private _mustUpdateRessources;
  47336. private _hasReachedQuota;
  47337. private _isSupported;
  47338. private _idbFactory;
  47339. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  47340. private static IsUASupportingBlobStorage;
  47341. /**
  47342. * Gets a boolean indicating if Database storate is enabled (off by default)
  47343. */
  47344. static IDBStorageEnabled: boolean;
  47345. /**
  47346. * Gets a boolean indicating if scene must be saved in the database
  47347. */
  47348. readonly enableSceneOffline: boolean;
  47349. /**
  47350. * Gets a boolean indicating if textures must be saved in the database
  47351. */
  47352. readonly enableTexturesOffline: boolean;
  47353. /**
  47354. * Creates a new Database
  47355. * @param urlToScene defines the url to load the scene
  47356. * @param callbackManifestChecked defines the callback to use when manifest is checked
  47357. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  47358. */
  47359. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  47360. private static _ParseURL;
  47361. private static _ReturnFullUrlLocation;
  47362. private _checkManifestFile;
  47363. /**
  47364. * Open the database and make it available
  47365. * @param successCallback defines the callback to call on success
  47366. * @param errorCallback defines the callback to call on error
  47367. */
  47368. open(successCallback: () => void, errorCallback: () => void): void;
  47369. /**
  47370. * Loads an image from the database
  47371. * @param url defines the url to load from
  47372. * @param image defines the target DOM image
  47373. */
  47374. loadImage(url: string, image: HTMLImageElement): void;
  47375. private _loadImageFromDBAsync;
  47376. private _saveImageIntoDBAsync;
  47377. private _checkVersionFromDB;
  47378. private _loadVersionFromDBAsync;
  47379. private _saveVersionIntoDBAsync;
  47380. /**
  47381. * Loads a file from database
  47382. * @param url defines the URL to load from
  47383. * @param sceneLoaded defines a callback to call on success
  47384. * @param progressCallBack defines a callback to call when progress changed
  47385. * @param errorCallback defines a callback to call on error
  47386. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  47387. */
  47388. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  47389. private _loadFileAsync;
  47390. private _saveFileAsync;
  47391. /**
  47392. * Validates if xhr data is correct
  47393. * @param xhr defines the request to validate
  47394. * @param dataType defines the expected data type
  47395. * @returns true if data is correct
  47396. */
  47397. private static _ValidateXHRData;
  47398. }
  47399. }
  47400. declare module BABYLON {
  47401. /** @hidden */
  47402. export var gpuUpdateParticlesPixelShader: {
  47403. name: string;
  47404. shader: string;
  47405. };
  47406. }
  47407. declare module BABYLON {
  47408. /** @hidden */
  47409. export var gpuUpdateParticlesVertexShader: {
  47410. name: string;
  47411. shader: string;
  47412. };
  47413. }
  47414. declare module BABYLON {
  47415. /** @hidden */
  47416. export var clipPlaneFragmentDeclaration2: {
  47417. name: string;
  47418. shader: string;
  47419. };
  47420. }
  47421. declare module BABYLON {
  47422. /** @hidden */
  47423. export var gpuRenderParticlesPixelShader: {
  47424. name: string;
  47425. shader: string;
  47426. };
  47427. }
  47428. declare module BABYLON {
  47429. /** @hidden */
  47430. export var clipPlaneVertexDeclaration2: {
  47431. name: string;
  47432. shader: string;
  47433. };
  47434. }
  47435. declare module BABYLON {
  47436. /** @hidden */
  47437. export var gpuRenderParticlesVertexShader: {
  47438. name: string;
  47439. shader: string;
  47440. };
  47441. }
  47442. declare module BABYLON {
  47443. /**
  47444. * This represents a GPU particle system in Babylon
  47445. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  47446. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  47447. */
  47448. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  47449. /**
  47450. * The layer mask we are rendering the particles through.
  47451. */
  47452. layerMask: number;
  47453. private _capacity;
  47454. private _activeCount;
  47455. private _currentActiveCount;
  47456. private _accumulatedCount;
  47457. private _renderEffect;
  47458. private _updateEffect;
  47459. private _buffer0;
  47460. private _buffer1;
  47461. private _spriteBuffer;
  47462. private _updateVAO;
  47463. private _renderVAO;
  47464. private _targetIndex;
  47465. private _sourceBuffer;
  47466. private _targetBuffer;
  47467. private _engine;
  47468. private _currentRenderId;
  47469. private _started;
  47470. private _stopped;
  47471. private _timeDelta;
  47472. private _randomTexture;
  47473. private _randomTexture2;
  47474. private _attributesStrideSize;
  47475. private _updateEffectOptions;
  47476. private _randomTextureSize;
  47477. private _actualFrame;
  47478. private readonly _rawTextureWidth;
  47479. /**
  47480. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  47481. */
  47482. static readonly IsSupported: boolean;
  47483. /**
  47484. * An event triggered when the system is disposed.
  47485. */
  47486. onDisposeObservable: Observable<GPUParticleSystem>;
  47487. /**
  47488. * Gets the maximum number of particles active at the same time.
  47489. * @returns The max number of active particles.
  47490. */
  47491. getCapacity(): number;
  47492. /**
  47493. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  47494. * to override the particles.
  47495. */
  47496. forceDepthWrite: boolean;
  47497. /**
  47498. * Gets or set the number of active particles
  47499. */
  47500. activeParticleCount: number;
  47501. private _preWarmDone;
  47502. /**
  47503. * Is this system ready to be used/rendered
  47504. * @return true if the system is ready
  47505. */
  47506. isReady(): boolean;
  47507. /**
  47508. * Gets if the system has been started. (Note: this will still be true after stop is called)
  47509. * @returns True if it has been started, otherwise false.
  47510. */
  47511. isStarted(): boolean;
  47512. /**
  47513. * Starts the particle system and begins to emit
  47514. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  47515. */
  47516. start(delay?: number): void;
  47517. /**
  47518. * Stops the particle system.
  47519. */
  47520. stop(): void;
  47521. /**
  47522. * Remove all active particles
  47523. */
  47524. reset(): void;
  47525. /**
  47526. * Returns the string "GPUParticleSystem"
  47527. * @returns a string containing the class name
  47528. */
  47529. getClassName(): string;
  47530. private _colorGradientsTexture;
  47531. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  47532. /**
  47533. * Adds a new color gradient
  47534. * @param gradient defines the gradient to use (between 0 and 1)
  47535. * @param color1 defines the color to affect to the specified gradient
  47536. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  47537. * @returns the current particle system
  47538. */
  47539. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  47540. /**
  47541. * Remove a specific color gradient
  47542. * @param gradient defines the gradient to remove
  47543. * @returns the current particle system
  47544. */
  47545. removeColorGradient(gradient: number): GPUParticleSystem;
  47546. private _angularSpeedGradientsTexture;
  47547. private _sizeGradientsTexture;
  47548. private _velocityGradientsTexture;
  47549. private _limitVelocityGradientsTexture;
  47550. private _dragGradientsTexture;
  47551. private _addFactorGradient;
  47552. /**
  47553. * Adds a new size gradient
  47554. * @param gradient defines the gradient to use (between 0 and 1)
  47555. * @param factor defines the size factor to affect to the specified gradient
  47556. * @returns the current particle system
  47557. */
  47558. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  47559. /**
  47560. * Remove a specific size gradient
  47561. * @param gradient defines the gradient to remove
  47562. * @returns the current particle system
  47563. */
  47564. removeSizeGradient(gradient: number): GPUParticleSystem;
  47565. /**
  47566. * Adds a new angular speed gradient
  47567. * @param gradient defines the gradient to use (between 0 and 1)
  47568. * @param factor defines the angular speed to affect to the specified gradient
  47569. * @returns the current particle system
  47570. */
  47571. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  47572. /**
  47573. * Remove a specific angular speed gradient
  47574. * @param gradient defines the gradient to remove
  47575. * @returns the current particle system
  47576. */
  47577. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  47578. /**
  47579. * Adds a new velocity gradient
  47580. * @param gradient defines the gradient to use (between 0 and 1)
  47581. * @param factor defines the velocity to affect to the specified gradient
  47582. * @returns the current particle system
  47583. */
  47584. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  47585. /**
  47586. * Remove a specific velocity gradient
  47587. * @param gradient defines the gradient to remove
  47588. * @returns the current particle system
  47589. */
  47590. removeVelocityGradient(gradient: number): GPUParticleSystem;
  47591. /**
  47592. * Adds a new limit velocity gradient
  47593. * @param gradient defines the gradient to use (between 0 and 1)
  47594. * @param factor defines the limit velocity value to affect to the specified gradient
  47595. * @returns the current particle system
  47596. */
  47597. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  47598. /**
  47599. * Remove a specific limit velocity gradient
  47600. * @param gradient defines the gradient to remove
  47601. * @returns the current particle system
  47602. */
  47603. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  47604. /**
  47605. * Adds a new drag gradient
  47606. * @param gradient defines the gradient to use (between 0 and 1)
  47607. * @param factor defines the drag value to affect to the specified gradient
  47608. * @returns the current particle system
  47609. */
  47610. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  47611. /**
  47612. * Remove a specific drag gradient
  47613. * @param gradient defines the gradient to remove
  47614. * @returns the current particle system
  47615. */
  47616. removeDragGradient(gradient: number): GPUParticleSystem;
  47617. /**
  47618. * Not supported by GPUParticleSystem
  47619. * @param gradient defines the gradient to use (between 0 and 1)
  47620. * @param factor defines the emit rate value to affect to the specified gradient
  47621. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  47622. * @returns the current particle system
  47623. */
  47624. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  47625. /**
  47626. * Not supported by GPUParticleSystem
  47627. * @param gradient defines the gradient to remove
  47628. * @returns the current particle system
  47629. */
  47630. removeEmitRateGradient(gradient: number): IParticleSystem;
  47631. /**
  47632. * Not supported by GPUParticleSystem
  47633. * @param gradient defines the gradient to use (between 0 and 1)
  47634. * @param factor defines the start size value to affect to the specified gradient
  47635. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  47636. * @returns the current particle system
  47637. */
  47638. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  47639. /**
  47640. * Not supported by GPUParticleSystem
  47641. * @param gradient defines the gradient to remove
  47642. * @returns the current particle system
  47643. */
  47644. removeStartSizeGradient(gradient: number): IParticleSystem;
  47645. /**
  47646. * Not supported by GPUParticleSystem
  47647. * @param gradient defines the gradient to use (between 0 and 1)
  47648. * @param min defines the color remap minimal range
  47649. * @param max defines the color remap maximal range
  47650. * @returns the current particle system
  47651. */
  47652. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  47653. /**
  47654. * Not supported by GPUParticleSystem
  47655. * @param gradient defines the gradient to remove
  47656. * @returns the current particle system
  47657. */
  47658. removeColorRemapGradient(): IParticleSystem;
  47659. /**
  47660. * Not supported by GPUParticleSystem
  47661. * @param gradient defines the gradient to use (between 0 and 1)
  47662. * @param min defines the alpha remap minimal range
  47663. * @param max defines the alpha remap maximal range
  47664. * @returns the current particle system
  47665. */
  47666. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  47667. /**
  47668. * Not supported by GPUParticleSystem
  47669. * @param gradient defines the gradient to remove
  47670. * @returns the current particle system
  47671. */
  47672. removeAlphaRemapGradient(): IParticleSystem;
  47673. /**
  47674. * Not supported by GPUParticleSystem
  47675. * @param gradient defines the gradient to use (between 0 and 1)
  47676. * @param color defines the color to affect to the specified gradient
  47677. * @returns the current particle system
  47678. */
  47679. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  47680. /**
  47681. * Not supported by GPUParticleSystem
  47682. * @param gradient defines the gradient to remove
  47683. * @returns the current particle system
  47684. */
  47685. removeRampGradient(): IParticleSystem;
  47686. /**
  47687. * Not supported by GPUParticleSystem
  47688. * @returns the list of ramp gradients
  47689. */
  47690. getRampGradients(): Nullable<Array<Color3Gradient>>;
  47691. /**
  47692. * Not supported by GPUParticleSystem
  47693. * Gets or sets a boolean indicating that ramp gradients must be used
  47694. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  47695. */
  47696. useRampGradients: boolean;
  47697. /**
  47698. * Not supported by GPUParticleSystem
  47699. * @param gradient defines the gradient to use (between 0 and 1)
  47700. * @param factor defines the life time factor to affect to the specified gradient
  47701. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  47702. * @returns the current particle system
  47703. */
  47704. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  47705. /**
  47706. * Not supported by GPUParticleSystem
  47707. * @param gradient defines the gradient to remove
  47708. * @returns the current particle system
  47709. */
  47710. removeLifeTimeGradient(gradient: number): IParticleSystem;
  47711. /**
  47712. * Instantiates a GPU particle system.
  47713. * 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.
  47714. * @param name The name of the particle system
  47715. * @param options The options used to create the system
  47716. * @param scene The scene the particle system belongs to
  47717. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  47718. */
  47719. constructor(name: string, options: Partial<{
  47720. capacity: number;
  47721. randomTextureSize: number;
  47722. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  47723. protected _reset(): void;
  47724. private _createUpdateVAO;
  47725. private _createRenderVAO;
  47726. private _initialize;
  47727. /** @hidden */ recreateUpdateEffect(): void;
  47728. /** @hidden */ recreateRenderEffect(): void;
  47729. /**
  47730. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  47731. * @param preWarm defines if we are in the pre-warmimg phase
  47732. */
  47733. animate(preWarm?: boolean): void;
  47734. private _createFactorGradientTexture;
  47735. private _createSizeGradientTexture;
  47736. private _createAngularSpeedGradientTexture;
  47737. private _createVelocityGradientTexture;
  47738. private _createLimitVelocityGradientTexture;
  47739. private _createDragGradientTexture;
  47740. private _createColorGradientTexture;
  47741. /**
  47742. * Renders the particle system in its current state
  47743. * @param preWarm defines if the system should only update the particles but not render them
  47744. * @returns the current number of particles
  47745. */
  47746. render(preWarm?: boolean): number;
  47747. /**
  47748. * Rebuilds the particle system
  47749. */
  47750. rebuild(): void;
  47751. private _releaseBuffers;
  47752. private _releaseVAOs;
  47753. /**
  47754. * Disposes the particle system and free the associated resources
  47755. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  47756. */
  47757. dispose(disposeTexture?: boolean): void;
  47758. /**
  47759. * Clones the particle system.
  47760. * @param name The name of the cloned object
  47761. * @param newEmitter The new emitter to use
  47762. * @returns the cloned particle system
  47763. */
  47764. clone(name: string, newEmitter: any): GPUParticleSystem;
  47765. /**
  47766. * Serializes the particle system to a JSON object.
  47767. * @returns the JSON object
  47768. */
  47769. serialize(): any;
  47770. /**
  47771. * Parses a JSON object to create a GPU particle system.
  47772. * @param parsedParticleSystem The JSON object to parse
  47773. * @param scene The scene to create the particle system in
  47774. * @param rootUrl The root url to use to load external dependencies like texture
  47775. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  47776. * @returns the parsed GPU particle system
  47777. */
  47778. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  47779. }
  47780. }
  47781. declare module BABYLON {
  47782. /**
  47783. * Represents a set of particle systems working together to create a specific effect
  47784. */
  47785. export class ParticleSystemSet implements IDisposable {
  47786. private _emitterCreationOptions;
  47787. private _emitterNode;
  47788. /**
  47789. * Gets the particle system list
  47790. */
  47791. systems: IParticleSystem[];
  47792. /**
  47793. * Gets the emitter node used with this set
  47794. */
  47795. readonly emitterNode: Nullable<TransformNode>;
  47796. /**
  47797. * Creates a new emitter mesh as a sphere
  47798. * @param options defines the options used to create the sphere
  47799. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  47800. * @param scene defines the hosting scene
  47801. */
  47802. setEmitterAsSphere(options: {
  47803. diameter: number;
  47804. segments: number;
  47805. color: Color3;
  47806. }, renderingGroupId: number, scene: Scene): void;
  47807. /**
  47808. * Starts all particle systems of the set
  47809. * @param emitter defines an optional mesh to use as emitter for the particle systems
  47810. */
  47811. start(emitter?: AbstractMesh): void;
  47812. /**
  47813. * Release all associated resources
  47814. */
  47815. dispose(): void;
  47816. /**
  47817. * Serialize the set into a JSON compatible object
  47818. * @returns a JSON compatible representation of the set
  47819. */
  47820. serialize(): any;
  47821. /**
  47822. * Parse a new ParticleSystemSet from a serialized source
  47823. * @param data defines a JSON compatible representation of the set
  47824. * @param scene defines the hosting scene
  47825. * @param gpu defines if we want GPU particles or CPU particles
  47826. * @returns a new ParticleSystemSet
  47827. */
  47828. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  47829. }
  47830. }
  47831. declare module BABYLON {
  47832. /**
  47833. * This class is made for on one-liner static method to help creating particle system set.
  47834. */
  47835. export class ParticleHelper {
  47836. /**
  47837. * Gets or sets base Assets URL
  47838. */
  47839. static BaseAssetsUrl: string;
  47840. /**
  47841. * Create a default particle system that you can tweak
  47842. * @param emitter defines the emitter to use
  47843. * @param capacity defines the system capacity (default is 500 particles)
  47844. * @param scene defines the hosting scene
  47845. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  47846. * @returns the new Particle system
  47847. */
  47848. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  47849. /**
  47850. * This is the main static method (one-liner) of this helper to create different particle systems
  47851. * @param type This string represents the type to the particle system to create
  47852. * @param scene The scene where the particle system should live
  47853. * @param gpu If the system will use gpu
  47854. * @returns the ParticleSystemSet created
  47855. */
  47856. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  47857. /**
  47858. * Static function used to export a particle system to a ParticleSystemSet variable.
  47859. * Please note that the emitter shape is not exported
  47860. * @param systems defines the particle systems to export
  47861. * @returns the created particle system set
  47862. */
  47863. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  47864. }
  47865. }
  47866. declare module BABYLON {
  47867. interface Engine {
  47868. /**
  47869. * Create an effect to use with particle systems.
  47870. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  47871. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  47872. * @param uniformsNames defines a list of attribute names
  47873. * @param samplers defines an array of string used to represent textures
  47874. * @param defines defines the string containing the defines to use to compile the shaders
  47875. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  47876. * @param onCompiled defines a function to call when the effect creation is successful
  47877. * @param onError defines a function to call when the effect creation has failed
  47878. * @returns the new Effect
  47879. */
  47880. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  47881. }
  47882. interface Mesh {
  47883. /**
  47884. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  47885. * @returns an array of IParticleSystem
  47886. */
  47887. getEmittedParticleSystems(): IParticleSystem[];
  47888. /**
  47889. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  47890. * @returns an array of IParticleSystem
  47891. */
  47892. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  47893. }
  47894. /**
  47895. * @hidden
  47896. */
  47897. export var _IDoNeedToBeInTheBuild: number;
  47898. }
  47899. declare module BABYLON {
  47900. interface Scene {
  47901. /** @hidden (Backing field) */ physicsEngine: Nullable<IPhysicsEngine>;
  47902. /**
  47903. * Gets the current physics engine
  47904. * @returns a IPhysicsEngine or null if none attached
  47905. */
  47906. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  47907. /**
  47908. * Enables physics to the current scene
  47909. * @param gravity defines the scene's gravity for the physics engine
  47910. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  47911. * @return a boolean indicating if the physics engine was initialized
  47912. */
  47913. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  47914. /**
  47915. * Disables and disposes the physics engine associated with the scene
  47916. */
  47917. disablePhysicsEngine(): void;
  47918. /**
  47919. * Gets a boolean indicating if there is an active physics engine
  47920. * @returns a boolean indicating if there is an active physics engine
  47921. */
  47922. isPhysicsEnabled(): boolean;
  47923. /**
  47924. * Deletes a physics compound impostor
  47925. * @param compound defines the compound to delete
  47926. */
  47927. deleteCompoundImpostor(compound: any): void;
  47928. /**
  47929. * An event triggered when physic simulation is about to be run
  47930. */
  47931. onBeforePhysicsObservable: Observable<Scene>;
  47932. /**
  47933. * An event triggered when physic simulation has been done
  47934. */
  47935. onAfterPhysicsObservable: Observable<Scene>;
  47936. }
  47937. interface AbstractMesh {
  47938. /** @hidden */ physicsImpostor: Nullable<PhysicsImpostor>;
  47939. /**
  47940. * Gets or sets impostor used for physic simulation
  47941. * @see http://doc.babylonjs.com/features/physics_engine
  47942. */
  47943. physicsImpostor: Nullable<PhysicsImpostor>;
  47944. /**
  47945. * Gets the current physics impostor
  47946. * @see http://doc.babylonjs.com/features/physics_engine
  47947. * @returns a physics impostor or null
  47948. */
  47949. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  47950. /** Apply a physic impulse to the mesh
  47951. * @param force defines the force to apply
  47952. * @param contactPoint defines where to apply the force
  47953. * @returns the current mesh
  47954. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47955. */
  47956. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  47957. /**
  47958. * Creates a physic joint between two meshes
  47959. * @param otherMesh defines the other mesh to use
  47960. * @param pivot1 defines the pivot to use on this mesh
  47961. * @param pivot2 defines the pivot to use on the other mesh
  47962. * @param options defines additional options (can be plugin dependent)
  47963. * @returns the current mesh
  47964. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  47965. */
  47966. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  47967. /** @hidden */ disposePhysicsObserver: Nullable<Observer<Node>>;
  47968. }
  47969. /**
  47970. * Defines the physics engine scene component responsible to manage a physics engine
  47971. */
  47972. export class PhysicsEngineSceneComponent implements ISceneComponent {
  47973. /**
  47974. * The component name helpful to identify the component in the list of scene components.
  47975. */
  47976. readonly name: string;
  47977. /**
  47978. * The scene the component belongs to.
  47979. */
  47980. scene: Scene;
  47981. /**
  47982. * Creates a new instance of the component for the given scene
  47983. * @param scene Defines the scene to register the component in
  47984. */
  47985. constructor(scene: Scene);
  47986. /**
  47987. * Registers the component in a given scene
  47988. */
  47989. register(): void;
  47990. /**
  47991. * Rebuilds the elements related to this component in case of
  47992. * context lost for instance.
  47993. */
  47994. rebuild(): void;
  47995. /**
  47996. * Disposes the component and the associated ressources
  47997. */
  47998. dispose(): void;
  47999. }
  48000. }
  48001. declare module BABYLON {
  48002. /**
  48003. * A helper for physics simulations
  48004. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48005. */
  48006. export class PhysicsHelper {
  48007. private _scene;
  48008. private _physicsEngine;
  48009. /**
  48010. * Initializes the Physics helper
  48011. * @param scene Babylon.js scene
  48012. */
  48013. constructor(scene: Scene);
  48014. /**
  48015. * Applies a radial explosion impulse
  48016. * @param origin the origin of the explosion
  48017. * @param radius the explosion radius
  48018. * @param strength the explosion strength
  48019. * @param falloff possible options: Constant & Linear. Defaults to Constant
  48020. * @returns A physics radial explosion event, or null
  48021. */
  48022. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  48023. /**
  48024. * Applies a radial explosion force
  48025. * @param origin the origin of the explosion
  48026. * @param radius the explosion radius
  48027. * @param strength the explosion strength
  48028. * @param falloff possible options: Constant & Linear. Defaults to Constant
  48029. * @returns A physics radial explosion event, or null
  48030. */
  48031. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  48032. /**
  48033. * Creates a gravitational field
  48034. * @param origin the origin of the explosion
  48035. * @param radius the explosion radius
  48036. * @param strength the explosion strength
  48037. * @param falloff possible options: Constant & Linear. Defaults to Constant
  48038. * @returns A physics gravitational field event, or null
  48039. */
  48040. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  48041. /**
  48042. * Creates a physics updraft event
  48043. * @param origin the origin of the updraft
  48044. * @param radius the radius of the updraft
  48045. * @param strength the strength of the updraft
  48046. * @param height the height of the updraft
  48047. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  48048. * @returns A physics updraft event, or null
  48049. */
  48050. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  48051. /**
  48052. * Creates a physics vortex event
  48053. * @param origin the of the vortex
  48054. * @param radius the radius of the vortex
  48055. * @param strength the strength of the vortex
  48056. * @param height the height of the vortex
  48057. * @returns a Physics vortex event, or null
  48058. * A physics vortex event or null
  48059. */
  48060. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  48061. }
  48062. /**
  48063. * Represents a physics radial explosion event
  48064. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48065. */
  48066. export class PhysicsRadialExplosionEvent {
  48067. private _scene;
  48068. private _sphere;
  48069. private _sphereOptions;
  48070. private _rays;
  48071. private _dataFetched;
  48072. /**
  48073. * Initializes a radial explosioin event
  48074. * @param scene BabylonJS scene
  48075. */
  48076. constructor(scene: Scene);
  48077. /**
  48078. * Returns the data related to the radial explosion event (sphere & rays).
  48079. * @returns The radial explosion event data
  48080. */
  48081. getData(): PhysicsRadialExplosionEventData;
  48082. /**
  48083. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  48084. * @param impostor A physics imposter
  48085. * @param origin the origin of the explosion
  48086. * @param radius the explosion radius
  48087. * @param strength the explosion strength
  48088. * @param falloff possible options: Constant & Linear
  48089. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  48090. */
  48091. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  48092. /**
  48093. * Disposes the sphere.
  48094. * @param force Specifies if the sphere should be disposed by force
  48095. */
  48096. dispose(force?: boolean): void;
  48097. /*** Helpers ***/
  48098. private _prepareSphere;
  48099. private _intersectsWithSphere;
  48100. }
  48101. /**
  48102. * Represents a gravitational field event
  48103. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48104. */
  48105. export class PhysicsGravitationalFieldEvent {
  48106. private _physicsHelper;
  48107. private _scene;
  48108. private _origin;
  48109. private _radius;
  48110. private _strength;
  48111. private _falloff;
  48112. private _tickCallback;
  48113. private _sphere;
  48114. private _dataFetched;
  48115. /**
  48116. * Initializes the physics gravitational field event
  48117. * @param physicsHelper A physics helper
  48118. * @param scene BabylonJS scene
  48119. * @param origin The origin position of the gravitational field event
  48120. * @param radius The radius of the gravitational field event
  48121. * @param strength The strength of the gravitational field event
  48122. * @param falloff The falloff for the gravitational field event
  48123. */
  48124. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  48125. /**
  48126. * Returns the data related to the gravitational field event (sphere).
  48127. * @returns A gravitational field event
  48128. */
  48129. getData(): PhysicsGravitationalFieldEventData;
  48130. /**
  48131. * Enables the gravitational field.
  48132. */
  48133. enable(): void;
  48134. /**
  48135. * Disables the gravitational field.
  48136. */
  48137. disable(): void;
  48138. /**
  48139. * Disposes the sphere.
  48140. * @param force The force to dispose from the gravitational field event
  48141. */
  48142. dispose(force?: boolean): void;
  48143. private _tick;
  48144. }
  48145. /**
  48146. * Represents a physics updraft event
  48147. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48148. */
  48149. export class PhysicsUpdraftEvent {
  48150. private _scene;
  48151. private _origin;
  48152. private _radius;
  48153. private _strength;
  48154. private _height;
  48155. private _updraftMode;
  48156. private _physicsEngine;
  48157. private _originTop;
  48158. private _originDirection;
  48159. private _tickCallback;
  48160. private _cylinder;
  48161. private _cylinderPosition;
  48162. private _dataFetched;
  48163. /**
  48164. * Initializes the physics updraft event
  48165. * @param _scene BabylonJS scene
  48166. * @param _origin The origin position of the updraft
  48167. * @param _radius The radius of the updraft
  48168. * @param _strength The strength of the updraft
  48169. * @param _height The height of the updraft
  48170. * @param _updraftMode The mode of the updraft
  48171. */
  48172. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  48173. /**
  48174. * Returns the data related to the updraft event (cylinder).
  48175. * @returns A physics updraft event
  48176. */
  48177. getData(): PhysicsUpdraftEventData;
  48178. /**
  48179. * Enables the updraft.
  48180. */
  48181. enable(): void;
  48182. /**
  48183. * Disables the cortex.
  48184. */
  48185. disable(): void;
  48186. /**
  48187. * Disposes the sphere.
  48188. * @param force Specifies if the updraft should be disposed by force
  48189. */
  48190. dispose(force?: boolean): void;
  48191. private getImpostorForceAndContactPoint;
  48192. private _tick;
  48193. /*** Helpers ***/
  48194. private _prepareCylinder;
  48195. private _intersectsWithCylinder;
  48196. }
  48197. /**
  48198. * Represents a physics vortex event
  48199. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48200. */
  48201. export class PhysicsVortexEvent {
  48202. private _scene;
  48203. private _origin;
  48204. private _radius;
  48205. private _strength;
  48206. private _height;
  48207. private _physicsEngine;
  48208. private _originTop;
  48209. private _centripetalForceThreshold;
  48210. private _updraftMultiplier;
  48211. private _tickCallback;
  48212. private _cylinder;
  48213. private _cylinderPosition;
  48214. private _dataFetched;
  48215. /**
  48216. * Initializes the physics vortex event
  48217. * @param _scene The BabylonJS scene
  48218. * @param _origin The origin position of the vortex
  48219. * @param _radius The radius of the vortex
  48220. * @param _strength The strength of the vortex
  48221. * @param _height The height of the vortex
  48222. */
  48223. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  48224. /**
  48225. * Returns the data related to the vortex event (cylinder).
  48226. * @returns The physics vortex event data
  48227. */
  48228. getData(): PhysicsVortexEventData;
  48229. /**
  48230. * Enables the vortex.
  48231. */
  48232. enable(): void;
  48233. /**
  48234. * Disables the cortex.
  48235. */
  48236. disable(): void;
  48237. /**
  48238. * Disposes the sphere.
  48239. * @param force
  48240. */
  48241. dispose(force?: boolean): void;
  48242. private getImpostorForceAndContactPoint;
  48243. private _tick;
  48244. /*** Helpers ***/
  48245. private _prepareCylinder;
  48246. private _intersectsWithCylinder;
  48247. }
  48248. /**
  48249. * The strenght of the force in correspondence to the distance of the affected object
  48250. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48251. */
  48252. export enum PhysicsRadialImpulseFalloff {
  48253. /** Defines that impulse is constant in strength across it's whole radius */
  48254. Constant = 0,
  48255. /** DEfines that impulse gets weaker if it's further from the origin */
  48256. Linear = 1
  48257. }
  48258. /**
  48259. * The strength of the force in correspondence to the distance of the affected object
  48260. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48261. */
  48262. export enum PhysicsUpdraftMode {
  48263. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  48264. Center = 0,
  48265. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  48266. Perpendicular = 1
  48267. }
  48268. /**
  48269. * Interface for a physics force and contact point
  48270. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48271. */
  48272. export interface PhysicsForceAndContactPoint {
  48273. /**
  48274. * The force applied at the contact point
  48275. */
  48276. force: Vector3;
  48277. /**
  48278. * The contact point
  48279. */
  48280. contactPoint: Vector3;
  48281. }
  48282. /**
  48283. * Interface for radial explosion event data
  48284. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48285. */
  48286. export interface PhysicsRadialExplosionEventData {
  48287. /**
  48288. * A sphere used for the radial explosion event
  48289. */
  48290. sphere: Mesh;
  48291. /**
  48292. * An array of rays for the radial explosion event
  48293. */
  48294. rays: Array<Ray>;
  48295. }
  48296. /**
  48297. * Interface for gravitational field event data
  48298. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48299. */
  48300. export interface PhysicsGravitationalFieldEventData {
  48301. /**
  48302. * A sphere mesh used for the gravitational field event
  48303. */
  48304. sphere: Mesh;
  48305. }
  48306. /**
  48307. * Interface for updraft event data
  48308. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48309. */
  48310. export interface PhysicsUpdraftEventData {
  48311. /**
  48312. * A cylinder used for the updraft event
  48313. */
  48314. cylinder: Mesh;
  48315. }
  48316. /**
  48317. * Interface for vortex event data
  48318. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48319. */
  48320. export interface PhysicsVortexEventData {
  48321. /**
  48322. * A cylinder used for the vortex event
  48323. */
  48324. cylinder: Mesh;
  48325. }
  48326. }
  48327. declare module BABYLON {
  48328. /**
  48329. * AmmoJS Physics plugin
  48330. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48331. * @see https://github.com/kripken/ammo.js/
  48332. */
  48333. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  48334. private _useDeltaForWorldStep;
  48335. /**
  48336. * Reference to the Ammo library
  48337. */
  48338. bjsAMMO: any;
  48339. /**
  48340. * Created ammoJS world which physics bodies are added to
  48341. */
  48342. world: any;
  48343. /**
  48344. * Name of the plugin
  48345. */
  48346. name: string;
  48347. private _timeStep;
  48348. private _fixedTimeStep;
  48349. private _maxSteps;
  48350. private _tmpQuaternion;
  48351. private _tmpAmmoTransform;
  48352. private _tmpAmmoQuaternion;
  48353. private _tmpAmmoConcreteContactResultCallback;
  48354. private _collisionConfiguration;
  48355. private _dispatcher;
  48356. private _overlappingPairCache;
  48357. private _solver;
  48358. private _tmpAmmoVectorA;
  48359. private _tmpAmmoVectorB;
  48360. private _tmpAmmoVectorC;
  48361. private _tmpContactCallbackResult;
  48362. private static readonly DISABLE_COLLISION_FLAG;
  48363. private static readonly KINEMATIC_FLAG;
  48364. private static readonly DISABLE_DEACTIVATION_FLAG;
  48365. /**
  48366. * Initializes the ammoJS plugin
  48367. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  48368. * @param ammoInjection can be used to inject your own ammo reference
  48369. */
  48370. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  48371. /**
  48372. * Sets the gravity of the physics world (m/(s^2))
  48373. * @param gravity Gravity to set
  48374. */
  48375. setGravity(gravity: Vector3): void;
  48376. /**
  48377. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  48378. * @param timeStep timestep to use in seconds
  48379. */
  48380. setTimeStep(timeStep: number): void;
  48381. /**
  48382. * 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)
  48383. * @param fixedTimeStep fixedTimeStep to use in seconds
  48384. */
  48385. setFixedTimeStep(fixedTimeStep: number): void;
  48386. /**
  48387. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  48388. * @param maxSteps the maximum number of steps by the physics engine per frame
  48389. */
  48390. setMaxSteps(maxSteps: number): void;
  48391. /**
  48392. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  48393. * @returns the current timestep in seconds
  48394. */
  48395. getTimeStep(): number;
  48396. private _isImpostorInContact;
  48397. private _isImpostorPairInContact;
  48398. private _stepSimulation;
  48399. /**
  48400. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  48401. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  48402. * After the step the babylon meshes are set to the position of the physics imposters
  48403. * @param delta amount of time to step forward
  48404. * @param impostors array of imposters to update before/after the step
  48405. */
  48406. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48407. private _tmpVector;
  48408. private _tmpMatrix;
  48409. /**
  48410. * Applies an implulse on the imposter
  48411. * @param impostor imposter to apply impulse
  48412. * @param force amount of force to be applied to the imposter
  48413. * @param contactPoint the location to apply the impulse on the imposter
  48414. */
  48415. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48416. /**
  48417. * Applies a force on the imposter
  48418. * @param impostor imposter to apply force
  48419. * @param force amount of force to be applied to the imposter
  48420. * @param contactPoint the location to apply the force on the imposter
  48421. */
  48422. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48423. /**
  48424. * Creates a physics body using the plugin
  48425. * @param impostor the imposter to create the physics body on
  48426. */
  48427. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48428. /**
  48429. * Removes the physics body from the imposter and disposes of the body's memory
  48430. * @param impostor imposter to remove the physics body from
  48431. */
  48432. removePhysicsBody(impostor: PhysicsImpostor): void;
  48433. /**
  48434. * Generates a joint
  48435. * @param impostorJoint the imposter joint to create the joint with
  48436. */
  48437. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48438. /**
  48439. * Removes a joint
  48440. * @param impostorJoint the imposter joint to remove the joint from
  48441. */
  48442. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48443. private _addMeshVerts;
  48444. private _createShape;
  48445. /**
  48446. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  48447. * @param impostor imposter containing the physics body and babylon object
  48448. */
  48449. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48450. /**
  48451. * Sets the babylon object's position/rotation from the physics body's position/rotation
  48452. * @param impostor imposter containing the physics body and babylon object
  48453. * @param newPosition new position
  48454. * @param newRotation new rotation
  48455. */
  48456. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48457. /**
  48458. * If this plugin is supported
  48459. * @returns true if its supported
  48460. */
  48461. isSupported(): boolean;
  48462. /**
  48463. * Sets the linear velocity of the physics body
  48464. * @param impostor imposter to set the velocity on
  48465. * @param velocity velocity to set
  48466. */
  48467. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48468. /**
  48469. * Sets the angular velocity of the physics body
  48470. * @param impostor imposter to set the velocity on
  48471. * @param velocity velocity to set
  48472. */
  48473. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48474. /**
  48475. * gets the linear velocity
  48476. * @param impostor imposter to get linear velocity from
  48477. * @returns linear velocity
  48478. */
  48479. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48480. /**
  48481. * gets the angular velocity
  48482. * @param impostor imposter to get angular velocity from
  48483. * @returns angular velocity
  48484. */
  48485. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48486. /**
  48487. * Sets the mass of physics body
  48488. * @param impostor imposter to set the mass on
  48489. * @param mass mass to set
  48490. */
  48491. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48492. /**
  48493. * Gets the mass of the physics body
  48494. * @param impostor imposter to get the mass from
  48495. * @returns mass
  48496. */
  48497. getBodyMass(impostor: PhysicsImpostor): number;
  48498. /**
  48499. * Gets friction of the impostor
  48500. * @param impostor impostor to get friction from
  48501. * @returns friction value
  48502. */
  48503. getBodyFriction(impostor: PhysicsImpostor): number;
  48504. /**
  48505. * Sets friction of the impostor
  48506. * @param impostor impostor to set friction on
  48507. * @param friction friction value
  48508. */
  48509. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48510. /**
  48511. * Gets restitution of the impostor
  48512. * @param impostor impostor to get restitution from
  48513. * @returns restitution value
  48514. */
  48515. getBodyRestitution(impostor: PhysicsImpostor): number;
  48516. /**
  48517. * Sets resitution of the impostor
  48518. * @param impostor impostor to set resitution on
  48519. * @param restitution resitution value
  48520. */
  48521. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48522. /**
  48523. * Sleeps the physics body and stops it from being active
  48524. * @param impostor impostor to sleep
  48525. */
  48526. sleepBody(impostor: PhysicsImpostor): void;
  48527. /**
  48528. * Activates the physics body
  48529. * @param impostor impostor to activate
  48530. */
  48531. wakeUpBody(impostor: PhysicsImpostor): void;
  48532. /**
  48533. * Updates the distance parameters of the joint
  48534. * @param joint joint to update
  48535. * @param maxDistance maximum distance of the joint
  48536. * @param minDistance minimum distance of the joint
  48537. */
  48538. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48539. /**
  48540. * Sets a motor on the joint
  48541. * @param joint joint to set motor on
  48542. * @param speed speed of the motor
  48543. * @param maxForce maximum force of the motor
  48544. * @param motorIndex index of the motor
  48545. */
  48546. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48547. /**
  48548. * Sets the motors limit
  48549. * @param joint joint to set limit on
  48550. * @param upperLimit upper limit
  48551. * @param lowerLimit lower limit
  48552. */
  48553. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48554. /**
  48555. * Syncs the position and rotation of a mesh with the impostor
  48556. * @param mesh mesh to sync
  48557. * @param impostor impostor to update the mesh with
  48558. */
  48559. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48560. /**
  48561. * Gets the radius of the impostor
  48562. * @param impostor impostor to get radius from
  48563. * @returns the radius
  48564. */
  48565. getRadius(impostor: PhysicsImpostor): number;
  48566. /**
  48567. * Gets the box size of the impostor
  48568. * @param impostor impostor to get box size from
  48569. * @param result the resulting box size
  48570. */
  48571. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48572. /**
  48573. * Disposes of the impostor
  48574. */
  48575. dispose(): void;
  48576. }
  48577. }
  48578. declare module BABYLON {
  48579. /** @hidden */
  48580. export var blackAndWhitePixelShader: {
  48581. name: string;
  48582. shader: string;
  48583. };
  48584. }
  48585. declare module BABYLON {
  48586. /**
  48587. * Post process used to render in black and white
  48588. */
  48589. export class BlackAndWhitePostProcess extends PostProcess {
  48590. /**
  48591. * Linear about to convert he result to black and white (default: 1)
  48592. */
  48593. degree: number;
  48594. /**
  48595. * Creates a black and white post process
  48596. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  48597. * @param name The name of the effect.
  48598. * @param options The required width/height ratio to downsize to before computing the render pass.
  48599. * @param camera The camera to apply the render pass to.
  48600. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  48601. * @param engine The engine which the post process will be applied. (default: current engine)
  48602. * @param reusable If the post process can be reused on the same frame. (default: false)
  48603. */
  48604. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  48605. }
  48606. }
  48607. declare module BABYLON {
  48608. /**
  48609. * This represents a set of one or more post processes in Babylon.
  48610. * A post process can be used to apply a shader to a texture after it is rendered.
  48611. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48612. */
  48613. export class PostProcessRenderEffect {
  48614. private _postProcesses;
  48615. private _getPostProcesses;
  48616. private _singleInstance;
  48617. private _cameras;
  48618. private _indicesForCamera;
  48619. /**
  48620. * Name of the effect
  48621. * @hidden
  48622. */ name: string;
  48623. /**
  48624. * Instantiates a post process render effect.
  48625. * A post process can be used to apply a shader to a texture after it is rendered.
  48626. * @param engine The engine the effect is tied to
  48627. * @param name The name of the effect
  48628. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  48629. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  48630. */
  48631. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  48632. /**
  48633. * Checks if all the post processes in the effect are supported.
  48634. */
  48635. readonly isSupported: boolean;
  48636. /**
  48637. * Updates the current state of the effect
  48638. * @hidden
  48639. */ update(): void;
  48640. /**
  48641. * Attaches the effect on cameras
  48642. * @param cameras The camera to attach to.
  48643. * @hidden
  48644. */ attachCameras(cameras: Camera): void;
  48645. /**
  48646. * Attaches the effect on cameras
  48647. * @param cameras The camera to attach to.
  48648. * @hidden
  48649. */ attachCameras(cameras: Camera[]): void;
  48650. /**
  48651. * Detatches the effect on cameras
  48652. * @param cameras The camera to detatch from.
  48653. * @hidden
  48654. */ detachCameras(cameras: Camera): void;
  48655. /**
  48656. * Detatches the effect on cameras
  48657. * @param cameras The camera to detatch from.
  48658. * @hidden
  48659. */ detachCameras(cameras: Camera[]): void;
  48660. /**
  48661. * Enables the effect on given cameras
  48662. * @param cameras The camera to enable.
  48663. * @hidden
  48664. */ enable(cameras: Camera): void;
  48665. /**
  48666. * Enables the effect on given cameras
  48667. * @param cameras The camera to enable.
  48668. * @hidden
  48669. */ enable(cameras: Nullable<Camera[]>): void;
  48670. /**
  48671. * Disables the effect on the given cameras
  48672. * @param cameras The camera to disable.
  48673. * @hidden
  48674. */ disable(cameras: Camera): void;
  48675. /**
  48676. * Disables the effect on the given cameras
  48677. * @param cameras The camera to disable.
  48678. * @hidden
  48679. */ disable(cameras: Nullable<Camera[]>): void;
  48680. /**
  48681. * Gets a list of the post processes contained in the effect.
  48682. * @param camera The camera to get the post processes on.
  48683. * @returns The list of the post processes in the effect.
  48684. */
  48685. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  48686. }
  48687. }
  48688. declare module BABYLON {
  48689. /** @hidden */
  48690. export var extractHighlightsPixelShader: {
  48691. name: string;
  48692. shader: string;
  48693. };
  48694. }
  48695. declare module BABYLON {
  48696. /**
  48697. * 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.
  48698. */
  48699. export class ExtractHighlightsPostProcess extends PostProcess {
  48700. /**
  48701. * The luminance threshold, pixels below this value will be set to black.
  48702. */
  48703. threshold: number;
  48704. /** @hidden */ exposure: number;
  48705. /**
  48706. * Post process which has the input texture to be used when performing highlight extraction
  48707. * @hidden
  48708. */ inputPostProcess: Nullable<PostProcess>;
  48709. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  48710. }
  48711. }
  48712. declare module BABYLON {
  48713. /** @hidden */
  48714. export var bloomMergePixelShader: {
  48715. name: string;
  48716. shader: string;
  48717. };
  48718. }
  48719. declare module BABYLON {
  48720. /**
  48721. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  48722. */
  48723. export class BloomMergePostProcess extends PostProcess {
  48724. /** Weight of the bloom to be added to the original input. */
  48725. weight: number;
  48726. /**
  48727. * Creates a new instance of @see BloomMergePostProcess
  48728. * @param name The name of the effect.
  48729. * @param originalFromInput Post process which's input will be used for the merge.
  48730. * @param blurred Blurred highlights post process which's output will be used.
  48731. * @param weight Weight of the bloom to be added to the original input.
  48732. * @param options The required width/height ratio to downsize to before computing the render pass.
  48733. * @param camera The camera to apply the render pass to.
  48734. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  48735. * @param engine The engine which the post process will be applied. (default: current engine)
  48736. * @param reusable If the post process can be reused on the same frame. (default: false)
  48737. * @param textureType Type of textures used when performing the post process. (default: 0)
  48738. * @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)
  48739. */
  48740. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  48741. /** Weight of the bloom to be added to the original input. */
  48742. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  48743. }
  48744. }
  48745. declare module BABYLON {
  48746. /**
  48747. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  48748. */
  48749. export class BloomEffect extends PostProcessRenderEffect {
  48750. private bloomScale;
  48751. /**
  48752. * @hidden Internal
  48753. */ effects: Array<PostProcess>;
  48754. /**
  48755. * @hidden Internal
  48756. */ downscale: ExtractHighlightsPostProcess;
  48757. private _blurX;
  48758. private _blurY;
  48759. private _merge;
  48760. /**
  48761. * The luminance threshold to find bright areas of the image to bloom.
  48762. */
  48763. threshold: number;
  48764. /**
  48765. * The strength of the bloom.
  48766. */
  48767. weight: number;
  48768. /**
  48769. * Specifies the size of the bloom blur kernel, relative to the final output size
  48770. */
  48771. kernel: number;
  48772. /**
  48773. * Creates a new instance of @see BloomEffect
  48774. * @param scene The scene the effect belongs to.
  48775. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  48776. * @param bloomKernel The size of the kernel to be used when applying the blur.
  48777. * @param bloomWeight The the strength of bloom.
  48778. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  48779. * @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)
  48780. */
  48781. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  48782. /**
  48783. * Disposes each of the internal effects for a given camera.
  48784. * @param camera The camera to dispose the effect on.
  48785. */
  48786. disposeEffects(camera: Camera): void;
  48787. /**
  48788. * @hidden Internal
  48789. */ updateEffects(): void;
  48790. /**
  48791. * Internal
  48792. * @returns if all the contained post processes are ready.
  48793. * @hidden
  48794. */ isReady(): boolean;
  48795. }
  48796. }
  48797. declare module BABYLON {
  48798. /** @hidden */
  48799. export var chromaticAberrationPixelShader: {
  48800. name: string;
  48801. shader: string;
  48802. };
  48803. }
  48804. declare module BABYLON {
  48805. /**
  48806. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  48807. */
  48808. export class ChromaticAberrationPostProcess extends PostProcess {
  48809. /**
  48810. * The amount of seperation of rgb channels (default: 30)
  48811. */
  48812. aberrationAmount: number;
  48813. /**
  48814. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  48815. */
  48816. radialIntensity: number;
  48817. /**
  48818. * 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))
  48819. */
  48820. direction: Vector2;
  48821. /**
  48822. * 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))
  48823. */
  48824. centerPosition: Vector2;
  48825. /**
  48826. * Creates a new instance ChromaticAberrationPostProcess
  48827. * @param name The name of the effect.
  48828. * @param screenWidth The width of the screen to apply the effect on.
  48829. * @param screenHeight The height of the screen to apply the effect on.
  48830. * @param options The required width/height ratio to downsize to before computing the render pass.
  48831. * @param camera The camera to apply the render pass to.
  48832. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  48833. * @param engine The engine which the post process will be applied. (default: current engine)
  48834. * @param reusable If the post process can be reused on the same frame. (default: false)
  48835. * @param textureType Type of textures used when performing the post process. (default: 0)
  48836. * @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)
  48837. */
  48838. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  48839. }
  48840. }
  48841. declare module BABYLON {
  48842. /** @hidden */
  48843. export var circleOfConfusionPixelShader: {
  48844. name: string;
  48845. shader: string;
  48846. };
  48847. }
  48848. declare module BABYLON {
  48849. /**
  48850. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  48851. */
  48852. export class CircleOfConfusionPostProcess extends PostProcess {
  48853. /**
  48854. * 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.
  48855. */
  48856. lensSize: number;
  48857. /**
  48858. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  48859. */
  48860. fStop: number;
  48861. /**
  48862. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  48863. */
  48864. focusDistance: number;
  48865. /**
  48866. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  48867. */
  48868. focalLength: number;
  48869. private _depthTexture;
  48870. /**
  48871. * Creates a new instance CircleOfConfusionPostProcess
  48872. * @param name The name of the effect.
  48873. * @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.
  48874. * @param options The required width/height ratio to downsize to before computing the render pass.
  48875. * @param camera The camera to apply the render pass to.
  48876. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  48877. * @param engine The engine which the post process will be applied. (default: current engine)
  48878. * @param reusable If the post process can be reused on the same frame. (default: false)
  48879. * @param textureType Type of textures used when performing the post process. (default: 0)
  48880. * @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)
  48881. */
  48882. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  48883. /**
  48884. * 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.
  48885. */
  48886. depthTexture: RenderTargetTexture;
  48887. }
  48888. }
  48889. declare module BABYLON {
  48890. /** @hidden */
  48891. export var colorCorrectionPixelShader: {
  48892. name: string;
  48893. shader: string;
  48894. };
  48895. }
  48896. declare module BABYLON {
  48897. /**
  48898. *
  48899. * This post-process allows the modification of rendered colors by using
  48900. * a 'look-up table' (LUT). This effect is also called Color Grading.
  48901. *
  48902. * The object needs to be provided an url to a texture containing the color
  48903. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  48904. * Use an image editing software to tweak the LUT to match your needs.
  48905. *
  48906. * For an example of a color LUT, see here:
  48907. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  48908. * For explanations on color grading, see here:
  48909. * @see http://udn.epicgames.com/Three/ColorGrading.html
  48910. *
  48911. */
  48912. export class ColorCorrectionPostProcess extends PostProcess {
  48913. private _colorTableTexture;
  48914. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  48915. }
  48916. }
  48917. declare module BABYLON {
  48918. /** @hidden */
  48919. export var convolutionPixelShader: {
  48920. name: string;
  48921. shader: string;
  48922. };
  48923. }
  48924. declare module BABYLON {
  48925. /**
  48926. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  48927. * input texture to perform effects such as edge detection or sharpening
  48928. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  48929. */
  48930. export class ConvolutionPostProcess extends PostProcess {
  48931. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  48932. kernel: number[];
  48933. /**
  48934. * Creates a new instance ConvolutionPostProcess
  48935. * @param name The name of the effect.
  48936. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  48937. * @param options The required width/height ratio to downsize to before computing the render pass.
  48938. * @param camera The camera to apply the render pass to.
  48939. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  48940. * @param engine The engine which the post process will be applied. (default: current engine)
  48941. * @param reusable If the post process can be reused on the same frame. (default: false)
  48942. * @param textureType Type of textures used when performing the post process. (default: 0)
  48943. */
  48944. constructor(name: string,
  48945. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  48946. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  48947. /**
  48948. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  48949. */
  48950. static EdgeDetect0Kernel: number[];
  48951. /**
  48952. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  48953. */
  48954. static EdgeDetect1Kernel: number[];
  48955. /**
  48956. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  48957. */
  48958. static EdgeDetect2Kernel: number[];
  48959. /**
  48960. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  48961. */
  48962. static SharpenKernel: number[];
  48963. /**
  48964. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  48965. */
  48966. static EmbossKernel: number[];
  48967. /**
  48968. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  48969. */
  48970. static GaussianKernel: number[];
  48971. }
  48972. }
  48973. declare module BABYLON {
  48974. /**
  48975. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  48976. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  48977. * based on samples that have a large difference in distance than the center pixel.
  48978. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  48979. */
  48980. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  48981. direction: Vector2;
  48982. /**
  48983. * Creates a new instance CircleOfConfusionPostProcess
  48984. * @param name The name of the effect.
  48985. * @param scene The scene the effect belongs to.
  48986. * @param direction The direction the blur should be applied.
  48987. * @param kernel The size of the kernel used to blur.
  48988. * @param options The required width/height ratio to downsize to before computing the render pass.
  48989. * @param camera The camera to apply the render pass to.
  48990. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  48991. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  48992. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  48993. * @param engine The engine which the post process will be applied. (default: current engine)
  48994. * @param reusable If the post process can be reused on the same frame. (default: false)
  48995. * @param textureType Type of textures used when performing the post process. (default: 0)
  48996. * @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)
  48997. */
  48998. 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);
  48999. }
  49000. }
  49001. declare module BABYLON {
  49002. /** @hidden */
  49003. export var depthOfFieldMergePixelShader: {
  49004. name: string;
  49005. shader: string;
  49006. };
  49007. }
  49008. declare module BABYLON {
  49009. /**
  49010. * Options to be set when merging outputs from the default pipeline.
  49011. */
  49012. export class DepthOfFieldMergePostProcessOptions {
  49013. /**
  49014. * The original image to merge on top of
  49015. */
  49016. originalFromInput: PostProcess;
  49017. /**
  49018. * Parameters to perform the merge of the depth of field effect
  49019. */
  49020. depthOfField?: {
  49021. circleOfConfusion: PostProcess;
  49022. blurSteps: Array<PostProcess>;
  49023. };
  49024. /**
  49025. * Parameters to perform the merge of bloom effect
  49026. */
  49027. bloom?: {
  49028. blurred: PostProcess;
  49029. weight: number;
  49030. };
  49031. }
  49032. /**
  49033. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  49034. */
  49035. export class DepthOfFieldMergePostProcess extends PostProcess {
  49036. private blurSteps;
  49037. /**
  49038. * Creates a new instance of DepthOfFieldMergePostProcess
  49039. * @param name The name of the effect.
  49040. * @param originalFromInput Post process which's input will be used for the merge.
  49041. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  49042. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  49043. * @param options The required width/height ratio to downsize to before computing the render pass.
  49044. * @param camera The camera to apply the render pass to.
  49045. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49046. * @param engine The engine which the post process will be applied. (default: current engine)
  49047. * @param reusable If the post process can be reused on the same frame. (default: false)
  49048. * @param textureType Type of textures used when performing the post process. (default: 0)
  49049. * @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)
  49050. */
  49051. 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);
  49052. /**
  49053. * Updates the effect with the current post process compile time values and recompiles the shader.
  49054. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  49055. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  49056. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  49057. * @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
  49058. * @param onCompiled Called when the shader has been compiled.
  49059. * @param onError Called if there is an error when compiling a shader.
  49060. */
  49061. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  49062. }
  49063. }
  49064. declare module BABYLON {
  49065. /**
  49066. * Specifies the level of max blur that should be applied when using the depth of field effect
  49067. */
  49068. export enum DepthOfFieldEffectBlurLevel {
  49069. /**
  49070. * Subtle blur
  49071. */
  49072. Low = 0,
  49073. /**
  49074. * Medium blur
  49075. */
  49076. Medium = 1,
  49077. /**
  49078. * Large blur
  49079. */
  49080. High = 2
  49081. }
  49082. /**
  49083. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  49084. */
  49085. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  49086. private _circleOfConfusion;
  49087. /**
  49088. * @hidden Internal, blurs from high to low
  49089. */ depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  49090. private _depthOfFieldBlurY;
  49091. private _dofMerge;
  49092. /**
  49093. * @hidden Internal post processes in depth of field effect
  49094. */ effects: Array<PostProcess>;
  49095. /**
  49096. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  49097. */
  49098. focalLength: number;
  49099. /**
  49100. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  49101. */
  49102. fStop: number;
  49103. /**
  49104. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  49105. */
  49106. focusDistance: number;
  49107. /**
  49108. * 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.
  49109. */
  49110. lensSize: number;
  49111. /**
  49112. * Creates a new instance DepthOfFieldEffect
  49113. * @param scene The scene the effect belongs to.
  49114. * @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.
  49115. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  49116. * @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)
  49117. */
  49118. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  49119. /**
  49120. * 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.
  49121. */
  49122. depthTexture: RenderTargetTexture;
  49123. /**
  49124. * Disposes each of the internal effects for a given camera.
  49125. * @param camera The camera to dispose the effect on.
  49126. */
  49127. disposeEffects(camera: Camera): void;
  49128. /**
  49129. * @hidden Internal
  49130. */ updateEffects(): void;
  49131. /**
  49132. * Internal
  49133. * @returns if all the contained post processes are ready.
  49134. * @hidden
  49135. */ isReady(): boolean;
  49136. }
  49137. }
  49138. declare module BABYLON {
  49139. /** @hidden */
  49140. export var displayPassPixelShader: {
  49141. name: string;
  49142. shader: string;
  49143. };
  49144. }
  49145. declare module BABYLON {
  49146. /**
  49147. * DisplayPassPostProcess which produces an output the same as it's input
  49148. */
  49149. export class DisplayPassPostProcess extends PostProcess {
  49150. /**
  49151. * Creates the DisplayPassPostProcess
  49152. * @param name The name of the effect.
  49153. * @param options The required width/height ratio to downsize to before computing the render pass.
  49154. * @param camera The camera to apply the render pass to.
  49155. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49156. * @param engine The engine which the post process will be applied. (default: current engine)
  49157. * @param reusable If the post process can be reused on the same frame. (default: false)
  49158. */
  49159. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  49160. }
  49161. }
  49162. declare module BABYLON {
  49163. /** @hidden */
  49164. export var filterPixelShader: {
  49165. name: string;
  49166. shader: string;
  49167. };
  49168. }
  49169. declare module BABYLON {
  49170. /**
  49171. * Applies a kernel filter to the image
  49172. */
  49173. export class FilterPostProcess extends PostProcess {
  49174. /** The matrix to be applied to the image */
  49175. kernelMatrix: Matrix;
  49176. /**
  49177. *
  49178. * @param name The name of the effect.
  49179. * @param kernelMatrix The matrix to be applied to the image
  49180. * @param options The required width/height ratio to downsize to before computing the render pass.
  49181. * @param camera The camera to apply the render pass to.
  49182. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49183. * @param engine The engine which the post process will be applied. (default: current engine)
  49184. * @param reusable If the post process can be reused on the same frame. (default: false)
  49185. */
  49186. constructor(name: string,
  49187. /** The matrix to be applied to the image */
  49188. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  49189. }
  49190. }
  49191. declare module BABYLON {
  49192. /** @hidden */
  49193. export var fxaaPixelShader: {
  49194. name: string;
  49195. shader: string;
  49196. };
  49197. }
  49198. declare module BABYLON {
  49199. /** @hidden */
  49200. export var fxaaVertexShader: {
  49201. name: string;
  49202. shader: string;
  49203. };
  49204. }
  49205. declare module BABYLON {
  49206. /**
  49207. * Fxaa post process
  49208. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  49209. */
  49210. export class FxaaPostProcess extends PostProcess {
  49211. /** @hidden */
  49212. texelWidth: number;
  49213. /** @hidden */
  49214. texelHeight: number;
  49215. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  49216. private _getDefines;
  49217. }
  49218. }
  49219. declare module BABYLON {
  49220. /** @hidden */
  49221. export var grainPixelShader: {
  49222. name: string;
  49223. shader: string;
  49224. };
  49225. }
  49226. declare module BABYLON {
  49227. /**
  49228. * The GrainPostProcess adds noise to the image at mid luminance levels
  49229. */
  49230. export class GrainPostProcess extends PostProcess {
  49231. /**
  49232. * The intensity of the grain added (default: 30)
  49233. */
  49234. intensity: number;
  49235. /**
  49236. * If the grain should be randomized on every frame
  49237. */
  49238. animated: boolean;
  49239. /**
  49240. * Creates a new instance of @see GrainPostProcess
  49241. * @param name The name of the effect.
  49242. * @param options The required width/height ratio to downsize to before computing the render pass.
  49243. * @param camera The camera to apply the render pass to.
  49244. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49245. * @param engine The engine which the post process will be applied. (default: current engine)
  49246. * @param reusable If the post process can be reused on the same frame. (default: false)
  49247. * @param textureType Type of textures used when performing the post process. (default: 0)
  49248. * @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)
  49249. */
  49250. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49251. }
  49252. }
  49253. declare module BABYLON {
  49254. /** @hidden */
  49255. export var highlightsPixelShader: {
  49256. name: string;
  49257. shader: string;
  49258. };
  49259. }
  49260. declare module BABYLON {
  49261. /**
  49262. * Extracts highlights from the image
  49263. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  49264. */
  49265. export class HighlightsPostProcess extends PostProcess {
  49266. /**
  49267. * Extracts highlights from the image
  49268. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  49269. * @param name The name of the effect.
  49270. * @param options The required width/height ratio to downsize to before computing the render pass.
  49271. * @param camera The camera to apply the render pass to.
  49272. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49273. * @param engine The engine which the post process will be applied. (default: current engine)
  49274. * @param reusable If the post process can be reused on the same frame. (default: false)
  49275. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  49276. */
  49277. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  49278. }
  49279. }
  49280. declare module BABYLON {
  49281. /** @hidden */
  49282. export var mrtFragmentDeclaration: {
  49283. name: string;
  49284. shader: string;
  49285. };
  49286. }
  49287. declare module BABYLON {
  49288. /** @hidden */
  49289. export var geometryPixelShader: {
  49290. name: string;
  49291. shader: string;
  49292. };
  49293. }
  49294. declare module BABYLON {
  49295. /** @hidden */
  49296. export var geometryVertexShader: {
  49297. name: string;
  49298. shader: string;
  49299. };
  49300. }
  49301. declare module BABYLON {
  49302. /**
  49303. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  49304. */
  49305. export class GeometryBufferRenderer {
  49306. /**
  49307. * Constant used to retrieve the position texture index in the G-Buffer textures array
  49308. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  49309. */
  49310. static readonly POSITION_TEXTURE_TYPE: number;
  49311. /**
  49312. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  49313. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  49314. */
  49315. static readonly VELOCITY_TEXTURE_TYPE: number;
  49316. /**
  49317. * Dictionary used to store the previous transformation matrices of each rendered mesh
  49318. * in order to compute objects velocities when enableVelocity is set to "true"
  49319. * @hidden
  49320. */ previousTransformationMatrices: {
  49321. [index: number]: Matrix;
  49322. };
  49323. private _scene;
  49324. private _multiRenderTarget;
  49325. private _ratio;
  49326. private _enablePosition;
  49327. private _enableVelocity;
  49328. private _positionIndex;
  49329. private _velocityIndex;
  49330. protected _effect: Effect;
  49331. protected _cachedDefines: string;
  49332. /**
  49333. * Set the render list (meshes to be rendered) used in the G buffer.
  49334. */
  49335. renderList: Mesh[];
  49336. /**
  49337. * Gets wether or not G buffer are supported by the running hardware.
  49338. * This requires draw buffer supports
  49339. */
  49340. readonly isSupported: boolean;
  49341. /**
  49342. * Returns the index of the given texture type in the G-Buffer textures array
  49343. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  49344. * @returns the index of the given texture type in the G-Buffer textures array
  49345. */
  49346. getTextureIndex(textureType: number): number;
  49347. /**
  49348. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  49349. */
  49350. /**
  49351. * Sets whether or not objects positions are enabled for the G buffer.
  49352. */
  49353. enablePosition: boolean;
  49354. /**
  49355. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  49356. */
  49357. /**
  49358. * Sets wether or not objects velocities are enabled for the G buffer.
  49359. */
  49360. enableVelocity: boolean;
  49361. /**
  49362. * Gets the scene associated with the buffer.
  49363. */
  49364. readonly scene: Scene;
  49365. /**
  49366. * Gets the ratio used by the buffer during its creation.
  49367. * How big is the buffer related to the main canvas.
  49368. */
  49369. readonly ratio: number;
  49370. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  49371. /**
  49372. * Creates a new G Buffer for the scene
  49373. * @param scene The scene the buffer belongs to
  49374. * @param ratio How big is the buffer related to the main canvas.
  49375. */
  49376. constructor(scene: Scene, ratio?: number);
  49377. /**
  49378. * Checks wether everything is ready to render a submesh to the G buffer.
  49379. * @param subMesh the submesh to check readiness for
  49380. * @param useInstances is the mesh drawn using instance or not
  49381. * @returns true if ready otherwise false
  49382. */
  49383. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49384. /**
  49385. * Gets the current underlying G Buffer.
  49386. * @returns the buffer
  49387. */
  49388. getGBuffer(): MultiRenderTarget;
  49389. /**
  49390. * Gets the number of samples used to render the buffer (anti aliasing).
  49391. */
  49392. /**
  49393. * Sets the number of samples used to render the buffer (anti aliasing).
  49394. */
  49395. samples: number;
  49396. /**
  49397. * Disposes the renderer and frees up associated resources.
  49398. */
  49399. dispose(): void;
  49400. protected _createRenderTargets(): void;
  49401. }
  49402. }
  49403. declare module BABYLON {
  49404. /** @hidden */
  49405. export var motionBlurPixelShader: {
  49406. name: string;
  49407. shader: string;
  49408. };
  49409. }
  49410. declare module BABYLON {
  49411. /**
  49412. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  49413. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  49414. * As an example, all you have to do is to create the post-process:
  49415. * var mb = new BABYLON.MotionBlurPostProcess(
  49416. * 'mb', // The name of the effect.
  49417. * scene, // The scene containing the objects to blur according to their velocity.
  49418. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  49419. * camera // The camera to apply the render pass to.
  49420. * );
  49421. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  49422. */
  49423. export class MotionBlurPostProcess extends PostProcess {
  49424. /**
  49425. * Defines how much the image is blurred by the movement. Default value is equal to 1
  49426. */
  49427. motionStrength: number;
  49428. /**
  49429. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  49430. */
  49431. /**
  49432. * Sets the number of iterations to be used for motion blur quality
  49433. */
  49434. motionBlurSamples: number;
  49435. private _motionBlurSamples;
  49436. private _geometryBufferRenderer;
  49437. /**
  49438. * Creates a new instance MotionBlurPostProcess
  49439. * @param name The name of the effect.
  49440. * @param scene The scene containing the objects to blur according to their velocity.
  49441. * @param options The required width/height ratio to downsize to before computing the render pass.
  49442. * @param camera The camera to apply the render pass to.
  49443. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49444. * @param engine The engine which the post process will be applied. (default: current engine)
  49445. * @param reusable If the post process can be reused on the same frame. (default: false)
  49446. * @param textureType Type of textures used when performing the post process. (default: 0)
  49447. * @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)
  49448. */
  49449. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49450. /**
  49451. * Disposes the post process.
  49452. * @param camera The camera to dispose the post process on.
  49453. */
  49454. dispose(camera?: Camera): void;
  49455. }
  49456. }
  49457. declare module BABYLON {
  49458. /** @hidden */
  49459. export var refractionPixelShader: {
  49460. name: string;
  49461. shader: string;
  49462. };
  49463. }
  49464. declare module BABYLON {
  49465. /**
  49466. * Post process which applies a refractin texture
  49467. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  49468. */
  49469. export class RefractionPostProcess extends PostProcess {
  49470. /** the base color of the refraction (used to taint the rendering) */
  49471. color: Color3;
  49472. /** simulated refraction depth */
  49473. depth: number;
  49474. /** the coefficient of the base color (0 to remove base color tainting) */
  49475. colorLevel: number;
  49476. private _refTexture;
  49477. private _ownRefractionTexture;
  49478. /**
  49479. * Gets or sets the refraction texture
  49480. * Please note that you are responsible for disposing the texture if you set it manually
  49481. */
  49482. refractionTexture: Texture;
  49483. /**
  49484. * Initializes the RefractionPostProcess
  49485. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  49486. * @param name The name of the effect.
  49487. * @param refractionTextureUrl Url of the refraction texture to use
  49488. * @param color the base color of the refraction (used to taint the rendering)
  49489. * @param depth simulated refraction depth
  49490. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  49491. * @param camera The camera to apply the render pass to.
  49492. * @param options The required width/height ratio to downsize to before computing the render pass.
  49493. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49494. * @param engine The engine which the post process will be applied. (default: current engine)
  49495. * @param reusable If the post process can be reused on the same frame. (default: false)
  49496. */
  49497. constructor(name: string, refractionTextureUrl: string,
  49498. /** the base color of the refraction (used to taint the rendering) */
  49499. color: Color3,
  49500. /** simulated refraction depth */
  49501. depth: number,
  49502. /** the coefficient of the base color (0 to remove base color tainting) */
  49503. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  49504. /**
  49505. * Disposes of the post process
  49506. * @param camera Camera to dispose post process on
  49507. */
  49508. dispose(camera: Camera): void;
  49509. }
  49510. }
  49511. declare module BABYLON {
  49512. /** @hidden */
  49513. export var sharpenPixelShader: {
  49514. name: string;
  49515. shader: string;
  49516. };
  49517. }
  49518. declare module BABYLON {
  49519. /**
  49520. * The SharpenPostProcess applies a sharpen kernel to every pixel
  49521. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  49522. */
  49523. export class SharpenPostProcess extends PostProcess {
  49524. /**
  49525. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  49526. */
  49527. colorAmount: number;
  49528. /**
  49529. * How much sharpness should be applied (default: 0.3)
  49530. */
  49531. edgeAmount: number;
  49532. /**
  49533. * Creates a new instance ConvolutionPostProcess
  49534. * @param name The name of the effect.
  49535. * @param options The required width/height ratio to downsize to before computing the render pass.
  49536. * @param camera The camera to apply the render pass to.
  49537. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49538. * @param engine The engine which the post process will be applied. (default: current engine)
  49539. * @param reusable If the post process can be reused on the same frame. (default: false)
  49540. * @param textureType Type of textures used when performing the post process. (default: 0)
  49541. * @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)
  49542. */
  49543. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49544. }
  49545. }
  49546. declare module BABYLON {
  49547. /**
  49548. * PostProcessRenderPipeline
  49549. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49550. */
  49551. export class PostProcessRenderPipeline {
  49552. private engine;
  49553. private _renderEffects;
  49554. private _renderEffectsForIsolatedPass;
  49555. /**
  49556. * @hidden
  49557. */
  49558. protected _cameras: Camera[];
  49559. /** @hidden */ name: string;
  49560. /**
  49561. * Initializes a PostProcessRenderPipeline
  49562. * @param engine engine to add the pipeline to
  49563. * @param name name of the pipeline
  49564. */
  49565. constructor(engine: Engine, name: string);
  49566. /**
  49567. * "PostProcessRenderPipeline"
  49568. * @returns "PostProcessRenderPipeline"
  49569. */
  49570. getClassName(): string;
  49571. /**
  49572. * If all the render effects in the pipeline are support
  49573. */
  49574. readonly isSupported: boolean;
  49575. /**
  49576. * Adds an effect to the pipeline
  49577. * @param renderEffect the effect to add
  49578. */
  49579. addEffect(renderEffect: PostProcessRenderEffect): void;
  49580. /** @hidden */ rebuild(): void;
  49581. /** @hidden */ enableEffect(renderEffectName: string, cameras: Camera): void;
  49582. /** @hidden */ enableEffect(renderEffectName: string, cameras: Camera[]): void;
  49583. /** @hidden */ disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49584. /** @hidden */ disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49585. /** @hidden */ attachCameras(cameras: Camera, unique: boolean): void;
  49586. /** @hidden */ attachCameras(cameras: Camera[], unique: boolean): void;
  49587. /** @hidden */ detachCameras(cameras: Camera): void;
  49588. /** @hidden */ detachCameras(cameras: Nullable<Camera[]>): void;
  49589. /** @hidden */ update(): void;
  49590. /** @hidden */ reset(): void;
  49591. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  49592. /**
  49593. * Disposes of the pipeline
  49594. */
  49595. dispose(): void;
  49596. }
  49597. }
  49598. declare module BABYLON {
  49599. /**
  49600. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  49601. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  49602. */
  49603. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  49604. private _scene;
  49605. private _camerasToBeAttached;
  49606. /**
  49607. * ID of the sharpen post process,
  49608. */
  49609. private readonly SharpenPostProcessId;
  49610. /**
  49611. * @ignore
  49612. * ID of the image processing post process;
  49613. */
  49614. readonly ImageProcessingPostProcessId: string;
  49615. /**
  49616. * @ignore
  49617. * ID of the Fast Approximate Anti-Aliasing post process;
  49618. */
  49619. readonly FxaaPostProcessId: string;
  49620. /**
  49621. * ID of the chromatic aberration post process,
  49622. */
  49623. private readonly ChromaticAberrationPostProcessId;
  49624. /**
  49625. * ID of the grain post process
  49626. */
  49627. private readonly GrainPostProcessId;
  49628. /**
  49629. * Sharpen post process which will apply a sharpen convolution to enhance edges
  49630. */
  49631. sharpen: SharpenPostProcess;
  49632. private _sharpenEffect;
  49633. private bloom;
  49634. /**
  49635. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  49636. */
  49637. depthOfField: DepthOfFieldEffect;
  49638. /**
  49639. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  49640. */
  49641. fxaa: FxaaPostProcess;
  49642. /**
  49643. * Image post processing pass used to perform operations such as tone mapping or color grading.
  49644. */
  49645. imageProcessing: ImageProcessingPostProcess;
  49646. /**
  49647. * Chromatic aberration post process which will shift rgb colors in the image
  49648. */
  49649. chromaticAberration: ChromaticAberrationPostProcess;
  49650. private _chromaticAberrationEffect;
  49651. /**
  49652. * Grain post process which add noise to the image
  49653. */
  49654. grain: GrainPostProcess;
  49655. private _grainEffect;
  49656. /**
  49657. * Glow post process which adds a glow to emmisive areas of the image
  49658. */
  49659. private _glowLayer;
  49660. /**
  49661. * Animations which can be used to tweak settings over a period of time
  49662. */
  49663. animations: Animation[];
  49664. private _imageProcessingConfigurationObserver;
  49665. private _sharpenEnabled;
  49666. private _bloomEnabled;
  49667. private _depthOfFieldEnabled;
  49668. private _depthOfFieldBlurLevel;
  49669. private _fxaaEnabled;
  49670. private _imageProcessingEnabled;
  49671. private _defaultPipelineTextureType;
  49672. private _bloomScale;
  49673. private _chromaticAberrationEnabled;
  49674. private _grainEnabled;
  49675. private _buildAllowed;
  49676. /**
  49677. * Enable or disable the sharpen process from the pipeline
  49678. */
  49679. sharpenEnabled: boolean;
  49680. private _resizeObserver;
  49681. private _hardwareScaleLevel;
  49682. private _bloomKernel;
  49683. /**
  49684. * Specifies the size of the bloom blur kernel, relative to the final output size
  49685. */
  49686. bloomKernel: number;
  49687. /**
  49688. * Specifies the weight of the bloom in the final rendering
  49689. */
  49690. private _bloomWeight;
  49691. /**
  49692. * Specifies the luma threshold for the area that will be blurred by the bloom
  49693. */
  49694. private _bloomThreshold;
  49695. private _hdr;
  49696. /**
  49697. * The strength of the bloom.
  49698. */
  49699. bloomWeight: number;
  49700. /**
  49701. * The strength of the bloom.
  49702. */
  49703. bloomThreshold: number;
  49704. /**
  49705. * The scale of the bloom, lower value will provide better performance.
  49706. */
  49707. bloomScale: number;
  49708. /**
  49709. * Enable or disable the bloom from the pipeline
  49710. */
  49711. bloomEnabled: boolean;
  49712. private _rebuildBloom;
  49713. /**
  49714. * If the depth of field is enabled.
  49715. */
  49716. depthOfFieldEnabled: boolean;
  49717. /**
  49718. * Blur level of the depth of field effect. (Higher blur will effect performance)
  49719. */
  49720. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  49721. /**
  49722. * If the anti aliasing is enabled.
  49723. */
  49724. fxaaEnabled: boolean;
  49725. private _samples;
  49726. /**
  49727. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  49728. */
  49729. samples: number;
  49730. /**
  49731. * If image processing is enabled.
  49732. */
  49733. imageProcessingEnabled: boolean;
  49734. /**
  49735. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  49736. */
  49737. glowLayerEnabled: boolean;
  49738. /**
  49739. * Enable or disable the chromaticAberration process from the pipeline
  49740. */
  49741. chromaticAberrationEnabled: boolean;
  49742. /**
  49743. * Enable or disable the grain process from the pipeline
  49744. */
  49745. grainEnabled: boolean;
  49746. /**
  49747. * @constructor
  49748. * @param name - The rendering pipeline name (default: "")
  49749. * @param hdr - If high dynamic range textures should be used (default: true)
  49750. * @param scene - The scene linked to this pipeline (default: the last created scene)
  49751. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  49752. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  49753. */
  49754. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  49755. /**
  49756. * Force the compilation of the entire pipeline.
  49757. */
  49758. prepare(): void;
  49759. private _hasCleared;
  49760. private _prevPostProcess;
  49761. private _prevPrevPostProcess;
  49762. private _setAutoClearAndTextureSharing;
  49763. private _depthOfFieldSceneObserver;
  49764. private _buildPipeline;
  49765. private _disposePostProcesses;
  49766. /**
  49767. * Adds a camera to the pipeline
  49768. * @param camera the camera to be added
  49769. */
  49770. addCamera(camera: Camera): void;
  49771. /**
  49772. * Removes a camera from the pipeline
  49773. * @param camera the camera to remove
  49774. */
  49775. removeCamera(camera: Camera): void;
  49776. /**
  49777. * Dispose of the pipeline and stop all post processes
  49778. */
  49779. dispose(): void;
  49780. /**
  49781. * Serialize the rendering pipeline (Used when exporting)
  49782. * @returns the serialized object
  49783. */
  49784. serialize(): any;
  49785. /**
  49786. * Parse the serialized pipeline
  49787. * @param source Source pipeline.
  49788. * @param scene The scene to load the pipeline to.
  49789. * @param rootUrl The URL of the serialized pipeline.
  49790. * @returns An instantiated pipeline from the serialized object.
  49791. */
  49792. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  49793. }
  49794. }
  49795. declare module BABYLON {
  49796. /** @hidden */
  49797. export var lensHighlightsPixelShader: {
  49798. name: string;
  49799. shader: string;
  49800. };
  49801. }
  49802. declare module BABYLON {
  49803. /** @hidden */
  49804. export var depthOfFieldPixelShader: {
  49805. name: string;
  49806. shader: string;
  49807. };
  49808. }
  49809. declare module BABYLON {
  49810. /**
  49811. * BABYLON.JS Chromatic Aberration GLSL Shader
  49812. * Author: Olivier Guyot
  49813. * Separates very slightly R, G and B colors on the edges of the screen
  49814. * Inspired by Francois Tarlier & Martins Upitis
  49815. */
  49816. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  49817. /**
  49818. * @ignore
  49819. * The chromatic aberration PostProcess id in the pipeline
  49820. */
  49821. LensChromaticAberrationEffect: string;
  49822. /**
  49823. * @ignore
  49824. * The highlights enhancing PostProcess id in the pipeline
  49825. */
  49826. HighlightsEnhancingEffect: string;
  49827. /**
  49828. * @ignore
  49829. * The depth-of-field PostProcess id in the pipeline
  49830. */
  49831. LensDepthOfFieldEffect: string;
  49832. private _scene;
  49833. private _depthTexture;
  49834. private _grainTexture;
  49835. private _chromaticAberrationPostProcess;
  49836. private _highlightsPostProcess;
  49837. private _depthOfFieldPostProcess;
  49838. private _edgeBlur;
  49839. private _grainAmount;
  49840. private _chromaticAberration;
  49841. private _distortion;
  49842. private _highlightsGain;
  49843. private _highlightsThreshold;
  49844. private _dofDistance;
  49845. private _dofAperture;
  49846. private _dofDarken;
  49847. private _dofPentagon;
  49848. private _blurNoise;
  49849. /**
  49850. * @constructor
  49851. *
  49852. * Effect parameters are as follow:
  49853. * {
  49854. * chromatic_aberration: number; // from 0 to x (1 for realism)
  49855. * edge_blur: number; // from 0 to x (1 for realism)
  49856. * distortion: number; // from 0 to x (1 for realism)
  49857. * grain_amount: number; // from 0 to 1
  49858. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  49859. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  49860. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  49861. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  49862. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  49863. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  49864. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  49865. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  49866. * }
  49867. * Note: if an effect parameter is unset, effect is disabled
  49868. *
  49869. * @param name The rendering pipeline name
  49870. * @param parameters - An object containing all parameters (see above)
  49871. * @param scene The scene linked to this pipeline
  49872. * @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)
  49873. * @param cameras The array of cameras that the rendering pipeline will be attached to
  49874. */
  49875. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  49876. /**
  49877. * Sets the amount of blur at the edges
  49878. * @param amount blur amount
  49879. */
  49880. setEdgeBlur(amount: number): void;
  49881. /**
  49882. * Sets edge blur to 0
  49883. */
  49884. disableEdgeBlur(): void;
  49885. /**
  49886. * Sets the amout of grain
  49887. * @param amount Amount of grain
  49888. */
  49889. setGrainAmount(amount: number): void;
  49890. /**
  49891. * Set grain amount to 0
  49892. */
  49893. disableGrain(): void;
  49894. /**
  49895. * Sets the chromatic aberration amount
  49896. * @param amount amount of chromatic aberration
  49897. */
  49898. setChromaticAberration(amount: number): void;
  49899. /**
  49900. * Sets chromatic aberration amount to 0
  49901. */
  49902. disableChromaticAberration(): void;
  49903. /**
  49904. * Sets the EdgeDistortion amount
  49905. * @param amount amount of EdgeDistortion
  49906. */
  49907. setEdgeDistortion(amount: number): void;
  49908. /**
  49909. * Sets edge distortion to 0
  49910. */
  49911. disableEdgeDistortion(): void;
  49912. /**
  49913. * Sets the FocusDistance amount
  49914. * @param amount amount of FocusDistance
  49915. */
  49916. setFocusDistance(amount: number): void;
  49917. /**
  49918. * Disables depth of field
  49919. */
  49920. disableDepthOfField(): void;
  49921. /**
  49922. * Sets the Aperture amount
  49923. * @param amount amount of Aperture
  49924. */
  49925. setAperture(amount: number): void;
  49926. /**
  49927. * Sets the DarkenOutOfFocus amount
  49928. * @param amount amount of DarkenOutOfFocus
  49929. */
  49930. setDarkenOutOfFocus(amount: number): void;
  49931. /**
  49932. * Creates a pentagon bokeh effect
  49933. */
  49934. enablePentagonBokeh(): void;
  49935. /**
  49936. * Disables the pentagon bokeh effect
  49937. */
  49938. disablePentagonBokeh(): void;
  49939. /**
  49940. * Enables noise blur
  49941. */
  49942. enableNoiseBlur(): void;
  49943. /**
  49944. * Disables noise blur
  49945. */
  49946. disableNoiseBlur(): void;
  49947. /**
  49948. * Sets the HighlightsGain amount
  49949. * @param amount amount of HighlightsGain
  49950. */
  49951. setHighlightsGain(amount: number): void;
  49952. /**
  49953. * Sets the HighlightsThreshold amount
  49954. * @param amount amount of HighlightsThreshold
  49955. */
  49956. setHighlightsThreshold(amount: number): void;
  49957. /**
  49958. * Disables highlights
  49959. */
  49960. disableHighlights(): void;
  49961. /**
  49962. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  49963. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  49964. */
  49965. dispose(disableDepthRender?: boolean): void;
  49966. private _createChromaticAberrationPostProcess;
  49967. private _createHighlightsPostProcess;
  49968. private _createDepthOfFieldPostProcess;
  49969. private _createGrainTexture;
  49970. }
  49971. }
  49972. declare module BABYLON {
  49973. /** @hidden */
  49974. export var ssao2PixelShader: {
  49975. name: string;
  49976. shader: string;
  49977. };
  49978. }
  49979. declare module BABYLON {
  49980. /** @hidden */
  49981. export var ssaoCombinePixelShader: {
  49982. name: string;
  49983. shader: string;
  49984. };
  49985. }
  49986. declare module BABYLON {
  49987. /**
  49988. * Render pipeline to produce ssao effect
  49989. */
  49990. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  49991. /**
  49992. * @ignore
  49993. * The PassPostProcess id in the pipeline that contains the original scene color
  49994. */
  49995. SSAOOriginalSceneColorEffect: string;
  49996. /**
  49997. * @ignore
  49998. * The SSAO PostProcess id in the pipeline
  49999. */
  50000. SSAORenderEffect: string;
  50001. /**
  50002. * @ignore
  50003. * The horizontal blur PostProcess id in the pipeline
  50004. */
  50005. SSAOBlurHRenderEffect: string;
  50006. /**
  50007. * @ignore
  50008. * The vertical blur PostProcess id in the pipeline
  50009. */
  50010. SSAOBlurVRenderEffect: string;
  50011. /**
  50012. * @ignore
  50013. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50014. */
  50015. SSAOCombineRenderEffect: string;
  50016. /**
  50017. * The output strength of the SSAO post-process. Default value is 1.0.
  50018. */
  50019. totalStrength: number;
  50020. /**
  50021. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  50022. */
  50023. maxZ: number;
  50024. /**
  50025. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  50026. */
  50027. minZAspect: number;
  50028. private _samples;
  50029. /**
  50030. * Number of samples used for the SSAO calculations. Default value is 8
  50031. */
  50032. samples: number;
  50033. private _textureSamples;
  50034. /**
  50035. * Number of samples to use for antialiasing
  50036. */
  50037. textureSamples: number;
  50038. /**
  50039. * Ratio object used for SSAO ratio and blur ratio
  50040. */
  50041. private _ratio;
  50042. /**
  50043. * Dynamically generated sphere sampler.
  50044. */
  50045. private _sampleSphere;
  50046. /**
  50047. * Blur filter offsets
  50048. */
  50049. private _samplerOffsets;
  50050. private _expensiveBlur;
  50051. /**
  50052. * If bilateral blur should be used
  50053. */
  50054. expensiveBlur: boolean;
  50055. /**
  50056. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  50057. */
  50058. radius: number;
  50059. /**
  50060. * The base color of the SSAO post-process
  50061. * The final result is "base + ssao" between [0, 1]
  50062. */
  50063. base: number;
  50064. /**
  50065. * Support test.
  50066. */
  50067. static readonly IsSupported: boolean;
  50068. private _scene;
  50069. private _depthTexture;
  50070. private _normalTexture;
  50071. private _randomTexture;
  50072. private _originalColorPostProcess;
  50073. private _ssaoPostProcess;
  50074. private _blurHPostProcess;
  50075. private _blurVPostProcess;
  50076. private _ssaoCombinePostProcess;
  50077. private _firstUpdate;
  50078. /**
  50079. * @constructor
  50080. * @param name The rendering pipeline name
  50081. * @param scene The scene linked to this pipeline
  50082. * @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 }
  50083. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50084. */
  50085. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50086. /**
  50087. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50088. */
  50089. dispose(disableGeometryBufferRenderer?: boolean): void;
  50090. private _createBlurPostProcess;
  50091. /** @hidden */ rebuild(): void;
  50092. private _bits;
  50093. private _radicalInverse_VdC;
  50094. private _hammersley;
  50095. private _hemisphereSample_uniform;
  50096. private _generateHemisphere;
  50097. private _createSSAOPostProcess;
  50098. private _createSSAOCombinePostProcess;
  50099. private _createRandomTexture;
  50100. /**
  50101. * Serialize the rendering pipeline (Used when exporting)
  50102. * @returns the serialized object
  50103. */
  50104. serialize(): any;
  50105. /**
  50106. * Parse the serialized pipeline
  50107. * @param source Source pipeline.
  50108. * @param scene The scene to load the pipeline to.
  50109. * @param rootUrl The URL of the serialized pipeline.
  50110. * @returns An instantiated pipeline from the serialized object.
  50111. */
  50112. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  50113. }
  50114. }
  50115. declare module BABYLON {
  50116. /** @hidden */
  50117. export var ssaoPixelShader: {
  50118. name: string;
  50119. shader: string;
  50120. };
  50121. }
  50122. declare module BABYLON {
  50123. /**
  50124. * Render pipeline to produce ssao effect
  50125. */
  50126. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  50127. /**
  50128. * @ignore
  50129. * The PassPostProcess id in the pipeline that contains the original scene color
  50130. */
  50131. SSAOOriginalSceneColorEffect: string;
  50132. /**
  50133. * @ignore
  50134. * The SSAO PostProcess id in the pipeline
  50135. */
  50136. SSAORenderEffect: string;
  50137. /**
  50138. * @ignore
  50139. * The horizontal blur PostProcess id in the pipeline
  50140. */
  50141. SSAOBlurHRenderEffect: string;
  50142. /**
  50143. * @ignore
  50144. * The vertical blur PostProcess id in the pipeline
  50145. */
  50146. SSAOBlurVRenderEffect: string;
  50147. /**
  50148. * @ignore
  50149. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50150. */
  50151. SSAOCombineRenderEffect: string;
  50152. /**
  50153. * The output strength of the SSAO post-process. Default value is 1.0.
  50154. */
  50155. totalStrength: number;
  50156. /**
  50157. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  50158. */
  50159. radius: number;
  50160. /**
  50161. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  50162. * Must not be equal to fallOff and superior to fallOff.
  50163. * Default value is 0.975
  50164. */
  50165. area: number;
  50166. /**
  50167. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  50168. * Must not be equal to area and inferior to area.
  50169. * Default value is 0.0
  50170. */
  50171. fallOff: number;
  50172. /**
  50173. * The base color of the SSAO post-process
  50174. * The final result is "base + ssao" between [0, 1]
  50175. */
  50176. base: number;
  50177. private _scene;
  50178. private _depthTexture;
  50179. private _randomTexture;
  50180. private _originalColorPostProcess;
  50181. private _ssaoPostProcess;
  50182. private _blurHPostProcess;
  50183. private _blurVPostProcess;
  50184. private _ssaoCombinePostProcess;
  50185. private _firstUpdate;
  50186. /**
  50187. * @constructor
  50188. * @param name - The rendering pipeline name
  50189. * @param scene - The scene linked to this pipeline
  50190. * @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 }
  50191. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  50192. */
  50193. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50194. /**
  50195. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50196. */
  50197. dispose(disableDepthRender?: boolean): void;
  50198. private _createBlurPostProcess;
  50199. /** @hidden */ rebuild(): void;
  50200. private _createSSAOPostProcess;
  50201. private _createSSAOCombinePostProcess;
  50202. private _createRandomTexture;
  50203. }
  50204. }
  50205. declare module BABYLON {
  50206. /** @hidden */
  50207. export var standardPixelShader: {
  50208. name: string;
  50209. shader: string;
  50210. };
  50211. }
  50212. declare module BABYLON {
  50213. /**
  50214. * Standard rendering pipeline
  50215. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  50216. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  50217. */
  50218. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50219. /**
  50220. * Public members
  50221. */
  50222. /**
  50223. * Post-process which contains the original scene color before the pipeline applies all the effects
  50224. */
  50225. originalPostProcess: Nullable<PostProcess>;
  50226. /**
  50227. * Post-process used to down scale an image x4
  50228. */
  50229. downSampleX4PostProcess: Nullable<PostProcess>;
  50230. /**
  50231. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  50232. */
  50233. brightPassPostProcess: Nullable<PostProcess>;
  50234. /**
  50235. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  50236. */
  50237. blurHPostProcesses: PostProcess[];
  50238. /**
  50239. * Post-process array storing all the vertical blur post-processes used by the pipeline
  50240. */
  50241. blurVPostProcesses: PostProcess[];
  50242. /**
  50243. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  50244. */
  50245. textureAdderPostProcess: Nullable<PostProcess>;
  50246. /**
  50247. * Post-process used to create volumetric lighting effect
  50248. */
  50249. volumetricLightPostProcess: Nullable<PostProcess>;
  50250. /**
  50251. * Post-process used to smooth the previous volumetric light post-process on the X axis
  50252. */
  50253. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  50254. /**
  50255. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  50256. */
  50257. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  50258. /**
  50259. * Post-process used to merge the volumetric light effect and the real scene color
  50260. */
  50261. volumetricLightMergePostProces: Nullable<PostProcess>;
  50262. /**
  50263. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  50264. */
  50265. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  50266. /**
  50267. * Base post-process used to calculate the average luminance of the final image for HDR
  50268. */
  50269. luminancePostProcess: Nullable<PostProcess>;
  50270. /**
  50271. * Post-processes used to create down sample post-processes in order to get
  50272. * the average luminance of the final image for HDR
  50273. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  50274. */
  50275. luminanceDownSamplePostProcesses: PostProcess[];
  50276. /**
  50277. * Post-process used to create a HDR effect (light adaptation)
  50278. */
  50279. hdrPostProcess: Nullable<PostProcess>;
  50280. /**
  50281. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  50282. */
  50283. textureAdderFinalPostProcess: Nullable<PostProcess>;
  50284. /**
  50285. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  50286. */
  50287. lensFlareFinalPostProcess: Nullable<PostProcess>;
  50288. /**
  50289. * Post-process used to merge the final HDR post-process and the real scene color
  50290. */
  50291. hdrFinalPostProcess: Nullable<PostProcess>;
  50292. /**
  50293. * Post-process used to create a lens flare effect
  50294. */
  50295. lensFlarePostProcess: Nullable<PostProcess>;
  50296. /**
  50297. * Post-process that merges the result of the lens flare post-process and the real scene color
  50298. */
  50299. lensFlareComposePostProcess: Nullable<PostProcess>;
  50300. /**
  50301. * Post-process used to create a motion blur effect
  50302. */
  50303. motionBlurPostProcess: Nullable<PostProcess>;
  50304. /**
  50305. * Post-process used to create a depth of field effect
  50306. */
  50307. depthOfFieldPostProcess: Nullable<PostProcess>;
  50308. /**
  50309. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  50310. */
  50311. fxaaPostProcess: Nullable<FxaaPostProcess>;
  50312. /**
  50313. * Represents the brightness threshold in order to configure the illuminated surfaces
  50314. */
  50315. brightThreshold: number;
  50316. /**
  50317. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  50318. */
  50319. blurWidth: number;
  50320. /**
  50321. * Sets if the blur for highlighted surfaces must be only horizontal
  50322. */
  50323. horizontalBlur: boolean;
  50324. /**
  50325. * Sets the overall exposure used by the pipeline
  50326. */
  50327. exposure: number;
  50328. /**
  50329. * Texture used typically to simulate "dirty" on camera lens
  50330. */
  50331. lensTexture: Nullable<Texture>;
  50332. /**
  50333. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  50334. */
  50335. volumetricLightCoefficient: number;
  50336. /**
  50337. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  50338. */
  50339. volumetricLightPower: number;
  50340. /**
  50341. * Used the set the blur intensity to smooth the volumetric lights
  50342. */
  50343. volumetricLightBlurScale: number;
  50344. /**
  50345. * Light (spot or directional) used to generate the volumetric lights rays
  50346. * The source light must have a shadow generate so the pipeline can get its
  50347. * depth map
  50348. */
  50349. sourceLight: Nullable<SpotLight | DirectionalLight>;
  50350. /**
  50351. * For eye adaptation, represents the minimum luminance the eye can see
  50352. */
  50353. hdrMinimumLuminance: number;
  50354. /**
  50355. * For eye adaptation, represents the decrease luminance speed
  50356. */
  50357. hdrDecreaseRate: number;
  50358. /**
  50359. * For eye adaptation, represents the increase luminance speed
  50360. */
  50361. hdrIncreaseRate: number;
  50362. /**
  50363. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  50364. */
  50365. lensColorTexture: Nullable<Texture>;
  50366. /**
  50367. * The overall strengh for the lens flare effect
  50368. */
  50369. lensFlareStrength: number;
  50370. /**
  50371. * Dispersion coefficient for lens flare ghosts
  50372. */
  50373. lensFlareGhostDispersal: number;
  50374. /**
  50375. * Main lens flare halo width
  50376. */
  50377. lensFlareHaloWidth: number;
  50378. /**
  50379. * Based on the lens distortion effect, defines how much the lens flare result
  50380. * is distorted
  50381. */
  50382. lensFlareDistortionStrength: number;
  50383. /**
  50384. * Lens star texture must be used to simulate rays on the flares and is available
  50385. * in the documentation
  50386. */
  50387. lensStarTexture: Nullable<Texture>;
  50388. /**
  50389. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  50390. * flare effect by taking account of the dirt texture
  50391. */
  50392. lensFlareDirtTexture: Nullable<Texture>;
  50393. /**
  50394. * Represents the focal length for the depth of field effect
  50395. */
  50396. depthOfFieldDistance: number;
  50397. /**
  50398. * Represents the blur intensity for the blurred part of the depth of field effect
  50399. */
  50400. depthOfFieldBlurWidth: number;
  50401. /**
  50402. * For motion blur, defines how much the image is blurred by the movement
  50403. */
  50404. motionStrength: number;
  50405. /**
  50406. * List of animations for the pipeline (IAnimatable implementation)
  50407. */
  50408. animations: Animation[];
  50409. /**
  50410. * Private members
  50411. */
  50412. private _scene;
  50413. private _currentDepthOfFieldSource;
  50414. private _basePostProcess;
  50415. private _hdrCurrentLuminance;
  50416. private _floatTextureType;
  50417. private _ratio;
  50418. private _bloomEnabled;
  50419. private _depthOfFieldEnabled;
  50420. private _vlsEnabled;
  50421. private _lensFlareEnabled;
  50422. private _hdrEnabled;
  50423. private _motionBlurEnabled;
  50424. private _fxaaEnabled;
  50425. private _motionBlurSamples;
  50426. private _volumetricLightStepsCount;
  50427. private _samples;
  50428. /**
  50429. * @ignore
  50430. * Specifies if the bloom pipeline is enabled
  50431. */
  50432. BloomEnabled: boolean;
  50433. /**
  50434. * @ignore
  50435. * Specifies if the depth of field pipeline is enabed
  50436. */
  50437. DepthOfFieldEnabled: boolean;
  50438. /**
  50439. * @ignore
  50440. * Specifies if the lens flare pipeline is enabed
  50441. */
  50442. LensFlareEnabled: boolean;
  50443. /**
  50444. * @ignore
  50445. * Specifies if the HDR pipeline is enabled
  50446. */
  50447. HDREnabled: boolean;
  50448. /**
  50449. * @ignore
  50450. * Specifies if the volumetric lights scattering effect is enabled
  50451. */
  50452. VLSEnabled: boolean;
  50453. /**
  50454. * @ignore
  50455. * Specifies if the motion blur effect is enabled
  50456. */
  50457. MotionBlurEnabled: boolean;
  50458. /**
  50459. * Specifies if anti-aliasing is enabled
  50460. */
  50461. fxaaEnabled: boolean;
  50462. /**
  50463. * Specifies the number of steps used to calculate the volumetric lights
  50464. * Typically in interval [50, 200]
  50465. */
  50466. volumetricLightStepsCount: number;
  50467. /**
  50468. * Specifies the number of samples used for the motion blur effect
  50469. * Typically in interval [16, 64]
  50470. */
  50471. motionBlurSamples: number;
  50472. /**
  50473. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  50474. */
  50475. samples: number;
  50476. /**
  50477. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  50478. * @constructor
  50479. * @param name The rendering pipeline name
  50480. * @param scene The scene linked to this pipeline
  50481. * @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)
  50482. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  50483. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50484. */
  50485. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  50486. private _buildPipeline;
  50487. private _createDownSampleX4PostProcess;
  50488. private _createBrightPassPostProcess;
  50489. private _createBlurPostProcesses;
  50490. private _createTextureAdderPostProcess;
  50491. private _createVolumetricLightPostProcess;
  50492. private _createLuminancePostProcesses;
  50493. private _createHdrPostProcess;
  50494. private _createLensFlarePostProcess;
  50495. private _createDepthOfFieldPostProcess;
  50496. private _createMotionBlurPostProcess;
  50497. private _getDepthTexture;
  50498. private _disposePostProcesses;
  50499. /**
  50500. * Dispose of the pipeline and stop all post processes
  50501. */
  50502. dispose(): void;
  50503. /**
  50504. * Serialize the rendering pipeline (Used when exporting)
  50505. * @returns the serialized object
  50506. */
  50507. serialize(): any;
  50508. /**
  50509. * Parse the serialized pipeline
  50510. * @param source Source pipeline.
  50511. * @param scene The scene to load the pipeline to.
  50512. * @param rootUrl The URL of the serialized pipeline.
  50513. * @returns An instantiated pipeline from the serialized object.
  50514. */
  50515. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  50516. /**
  50517. * Luminance steps
  50518. */
  50519. static LuminanceSteps: number;
  50520. }
  50521. }
  50522. declare module BABYLON {
  50523. /**
  50524. * PostProcessRenderPipelineManager class
  50525. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  50526. */
  50527. export class PostProcessRenderPipelineManager {
  50528. private _renderPipelines;
  50529. /**
  50530. * Initializes a PostProcessRenderPipelineManager
  50531. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  50532. */
  50533. constructor();
  50534. /**
  50535. * Adds a pipeline to the manager
  50536. * @param renderPipeline The pipeline to add
  50537. */
  50538. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  50539. /**
  50540. * Attaches a camera to the pipeline
  50541. * @param renderPipelineName The name of the pipeline to attach to
  50542. * @param cameras the camera to attach
  50543. * @param unique if the camera can be attached multiple times to the pipeline
  50544. */
  50545. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  50546. /**
  50547. * Detaches a camera from the pipeline
  50548. * @param renderPipelineName The name of the pipeline to detach from
  50549. * @param cameras the camera to detach
  50550. */
  50551. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  50552. /**
  50553. * Enables an effect by name on a pipeline
  50554. * @param renderPipelineName the name of the pipeline to enable the effect in
  50555. * @param renderEffectName the name of the effect to enable
  50556. * @param cameras the cameras that the effect should be enabled on
  50557. */
  50558. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  50559. /**
  50560. * Disables an effect by name on a pipeline
  50561. * @param renderPipelineName the name of the pipeline to disable the effect in
  50562. * @param renderEffectName the name of the effect to disable
  50563. * @param cameras the cameras that the effect should be disabled on
  50564. */
  50565. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  50566. /**
  50567. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  50568. */
  50569. update(): void;
  50570. /** @hidden */ rebuild(): void;
  50571. /**
  50572. * Disposes of the manager and pipelines
  50573. */
  50574. dispose(): void;
  50575. }
  50576. }
  50577. declare module BABYLON {
  50578. interface Scene {
  50579. /** @hidden (Backing field) */ postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  50580. /**
  50581. * Gets the postprocess render pipeline manager
  50582. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  50583. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  50584. */
  50585. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  50586. }
  50587. /**
  50588. * Defines the Render Pipeline scene component responsible to rendering pipelines
  50589. */
  50590. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  50591. /**
  50592. * The component name helpfull to identify the component in the list of scene components.
  50593. */
  50594. readonly name: string;
  50595. /**
  50596. * The scene the component belongs to.
  50597. */
  50598. scene: Scene;
  50599. /**
  50600. * Creates a new instance of the component for the given scene
  50601. * @param scene Defines the scene to register the component in
  50602. */
  50603. constructor(scene: Scene);
  50604. /**
  50605. * Registers the component in a given scene
  50606. */
  50607. register(): void;
  50608. /**
  50609. * Rebuilds the elements related to this component in case of
  50610. * context lost for instance.
  50611. */
  50612. rebuild(): void;
  50613. /**
  50614. * Disposes the component and the associated ressources
  50615. */
  50616. dispose(): void;
  50617. private _gatherRenderTargets;
  50618. }
  50619. }
  50620. declare module BABYLON {
  50621. /** @hidden */
  50622. export var tonemapPixelShader: {
  50623. name: string;
  50624. shader: string;
  50625. };
  50626. }
  50627. declare module BABYLON {
  50628. /** Defines operator used for tonemapping */
  50629. export enum TonemappingOperator {
  50630. /** Hable */
  50631. Hable = 0,
  50632. /** Reinhard */
  50633. Reinhard = 1,
  50634. /** HejiDawson */
  50635. HejiDawson = 2,
  50636. /** Photographic */
  50637. Photographic = 3
  50638. }
  50639. /**
  50640. * Defines a post process to apply tone mapping
  50641. */
  50642. export class TonemapPostProcess extends PostProcess {
  50643. private _operator;
  50644. /** Defines the required exposure adjustement */
  50645. exposureAdjustment: number;
  50646. /**
  50647. * Creates a new TonemapPostProcess
  50648. * @param name defines the name of the postprocess
  50649. * @param _operator defines the operator to use
  50650. * @param exposureAdjustment defines the required exposure adjustement
  50651. * @param camera defines the camera to use (can be null)
  50652. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  50653. * @param engine defines the hosting engine (can be ignore if camera is set)
  50654. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  50655. */
  50656. constructor(name: string, _operator: TonemappingOperator,
  50657. /** Defines the required exposure adjustement */
  50658. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  50659. }
  50660. }
  50661. declare module BABYLON {
  50662. /** @hidden */
  50663. export var depthVertexShader: {
  50664. name: string;
  50665. shader: string;
  50666. };
  50667. }
  50668. declare module BABYLON {
  50669. /** @hidden */
  50670. export var volumetricLightScatteringPixelShader: {
  50671. name: string;
  50672. shader: string;
  50673. };
  50674. }
  50675. declare module BABYLON {
  50676. /** @hidden */
  50677. export var volumetricLightScatteringPassPixelShader: {
  50678. name: string;
  50679. shader: string;
  50680. };
  50681. }
  50682. declare module BABYLON {
  50683. /**
  50684. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  50685. */
  50686. export class VolumetricLightScatteringPostProcess extends PostProcess {
  50687. private _volumetricLightScatteringPass;
  50688. private _volumetricLightScatteringRTT;
  50689. private _viewPort;
  50690. private _screenCoordinates;
  50691. private _cachedDefines;
  50692. /**
  50693. * If not undefined, the mesh position is computed from the attached node position
  50694. */
  50695. attachedNode: {
  50696. position: Vector3;
  50697. };
  50698. /**
  50699. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  50700. */
  50701. customMeshPosition: Vector3;
  50702. /**
  50703. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  50704. */
  50705. useCustomMeshPosition: boolean;
  50706. /**
  50707. * If the post-process should inverse the light scattering direction
  50708. */
  50709. invert: boolean;
  50710. /**
  50711. * The internal mesh used by the post-process
  50712. */
  50713. mesh: Mesh;
  50714. /**
  50715. * @hidden
  50716. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  50717. */
  50718. useDiffuseColor: boolean;
  50719. /**
  50720. * Array containing the excluded meshes not rendered in the internal pass
  50721. */
  50722. excludedMeshes: AbstractMesh[];
  50723. /**
  50724. * Controls the overall intensity of the post-process
  50725. */
  50726. exposure: number;
  50727. /**
  50728. * Dissipates each sample's contribution in range [0, 1]
  50729. */
  50730. decay: number;
  50731. /**
  50732. * Controls the overall intensity of each sample
  50733. */
  50734. weight: number;
  50735. /**
  50736. * Controls the density of each sample
  50737. */
  50738. density: number;
  50739. /**
  50740. * @constructor
  50741. * @param name The post-process name
  50742. * @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)
  50743. * @param camera The camera that the post-process will be attached to
  50744. * @param mesh The mesh used to create the light scattering
  50745. * @param samples The post-process quality, default 100
  50746. * @param samplingModeThe post-process filtering mode
  50747. * @param engine The babylon engine
  50748. * @param reusable If the post-process is reusable
  50749. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  50750. */
  50751. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  50752. /**
  50753. * Returns the string "VolumetricLightScatteringPostProcess"
  50754. * @returns "VolumetricLightScatteringPostProcess"
  50755. */
  50756. getClassName(): string;
  50757. private _isReady;
  50758. /**
  50759. * Sets the new light position for light scattering effect
  50760. * @param position The new custom light position
  50761. */
  50762. setCustomMeshPosition(position: Vector3): void;
  50763. /**
  50764. * Returns the light position for light scattering effect
  50765. * @return Vector3 The custom light position
  50766. */
  50767. getCustomMeshPosition(): Vector3;
  50768. /**
  50769. * Disposes the internal assets and detaches the post-process from the camera
  50770. */
  50771. dispose(camera: Camera): void;
  50772. /**
  50773. * Returns the render target texture used by the post-process
  50774. * @return the render target texture used by the post-process
  50775. */
  50776. getPass(): RenderTargetTexture;
  50777. private _meshExcluded;
  50778. private _createPass;
  50779. private _updateMeshScreenCoordinates;
  50780. /**
  50781. * Creates a default mesh for the Volumeric Light Scattering post-process
  50782. * @param name The mesh name
  50783. * @param scene The scene where to create the mesh
  50784. * @return the default mesh
  50785. */
  50786. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  50787. }
  50788. }
  50789. declare module BABYLON {
  50790. interface Scene {
  50791. /** @hidden (Backing field) */ boundingBoxRenderer: BoundingBoxRenderer;
  50792. /** @hidden (Backing field) */ forceShowBoundingBoxes: boolean;
  50793. /**
  50794. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  50795. */
  50796. forceShowBoundingBoxes: boolean;
  50797. /**
  50798. * Gets the bounding box renderer associated with the scene
  50799. * @returns a BoundingBoxRenderer
  50800. */
  50801. getBoundingBoxRenderer(): BoundingBoxRenderer;
  50802. }
  50803. interface AbstractMesh {
  50804. /** @hidden (Backing field) */ showBoundingBox: boolean;
  50805. /**
  50806. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  50807. */
  50808. showBoundingBox: boolean;
  50809. }
  50810. /**
  50811. * Component responsible of rendering the bounding box of the meshes in a scene.
  50812. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  50813. */
  50814. export class BoundingBoxRenderer implements ISceneComponent {
  50815. /**
  50816. * The component name helpfull to identify the component in the list of scene components.
  50817. */
  50818. readonly name: string;
  50819. /**
  50820. * The scene the component belongs to.
  50821. */
  50822. scene: Scene;
  50823. /**
  50824. * Color of the bounding box lines placed in front of an object
  50825. */
  50826. frontColor: Color3;
  50827. /**
  50828. * Color of the bounding box lines placed behind an object
  50829. */
  50830. backColor: Color3;
  50831. /**
  50832. * Defines if the renderer should show the back lines or not
  50833. */
  50834. showBackLines: boolean;
  50835. /**
  50836. * @hidden
  50837. */
  50838. renderList: SmartArray<BoundingBox>;
  50839. private _colorShader;
  50840. private _vertexBuffers;
  50841. private _indexBuffer;
  50842. /**
  50843. * Instantiates a new bounding box renderer in a scene.
  50844. * @param scene the scene the renderer renders in
  50845. */
  50846. constructor(scene: Scene);
  50847. /**
  50848. * Registers the component in a given scene
  50849. */
  50850. register(): void;
  50851. private _evaluateSubMesh;
  50852. private _activeMesh;
  50853. private _prepareRessources;
  50854. private _createIndexBuffer;
  50855. /**
  50856. * Rebuilds the elements related to this component in case of
  50857. * context lost for instance.
  50858. */
  50859. rebuild(): void;
  50860. /**
  50861. * @hidden
  50862. */
  50863. reset(): void;
  50864. /**
  50865. * Render the bounding boxes of a specific rendering group
  50866. * @param renderingGroupId defines the rendering group to render
  50867. */
  50868. render(renderingGroupId: number): void;
  50869. /**
  50870. * In case of occlusion queries, we can render the occlusion bounding box through this method
  50871. * @param mesh Define the mesh to render the occlusion bounding box for
  50872. */
  50873. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  50874. /**
  50875. * Dispose and release the resources attached to this renderer.
  50876. */
  50877. dispose(): void;
  50878. }
  50879. }
  50880. declare module BABYLON {
  50881. /** @hidden */
  50882. export var depthPixelShader: {
  50883. name: string;
  50884. shader: string;
  50885. };
  50886. }
  50887. declare module BABYLON {
  50888. /**
  50889. * This represents a depth renderer in Babylon.
  50890. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  50891. */
  50892. export class DepthRenderer {
  50893. private _scene;
  50894. private _depthMap;
  50895. private _effect;
  50896. private _cachedDefines;
  50897. private _camera;
  50898. /**
  50899. * Specifiess that the depth renderer will only be used within
  50900. * the camera it is created for.
  50901. * This can help forcing its rendering during the camera processing.
  50902. */
  50903. useOnlyInActiveCamera: boolean;
  50904. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  50905. /**
  50906. * Instantiates a depth renderer
  50907. * @param scene The scene the renderer belongs to
  50908. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  50909. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  50910. */
  50911. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  50912. /**
  50913. * Creates the depth rendering effect and checks if the effect is ready.
  50914. * @param subMesh The submesh to be used to render the depth map of
  50915. * @param useInstances If multiple world instances should be used
  50916. * @returns if the depth renderer is ready to render the depth map
  50917. */
  50918. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50919. /**
  50920. * Gets the texture which the depth map will be written to.
  50921. * @returns The depth map texture
  50922. */
  50923. getDepthMap(): RenderTargetTexture;
  50924. /**
  50925. * Disposes of the depth renderer.
  50926. */
  50927. dispose(): void;
  50928. }
  50929. }
  50930. declare module BABYLON {
  50931. interface Scene {
  50932. /** @hidden (Backing field) */ depthRenderer: {
  50933. [id: string]: DepthRenderer;
  50934. };
  50935. /**
  50936. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  50937. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  50938. * @returns the created depth renderer
  50939. */
  50940. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  50941. /**
  50942. * Disables a depth renderer for a given camera
  50943. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  50944. */
  50945. disableDepthRenderer(camera?: Nullable<Camera>): void;
  50946. }
  50947. /**
  50948. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  50949. * in several rendering techniques.
  50950. */
  50951. export class DepthRendererSceneComponent implements ISceneComponent {
  50952. /**
  50953. * The component name helpfull to identify the component in the list of scene components.
  50954. */
  50955. readonly name: string;
  50956. /**
  50957. * The scene the component belongs to.
  50958. */
  50959. scene: Scene;
  50960. /**
  50961. * Creates a new instance of the component for the given scene
  50962. * @param scene Defines the scene to register the component in
  50963. */
  50964. constructor(scene: Scene);
  50965. /**
  50966. * Registers the component in a given scene
  50967. */
  50968. register(): void;
  50969. /**
  50970. * Rebuilds the elements related to this component in case of
  50971. * context lost for instance.
  50972. */
  50973. rebuild(): void;
  50974. /**
  50975. * Disposes the component and the associated ressources
  50976. */
  50977. dispose(): void;
  50978. private _gatherRenderTargets;
  50979. private _gatherActiveCameraRenderTargets;
  50980. }
  50981. }
  50982. declare module BABYLON {
  50983. interface Scene {
  50984. /** @hidden (Backing field) */ geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  50985. /**
  50986. * Gets or Sets the current geometry buffer associated to the scene.
  50987. */
  50988. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  50989. /**
  50990. * Enables a GeometryBufferRender and associates it with the scene
  50991. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  50992. * @returns the GeometryBufferRenderer
  50993. */
  50994. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  50995. /**
  50996. * Disables the GeometryBufferRender associated with the scene
  50997. */
  50998. disableGeometryBufferRenderer(): void;
  50999. }
  51000. /**
  51001. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  51002. * in several rendering techniques.
  51003. */
  51004. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  51005. /**
  51006. * The component name helpful to identify the component in the list of scene components.
  51007. */
  51008. readonly name: string;
  51009. /**
  51010. * The scene the component belongs to.
  51011. */
  51012. scene: Scene;
  51013. /**
  51014. * Creates a new instance of the component for the given scene
  51015. * @param scene Defines the scene to register the component in
  51016. */
  51017. constructor(scene: Scene);
  51018. /**
  51019. * Registers the component in a given scene
  51020. */
  51021. register(): void;
  51022. /**
  51023. * Rebuilds the elements related to this component in case of
  51024. * context lost for instance.
  51025. */
  51026. rebuild(): void;
  51027. /**
  51028. * Disposes the component and the associated ressources
  51029. */
  51030. dispose(): void;
  51031. private _gatherRenderTargets;
  51032. }
  51033. }
  51034. declare module BABYLON {
  51035. /** @hidden */
  51036. export var outlinePixelShader: {
  51037. name: string;
  51038. shader: string;
  51039. };
  51040. }
  51041. declare module BABYLON {
  51042. /** @hidden */
  51043. export var outlineVertexShader: {
  51044. name: string;
  51045. shader: string;
  51046. };
  51047. }
  51048. declare module BABYLON {
  51049. interface Scene {
  51050. /** @hidden */ outlineRenderer: OutlineRenderer;
  51051. /**
  51052. * Gets the outline renderer associated with the scene
  51053. * @returns a OutlineRenderer
  51054. */
  51055. getOutlineRenderer(): OutlineRenderer;
  51056. }
  51057. interface AbstractMesh {
  51058. /** @hidden (Backing field) */ renderOutline: boolean;
  51059. /**
  51060. * Gets or sets a boolean indicating if the outline must be rendered as well
  51061. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  51062. */
  51063. renderOutline: boolean;
  51064. /** @hidden (Backing field) */ renderOverlay: boolean;
  51065. /**
  51066. * Gets or sets a boolean indicating if the overlay must be rendered as well
  51067. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  51068. */
  51069. renderOverlay: boolean;
  51070. }
  51071. /**
  51072. * This class is responsible to draw bothe outline/overlay of meshes.
  51073. * It should not be used directly but through the available method on mesh.
  51074. */
  51075. export class OutlineRenderer implements ISceneComponent {
  51076. /**
  51077. * The name of the component. Each component must have a unique name.
  51078. */
  51079. name: string;
  51080. /**
  51081. * The scene the component belongs to.
  51082. */
  51083. scene: Scene;
  51084. /**
  51085. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  51086. */
  51087. zOffset: number;
  51088. private _engine;
  51089. private _effect;
  51090. private _cachedDefines;
  51091. private _savedDepthWrite;
  51092. /**
  51093. * Instantiates a new outline renderer. (There could be only one per scene).
  51094. * @param scene Defines the scene it belongs to
  51095. */
  51096. constructor(scene: Scene);
  51097. /**
  51098. * Register the component to one instance of a scene.
  51099. */
  51100. register(): void;
  51101. /**
  51102. * Rebuilds the elements related to this component in case of
  51103. * context lost for instance.
  51104. */
  51105. rebuild(): void;
  51106. /**
  51107. * Disposes the component and the associated ressources.
  51108. */
  51109. dispose(): void;
  51110. /**
  51111. * Renders the outline in the canvas.
  51112. * @param subMesh Defines the sumesh to render
  51113. * @param batch Defines the batch of meshes in case of instances
  51114. * @param useOverlay Defines if the rendering is for the overlay or the outline
  51115. */
  51116. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  51117. /**
  51118. * Returns whether or not the outline renderer is ready for a given submesh.
  51119. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  51120. * @param subMesh Defines the submesh to check readyness for
  51121. * @param useInstances Defines wheter wee are trying to render instances or not
  51122. * @returns true if ready otherwise false
  51123. */
  51124. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51125. private _beforeRenderingMesh;
  51126. private _afterRenderingMesh;
  51127. }
  51128. }
  51129. declare module BABYLON {
  51130. /**
  51131. * Defines the list of states available for a task inside a AssetsManager
  51132. */
  51133. export enum AssetTaskState {
  51134. /**
  51135. * Initialization
  51136. */
  51137. INIT = 0,
  51138. /**
  51139. * Running
  51140. */
  51141. RUNNING = 1,
  51142. /**
  51143. * Done
  51144. */
  51145. DONE = 2,
  51146. /**
  51147. * Error
  51148. */
  51149. ERROR = 3
  51150. }
  51151. /**
  51152. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  51153. */
  51154. export abstract class AbstractAssetTask {
  51155. /**
  51156. * Task name
  51157. */ name: string;
  51158. /**
  51159. * Callback called when the task is successful
  51160. */
  51161. onSuccess: (task: any) => void;
  51162. /**
  51163. * Callback called when the task is not successful
  51164. */
  51165. onError: (task: any, message?: string, exception?: any) => void;
  51166. /**
  51167. * Creates a new AssetsManager
  51168. * @param name defines the name of the task
  51169. */
  51170. constructor(
  51171. /**
  51172. * Task name
  51173. */ name: string);
  51174. private _isCompleted;
  51175. private _taskState;
  51176. private _errorObject;
  51177. /**
  51178. * Get if the task is completed
  51179. */
  51180. readonly isCompleted: boolean;
  51181. /**
  51182. * Gets the current state of the task
  51183. */
  51184. readonly taskState: AssetTaskState;
  51185. /**
  51186. * Gets the current error object (if task is in error)
  51187. */
  51188. readonly errorObject: {
  51189. message?: string;
  51190. exception?: any;
  51191. };
  51192. /**
  51193. * Internal only
  51194. * @hidden
  51195. */ setErrorObject(message?: string, exception?: any): void;
  51196. /**
  51197. * Execute the current task
  51198. * @param scene defines the scene where you want your assets to be loaded
  51199. * @param onSuccess is a callback called when the task is successfully executed
  51200. * @param onError is a callback called if an error occurs
  51201. */
  51202. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51203. /**
  51204. * Execute the current task
  51205. * @param scene defines the scene where you want your assets to be loaded
  51206. * @param onSuccess is a callback called when the task is successfully executed
  51207. * @param onError is a callback called if an error occurs
  51208. */
  51209. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51210. /**
  51211. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  51212. * This can be used with failed tasks that have the reason for failure fixed.
  51213. */
  51214. reset(): void;
  51215. private onErrorCallback;
  51216. private onDoneCallback;
  51217. }
  51218. /**
  51219. * Define the interface used by progress events raised during assets loading
  51220. */
  51221. export interface IAssetsProgressEvent {
  51222. /**
  51223. * Defines the number of remaining tasks to process
  51224. */
  51225. remainingCount: number;
  51226. /**
  51227. * Defines the total number of tasks
  51228. */
  51229. totalCount: number;
  51230. /**
  51231. * Defines the task that was just processed
  51232. */
  51233. task: AbstractAssetTask;
  51234. }
  51235. /**
  51236. * Class used to share progress information about assets loading
  51237. */
  51238. export class AssetsProgressEvent implements IAssetsProgressEvent {
  51239. /**
  51240. * Defines the number of remaining tasks to process
  51241. */
  51242. remainingCount: number;
  51243. /**
  51244. * Defines the total number of tasks
  51245. */
  51246. totalCount: number;
  51247. /**
  51248. * Defines the task that was just processed
  51249. */
  51250. task: AbstractAssetTask;
  51251. /**
  51252. * Creates a AssetsProgressEvent
  51253. * @param remainingCount defines the number of remaining tasks to process
  51254. * @param totalCount defines the total number of tasks
  51255. * @param task defines the task that was just processed
  51256. */
  51257. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  51258. }
  51259. /**
  51260. * Define a task used by AssetsManager to load meshes
  51261. */
  51262. export class MeshAssetTask extends AbstractAssetTask {
  51263. /**
  51264. * Defines the name of the task
  51265. */
  51266. name: string;
  51267. /**
  51268. * Defines the list of mesh's names you want to load
  51269. */
  51270. meshesNames: any;
  51271. /**
  51272. * Defines the root url to use as a base to load your meshes and associated resources
  51273. */
  51274. rootUrl: string;
  51275. /**
  51276. * Defines the filename of the scene to load from
  51277. */
  51278. sceneFilename: string;
  51279. /**
  51280. * Gets the list of loaded meshes
  51281. */
  51282. loadedMeshes: Array<AbstractMesh>;
  51283. /**
  51284. * Gets the list of loaded particle systems
  51285. */
  51286. loadedParticleSystems: Array<IParticleSystem>;
  51287. /**
  51288. * Gets the list of loaded skeletons
  51289. */
  51290. loadedSkeletons: Array<Skeleton>;
  51291. /**
  51292. * Gets the list of loaded animation groups
  51293. */
  51294. loadedAnimationGroups: Array<AnimationGroup>;
  51295. /**
  51296. * Callback called when the task is successful
  51297. */
  51298. onSuccess: (task: MeshAssetTask) => void;
  51299. /**
  51300. * Callback called when the task is successful
  51301. */
  51302. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  51303. /**
  51304. * Creates a new MeshAssetTask
  51305. * @param name defines the name of the task
  51306. * @param meshesNames defines the list of mesh's names you want to load
  51307. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  51308. * @param sceneFilename defines the filename of the scene to load from
  51309. */
  51310. constructor(
  51311. /**
  51312. * Defines the name of the task
  51313. */
  51314. name: string,
  51315. /**
  51316. * Defines the list of mesh's names you want to load
  51317. */
  51318. meshesNames: any,
  51319. /**
  51320. * Defines the root url to use as a base to load your meshes and associated resources
  51321. */
  51322. rootUrl: string,
  51323. /**
  51324. * Defines the filename of the scene to load from
  51325. */
  51326. sceneFilename: string);
  51327. /**
  51328. * Execute the current task
  51329. * @param scene defines the scene where you want your assets to be loaded
  51330. * @param onSuccess is a callback called when the task is successfully executed
  51331. * @param onError is a callback called if an error occurs
  51332. */
  51333. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51334. }
  51335. /**
  51336. * Define a task used by AssetsManager to load text content
  51337. */
  51338. export class TextFileAssetTask extends AbstractAssetTask {
  51339. /**
  51340. * Defines the name of the task
  51341. */
  51342. name: string;
  51343. /**
  51344. * Defines the location of the file to load
  51345. */
  51346. url: string;
  51347. /**
  51348. * Gets the loaded text string
  51349. */
  51350. text: string;
  51351. /**
  51352. * Callback called when the task is successful
  51353. */
  51354. onSuccess: (task: TextFileAssetTask) => void;
  51355. /**
  51356. * Callback called when the task is successful
  51357. */
  51358. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  51359. /**
  51360. * Creates a new TextFileAssetTask object
  51361. * @param name defines the name of the task
  51362. * @param url defines the location of the file to load
  51363. */
  51364. constructor(
  51365. /**
  51366. * Defines the name of the task
  51367. */
  51368. name: string,
  51369. /**
  51370. * Defines the location of the file to load
  51371. */
  51372. url: string);
  51373. /**
  51374. * Execute the current task
  51375. * @param scene defines the scene where you want your assets to be loaded
  51376. * @param onSuccess is a callback called when the task is successfully executed
  51377. * @param onError is a callback called if an error occurs
  51378. */
  51379. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51380. }
  51381. /**
  51382. * Define a task used by AssetsManager to load binary data
  51383. */
  51384. export class BinaryFileAssetTask extends AbstractAssetTask {
  51385. /**
  51386. * Defines the name of the task
  51387. */
  51388. name: string;
  51389. /**
  51390. * Defines the location of the file to load
  51391. */
  51392. url: string;
  51393. /**
  51394. * Gets the lodaded data (as an array buffer)
  51395. */
  51396. data: ArrayBuffer;
  51397. /**
  51398. * Callback called when the task is successful
  51399. */
  51400. onSuccess: (task: BinaryFileAssetTask) => void;
  51401. /**
  51402. * Callback called when the task is successful
  51403. */
  51404. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  51405. /**
  51406. * Creates a new BinaryFileAssetTask object
  51407. * @param name defines the name of the new task
  51408. * @param url defines the location of the file to load
  51409. */
  51410. constructor(
  51411. /**
  51412. * Defines the name of the task
  51413. */
  51414. name: string,
  51415. /**
  51416. * Defines the location of the file to load
  51417. */
  51418. url: string);
  51419. /**
  51420. * Execute the current task
  51421. * @param scene defines the scene where you want your assets to be loaded
  51422. * @param onSuccess is a callback called when the task is successfully executed
  51423. * @param onError is a callback called if an error occurs
  51424. */
  51425. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51426. }
  51427. /**
  51428. * Define a task used by AssetsManager to load images
  51429. */
  51430. export class ImageAssetTask extends AbstractAssetTask {
  51431. /**
  51432. * Defines the name of the task
  51433. */
  51434. name: string;
  51435. /**
  51436. * Defines the location of the image to load
  51437. */
  51438. url: string;
  51439. /**
  51440. * Gets the loaded images
  51441. */
  51442. image: HTMLImageElement;
  51443. /**
  51444. * Callback called when the task is successful
  51445. */
  51446. onSuccess: (task: ImageAssetTask) => void;
  51447. /**
  51448. * Callback called when the task is successful
  51449. */
  51450. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  51451. /**
  51452. * Creates a new ImageAssetTask
  51453. * @param name defines the name of the task
  51454. * @param url defines the location of the image to load
  51455. */
  51456. constructor(
  51457. /**
  51458. * Defines the name of the task
  51459. */
  51460. name: string,
  51461. /**
  51462. * Defines the location of the image to load
  51463. */
  51464. url: string);
  51465. /**
  51466. * Execute the current task
  51467. * @param scene defines the scene where you want your assets to be loaded
  51468. * @param onSuccess is a callback called when the task is successfully executed
  51469. * @param onError is a callback called if an error occurs
  51470. */
  51471. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51472. }
  51473. /**
  51474. * Defines the interface used by texture loading tasks
  51475. */
  51476. export interface ITextureAssetTask<TEX extends BaseTexture> {
  51477. /**
  51478. * Gets the loaded texture
  51479. */
  51480. texture: TEX;
  51481. }
  51482. /**
  51483. * Define a task used by AssetsManager to load 2D textures
  51484. */
  51485. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  51486. /**
  51487. * Defines the name of the task
  51488. */
  51489. name: string;
  51490. /**
  51491. * Defines the location of the file to load
  51492. */
  51493. url: string;
  51494. /**
  51495. * Defines if mipmap should not be generated (default is false)
  51496. */
  51497. noMipmap?: boolean | undefined;
  51498. /**
  51499. * Defines if texture must be inverted on Y axis (default is false)
  51500. */
  51501. invertY?: boolean | undefined;
  51502. /**
  51503. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  51504. */
  51505. samplingMode: number;
  51506. /**
  51507. * Gets the loaded texture
  51508. */
  51509. texture: Texture;
  51510. /**
  51511. * Callback called when the task is successful
  51512. */
  51513. onSuccess: (task: TextureAssetTask) => void;
  51514. /**
  51515. * Callback called when the task is successful
  51516. */
  51517. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  51518. /**
  51519. * Creates a new TextureAssetTask object
  51520. * @param name defines the name of the task
  51521. * @param url defines the location of the file to load
  51522. * @param noMipmap defines if mipmap should not be generated (default is false)
  51523. * @param invertY defines if texture must be inverted on Y axis (default is false)
  51524. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  51525. */
  51526. constructor(
  51527. /**
  51528. * Defines the name of the task
  51529. */
  51530. name: string,
  51531. /**
  51532. * Defines the location of the file to load
  51533. */
  51534. url: string,
  51535. /**
  51536. * Defines if mipmap should not be generated (default is false)
  51537. */
  51538. noMipmap?: boolean | undefined,
  51539. /**
  51540. * Defines if texture must be inverted on Y axis (default is false)
  51541. */
  51542. invertY?: boolean | undefined,
  51543. /**
  51544. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  51545. */
  51546. samplingMode?: number);
  51547. /**
  51548. * Execute the current task
  51549. * @param scene defines the scene where you want your assets to be loaded
  51550. * @param onSuccess is a callback called when the task is successfully executed
  51551. * @param onError is a callback called if an error occurs
  51552. */
  51553. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51554. }
  51555. /**
  51556. * Define a task used by AssetsManager to load cube textures
  51557. */
  51558. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  51559. /**
  51560. * Defines the name of the task
  51561. */
  51562. name: string;
  51563. /**
  51564. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  51565. */
  51566. url: string;
  51567. /**
  51568. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  51569. */
  51570. extensions?: string[] | undefined;
  51571. /**
  51572. * Defines if mipmaps should not be generated (default is false)
  51573. */
  51574. noMipmap?: boolean | undefined;
  51575. /**
  51576. * Defines the explicit list of files (undefined by default)
  51577. */
  51578. files?: string[] | undefined;
  51579. /**
  51580. * Gets the loaded texture
  51581. */
  51582. texture: CubeTexture;
  51583. /**
  51584. * Callback called when the task is successful
  51585. */
  51586. onSuccess: (task: CubeTextureAssetTask) => void;
  51587. /**
  51588. * Callback called when the task is successful
  51589. */
  51590. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  51591. /**
  51592. * Creates a new CubeTextureAssetTask
  51593. * @param name defines the name of the task
  51594. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  51595. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  51596. * @param noMipmap defines if mipmaps should not be generated (default is false)
  51597. * @param files defines the explicit list of files (undefined by default)
  51598. */
  51599. constructor(
  51600. /**
  51601. * Defines the name of the task
  51602. */
  51603. name: string,
  51604. /**
  51605. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  51606. */
  51607. url: string,
  51608. /**
  51609. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  51610. */
  51611. extensions?: string[] | undefined,
  51612. /**
  51613. * Defines if mipmaps should not be generated (default is false)
  51614. */
  51615. noMipmap?: boolean | undefined,
  51616. /**
  51617. * Defines the explicit list of files (undefined by default)
  51618. */
  51619. files?: string[] | undefined);
  51620. /**
  51621. * Execute the current task
  51622. * @param scene defines the scene where you want your assets to be loaded
  51623. * @param onSuccess is a callback called when the task is successfully executed
  51624. * @param onError is a callback called if an error occurs
  51625. */
  51626. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51627. }
  51628. /**
  51629. * Define a task used by AssetsManager to load HDR cube textures
  51630. */
  51631. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  51632. /**
  51633. * Defines the name of the task
  51634. */
  51635. name: string;
  51636. /**
  51637. * Defines the location of the file to load
  51638. */
  51639. url: string;
  51640. /**
  51641. * Defines the desired size (the more it increases the longer the generation will be)
  51642. */
  51643. size: number;
  51644. /**
  51645. * Defines if mipmaps should not be generated (default is false)
  51646. */
  51647. noMipmap: boolean;
  51648. /**
  51649. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  51650. */
  51651. generateHarmonics: boolean;
  51652. /**
  51653. * 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)
  51654. */
  51655. gammaSpace: boolean;
  51656. /**
  51657. * Internal Use Only
  51658. */
  51659. reserved: boolean;
  51660. /**
  51661. * Gets the loaded texture
  51662. */
  51663. texture: HDRCubeTexture;
  51664. /**
  51665. * Callback called when the task is successful
  51666. */
  51667. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  51668. /**
  51669. * Callback called when the task is successful
  51670. */
  51671. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  51672. /**
  51673. * Creates a new HDRCubeTextureAssetTask object
  51674. * @param name defines the name of the task
  51675. * @param url defines the location of the file to load
  51676. * @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.
  51677. * @param noMipmap defines if mipmaps should not be generated (default is false)
  51678. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  51679. * @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)
  51680. * @param reserved Internal use only
  51681. */
  51682. constructor(
  51683. /**
  51684. * Defines the name of the task
  51685. */
  51686. name: string,
  51687. /**
  51688. * Defines the location of the file to load
  51689. */
  51690. url: string,
  51691. /**
  51692. * Defines the desired size (the more it increases the longer the generation will be)
  51693. */
  51694. size: number,
  51695. /**
  51696. * Defines if mipmaps should not be generated (default is false)
  51697. */
  51698. noMipmap?: boolean,
  51699. /**
  51700. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  51701. */
  51702. generateHarmonics?: boolean,
  51703. /**
  51704. * 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)
  51705. */
  51706. gammaSpace?: boolean,
  51707. /**
  51708. * Internal Use Only
  51709. */
  51710. reserved?: boolean);
  51711. /**
  51712. * Execute the current task
  51713. * @param scene defines the scene where you want your assets to be loaded
  51714. * @param onSuccess is a callback called when the task is successfully executed
  51715. * @param onError is a callback called if an error occurs
  51716. */
  51717. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51718. }
  51719. /**
  51720. * This class can be used to easily import assets into a scene
  51721. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  51722. */
  51723. export class AssetsManager {
  51724. private _scene;
  51725. private _isLoading;
  51726. protected _tasks: AbstractAssetTask[];
  51727. protected _waitingTasksCount: number;
  51728. protected _totalTasksCount: number;
  51729. /**
  51730. * Callback called when all tasks are processed
  51731. */
  51732. onFinish: (tasks: AbstractAssetTask[]) => void;
  51733. /**
  51734. * Callback called when a task is successful
  51735. */
  51736. onTaskSuccess: (task: AbstractAssetTask) => void;
  51737. /**
  51738. * Callback called when a task had an error
  51739. */
  51740. onTaskError: (task: AbstractAssetTask) => void;
  51741. /**
  51742. * Callback called when a task is done (whatever the result is)
  51743. */
  51744. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  51745. /**
  51746. * Observable called when all tasks are processed
  51747. */
  51748. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  51749. /**
  51750. * Observable called when a task had an error
  51751. */
  51752. onTaskErrorObservable: Observable<AbstractAssetTask>;
  51753. /**
  51754. * Observable called when a task is successful
  51755. */
  51756. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  51757. /**
  51758. * Observable called when a task is done (whatever the result is)
  51759. */
  51760. onProgressObservable: Observable<IAssetsProgressEvent>;
  51761. /**
  51762. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  51763. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  51764. */
  51765. useDefaultLoadingScreen: boolean;
  51766. /**
  51767. * Creates a new AssetsManager
  51768. * @param scene defines the scene to work on
  51769. */
  51770. constructor(scene: Scene);
  51771. /**
  51772. * Add a MeshAssetTask to the list of active tasks
  51773. * @param taskName defines the name of the new task
  51774. * @param meshesNames defines the name of meshes to load
  51775. * @param rootUrl defines the root url to use to locate files
  51776. * @param sceneFilename defines the filename of the scene file
  51777. * @returns a new MeshAssetTask object
  51778. */
  51779. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  51780. /**
  51781. * Add a TextFileAssetTask to the list of active tasks
  51782. * @param taskName defines the name of the new task
  51783. * @param url defines the url of the file to load
  51784. * @returns a new TextFileAssetTask object
  51785. */
  51786. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  51787. /**
  51788. * Add a BinaryFileAssetTask to the list of active tasks
  51789. * @param taskName defines the name of the new task
  51790. * @param url defines the url of the file to load
  51791. * @returns a new BinaryFileAssetTask object
  51792. */
  51793. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  51794. /**
  51795. * Add a ImageAssetTask to the list of active tasks
  51796. * @param taskName defines the name of the new task
  51797. * @param url defines the url of the file to load
  51798. * @returns a new ImageAssetTask object
  51799. */
  51800. addImageTask(taskName: string, url: string): ImageAssetTask;
  51801. /**
  51802. * Add a TextureAssetTask to the list of active tasks
  51803. * @param taskName defines the name of the new task
  51804. * @param url defines the url of the file to load
  51805. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  51806. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  51807. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51808. * @returns a new TextureAssetTask object
  51809. */
  51810. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  51811. /**
  51812. * Add a CubeTextureAssetTask to the list of active tasks
  51813. * @param taskName defines the name of the new task
  51814. * @param url defines the url of the file to load
  51815. * @param extensions defines the extension to use to load the cube map (can be null)
  51816. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  51817. * @param files defines the list of files to load (can be null)
  51818. * @returns a new CubeTextureAssetTask object
  51819. */
  51820. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  51821. /**
  51822. *
  51823. * Add a HDRCubeTextureAssetTask to the list of active tasks
  51824. * @param taskName defines the name of the new task
  51825. * @param url defines the url of the file to load
  51826. * @param size defines the size you want for the cubemap (can be null)
  51827. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  51828. * @param generateHarmonics defines if you want to automatically generate (true by default)
  51829. * @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)
  51830. * @param reserved Internal use only
  51831. * @returns a new HDRCubeTextureAssetTask object
  51832. */
  51833. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  51834. /**
  51835. * Remove a task from the assets manager.
  51836. * @param task the task to remove
  51837. */
  51838. removeTask(task: AbstractAssetTask): void;
  51839. private _decreaseWaitingTasksCount;
  51840. private _runTask;
  51841. /**
  51842. * Reset the AssetsManager and remove all tasks
  51843. * @return the current instance of the AssetsManager
  51844. */
  51845. reset(): AssetsManager;
  51846. /**
  51847. * Start the loading process
  51848. * @return the current instance of the AssetsManager
  51849. */
  51850. load(): AssetsManager;
  51851. }
  51852. }
  51853. declare module BABYLON {
  51854. /**
  51855. * Wrapper class for promise with external resolve and reject.
  51856. */
  51857. export class Deferred<T> {
  51858. /**
  51859. * The promise associated with this deferred object.
  51860. */
  51861. readonly promise: Promise<T>;
  51862. private _resolve;
  51863. private _reject;
  51864. /**
  51865. * The resolve method of the promise associated with this deferred object.
  51866. */
  51867. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  51868. /**
  51869. * The reject method of the promise associated with this deferred object.
  51870. */
  51871. readonly reject: (reason?: any) => void;
  51872. /**
  51873. * Constructor for this deferred object.
  51874. */
  51875. constructor();
  51876. }
  51877. }
  51878. declare module BABYLON {
  51879. /**
  51880. * Class used to help managing file picking and drag'n'drop
  51881. */
  51882. export class FilesInput {
  51883. /**
  51884. * List of files ready to be loaded
  51885. */
  51886. static readonly FilesToLoad: {
  51887. [key: string]: File;
  51888. };
  51889. /**
  51890. * Callback called when a file is processed
  51891. */
  51892. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  51893. private _engine;
  51894. private _currentScene;
  51895. private _sceneLoadedCallback;
  51896. private _progressCallback;
  51897. private _additionalRenderLoopLogicCallback;
  51898. private _textureLoadingCallback;
  51899. private _startingProcessingFilesCallback;
  51900. private _onReloadCallback;
  51901. private _errorCallback;
  51902. private _elementToMonitor;
  51903. private _sceneFileToLoad;
  51904. private _filesToLoad;
  51905. /**
  51906. * Creates a new FilesInput
  51907. * @param engine defines the rendering engine
  51908. * @param scene defines the hosting scene
  51909. * @param sceneLoadedCallback callback called when scene is loaded
  51910. * @param progressCallback callback called to track progress
  51911. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  51912. * @param textureLoadingCallback callback called when a texture is loading
  51913. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  51914. * @param onReloadCallback callback called when a reload is requested
  51915. * @param errorCallback callback call if an error occurs
  51916. */
  51917. 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);
  51918. private _dragEnterHandler;
  51919. private _dragOverHandler;
  51920. private _dropHandler;
  51921. /**
  51922. * Calls this function to listen to drag'n'drop events on a specific DOM element
  51923. * @param elementToMonitor defines the DOM element to track
  51924. */
  51925. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  51926. /**
  51927. * Release all associated resources
  51928. */
  51929. dispose(): void;
  51930. private renderFunction;
  51931. private drag;
  51932. private drop;
  51933. private _traverseFolder;
  51934. private _processFiles;
  51935. /**
  51936. * Load files from a drop event
  51937. * @param event defines the drop event to use as source
  51938. */
  51939. loadFiles(event: any): void;
  51940. private _processReload;
  51941. /**
  51942. * Reload the current scene from the loaded files
  51943. */
  51944. reload(): void;
  51945. }
  51946. }
  51947. declare module BABYLON {
  51948. /**
  51949. * Defines the root class used to create scene optimization to use with SceneOptimizer
  51950. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  51951. */
  51952. export class SceneOptimization {
  51953. /**
  51954. * Defines the priority of this optimization (0 by default which means first in the list)
  51955. */
  51956. priority: number;
  51957. /**
  51958. * Gets a string describing the action executed by the current optimization
  51959. * @returns description string
  51960. */
  51961. getDescription(): string;
  51962. /**
  51963. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  51964. * @param scene defines the current scene where to apply this optimization
  51965. * @param optimizer defines the current optimizer
  51966. * @returns true if everything that can be done was applied
  51967. */
  51968. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  51969. /**
  51970. * Creates the SceneOptimization object
  51971. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  51972. * @param desc defines the description associated with the optimization
  51973. */
  51974. constructor(
  51975. /**
  51976. * Defines the priority of this optimization (0 by default which means first in the list)
  51977. */
  51978. priority?: number);
  51979. }
  51980. /**
  51981. * Defines an optimization used to reduce the size of render target textures
  51982. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  51983. */
  51984. export class TextureOptimization extends SceneOptimization {
  51985. /**
  51986. * Defines the priority of this optimization (0 by default which means first in the list)
  51987. */
  51988. priority: number;
  51989. /**
  51990. * 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
  51991. */
  51992. maximumSize: number;
  51993. /**
  51994. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  51995. */
  51996. step: number;
  51997. /**
  51998. * Gets a string describing the action executed by the current optimization
  51999. * @returns description string
  52000. */
  52001. getDescription(): string;
  52002. /**
  52003. * Creates the TextureOptimization object
  52004. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  52005. * @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
  52006. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  52007. */
  52008. constructor(
  52009. /**
  52010. * Defines the priority of this optimization (0 by default which means first in the list)
  52011. */
  52012. priority?: number,
  52013. /**
  52014. * 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
  52015. */
  52016. maximumSize?: number,
  52017. /**
  52018. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  52019. */
  52020. step?: number);
  52021. /**
  52022. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52023. * @param scene defines the current scene where to apply this optimization
  52024. * @param optimizer defines the current optimizer
  52025. * @returns true if everything that can be done was applied
  52026. */
  52027. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52028. }
  52029. /**
  52030. * Defines an optimization used to increase or decrease the rendering resolution
  52031. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52032. */
  52033. export class HardwareScalingOptimization extends SceneOptimization {
  52034. /**
  52035. * Defines the priority of this optimization (0 by default which means first in the list)
  52036. */
  52037. priority: number;
  52038. /**
  52039. * Defines the maximum scale to use (2 by default)
  52040. */
  52041. maximumScale: number;
  52042. /**
  52043. * Defines the step to use between two passes (0.5 by default)
  52044. */
  52045. step: number;
  52046. private _currentScale;
  52047. private _directionOffset;
  52048. /**
  52049. * Gets a string describing the action executed by the current optimization
  52050. * @return description string
  52051. */
  52052. getDescription(): string;
  52053. /**
  52054. * Creates the HardwareScalingOptimization object
  52055. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  52056. * @param maximumScale defines the maximum scale to use (2 by default)
  52057. * @param step defines the step to use between two passes (0.5 by default)
  52058. */
  52059. constructor(
  52060. /**
  52061. * Defines the priority of this optimization (0 by default which means first in the list)
  52062. */
  52063. priority?: number,
  52064. /**
  52065. * Defines the maximum scale to use (2 by default)
  52066. */
  52067. maximumScale?: number,
  52068. /**
  52069. * Defines the step to use between two passes (0.5 by default)
  52070. */
  52071. step?: number);
  52072. /**
  52073. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52074. * @param scene defines the current scene where to apply this optimization
  52075. * @param optimizer defines the current optimizer
  52076. * @returns true if everything that can be done was applied
  52077. */
  52078. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52079. }
  52080. /**
  52081. * Defines an optimization used to remove shadows
  52082. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52083. */
  52084. export class ShadowsOptimization extends SceneOptimization {
  52085. /**
  52086. * Gets a string describing the action executed by the current optimization
  52087. * @return description string
  52088. */
  52089. getDescription(): string;
  52090. /**
  52091. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52092. * @param scene defines the current scene where to apply this optimization
  52093. * @param optimizer defines the current optimizer
  52094. * @returns true if everything that can be done was applied
  52095. */
  52096. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52097. }
  52098. /**
  52099. * Defines an optimization used to turn post-processes off
  52100. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52101. */
  52102. export class PostProcessesOptimization extends SceneOptimization {
  52103. /**
  52104. * Gets a string describing the action executed by the current optimization
  52105. * @return description string
  52106. */
  52107. getDescription(): string;
  52108. /**
  52109. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52110. * @param scene defines the current scene where to apply this optimization
  52111. * @param optimizer defines the current optimizer
  52112. * @returns true if everything that can be done was applied
  52113. */
  52114. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52115. }
  52116. /**
  52117. * Defines an optimization used to turn lens flares off
  52118. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52119. */
  52120. export class LensFlaresOptimization extends SceneOptimization {
  52121. /**
  52122. * Gets a string describing the action executed by the current optimization
  52123. * @return description string
  52124. */
  52125. getDescription(): string;
  52126. /**
  52127. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52128. * @param scene defines the current scene where to apply this optimization
  52129. * @param optimizer defines the current optimizer
  52130. * @returns true if everything that can be done was applied
  52131. */
  52132. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52133. }
  52134. /**
  52135. * Defines an optimization based on user defined callback.
  52136. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52137. */
  52138. export class CustomOptimization extends SceneOptimization {
  52139. /**
  52140. * Callback called to apply the custom optimization.
  52141. */
  52142. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  52143. /**
  52144. * Callback called to get custom description
  52145. */
  52146. onGetDescription: () => string;
  52147. /**
  52148. * Gets a string describing the action executed by the current optimization
  52149. * @returns description string
  52150. */
  52151. getDescription(): string;
  52152. /**
  52153. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52154. * @param scene defines the current scene where to apply this optimization
  52155. * @param optimizer defines the current optimizer
  52156. * @returns true if everything that can be done was applied
  52157. */
  52158. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52159. }
  52160. /**
  52161. * Defines an optimization used to turn particles off
  52162. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52163. */
  52164. export class ParticlesOptimization extends SceneOptimization {
  52165. /**
  52166. * Gets a string describing the action executed by the current optimization
  52167. * @return description string
  52168. */
  52169. getDescription(): string;
  52170. /**
  52171. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52172. * @param scene defines the current scene where to apply this optimization
  52173. * @param optimizer defines the current optimizer
  52174. * @returns true if everything that can be done was applied
  52175. */
  52176. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52177. }
  52178. /**
  52179. * Defines an optimization used to turn render targets off
  52180. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52181. */
  52182. export class RenderTargetsOptimization extends SceneOptimization {
  52183. /**
  52184. * Gets a string describing the action executed by the current optimization
  52185. * @return description string
  52186. */
  52187. getDescription(): string;
  52188. /**
  52189. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52190. * @param scene defines the current scene where to apply this optimization
  52191. * @param optimizer defines the current optimizer
  52192. * @returns true if everything that can be done was applied
  52193. */
  52194. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52195. }
  52196. /**
  52197. * Defines an optimization used to merge meshes with compatible materials
  52198. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52199. */
  52200. export class MergeMeshesOptimization extends SceneOptimization {
  52201. private static _UpdateSelectionTree;
  52202. /**
  52203. * Gets or sets a boolean which defines if optimization octree has to be updated
  52204. */
  52205. /**
  52206. * Gets or sets a boolean which defines if optimization octree has to be updated
  52207. */
  52208. static UpdateSelectionTree: boolean;
  52209. /**
  52210. * Gets a string describing the action executed by the current optimization
  52211. * @return description string
  52212. */
  52213. getDescription(): string;
  52214. private _canBeMerged;
  52215. /**
  52216. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52217. * @param scene defines the current scene where to apply this optimization
  52218. * @param optimizer defines the current optimizer
  52219. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  52220. * @returns true if everything that can be done was applied
  52221. */
  52222. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  52223. }
  52224. /**
  52225. * Defines a list of options used by SceneOptimizer
  52226. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52227. */
  52228. export class SceneOptimizerOptions {
  52229. /**
  52230. * Defines the target frame rate to reach (60 by default)
  52231. */
  52232. targetFrameRate: number;
  52233. /**
  52234. * Defines the interval between two checkes (2000ms by default)
  52235. */
  52236. trackerDuration: number;
  52237. /**
  52238. * Gets the list of optimizations to apply
  52239. */
  52240. optimizations: SceneOptimization[];
  52241. /**
  52242. * Creates a new list of options used by SceneOptimizer
  52243. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  52244. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  52245. */
  52246. constructor(
  52247. /**
  52248. * Defines the target frame rate to reach (60 by default)
  52249. */
  52250. targetFrameRate?: number,
  52251. /**
  52252. * Defines the interval between two checkes (2000ms by default)
  52253. */
  52254. trackerDuration?: number);
  52255. /**
  52256. * Add a new optimization
  52257. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  52258. * @returns the current SceneOptimizerOptions
  52259. */
  52260. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  52261. /**
  52262. * Add a new custom optimization
  52263. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  52264. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  52265. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  52266. * @returns the current SceneOptimizerOptions
  52267. */
  52268. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  52269. /**
  52270. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  52271. * @param targetFrameRate defines the target frame rate (60 by default)
  52272. * @returns a SceneOptimizerOptions object
  52273. */
  52274. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  52275. /**
  52276. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  52277. * @param targetFrameRate defines the target frame rate (60 by default)
  52278. * @returns a SceneOptimizerOptions object
  52279. */
  52280. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  52281. /**
  52282. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  52283. * @param targetFrameRate defines the target frame rate (60 by default)
  52284. * @returns a SceneOptimizerOptions object
  52285. */
  52286. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  52287. }
  52288. /**
  52289. * Class used to run optimizations in order to reach a target frame rate
  52290. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52291. */
  52292. export class SceneOptimizer implements IDisposable {
  52293. private _isRunning;
  52294. private _options;
  52295. private _scene;
  52296. private _currentPriorityLevel;
  52297. private _targetFrameRate;
  52298. private _trackerDuration;
  52299. private _currentFrameRate;
  52300. private _sceneDisposeObserver;
  52301. private _improvementMode;
  52302. /**
  52303. * Defines an observable called when the optimizer reaches the target frame rate
  52304. */
  52305. onSuccessObservable: Observable<SceneOptimizer>;
  52306. /**
  52307. * Defines an observable called when the optimizer enables an optimization
  52308. */
  52309. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  52310. /**
  52311. * Defines an observable called when the optimizer is not able to reach the target frame rate
  52312. */
  52313. onFailureObservable: Observable<SceneOptimizer>;
  52314. /**
  52315. * Gets a boolean indicating if the optimizer is in improvement mode
  52316. */
  52317. readonly isInImprovementMode: boolean;
  52318. /**
  52319. * Gets the current priority level (0 at start)
  52320. */
  52321. readonly currentPriorityLevel: number;
  52322. /**
  52323. * Gets the current frame rate checked by the SceneOptimizer
  52324. */
  52325. readonly currentFrameRate: number;
  52326. /**
  52327. * Gets or sets the current target frame rate (60 by default)
  52328. */
  52329. /**
  52330. * Gets or sets the current target frame rate (60 by default)
  52331. */
  52332. targetFrameRate: number;
  52333. /**
  52334. * Gets or sets the current interval between two checks (every 2000ms by default)
  52335. */
  52336. /**
  52337. * Gets or sets the current interval between two checks (every 2000ms by default)
  52338. */
  52339. trackerDuration: number;
  52340. /**
  52341. * Gets the list of active optimizations
  52342. */
  52343. readonly optimizations: SceneOptimization[];
  52344. /**
  52345. * Creates a new SceneOptimizer
  52346. * @param scene defines the scene to work on
  52347. * @param options defines the options to use with the SceneOptimizer
  52348. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  52349. * @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)
  52350. */
  52351. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  52352. /**
  52353. * Stops the current optimizer
  52354. */
  52355. stop(): void;
  52356. /**
  52357. * Reset the optimizer to initial step (current priority level = 0)
  52358. */
  52359. reset(): void;
  52360. /**
  52361. * Start the optimizer. By default it will try to reach a specific framerate
  52362. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  52363. */
  52364. start(): void;
  52365. private _checkCurrentState;
  52366. /**
  52367. * Release all resources
  52368. */
  52369. dispose(): void;
  52370. /**
  52371. * Helper function to create a SceneOptimizer with one single line of code
  52372. * @param scene defines the scene to work on
  52373. * @param options defines the options to use with the SceneOptimizer
  52374. * @param onSuccess defines a callback to call on success
  52375. * @param onFailure defines a callback to call on failure
  52376. * @returns the new SceneOptimizer object
  52377. */
  52378. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  52379. }
  52380. }
  52381. declare module BABYLON {
  52382. /**
  52383. * Class used to serialize a scene into a string
  52384. */
  52385. export class SceneSerializer {
  52386. /**
  52387. * Clear cache used by a previous serialization
  52388. */
  52389. static ClearCache(): void;
  52390. /**
  52391. * Serialize a scene into a JSON compatible object
  52392. * @param scene defines the scene to serialize
  52393. * @returns a JSON compatible object
  52394. */
  52395. static Serialize(scene: Scene): any;
  52396. /**
  52397. * Serialize a mesh into a JSON compatible object
  52398. * @param toSerialize defines the mesh to serialize
  52399. * @param withParents defines if parents must be serialized as well
  52400. * @param withChildren defines if children must be serialized as well
  52401. * @returns a JSON compatible object
  52402. */
  52403. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  52404. }
  52405. }
  52406. declare module BABYLON {
  52407. /**
  52408. * This represents the different options avilable for the video capture.
  52409. */
  52410. export interface VideoRecorderOptions {
  52411. /** Defines the mime type of the video */
  52412. mimeType: string;
  52413. /** Defines the video the video should be recorded at */
  52414. fps: number;
  52415. /** Defines the chunk size for the recording data */
  52416. recordChunckSize: number;
  52417. }
  52418. /**
  52419. * This can helps recording videos from BabylonJS.
  52420. * This is based on the available WebRTC functionalities of the browser.
  52421. *
  52422. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  52423. */
  52424. export class VideoRecorder {
  52425. private static readonly _defaultOptions;
  52426. /**
  52427. * Returns wehther or not the VideoRecorder is available in your browser.
  52428. * @param engine Defines the Babylon Engine to check the support for
  52429. * @returns true if supported otherwise false
  52430. */
  52431. static IsSupported(engine: Engine): boolean;
  52432. private readonly _options;
  52433. private _canvas;
  52434. private _mediaRecorder;
  52435. private _recordedChunks;
  52436. private _fileName;
  52437. private _resolve;
  52438. private _reject;
  52439. /**
  52440. * True wether a recording is already in progress.
  52441. */
  52442. readonly isRecording: boolean;
  52443. /**
  52444. * Create a new VideoCapture object which can help converting what you see in Babylon to
  52445. * a video file.
  52446. * @param engine Defines the BabylonJS Engine you wish to record
  52447. * @param options Defines options that can be used to customized the capture
  52448. */
  52449. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  52450. /**
  52451. * Stops the current recording before the default capture timeout passed in the startRecording
  52452. * functions.
  52453. */
  52454. stopRecording(): void;
  52455. /**
  52456. * Starts recording the canvas for a max duration specified in parameters.
  52457. * @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.
  52458. * @param maxDuration Defines the maximum recording time in seconds.
  52459. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  52460. * @return a promise callback at the end of the recording with the video data in Blob.
  52461. */
  52462. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  52463. /**
  52464. * Releases internal resources used during the recording.
  52465. */
  52466. dispose(): void;
  52467. private _handleDataAvailable;
  52468. private _handleError;
  52469. private _handleStop;
  52470. }
  52471. }
  52472. declare module BABYLON {
  52473. /**
  52474. * Helper class to push actions to a pool of workers.
  52475. */
  52476. export class WorkerPool implements IDisposable {
  52477. private _workerInfos;
  52478. private _pendingActions;
  52479. /**
  52480. * Constructor
  52481. * @param workers Array of workers to use for actions
  52482. */
  52483. constructor(workers: Array<Worker>);
  52484. /**
  52485. * Terminates all workers and clears any pending actions.
  52486. */
  52487. dispose(): void;
  52488. /**
  52489. * Pushes an action to the worker pool. If all the workers are active, the action will be
  52490. * pended until a worker has completed its action.
  52491. * @param action The action to perform. Call onComplete when the action is complete.
  52492. */
  52493. push(action: (worker: Worker, onComplete: () => void) => void): void;
  52494. private _execute;
  52495. }
  52496. }
  52497. declare module BABYLON {
  52498. /**
  52499. * Class containing a set of static utilities functions for screenshots
  52500. */
  52501. export class ScreenshotTools {
  52502. /**
  52503. * Captures a screenshot of the current rendering
  52504. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  52505. * @param engine defines the rendering engine
  52506. * @param camera defines the source camera
  52507. * @param size This parameter can be set to a single number or to an object with the
  52508. * following (optional) properties: precision, width, height. If a single number is passed,
  52509. * it will be used for both width and height. If an object is passed, the screenshot size
  52510. * will be derived from the parameters. The precision property is a multiplier allowing
  52511. * rendering at a higher or lower resolution
  52512. * @param successCallback defines the callback receives a single parameter which contains the
  52513. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  52514. * src parameter of an <img> to display it
  52515. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  52516. * Check your browser for supported MIME types
  52517. */
  52518. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  52519. /**
  52520. * Generates an image screenshot from the specified camera.
  52521. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  52522. * @param engine The engine to use for rendering
  52523. * @param camera The camera to use for rendering
  52524. * @param size This parameter can be set to a single number or to an object with the
  52525. * following (optional) properties: precision, width, height. If a single number is passed,
  52526. * it will be used for both width and height. If an object is passed, the screenshot size
  52527. * will be derived from the parameters. The precision property is a multiplier allowing
  52528. * rendering at a higher or lower resolution
  52529. * @param successCallback The callback receives a single parameter which contains the
  52530. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  52531. * src parameter of an <img> to display it
  52532. * @param mimeType The MIME type of the screenshot image (default: image/png).
  52533. * Check your browser for supported MIME types
  52534. * @param samples Texture samples (default: 1)
  52535. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  52536. * @param fileName A name for for the downloaded file.
  52537. */
  52538. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  52539. }
  52540. }
  52541. declare module BABYLON {
  52542. /**
  52543. * A cursor which tracks a point on a path
  52544. */
  52545. export class PathCursor {
  52546. private path;
  52547. /**
  52548. * Stores path cursor callbacks for when an onchange event is triggered
  52549. */
  52550. private _onchange;
  52551. /**
  52552. * The value of the path cursor
  52553. */
  52554. value: number;
  52555. /**
  52556. * The animation array of the path cursor
  52557. */
  52558. animations: Animation[];
  52559. /**
  52560. * Initializes the path cursor
  52561. * @param path The path to track
  52562. */
  52563. constructor(path: Path2);
  52564. /**
  52565. * Gets the cursor point on the path
  52566. * @returns A point on the path cursor at the cursor location
  52567. */
  52568. getPoint(): Vector3;
  52569. /**
  52570. * Moves the cursor ahead by the step amount
  52571. * @param step The amount to move the cursor forward
  52572. * @returns This path cursor
  52573. */
  52574. moveAhead(step?: number): PathCursor;
  52575. /**
  52576. * Moves the cursor behind by the step amount
  52577. * @param step The amount to move the cursor back
  52578. * @returns This path cursor
  52579. */
  52580. moveBack(step?: number): PathCursor;
  52581. /**
  52582. * Moves the cursor by the step amount
  52583. * If the step amount is greater than one, an exception is thrown
  52584. * @param step The amount to move the cursor
  52585. * @returns This path cursor
  52586. */
  52587. move(step: number): PathCursor;
  52588. /**
  52589. * Ensures that the value is limited between zero and one
  52590. * @returns This path cursor
  52591. */
  52592. private ensureLimits;
  52593. /**
  52594. * Runs onchange callbacks on change (used by the animation engine)
  52595. * @returns This path cursor
  52596. */
  52597. private raiseOnChange;
  52598. /**
  52599. * Executes a function on change
  52600. * @param f A path cursor onchange callback
  52601. * @returns This path cursor
  52602. */
  52603. onchange(f: (cursor: PathCursor) => void): PathCursor;
  52604. }
  52605. }
  52606. declare module BABYLON {
  52607. /** @hidden */
  52608. export var blurPixelShader: {
  52609. name: string;
  52610. shader: string;
  52611. };
  52612. }
  52613. declare module BABYLON {
  52614. /** @hidden */
  52615. export var bones300Declaration: {
  52616. name: string;
  52617. shader: string;
  52618. };
  52619. }
  52620. declare module BABYLON {
  52621. /** @hidden */
  52622. export var instances300Declaration: {
  52623. name: string;
  52624. shader: string;
  52625. };
  52626. }
  52627. declare module BABYLON {
  52628. /** @hidden */
  52629. export var pointCloudVertexDeclaration: {
  52630. name: string;
  52631. shader: string;
  52632. };
  52633. }
  52634. // Mixins
  52635. interface Window {
  52636. mozIndexedDB: IDBFactory;
  52637. webkitIndexedDB: IDBFactory;
  52638. msIndexedDB: IDBFactory;
  52639. webkitURL: typeof URL;
  52640. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  52641. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  52642. WebGLRenderingContext: WebGLRenderingContext;
  52643. MSGesture: MSGesture;
  52644. CANNON: any;
  52645. AudioContext: AudioContext;
  52646. webkitAudioContext: AudioContext;
  52647. PointerEvent: any;
  52648. Math: Math;
  52649. Uint8Array: Uint8ArrayConstructor;
  52650. Float32Array: Float32ArrayConstructor;
  52651. mozURL: typeof URL;
  52652. msURL: typeof URL;
  52653. VRFrameData: any; // WebVR, from specs 1.1
  52654. DracoDecoderModule: any;
  52655. setImmediate(handler: (...args: any[]) => void): number;
  52656. }
  52657. interface Document {
  52658. mozCancelFullScreen(): void;
  52659. msCancelFullScreen(): void;
  52660. webkitCancelFullScreen(): void;
  52661. requestPointerLock(): void;
  52662. exitPointerLock(): void;
  52663. mozFullScreen: boolean;
  52664. msIsFullScreen: boolean;
  52665. readonly webkitIsFullScreen: boolean;
  52666. readonly pointerLockElement: Element;
  52667. mozPointerLockElement: HTMLElement;
  52668. msPointerLockElement: HTMLElement;
  52669. webkitPointerLockElement: HTMLElement;
  52670. }
  52671. interface HTMLCanvasElement {
  52672. requestPointerLock(): void;
  52673. msRequestPointerLock?(): void;
  52674. mozRequestPointerLock?(): void;
  52675. webkitRequestPointerLock?(): void;
  52676. /** Track wether a record is in progress */
  52677. isRecording: boolean;
  52678. /** Capture Stream method defined by some browsers */
  52679. captureStream(fps?: number): MediaStream;
  52680. }
  52681. interface CanvasRenderingContext2D {
  52682. msImageSmoothingEnabled: boolean;
  52683. }
  52684. interface MouseEvent {
  52685. mozMovementX: number;
  52686. mozMovementY: number;
  52687. webkitMovementX: number;
  52688. webkitMovementY: number;
  52689. msMovementX: number;
  52690. msMovementY: number;
  52691. }
  52692. interface Navigator {
  52693. mozGetVRDevices: (any: any) => any;
  52694. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  52695. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  52696. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  52697. webkitGetGamepads(): Gamepad[];
  52698. msGetGamepads(): Gamepad[];
  52699. webkitGamepads(): Gamepad[];
  52700. }
  52701. interface HTMLVideoElement {
  52702. mozSrcObject: any;
  52703. }
  52704. interface Math {
  52705. fround(x: number): number;
  52706. imul(a: number, b: number): number;
  52707. }
  52708. interface WebGLProgram {
  52709. context?: WebGLRenderingContext;
  52710. vertexShader?: WebGLShader;
  52711. fragmentShader?: WebGLShader;
  52712. isParallelCompiled: boolean;
  52713. onCompiled?: () => void;
  52714. }
  52715. interface WebGLRenderingContext {
  52716. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  52717. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  52718. vertexAttribDivisor(index: number, divisor: number): void;
  52719. createVertexArray(): any;
  52720. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  52721. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  52722. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  52723. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  52724. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  52725. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  52726. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  52727. // Queries
  52728. createQuery(): WebGLQuery;
  52729. deleteQuery(query: WebGLQuery): void;
  52730. beginQuery(target: number, query: WebGLQuery): void;
  52731. endQuery(target: number): void;
  52732. getQueryParameter(query: WebGLQuery, pname: number): any;
  52733. getQuery(target: number, pname: number): any;
  52734. MAX_SAMPLES: number;
  52735. RGBA8: number;
  52736. READ_FRAMEBUFFER: number;
  52737. DRAW_FRAMEBUFFER: number;
  52738. UNIFORM_BUFFER: number;
  52739. HALF_FLOAT_OES: number;
  52740. RGBA16F: number;
  52741. RGBA32F: number;
  52742. R32F: number;
  52743. RG32F: number;
  52744. RGB32F: number;
  52745. R16F: number;
  52746. RG16F: number;
  52747. RGB16F: number;
  52748. RED: number;
  52749. RG: number;
  52750. R8: number;
  52751. RG8: number;
  52752. UNSIGNED_INT_24_8: number;
  52753. DEPTH24_STENCIL8: number;
  52754. /* Multiple Render Targets */
  52755. drawBuffers(buffers: number[]): void;
  52756. readBuffer(src: number): void;
  52757. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  52758. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  52759. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  52760. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  52761. // Occlusion Query
  52762. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  52763. ANY_SAMPLES_PASSED: number;
  52764. QUERY_RESULT_AVAILABLE: number;
  52765. QUERY_RESULT: number;
  52766. }
  52767. interface WebGLBuffer {
  52768. references: number;
  52769. capacity: number;
  52770. is32Bits: boolean;
  52771. }
  52772. interface WebGLProgram {
  52773. transformFeedback?: WebGLTransformFeedback | null; private _SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  52774. }
  52775. interface EXT_disjoint_timer_query {
  52776. QUERY_COUNTER_BITS_EXT: number;
  52777. TIME_ELAPSED_EXT: number;
  52778. TIMESTAMP_EXT: number;
  52779. GPU_DISJOINT_EXT: number;
  52780. QUERY_RESULT_EXT: number;
  52781. QUERY_RESULT_AVAILABLE_EXT: number;
  52782. queryCounterEXT(query: WebGLQuery, target: number): void;
  52783. createQueryEXT(): WebGLQuery;
  52784. beginQueryEXT(target: number, query: WebGLQuery): void;
  52785. endQueryEXT(target: number): void;
  52786. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  52787. deleteQueryEXT(query: WebGLQuery): void;
  52788. }
  52789. interface WebGLUniformLocation { currentState: any;
  52790. }
  52791. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  52792. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  52793. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  52794. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  52795. interface WebGLRenderingContext {
  52796. readonly RASTERIZER_DISCARD: number;
  52797. readonly DEPTH_COMPONENT24: number;
  52798. readonly TEXTURE_3D: number;
  52799. readonly TEXTURE_2D_ARRAY: number;
  52800. readonly TEXTURE_COMPARE_FUNC: number;
  52801. readonly TEXTURE_COMPARE_MODE: number;
  52802. readonly COMPARE_REF_TO_TEXTURE: number;
  52803. readonly TEXTURE_WRAP_R: number;
  52804. readonly HALF_FLOAT: number;
  52805. readonly RGB8: number;
  52806. readonly RED_INTEGER: number;
  52807. readonly RG_INTEGER: number;
  52808. readonly RGB_INTEGER: number;
  52809. readonly RGBA_INTEGER: number;
  52810. readonly R8_SNORM: number;
  52811. readonly RG8_SNORM: number;
  52812. readonly RGB8_SNORM: number;
  52813. readonly RGBA8_SNORM: number;
  52814. readonly R8I: number;
  52815. readonly RG8I: number;
  52816. readonly RGB8I: number;
  52817. readonly RGBA8I: number;
  52818. readonly R8UI: number;
  52819. readonly RG8UI: number;
  52820. readonly RGB8UI: number;
  52821. readonly RGBA8UI: number;
  52822. readonly R16I: number;
  52823. readonly RG16I: number;
  52824. readonly RGB16I: number;
  52825. readonly RGBA16I: number;
  52826. readonly R16UI: number;
  52827. readonly RG16UI: number;
  52828. readonly RGB16UI: number;
  52829. readonly RGBA16UI: number;
  52830. readonly R32I: number;
  52831. readonly RG32I: number;
  52832. readonly RGB32I: number;
  52833. readonly RGBA32I: number;
  52834. readonly R32UI: number;
  52835. readonly RG32UI: number;
  52836. readonly RGB32UI: number;
  52837. readonly RGBA32UI: number;
  52838. readonly RGB10_A2UI: number;
  52839. readonly R11F_G11F_B10F: number;
  52840. readonly RGB9_E5: number;
  52841. readonly RGB10_A2: number;
  52842. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  52843. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  52844. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  52845. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  52846. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  52847. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  52848. 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;
  52849. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  52850. readonly TRANSFORM_FEEDBACK: number;
  52851. readonly INTERLEAVED_ATTRIBS: number;
  52852. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  52853. createTransformFeedback(): WebGLTransformFeedback;
  52854. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  52855. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  52856. beginTransformFeedback(primitiveMode: number): void;
  52857. endTransformFeedback(): void;
  52858. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  52859. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  52860. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  52861. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  52862. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  52863. }
  52864. interface ImageBitmap {
  52865. readonly width: number;
  52866. readonly height: number;
  52867. close(): void;
  52868. }
  52869. interface WebGLQuery extends WebGLObject {
  52870. }
  52871. declare var WebGLQuery: {
  52872. prototype: WebGLQuery;
  52873. new(): WebGLQuery;
  52874. };
  52875. interface WebGLSampler extends WebGLObject {
  52876. }
  52877. declare var WebGLSampler: {
  52878. prototype: WebGLSampler;
  52879. new(): WebGLSampler;
  52880. };
  52881. interface WebGLSync extends WebGLObject {
  52882. }
  52883. declare var WebGLSync: {
  52884. prototype: WebGLSync;
  52885. new(): WebGLSync;
  52886. };
  52887. interface WebGLTransformFeedback extends WebGLObject {
  52888. }
  52889. declare var WebGLTransformFeedback: {
  52890. prototype: WebGLTransformFeedback;
  52891. new(): WebGLTransformFeedback;
  52892. };
  52893. interface WebGLVertexArrayObject extends WebGLObject {
  52894. }
  52895. declare var WebGLVertexArrayObject: {
  52896. prototype: WebGLVertexArrayObject;
  52897. new(): WebGLVertexArrayObject;
  52898. };
  52899. // Type definitions for WebVR API
  52900. // Project: https://w3c.github.io/webvr/
  52901. // Definitions by: six a <https://github.com/lostfictions>
  52902. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  52903. interface VRDisplay extends EventTarget {
  52904. /**
  52905. * Dictionary of capabilities describing the VRDisplay.
  52906. */
  52907. readonly capabilities: VRDisplayCapabilities;
  52908. /**
  52909. * z-depth defining the far plane of the eye view frustum
  52910. * enables mapping of values in the render target depth
  52911. * attachment to scene coordinates. Initially set to 10000.0.
  52912. */
  52913. depthFar: number;
  52914. /**
  52915. * z-depth defining the near plane of the eye view frustum
  52916. * enables mapping of values in the render target depth
  52917. * attachment to scene coordinates. Initially set to 0.01.
  52918. */
  52919. depthNear: number;
  52920. /**
  52921. * An identifier for this distinct VRDisplay. Used as an
  52922. * association point in the Gamepad API.
  52923. */
  52924. readonly displayId: number;
  52925. /**
  52926. * A display name, a user-readable name identifying it.
  52927. */
  52928. readonly displayName: string;
  52929. readonly isConnected: boolean;
  52930. readonly isPresenting: boolean;
  52931. /**
  52932. * If this VRDisplay supports room-scale experiences, the optional
  52933. * stage attribute contains details on the room-scale parameters.
  52934. */
  52935. readonly stageParameters: VRStageParameters | null;
  52936. /**
  52937. * Passing the value returned by `requestAnimationFrame` to
  52938. * `cancelAnimationFrame` will unregister the callback.
  52939. * @param handle Define the hanle of the request to cancel
  52940. */
  52941. cancelAnimationFrame(handle: number): void;
  52942. /**
  52943. * Stops presenting to the VRDisplay.
  52944. * @returns a promise to know when it stopped
  52945. */
  52946. exitPresent(): Promise<void>;
  52947. /**
  52948. * Return the current VREyeParameters for the given eye.
  52949. * @param whichEye Define the eye we want the parameter for
  52950. * @returns the eye parameters
  52951. */
  52952. getEyeParameters(whichEye: string): VREyeParameters;
  52953. /**
  52954. * Populates the passed VRFrameData with the information required to render
  52955. * the current frame.
  52956. * @param frameData Define the data structure to populate
  52957. * @returns true if ok otherwise false
  52958. */
  52959. getFrameData(frameData: VRFrameData): boolean;
  52960. /**
  52961. * Get the layers currently being presented.
  52962. * @returns the list of VR layers
  52963. */
  52964. getLayers(): VRLayer[];
  52965. /**
  52966. * Return a VRPose containing the future predicted pose of the VRDisplay
  52967. * when the current frame will be presented. The value returned will not
  52968. * change until JavaScript has returned control to the browser.
  52969. *
  52970. * The VRPose will contain the position, orientation, velocity,
  52971. * and acceleration of each of these properties.
  52972. * @returns the pose object
  52973. */
  52974. getPose(): VRPose;
  52975. /**
  52976. * Return the current instantaneous pose of the VRDisplay, with no
  52977. * prediction applied.
  52978. * @returns the current instantaneous pose
  52979. */
  52980. getImmediatePose(): VRPose;
  52981. /**
  52982. * The callback passed to `requestAnimationFrame` will be called
  52983. * any time a new frame should be rendered. When the VRDisplay is
  52984. * presenting the callback will be called at the native refresh
  52985. * rate of the HMD. When not presenting this function acts
  52986. * identically to how window.requestAnimationFrame acts. Content should
  52987. * make no assumptions of frame rate or vsync behavior as the HMD runs
  52988. * asynchronously from other displays and at differing refresh rates.
  52989. * @param callback Define the eaction to run next frame
  52990. * @returns the request handle it
  52991. */
  52992. requestAnimationFrame(callback: FrameRequestCallback): number;
  52993. /**
  52994. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  52995. * Repeat calls while already presenting will update the VRLayers being displayed.
  52996. * @param layers Define the list of layer to present
  52997. * @returns a promise to know when the request has been fulfilled
  52998. */
  52999. requestPresent(layers: VRLayer[]): Promise<void>;
  53000. /**
  53001. * Reset the pose for this display, treating its current position and
  53002. * orientation as the "origin/zero" values. VRPose.position,
  53003. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  53004. * updated when calling resetPose(). This should be called in only
  53005. * sitting-space experiences.
  53006. */
  53007. resetPose(): void;
  53008. /**
  53009. * The VRLayer provided to the VRDisplay will be captured and presented
  53010. * in the HMD. Calling this function has the same effect on the source
  53011. * canvas as any other operation that uses its source image, and canvases
  53012. * created without preserveDrawingBuffer set to true will be cleared.
  53013. * @param pose Define the pose to submit
  53014. */
  53015. submitFrame(pose?: VRPose): void;
  53016. }
  53017. declare var VRDisplay: {
  53018. prototype: VRDisplay;
  53019. new(): VRDisplay;
  53020. };
  53021. interface VRLayer {
  53022. leftBounds?: number[] | Float32Array | null;
  53023. rightBounds?: number[] | Float32Array | null;
  53024. source?: HTMLCanvasElement | null;
  53025. }
  53026. interface VRDisplayCapabilities {
  53027. readonly canPresent: boolean;
  53028. readonly hasExternalDisplay: boolean;
  53029. readonly hasOrientation: boolean;
  53030. readonly hasPosition: boolean;
  53031. readonly maxLayers: number;
  53032. }
  53033. interface VREyeParameters {
  53034. /** @deprecated */
  53035. readonly fieldOfView: VRFieldOfView;
  53036. readonly offset: Float32Array;
  53037. readonly renderHeight: number;
  53038. readonly renderWidth: number;
  53039. }
  53040. interface VRFieldOfView {
  53041. readonly downDegrees: number;
  53042. readonly leftDegrees: number;
  53043. readonly rightDegrees: number;
  53044. readonly upDegrees: number;
  53045. }
  53046. interface VRFrameData {
  53047. readonly leftProjectionMatrix: Float32Array;
  53048. readonly leftViewMatrix: Float32Array;
  53049. readonly pose: VRPose;
  53050. readonly rightProjectionMatrix: Float32Array;
  53051. readonly rightViewMatrix: Float32Array;
  53052. readonly timestamp: number;
  53053. }
  53054. interface VRPose {
  53055. readonly angularAcceleration: Float32Array | null;
  53056. readonly angularVelocity: Float32Array | null;
  53057. readonly linearAcceleration: Float32Array | null;
  53058. readonly linearVelocity: Float32Array | null;
  53059. readonly orientation: Float32Array | null;
  53060. readonly position: Float32Array | null;
  53061. readonly timestamp: number;
  53062. }
  53063. interface VRStageParameters {
  53064. sittingToStandingTransform?: Float32Array;
  53065. sizeX?: number;
  53066. sizeY?: number;
  53067. }
  53068. interface Navigator {
  53069. getVRDisplays(): Promise<VRDisplay[]>;
  53070. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  53071. }
  53072. interface Window {
  53073. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  53074. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  53075. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  53076. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  53077. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  53078. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  53079. }
  53080. interface Gamepad {
  53081. readonly displayId: number;
  53082. }
  53083. interface XRDevice {
  53084. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  53085. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  53086. }
  53087. interface XRSession {
  53088. getInputSources(): Array<any>;
  53089. baseLayer: XRWebGLLayer;
  53090. requestFrameOfReference(type: string): Promise<void>;
  53091. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  53092. end(): Promise<void>;
  53093. requestAnimationFrame: Function;
  53094. addEventListener: Function;
  53095. }
  53096. interface XRSessionCreationOptions {
  53097. outputContext?: WebGLRenderingContext | null;
  53098. immersive?: boolean;
  53099. environmentIntegration?: boolean;
  53100. }
  53101. interface XRLayer {
  53102. getViewport: Function;
  53103. framebufferWidth: number;
  53104. framebufferHeight: number;
  53105. }
  53106. interface XRView {
  53107. projectionMatrix: Float32Array;
  53108. }
  53109. interface XRFrame {
  53110. getDevicePose: Function;
  53111. getInputPose: Function;
  53112. views: Array<XRView>;
  53113. baseLayer: XRLayer;
  53114. }
  53115. interface XRFrameOfReference {
  53116. }
  53117. interface XRWebGLLayer extends XRLayer {
  53118. framebuffer: WebGLFramebuffer;
  53119. }
  53120. declare var XRWebGLLayer: {
  53121. prototype: XRWebGLLayer;
  53122. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  53123. };
  53124. declare module BABYLON.GUI {
  53125. /**
  53126. * Class used to specific a value and its associated unit
  53127. */
  53128. export class ValueAndUnit {
  53129. /** defines the unit to store */
  53130. unit: number;
  53131. /** defines a boolean indicating if the value can be negative */
  53132. negativeValueAllowed: boolean;
  53133. private _value;
  53134. private _originalUnit;
  53135. /**
  53136. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  53137. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  53138. */
  53139. ignoreAdaptiveScaling: boolean;
  53140. /**
  53141. * Creates a new ValueAndUnit
  53142. * @param value defines the value to store
  53143. * @param unit defines the unit to store
  53144. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  53145. */
  53146. constructor(value: number,
  53147. /** defines the unit to store */
  53148. unit?: number,
  53149. /** defines a boolean indicating if the value can be negative */
  53150. negativeValueAllowed?: boolean);
  53151. /** Gets a boolean indicating if the value is a percentage */
  53152. readonly isPercentage: boolean;
  53153. /** Gets a boolean indicating if the value is store as pixel */
  53154. readonly isPixel: boolean;
  53155. /** Gets direct internal value */
  53156. readonly internalValue: number;
  53157. /**
  53158. * Gets value as pixel
  53159. * @param host defines the root host
  53160. * @param refValue defines the reference value for percentages
  53161. * @returns the value as pixel
  53162. */
  53163. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  53164. /**
  53165. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  53166. * @param value defines the value to store
  53167. * @param unit defines the unit to store
  53168. * @returns the current ValueAndUnit
  53169. */
  53170. updateInPlace(value: number, unit?: number): ValueAndUnit;
  53171. /**
  53172. * Gets the value accordingly to its unit
  53173. * @param host defines the root host
  53174. * @returns the value
  53175. */
  53176. getValue(host: AdvancedDynamicTexture): number;
  53177. /**
  53178. * Gets a string representation of the value
  53179. * @param host defines the root host
  53180. * @returns a string
  53181. */
  53182. toString(host: AdvancedDynamicTexture): string;
  53183. /**
  53184. * Store a value parsed from a string
  53185. * @param source defines the source string
  53186. * @returns true if the value was successfully parsed
  53187. */
  53188. fromString(source: string | number): boolean;
  53189. private static _Regex;
  53190. private static _UNITMODE_PERCENTAGE;
  53191. private static _UNITMODE_PIXEL;
  53192. /** UNITMODE_PERCENTAGE */
  53193. static readonly UNITMODE_PERCENTAGE: number;
  53194. /** UNITMODE_PIXEL */
  53195. static readonly UNITMODE_PIXEL: number;
  53196. }
  53197. }
  53198. declare module BABYLON.GUI {
  53199. /**
  53200. * Define a style used by control to automatically setup properties based on a template.
  53201. * Only support font related properties so far
  53202. */
  53203. export class Style implements BABYLON.IDisposable {
  53204. private _fontFamily;
  53205. private _fontStyle;
  53206. private _fontWeight;
  53207. /** @hidden */ host: AdvancedDynamicTexture;
  53208. /** @hidden */ fontSize: ValueAndUnit;
  53209. /**
  53210. * BABYLON.Observable raised when the style values are changed
  53211. */
  53212. onChangedObservable: BABYLON.Observable<Style>;
  53213. /**
  53214. * Creates a new style object
  53215. * @param host defines the AdvancedDynamicTexture which hosts this style
  53216. */
  53217. constructor(host: AdvancedDynamicTexture);
  53218. /**
  53219. * Gets or sets the font size
  53220. */
  53221. fontSize: string | number;
  53222. /**
  53223. * Gets or sets the font family
  53224. */
  53225. fontFamily: string;
  53226. /**
  53227. * Gets or sets the font style
  53228. */
  53229. fontStyle: string;
  53230. /** Gets or sets font weight */
  53231. fontWeight: string;
  53232. /** Dispose all associated resources */
  53233. dispose(): void;
  53234. }
  53235. }
  53236. declare module BABYLON.GUI {
  53237. /**
  53238. * Class used to transport BABYLON.Vector2 information for pointer events
  53239. */
  53240. export class Vector2WithInfo extends BABYLON.Vector2 {
  53241. /** defines the current mouse button index */
  53242. buttonIndex: number;
  53243. /**
  53244. * Creates a new Vector2WithInfo
  53245. * @param source defines the vector2 data to transport
  53246. * @param buttonIndex defines the current mouse button index
  53247. */
  53248. constructor(source: BABYLON.Vector2,
  53249. /** defines the current mouse button index */
  53250. buttonIndex?: number);
  53251. }
  53252. /** Class used to provide 2D matrix features */
  53253. export class Matrix2D {
  53254. /** Gets the internal array of 6 floats used to store matrix data */
  53255. m: Float32Array;
  53256. /**
  53257. * Creates a new matrix
  53258. * @param m00 defines value for (0, 0)
  53259. * @param m01 defines value for (0, 1)
  53260. * @param m10 defines value for (1, 0)
  53261. * @param m11 defines value for (1, 1)
  53262. * @param m20 defines value for (2, 0)
  53263. * @param m21 defines value for (2, 1)
  53264. */
  53265. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  53266. /**
  53267. * Fills the matrix from direct values
  53268. * @param m00 defines value for (0, 0)
  53269. * @param m01 defines value for (0, 1)
  53270. * @param m10 defines value for (1, 0)
  53271. * @param m11 defines value for (1, 1)
  53272. * @param m20 defines value for (2, 0)
  53273. * @param m21 defines value for (2, 1)
  53274. * @returns the current modified matrix
  53275. */
  53276. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  53277. /**
  53278. * Gets matrix determinant
  53279. * @returns the determinant
  53280. */
  53281. determinant(): number;
  53282. /**
  53283. * Inverses the matrix and stores it in a target matrix
  53284. * @param result defines the target matrix
  53285. * @returns the current matrix
  53286. */
  53287. invertToRef(result: Matrix2D): Matrix2D;
  53288. /**
  53289. * Multiplies the current matrix with another one
  53290. * @param other defines the second operand
  53291. * @param result defines the target matrix
  53292. * @returns the current matrix
  53293. */
  53294. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  53295. /**
  53296. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  53297. * @param x defines the x coordinate to transform
  53298. * @param y defines the x coordinate to transform
  53299. * @param result defines the target vector2
  53300. * @returns the current matrix
  53301. */
  53302. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  53303. /**
  53304. * Creates an identity matrix
  53305. * @returns a new matrix
  53306. */
  53307. static Identity(): Matrix2D;
  53308. /**
  53309. * Creates a translation matrix and stores it in a target matrix
  53310. * @param x defines the x coordinate of the translation
  53311. * @param y defines the y coordinate of the translation
  53312. * @param result defines the target matrix
  53313. */
  53314. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  53315. /**
  53316. * Creates a scaling matrix and stores it in a target matrix
  53317. * @param x defines the x coordinate of the scaling
  53318. * @param y defines the y coordinate of the scaling
  53319. * @param result defines the target matrix
  53320. */
  53321. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  53322. /**
  53323. * Creates a rotation matrix and stores it in a target matrix
  53324. * @param angle defines the rotation angle
  53325. * @param result defines the target matrix
  53326. */
  53327. static RotationToRef(angle: number, result: Matrix2D): void;
  53328. private static _TempPreTranslationMatrix;
  53329. private static _TempPostTranslationMatrix;
  53330. private static _TempRotationMatrix;
  53331. private static _TempScalingMatrix;
  53332. private static _TempCompose0;
  53333. private static _TempCompose1;
  53334. private static _TempCompose2;
  53335. /**
  53336. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  53337. * @param tx defines the x coordinate of the translation
  53338. * @param ty defines the y coordinate of the translation
  53339. * @param angle defines the rotation angle
  53340. * @param scaleX defines the x coordinate of the scaling
  53341. * @param scaleY defines the y coordinate of the scaling
  53342. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  53343. * @param result defines the target matrix
  53344. */
  53345. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  53346. }
  53347. }
  53348. declare module BABYLON.GUI {
  53349. /**
  53350. * Class used to store 2D control sizes
  53351. */
  53352. export class Measure {
  53353. /** defines left coordinate */
  53354. left: number;
  53355. /** defines top coordinate */
  53356. top: number;
  53357. /** defines width dimension */
  53358. width: number;
  53359. /** defines height dimension */
  53360. height: number;
  53361. /**
  53362. * Creates a new measure
  53363. * @param left defines left coordinate
  53364. * @param top defines top coordinate
  53365. * @param width defines width dimension
  53366. * @param height defines height dimension
  53367. */
  53368. constructor(
  53369. /** defines left coordinate */
  53370. left: number,
  53371. /** defines top coordinate */
  53372. top: number,
  53373. /** defines width dimension */
  53374. width: number,
  53375. /** defines height dimension */
  53376. height: number);
  53377. /**
  53378. * Copy from another measure
  53379. * @param other defines the other measure to copy from
  53380. */
  53381. copyFrom(other: Measure): void;
  53382. /**
  53383. * Copy from a group of 4 floats
  53384. * @param left defines left coordinate
  53385. * @param top defines top coordinate
  53386. * @param width defines width dimension
  53387. * @param height defines height dimension
  53388. */
  53389. copyFromFloats(left: number, top: number, width: number, height: number): void;
  53390. /**
  53391. * Computes the axis aligned bounding box measure for two given measures
  53392. * @param a Input measure
  53393. * @param b Input measure
  53394. * @param result the resulting bounding measure
  53395. */
  53396. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  53397. /**
  53398. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  53399. * @param transform the matrix to transform the measure before computing the AABB
  53400. * @param result the resulting AABB
  53401. */
  53402. transformToRef(transform: Matrix2D, result: Measure): void;
  53403. /**
  53404. * Check equality between this measure and another one
  53405. * @param other defines the other measures
  53406. * @returns true if both measures are equals
  53407. */
  53408. isEqualsTo(other: Measure): boolean;
  53409. /**
  53410. * Creates an empty measure
  53411. * @returns a new measure
  53412. */
  53413. static Empty(): Measure;
  53414. }
  53415. }
  53416. declare module BABYLON.GUI {
  53417. /**
  53418. * Interface used to define a control that can receive focus
  53419. */
  53420. export interface IFocusableControl {
  53421. /**
  53422. * Function called when the control receives the focus
  53423. */
  53424. onFocus(): void;
  53425. /**
  53426. * Function called when the control loses the focus
  53427. */
  53428. onBlur(): void;
  53429. /**
  53430. * Function called to let the control handle keyboard events
  53431. * @param evt defines the current keyboard event
  53432. */
  53433. processKeyboard(evt: KeyboardEvent): void;
  53434. /**
  53435. * Function called to get the list of controls that should not steal the focus from this control
  53436. * @returns an array of controls
  53437. */
  53438. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  53439. }
  53440. /**
  53441. * Class used to create texture to support 2D GUI elements
  53442. * @see http://doc.babylonjs.com/how_to/gui
  53443. */
  53444. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  53445. private _isDirty;
  53446. private _renderObserver;
  53447. private _resizeObserver;
  53448. private _preKeyboardObserver;
  53449. private _pointerMoveObserver;
  53450. private _pointerObserver;
  53451. private _canvasPointerOutObserver;
  53452. private _background;
  53453. /** @hidden */ rootContainer: Container;
  53454. /** @hidden */ lastPickedControl: Control;
  53455. /** @hidden */ lastControlOver: {
  53456. [pointerId: number]: Control;
  53457. };
  53458. /** @hidden */ lastControlDown: {
  53459. [pointerId: number]: Control;
  53460. };
  53461. /** @hidden */ capturingControl: {
  53462. [pointerId: number]: Control;
  53463. };
  53464. /** @hidden */ shouldBlockPointer: boolean;
  53465. /** @hidden */ layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  53466. /** @hidden */ linkedControls: Control[];
  53467. private _isFullscreen;
  53468. private _fullscreenViewport;
  53469. private _idealWidth;
  53470. private _idealHeight;
  53471. private _useSmallestIdeal;
  53472. private _renderAtIdealSize;
  53473. private _focusedControl;
  53474. private _blockNextFocusCheck;
  53475. private _renderScale;
  53476. private _rootCanvas;
  53477. /**
  53478. * Define type to string to ensure compatibility across browsers
  53479. * Safari doesn't support DataTransfer constructor
  53480. */
  53481. private _clipboardData;
  53482. /**
  53483. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  53484. */
  53485. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  53486. /**
  53487. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  53488. */
  53489. onControlPickedObservable: BABYLON.Observable<Control>;
  53490. /**
  53491. * BABYLON.Observable event triggered before layout is evaluated
  53492. */
  53493. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  53494. /**
  53495. * BABYLON.Observable event triggered after the layout was evaluated
  53496. */
  53497. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  53498. /**
  53499. * BABYLON.Observable event triggered before the texture is rendered
  53500. */
  53501. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  53502. /**
  53503. * BABYLON.Observable event triggered after the texture was rendered
  53504. */
  53505. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  53506. /**
  53507. * Gets or sets a boolean defining if alpha is stored as premultiplied
  53508. */
  53509. premulAlpha: boolean;
  53510. /**
  53511. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  53512. * Useful when you want more antialiasing
  53513. */
  53514. renderScale: number;
  53515. /** Gets or sets the background color */
  53516. background: string;
  53517. /**
  53518. * Gets or sets the ideal width used to design controls.
  53519. * The GUI will then rescale everything accordingly
  53520. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  53521. */
  53522. idealWidth: number;
  53523. /**
  53524. * Gets or sets the ideal height used to design controls.
  53525. * The GUI will then rescale everything accordingly
  53526. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  53527. */
  53528. idealHeight: number;
  53529. /**
  53530. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  53531. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  53532. */
  53533. useSmallestIdeal: boolean;
  53534. /**
  53535. * Gets or sets a boolean indicating if adaptive scaling must be used
  53536. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  53537. */
  53538. renderAtIdealSize: boolean;
  53539. /**
  53540. * Gets the underlying layer used to render the texture when in fullscreen mode
  53541. */
  53542. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  53543. /**
  53544. * Gets the root container control
  53545. */
  53546. readonly rootContainer: Container;
  53547. /**
  53548. * Returns an array containing the root container.
  53549. * This is mostly used to let the Inspector introspects the ADT
  53550. * @returns an array containing the rootContainer
  53551. */
  53552. getChildren(): Array<Container>;
  53553. /**
  53554. * Will return all controls that are inside this texture
  53555. * @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
  53556. * @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
  53557. * @return all child controls
  53558. */
  53559. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  53560. /**
  53561. * Gets or sets the current focused control
  53562. */
  53563. focusedControl: BABYLON.Nullable<IFocusableControl>;
  53564. /**
  53565. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  53566. */
  53567. isForeground: boolean;
  53568. /**
  53569. * Gets or set information about clipboardData
  53570. */
  53571. clipboardData: string;
  53572. /**
  53573. * Creates a new AdvancedDynamicTexture
  53574. * @param name defines the name of the texture
  53575. * @param width defines the width of the texture
  53576. * @param height defines the height of the texture
  53577. * @param scene defines the hosting scene
  53578. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  53579. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  53580. */
  53581. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  53582. /**
  53583. * Get the current class name of the texture useful for serialization or dynamic coding.
  53584. * @returns "AdvancedDynamicTexture"
  53585. */
  53586. getClassName(): string;
  53587. /**
  53588. * Function used to execute a function on all controls
  53589. * @param func defines the function to execute
  53590. * @param container defines the container where controls belong. If null the root container will be used
  53591. */
  53592. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  53593. private _useInvalidateRectOptimization;
  53594. /**
  53595. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  53596. */
  53597. useInvalidateRectOptimization: boolean;
  53598. private _invalidatedRectangle;
  53599. /**
  53600. * Invalidates a rectangle area on the gui texture
  53601. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  53602. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  53603. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  53604. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  53605. */
  53606. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  53607. /**
  53608. * Marks the texture as dirty forcing a complete update
  53609. */
  53610. markAsDirty(): void;
  53611. /**
  53612. * Helper function used to create a new style
  53613. * @returns a new style
  53614. * @see http://doc.babylonjs.com/how_to/gui#styles
  53615. */
  53616. createStyle(): Style;
  53617. /**
  53618. * Adds a new control to the root container
  53619. * @param control defines the control to add
  53620. * @returns the current texture
  53621. */
  53622. addControl(control: Control): AdvancedDynamicTexture;
  53623. /**
  53624. * Removes a control from the root container
  53625. * @param control defines the control to remove
  53626. * @returns the current texture
  53627. */
  53628. removeControl(control: Control): AdvancedDynamicTexture;
  53629. /**
  53630. * Release all resources
  53631. */
  53632. dispose(): void;
  53633. private _onResize;
  53634. /** @hidden */ getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  53635. /**
  53636. * Get screen coordinates for a vector3
  53637. * @param position defines the position to project
  53638. * @param worldMatrix defines the world matrix to use
  53639. * @returns the projected position
  53640. */
  53641. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  53642. private _checkUpdate;
  53643. private _clearMeasure;
  53644. private _render;
  53645. /** @hidden */ changeCursor(cursor: string): void;
  53646. /** @hidden */ registerLastControlDown(control: Control, pointerId: number): void;
  53647. private _doPicking;
  53648. /** @hidden */ cleanControlAfterRemovalFromList(list: {
  53649. [pointerId: number]: Control;
  53650. }, control: Control): void;
  53651. /** @hidden */ cleanControlAfterRemoval(control: Control): void;
  53652. /** Attach to all scene events required to support pointer events */
  53653. attach(): void;
  53654. /** @hidden */
  53655. private onClipboardCopy;
  53656. /** @hidden */
  53657. private onClipboardCut;
  53658. /** @hidden */
  53659. private onClipboardPaste;
  53660. /**
  53661. * Register the clipboard Events onto the canvas
  53662. */
  53663. registerClipboardEvents(): void;
  53664. /**
  53665. * Unregister the clipboard Events from the canvas
  53666. */
  53667. unRegisterClipboardEvents(): void;
  53668. /**
  53669. * Connect the texture to a hosting mesh to enable interactions
  53670. * @param mesh defines the mesh to attach to
  53671. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  53672. */
  53673. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  53674. /**
  53675. * Move the focus to a specific control
  53676. * @param control defines the control which will receive the focus
  53677. */
  53678. moveFocusToControl(control: IFocusableControl): void;
  53679. private _manageFocus;
  53680. private _attachToOnPointerOut;
  53681. /**
  53682. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  53683. * @param mesh defines the mesh which will receive the texture
  53684. * @param width defines the texture width (1024 by default)
  53685. * @param height defines the texture height (1024 by default)
  53686. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  53687. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  53688. * @returns a new AdvancedDynamicTexture
  53689. */
  53690. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  53691. /**
  53692. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  53693. * In this mode the texture will rely on a layer for its rendering.
  53694. * This allows it to be treated like any other layer.
  53695. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  53696. * LayerMask is set through advancedTexture.layer.layerMask
  53697. * @param name defines name for the texture
  53698. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  53699. * @param scene defines the hsoting scene
  53700. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  53701. * @returns a new AdvancedDynamicTexture
  53702. */
  53703. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  53704. }
  53705. }
  53706. declare module BABYLON.GUI {
  53707. /**
  53708. * Root class used for all 2D controls
  53709. * @see http://doc.babylonjs.com/how_to/gui#controls
  53710. */
  53711. export class Control {
  53712. /** defines the name of the control */
  53713. name?: string | undefined;
  53714. /**
  53715. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  53716. */
  53717. static AllowAlphaInheritance: boolean;
  53718. private _alpha;
  53719. private _alphaSet;
  53720. private _zIndex;
  53721. /** @hidden */ host: AdvancedDynamicTexture;
  53722. /** Gets or sets the control parent */
  53723. parent: BABYLON.Nullable<Container>;
  53724. /** @hidden */ currentMeasure: Measure;
  53725. private _fontFamily;
  53726. private _fontStyle;
  53727. private _fontWeight;
  53728. private _fontSize;
  53729. private _font;
  53730. /** @hidden */ width: ValueAndUnit;
  53731. /** @hidden */ height: ValueAndUnit;
  53732. /** @hidden */
  53733. protected _fontOffset: {
  53734. ascent: number;
  53735. height: number;
  53736. descent: number;
  53737. };
  53738. private _color;
  53739. private _style;
  53740. private _styleObserver;
  53741. /** @hidden */
  53742. protected _horizontalAlignment: number;
  53743. /** @hidden */
  53744. protected _verticalAlignment: number;
  53745. /** @hidden */
  53746. protected _isDirty: boolean;
  53747. /** @hidden */
  53748. protected _wasDirty: boolean;
  53749. /** @hidden */ tempParentMeasure: Measure;
  53750. /** @hidden */ prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  53751. /** @hidden */
  53752. protected _cachedParentMeasure: Measure;
  53753. private _paddingLeft;
  53754. private _paddingRight;
  53755. private _paddingTop;
  53756. private _paddingBottom;
  53757. /** @hidden */ left: ValueAndUnit;
  53758. /** @hidden */ top: ValueAndUnit;
  53759. private _scaleX;
  53760. private _scaleY;
  53761. private _rotation;
  53762. private _transformCenterX;
  53763. private _transformCenterY;
  53764. /** @hidden */ transformMatrix: Matrix2D;
  53765. /** @hidden */
  53766. protected _invertTransformMatrix: Matrix2D;
  53767. /** @hidden */
  53768. protected _transformedPosition: BABYLON.Vector2;
  53769. private _isMatrixDirty;
  53770. private _cachedOffsetX;
  53771. private _cachedOffsetY;
  53772. private _isVisible;
  53773. private _isHighlighted;
  53774. /** @hidden */ linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  53775. private _fontSet;
  53776. private _dummyVector2;
  53777. private _downCount;
  53778. private _enterCount;
  53779. private _doNotRender;
  53780. private _downPointerIds;
  53781. protected _isEnabled: boolean;
  53782. protected _disabledColor: string;
  53783. /** @hidden */
  53784. protected _rebuildLayout: boolean;
  53785. /** @hidden */ isClipped: boolean;
  53786. /** @hidden */ tag: any;
  53787. /**
  53788. * 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
  53789. */
  53790. uniqueId: number;
  53791. /**
  53792. * Gets or sets an object used to store user defined information for the node
  53793. */
  53794. metadata: any;
  53795. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  53796. isHitTestVisible: boolean;
  53797. /** Gets or sets a boolean indicating if the control can block pointer events */
  53798. isPointerBlocker: boolean;
  53799. /** Gets or sets a boolean indicating if the control can be focusable */
  53800. isFocusInvisible: boolean;
  53801. /**
  53802. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  53803. * 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
  53804. */
  53805. clipChildren: boolean;
  53806. /**
  53807. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  53808. */
  53809. useBitmapCache: boolean;
  53810. private _cacheData;
  53811. private _shadowOffsetX;
  53812. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  53813. shadowOffsetX: number;
  53814. private _shadowOffsetY;
  53815. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  53816. shadowOffsetY: number;
  53817. private _shadowBlur;
  53818. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  53819. shadowBlur: number;
  53820. private _shadowColor;
  53821. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  53822. shadowColor: string;
  53823. /** Gets or sets the cursor to use when the control is hovered */
  53824. hoverCursor: string;
  53825. /** @hidden */
  53826. protected _linkOffsetX: ValueAndUnit;
  53827. /** @hidden */
  53828. protected _linkOffsetY: ValueAndUnit;
  53829. /** Gets the control type name */
  53830. readonly typeName: string;
  53831. /**
  53832. * Get the current class name of the control.
  53833. * @returns current class name
  53834. */
  53835. getClassName(): string;
  53836. /**
  53837. * An event triggered when the pointer move over the control.
  53838. */
  53839. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  53840. /**
  53841. * An event triggered when the pointer move out of the control.
  53842. */
  53843. onPointerOutObservable: BABYLON.Observable<Control>;
  53844. /**
  53845. * An event triggered when the pointer taps the control
  53846. */
  53847. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  53848. /**
  53849. * An event triggered when pointer up
  53850. */
  53851. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  53852. /**
  53853. * An event triggered when a control is clicked on
  53854. */
  53855. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  53856. /**
  53857. * An event triggered when pointer enters the control
  53858. */
  53859. onPointerEnterObservable: BABYLON.Observable<Control>;
  53860. /**
  53861. * An event triggered when the control is marked as dirty
  53862. */
  53863. onDirtyObservable: BABYLON.Observable<Control>;
  53864. /**
  53865. * An event triggered before drawing the control
  53866. */
  53867. onBeforeDrawObservable: BABYLON.Observable<Control>;
  53868. /**
  53869. * An event triggered after the control was drawn
  53870. */
  53871. onAfterDrawObservable: BABYLON.Observable<Control>;
  53872. /**
  53873. * Get the hosting AdvancedDynamicTexture
  53874. */
  53875. readonly host: AdvancedDynamicTexture;
  53876. /** Gets or set information about font offsets (used to render and align text) */
  53877. fontOffset: {
  53878. ascent: number;
  53879. height: number;
  53880. descent: number;
  53881. };
  53882. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  53883. alpha: number;
  53884. /**
  53885. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  53886. */
  53887. isHighlighted: boolean;
  53888. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  53889. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  53890. */
  53891. scaleX: number;
  53892. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  53893. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  53894. */
  53895. scaleY: number;
  53896. /** Gets or sets the rotation angle (0 by default)
  53897. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  53898. */
  53899. rotation: number;
  53900. /** Gets or sets the transformation center on Y axis (0 by default)
  53901. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  53902. */
  53903. transformCenterY: number;
  53904. /** Gets or sets the transformation center on X axis (0 by default)
  53905. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  53906. */
  53907. transformCenterX: number;
  53908. /**
  53909. * Gets or sets the horizontal alignment
  53910. * @see http://doc.babylonjs.com/how_to/gui#alignments
  53911. */
  53912. horizontalAlignment: number;
  53913. /**
  53914. * Gets or sets the vertical alignment
  53915. * @see http://doc.babylonjs.com/how_to/gui#alignments
  53916. */
  53917. verticalAlignment: number;
  53918. /**
  53919. * Gets or sets control width
  53920. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  53921. */
  53922. width: string | number;
  53923. /**
  53924. * Gets control width in pixel
  53925. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  53926. */
  53927. readonly widthInPixels: number;
  53928. /**
  53929. * Gets or sets control height
  53930. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  53931. */
  53932. height: string | number;
  53933. /**
  53934. * Gets control height in pixel
  53935. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  53936. */
  53937. readonly heightInPixels: number;
  53938. /** Gets or set font family */
  53939. fontFamily: string;
  53940. /** Gets or sets font style */
  53941. fontStyle: string;
  53942. /** Gets or sets font weight */
  53943. fontWeight: string;
  53944. /**
  53945. * Gets or sets style
  53946. * @see http://doc.babylonjs.com/how_to/gui#styles
  53947. */
  53948. style: BABYLON.Nullable<Style>;
  53949. /** @hidden */ protected readonly _isFontSizeInPercentage: boolean;
  53950. /** Gets font size in pixels */
  53951. readonly fontSizeInPixels: number;
  53952. /** Gets or sets font size */
  53953. fontSize: string | number;
  53954. /** Gets or sets foreground color */
  53955. color: string;
  53956. /** Gets or sets z index which is used to reorder controls on the z axis */
  53957. zIndex: number;
  53958. /** Gets or sets a boolean indicating if the control can be rendered */
  53959. notRenderable: boolean;
  53960. /** Gets or sets a boolean indicating if the control is visible */
  53961. isVisible: boolean;
  53962. /** Gets a boolean indicating that the control needs to update its rendering */
  53963. readonly isDirty: boolean;
  53964. /**
  53965. * Gets the current linked mesh (or null if none)
  53966. */
  53967. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  53968. /**
  53969. * Gets or sets a value indicating the padding to use on the left of the control
  53970. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  53971. */
  53972. paddingLeft: string | number;
  53973. /**
  53974. * Gets a value indicating the padding in pixels to use on the left of the control
  53975. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  53976. */
  53977. readonly paddingLeftInPixels: number;
  53978. /**
  53979. * Gets or sets a value indicating the padding to use on the right of the control
  53980. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  53981. */
  53982. paddingRight: string | number;
  53983. /**
  53984. * Gets a value indicating the padding in pixels to use on the right of the control
  53985. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  53986. */
  53987. readonly paddingRightInPixels: number;
  53988. /**
  53989. * Gets or sets a value indicating the padding to use on the top of the control
  53990. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  53991. */
  53992. paddingTop: string | number;
  53993. /**
  53994. * Gets a value indicating the padding in pixels to use on the top of the control
  53995. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  53996. */
  53997. readonly paddingTopInPixels: number;
  53998. /**
  53999. * Gets or sets a value indicating the padding to use on the bottom of the control
  54000. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  54001. */
  54002. paddingBottom: string | number;
  54003. /**
  54004. * Gets a value indicating the padding in pixels to use on the bottom of the control
  54005. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  54006. */
  54007. readonly paddingBottomInPixels: number;
  54008. /**
  54009. * Gets or sets a value indicating the left coordinate of the control
  54010. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  54011. */
  54012. left: string | number;
  54013. /**
  54014. * Gets a value indicating the left coordinate in pixels of the control
  54015. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  54016. */
  54017. readonly leftInPixels: number;
  54018. /**
  54019. * Gets or sets a value indicating the top coordinate of the control
  54020. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  54021. */
  54022. top: string | number;
  54023. /**
  54024. * Gets a value indicating the top coordinate in pixels of the control
  54025. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  54026. */
  54027. readonly topInPixels: number;
  54028. /**
  54029. * Gets or sets a value indicating the offset on X axis to the linked mesh
  54030. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  54031. */
  54032. linkOffsetX: string | number;
  54033. /**
  54034. * Gets a value indicating the offset in pixels on X axis to the linked mesh
  54035. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  54036. */
  54037. readonly linkOffsetXInPixels: number;
  54038. /**
  54039. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  54040. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  54041. */
  54042. linkOffsetY: string | number;
  54043. /**
  54044. * Gets a value indicating the offset in pixels on Y axis to the linked mesh
  54045. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  54046. */
  54047. readonly linkOffsetYInPixels: number;
  54048. /** Gets the center coordinate on X axis */
  54049. readonly centerX: number;
  54050. /** Gets the center coordinate on Y axis */
  54051. readonly centerY: number;
  54052. /** Gets or sets if control is Enabled*/
  54053. isEnabled: boolean;
  54054. /** Gets or sets background color of control if it's disabled*/
  54055. disabledColor: string;
  54056. /**
  54057. * Creates a new control
  54058. * @param name defines the name of the control
  54059. */
  54060. constructor(
  54061. /** defines the name of the control */
  54062. name?: string | undefined);
  54063. /** @hidden */
  54064. protected _getTypeName(): string;
  54065. /**
  54066. * Gets the first ascendant in the hierarchy of the given type
  54067. * @param className defines the required type
  54068. * @returns the ascendant or null if not found
  54069. */
  54070. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  54071. /** @hidden */ resetFontCache(): void;
  54072. /**
  54073. * Determines if a container is an ascendant of the current control
  54074. * @param container defines the container to look for
  54075. * @returns true if the container is one of the ascendant of the control
  54076. */
  54077. isAscendant(container: Control): boolean;
  54078. /**
  54079. * Gets coordinates in local control space
  54080. * @param globalCoordinates defines the coordinates to transform
  54081. * @returns the new coordinates in local space
  54082. */
  54083. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  54084. /**
  54085. * Gets coordinates in local control space
  54086. * @param globalCoordinates defines the coordinates to transform
  54087. * @param result defines the target vector2 where to store the result
  54088. * @returns the current control
  54089. */
  54090. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  54091. /**
  54092. * Gets coordinates in parent local control space
  54093. * @param globalCoordinates defines the coordinates to transform
  54094. * @returns the new coordinates in parent local space
  54095. */
  54096. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  54097. /**
  54098. * Move the current control to a vector3 position projected onto the screen.
  54099. * @param position defines the target position
  54100. * @param scene defines the hosting scene
  54101. */
  54102. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  54103. /** @hidden */ getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  54104. /**
  54105. * Will return all controls that have this control as ascendant
  54106. * @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
  54107. * @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
  54108. * @return all child controls
  54109. */
  54110. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  54111. /**
  54112. * Link current control with a target mesh
  54113. * @param mesh defines the mesh to link with
  54114. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  54115. */
  54116. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  54117. /** @hidden */ moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  54118. /** @hidden */ offsetLeft(offset: number): void;
  54119. /** @hidden */ offsetTop(offset: number): void;
  54120. /** @hidden */ markMatrixAsDirty(): void;
  54121. /** @hidden */ flagDescendantsAsMatrixDirty(): void;
  54122. /** @hidden */ intersectsRect(rect: Measure): boolean;
  54123. /** @hidden */
  54124. protected invalidateRect(): void;
  54125. /** @hidden */ markAsDirty(force?: boolean): void;
  54126. /** @hidden */ markAllAsDirty(): void;
  54127. /** @hidden */ link(host: AdvancedDynamicTexture): void;
  54128. /** @hidden */
  54129. protected _transform(context?: CanvasRenderingContext2D): void;
  54130. /** @hidden */ renderHighlight(context: CanvasRenderingContext2D): void;
  54131. /** @hidden */ renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  54132. /** @hidden */
  54133. protected _applyStates(context: CanvasRenderingContext2D): void;
  54134. /** @hidden */ layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  54135. /** @hidden */
  54136. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  54137. protected _evaluateClippingState(parentMeasure: Measure): void;
  54138. /** @hidden */ measure(): void;
  54139. /** @hidden */
  54140. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  54141. /** @hidden */
  54142. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  54143. /** @hidden */
  54144. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  54145. /** @hidden */
  54146. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  54147. private static _ClipMeasure;
  54148. private _tmpMeasureA;
  54149. private _clip;
  54150. /** @hidden */ render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  54151. /** @hidden */ draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  54152. /**
  54153. * Tests if a given coordinates belong to the current control
  54154. * @param x defines x coordinate to test
  54155. * @param y defines y coordinate to test
  54156. * @returns true if the coordinates are inside the control
  54157. */
  54158. contains(x: number, y: number): boolean;
  54159. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  54160. /** @hidden */ onPointerMove(target: Control, coordinates: BABYLON.Vector2): void;
  54161. /** @hidden */ onPointerEnter(target: Control): boolean;
  54162. /** @hidden */ onPointerOut(target: Control): void;
  54163. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  54164. /** @hidden */ onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  54165. /** @hidden */ forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  54166. /** @hidden */ processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  54167. private _prepareFont;
  54168. /** Releases associated resources */
  54169. dispose(): void;
  54170. private static _HORIZONTAL_ALIGNMENT_LEFT;
  54171. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  54172. private static _HORIZONTAL_ALIGNMENT_CENTER;
  54173. private static _VERTICAL_ALIGNMENT_TOP;
  54174. private static _VERTICAL_ALIGNMENT_BOTTOM;
  54175. private static _VERTICAL_ALIGNMENT_CENTER;
  54176. /** HORIZONTAL_ALIGNMENT_LEFT */
  54177. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  54178. /** HORIZONTAL_ALIGNMENT_RIGHT */
  54179. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  54180. /** HORIZONTAL_ALIGNMENT_CENTER */
  54181. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  54182. /** VERTICAL_ALIGNMENT_TOP */
  54183. static readonly VERTICAL_ALIGNMENT_TOP: number;
  54184. /** VERTICAL_ALIGNMENT_BOTTOM */
  54185. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  54186. /** VERTICAL_ALIGNMENT_CENTER */
  54187. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  54188. private static _FontHeightSizes;
  54189. /** @hidden */ private static _GetFontOffset(font: string): {
  54190. ascent: number;
  54191. height: number;
  54192. descent: number;
  54193. };
  54194. /**
  54195. * Creates a stack panel that can be used to render headers
  54196. * @param control defines the control to associate with the header
  54197. * @param text defines the text of the header
  54198. * @param size defines the size of the header
  54199. * @param options defines options used to configure the header
  54200. * @returns a new StackPanel
  54201. * @ignore
  54202. * @hidden
  54203. */
  54204. static AddHeader: (control: Control, text: string, size: string | number, options: {
  54205. isHorizontal: boolean;
  54206. controlFirst: boolean;
  54207. }) => any;
  54208. /** @hidden */
  54209. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  54210. }
  54211. }
  54212. declare module BABYLON.GUI {
  54213. /**
  54214. * Root class for 2D containers
  54215. * @see http://doc.babylonjs.com/how_to/gui#containers
  54216. */
  54217. export class Container extends Control {
  54218. name?: string | undefined;
  54219. /** @hidden */
  54220. protected _children: Control[];
  54221. /** @hidden */
  54222. protected _measureForChildren: Measure;
  54223. /** @hidden */
  54224. protected _background: string;
  54225. /** @hidden */
  54226. protected _adaptWidthToChildren: boolean;
  54227. /** @hidden */
  54228. protected _adaptHeightToChildren: boolean;
  54229. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  54230. adaptHeightToChildren: boolean;
  54231. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  54232. adaptWidthToChildren: boolean;
  54233. /** Gets or sets background color */
  54234. background: string;
  54235. /** Gets the list of children */
  54236. readonly children: Control[];
  54237. /**
  54238. * Creates a new Container
  54239. * @param name defines the name of the container
  54240. */
  54241. constructor(name?: string | undefined);
  54242. protected _getTypeName(): string; flagDescendantsAsMatrixDirty(): void;
  54243. /**
  54244. * Gets a child using its name
  54245. * @param name defines the child name to look for
  54246. * @returns the child control if found
  54247. */
  54248. getChildByName(name: string): BABYLON.Nullable<Control>;
  54249. /**
  54250. * Gets a child using its type and its name
  54251. * @param name defines the child name to look for
  54252. * @param type defines the child type to look for
  54253. * @returns the child control if found
  54254. */
  54255. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  54256. /**
  54257. * Search for a specific control in children
  54258. * @param control defines the control to look for
  54259. * @returns true if the control is in child list
  54260. */
  54261. containsControl(control: Control): boolean;
  54262. /**
  54263. * Adds a new control to the current container
  54264. * @param control defines the control to add
  54265. * @returns the current container
  54266. */
  54267. addControl(control: BABYLON.Nullable<Control>): Container;
  54268. /**
  54269. * Removes all controls from the current container
  54270. * @returns the current container
  54271. */
  54272. clearControls(): Container;
  54273. /**
  54274. * Removes a control from the current container
  54275. * @param control defines the control to remove
  54276. * @returns the current container
  54277. */
  54278. removeControl(control: Control): Container;
  54279. /** @hidden */ reOrderControl(control: Control): void;
  54280. /** @hidden */ offsetLeft(offset: number): void;
  54281. /** @hidden */ offsetTop(offset: number): void;
  54282. /** @hidden */ markAllAsDirty(): void;
  54283. /** @hidden */
  54284. protected _localDraw(context: CanvasRenderingContext2D): void;
  54285. /** @hidden */ link(host: AdvancedDynamicTexture): void;
  54286. /** @hidden */
  54287. protected _beforeLayout(): void;
  54288. /** @hidden */
  54289. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  54290. /** @hidden */ layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  54291. protected _postMeasure(): void;
  54292. /** @hidden */ draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  54293. /** @hidden */ getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  54294. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  54295. /** @hidden */
  54296. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  54297. /** Releases associated resources */
  54298. dispose(): void;
  54299. }
  54300. }
  54301. declare module BABYLON.GUI {
  54302. /** Class used to create rectangle container */
  54303. export class Rectangle extends Container {
  54304. name?: string | undefined;
  54305. private _thickness;
  54306. private _cornerRadius;
  54307. /** Gets or sets border thickness */
  54308. thickness: number;
  54309. /** Gets or sets the corner radius angle */
  54310. cornerRadius: number;
  54311. /**
  54312. * Creates a new Rectangle
  54313. * @param name defines the control name
  54314. */
  54315. constructor(name?: string | undefined);
  54316. protected _getTypeName(): string;
  54317. protected _localDraw(context: CanvasRenderingContext2D): void;
  54318. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  54319. private _drawRoundedRect;
  54320. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  54321. }
  54322. }
  54323. declare module BABYLON.GUI {
  54324. /**
  54325. * Enum that determines the text-wrapping mode to use.
  54326. */
  54327. export enum TextWrapping {
  54328. /**
  54329. * Clip the text when it's larger than Control.width; this is the default mode.
  54330. */
  54331. Clip = 0,
  54332. /**
  54333. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  54334. */
  54335. WordWrap = 1,
  54336. /**
  54337. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  54338. */
  54339. Ellipsis = 2
  54340. }
  54341. /**
  54342. * Class used to create text block control
  54343. */
  54344. export class TextBlock extends Control {
  54345. /**
  54346. * Defines the name of the control
  54347. */
  54348. name?: string | undefined;
  54349. private _text;
  54350. private _textWrapping;
  54351. private _textHorizontalAlignment;
  54352. private _textVerticalAlignment;
  54353. private _lines;
  54354. private _resizeToFit;
  54355. private _lineSpacing;
  54356. private _outlineWidth;
  54357. private _outlineColor;
  54358. /**
  54359. * An event triggered after the text is changed
  54360. */
  54361. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  54362. /**
  54363. * An event triggered after the text was broken up into lines
  54364. */
  54365. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  54366. /**
  54367. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  54368. */
  54369. readonly lines: any[];
  54370. /**
  54371. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  54372. */
  54373. /**
  54374. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  54375. */
  54376. resizeToFit: boolean;
  54377. /**
  54378. * Gets or sets a boolean indicating if text must be wrapped
  54379. */
  54380. /**
  54381. * Gets or sets a boolean indicating if text must be wrapped
  54382. */
  54383. textWrapping: TextWrapping | boolean;
  54384. /**
  54385. * Gets or sets text to display
  54386. */
  54387. /**
  54388. * Gets or sets text to display
  54389. */
  54390. text: string;
  54391. /**
  54392. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  54393. */
  54394. /**
  54395. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  54396. */
  54397. textHorizontalAlignment: number;
  54398. /**
  54399. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  54400. */
  54401. /**
  54402. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  54403. */
  54404. textVerticalAlignment: number;
  54405. /**
  54406. * Gets or sets line spacing value
  54407. */
  54408. /**
  54409. * Gets or sets line spacing value
  54410. */
  54411. lineSpacing: string | number;
  54412. /**
  54413. * Gets or sets outlineWidth of the text to display
  54414. */
  54415. /**
  54416. * Gets or sets outlineWidth of the text to display
  54417. */
  54418. outlineWidth: number;
  54419. /**
  54420. * Gets or sets outlineColor of the text to display
  54421. */
  54422. /**
  54423. * Gets or sets outlineColor of the text to display
  54424. */
  54425. outlineColor: string;
  54426. /**
  54427. * Creates a new TextBlock object
  54428. * @param name defines the name of the control
  54429. * @param text defines the text to display (emptry string by default)
  54430. */
  54431. constructor(
  54432. /**
  54433. * Defines the name of the control
  54434. */
  54435. name?: string | undefined, text?: string);
  54436. protected _getTypeName(): string;
  54437. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  54438. private _drawText;
  54439. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  54440. protected _applyStates(context: CanvasRenderingContext2D): void;
  54441. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  54442. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  54443. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  54444. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  54445. protected _renderLines(context: CanvasRenderingContext2D): void;
  54446. /**
  54447. * Given a width constraint applied on the text block, find the expected height
  54448. * @returns expected height
  54449. */
  54450. computeExpectedHeight(): number;
  54451. dispose(): void;
  54452. }
  54453. }
  54454. declare module BABYLON.GUI {
  54455. /**
  54456. * Class used to create 2D images
  54457. */
  54458. export class Image extends Control {
  54459. name?: string | undefined;
  54460. private static _WorkingCanvas;
  54461. private _domImage;
  54462. private _imageWidth;
  54463. private _imageHeight;
  54464. private _loaded;
  54465. private _stretch;
  54466. private _source;
  54467. private _autoScale;
  54468. private _sourceLeft;
  54469. private _sourceTop;
  54470. private _sourceWidth;
  54471. private _sourceHeight;
  54472. private _cellWidth;
  54473. private _cellHeight;
  54474. private _cellId;
  54475. private _populateNinePatchSlicesFromImage;
  54476. private _sliceLeft;
  54477. private _sliceRight;
  54478. private _sliceTop;
  54479. private _sliceBottom;
  54480. private _detectPointerOnOpaqueOnly;
  54481. /**
  54482. * BABYLON.Observable notified when the content is loaded
  54483. */
  54484. onImageLoadedObservable: BABYLON.Observable<Image>;
  54485. /**
  54486. * Gets a boolean indicating that the content is loaded
  54487. */
  54488. readonly isLoaded: boolean;
  54489. /**
  54490. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  54491. */
  54492. populateNinePatchSlicesFromImage: boolean;
  54493. /**
  54494. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  54495. * Beware using this as this will comsume more memory as the image has to be stored twice
  54496. */
  54497. detectPointerOnOpaqueOnly: boolean;
  54498. /**
  54499. * Gets or sets the left value for slicing (9-patch)
  54500. */
  54501. sliceLeft: number;
  54502. /**
  54503. * Gets or sets the right value for slicing (9-patch)
  54504. */
  54505. sliceRight: number;
  54506. /**
  54507. * Gets or sets the top value for slicing (9-patch)
  54508. */
  54509. sliceTop: number;
  54510. /**
  54511. * Gets or sets the bottom value for slicing (9-patch)
  54512. */
  54513. sliceBottom: number;
  54514. /**
  54515. * Gets or sets the left coordinate in the source image
  54516. */
  54517. sourceLeft: number;
  54518. /**
  54519. * Gets or sets the top coordinate in the source image
  54520. */
  54521. sourceTop: number;
  54522. /**
  54523. * Gets or sets the width to capture in the source image
  54524. */
  54525. sourceWidth: number;
  54526. /**
  54527. * Gets or sets the height to capture in the source image
  54528. */
  54529. sourceHeight: number;
  54530. /**
  54531. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  54532. * @see http://doc.babylonjs.com/how_to/gui#image
  54533. */
  54534. autoScale: boolean;
  54535. /** Gets or sets the streching mode used by the image */
  54536. stretch: number;
  54537. /**
  54538. * Gets or sets the internal DOM image used to render the control
  54539. */
  54540. domImage: HTMLImageElement;
  54541. private _onImageLoaded;
  54542. private _extractNinePatchSliceDataFromImage;
  54543. /**
  54544. * Gets or sets image source url
  54545. */
  54546. source: BABYLON.Nullable<string>;
  54547. /**
  54548. * Gets or sets the cell width to use when animation sheet is enabled
  54549. * @see http://doc.babylonjs.com/how_to/gui#image
  54550. */
  54551. cellWidth: number;
  54552. /**
  54553. * Gets or sets the cell height to use when animation sheet is enabled
  54554. * @see http://doc.babylonjs.com/how_to/gui#image
  54555. */
  54556. cellHeight: number;
  54557. /**
  54558. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  54559. * @see http://doc.babylonjs.com/how_to/gui#image
  54560. */
  54561. cellId: number;
  54562. /**
  54563. * Creates a new Image
  54564. * @param name defines the control name
  54565. * @param url defines the image url
  54566. */
  54567. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  54568. /**
  54569. * Tests if a given coordinates belong to the current control
  54570. * @param x defines x coordinate to test
  54571. * @param y defines y coordinate to test
  54572. * @returns true if the coordinates are inside the control
  54573. */
  54574. contains(x: number, y: number): boolean;
  54575. protected _getTypeName(): string;
  54576. /** Force the control to synchronize with its content */
  54577. synchronizeSizeWithContent(): void;
  54578. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  54579. private _prepareWorkingCanvasForOpaqueDetection;
  54580. private _drawImage; draw(context: CanvasRenderingContext2D): void;
  54581. private _renderCornerPatch;
  54582. private _renderNinePatch;
  54583. dispose(): void;
  54584. /** STRETCH_NONE */
  54585. static readonly STRETCH_NONE: number;
  54586. /** STRETCH_FILL */
  54587. static readonly STRETCH_FILL: number;
  54588. /** STRETCH_UNIFORM */
  54589. static readonly STRETCH_UNIFORM: number;
  54590. /** STRETCH_EXTEND */
  54591. static readonly STRETCH_EXTEND: number;
  54592. /** NINE_PATCH */
  54593. static readonly STRETCH_NINE_PATCH: number;
  54594. }
  54595. }
  54596. declare module BABYLON.GUI {
  54597. /**
  54598. * Class used to create 2D buttons
  54599. */
  54600. export class Button extends Rectangle {
  54601. name?: string | undefined;
  54602. /**
  54603. * Function called to generate a pointer enter animation
  54604. */
  54605. pointerEnterAnimation: () => void;
  54606. /**
  54607. * Function called to generate a pointer out animation
  54608. */
  54609. pointerOutAnimation: () => void;
  54610. /**
  54611. * Function called to generate a pointer down animation
  54612. */
  54613. pointerDownAnimation: () => void;
  54614. /**
  54615. * Function called to generate a pointer up animation
  54616. */
  54617. pointerUpAnimation: () => void;
  54618. private _image;
  54619. /**
  54620. * Returns the image part of the button (if any)
  54621. */
  54622. readonly image: BABYLON.Nullable<Image>;
  54623. private _textBlock;
  54624. /**
  54625. * Returns the image part of the button (if any)
  54626. */
  54627. readonly textBlock: BABYLON.Nullable<TextBlock>;
  54628. /**
  54629. * Creates a new Button
  54630. * @param name defines the name of the button
  54631. */
  54632. constructor(name?: string | undefined);
  54633. protected _getTypeName(): string;
  54634. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  54635. /** @hidden */ onPointerEnter(target: Control): boolean;
  54636. /** @hidden */ onPointerOut(target: Control): void;
  54637. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  54638. /** @hidden */ onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  54639. /**
  54640. * Creates a new button made with an image and a text
  54641. * @param name defines the name of the button
  54642. * @param text defines the text of the button
  54643. * @param imageUrl defines the url of the image
  54644. * @returns a new Button
  54645. */
  54646. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  54647. /**
  54648. * Creates a new button made with an image
  54649. * @param name defines the name of the button
  54650. * @param imageUrl defines the url of the image
  54651. * @returns a new Button
  54652. */
  54653. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  54654. /**
  54655. * Creates a new button made with a text
  54656. * @param name defines the name of the button
  54657. * @param text defines the text of the button
  54658. * @returns a new Button
  54659. */
  54660. static CreateSimpleButton(name: string, text: string): Button;
  54661. /**
  54662. * Creates a new button made with an image and a centered text
  54663. * @param name defines the name of the button
  54664. * @param text defines the text of the button
  54665. * @param imageUrl defines the url of the image
  54666. * @returns a new Button
  54667. */
  54668. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  54669. }
  54670. }
  54671. declare module BABYLON.GUI {
  54672. /**
  54673. * Class used to create a 2D stack panel container
  54674. */
  54675. export class StackPanel extends Container {
  54676. name?: string | undefined;
  54677. private _isVertical;
  54678. private _manualWidth;
  54679. private _manualHeight;
  54680. private _doNotTrackManualChanges;
  54681. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  54682. isVertical: boolean;
  54683. /**
  54684. * Gets or sets panel width.
  54685. * This value should not be set when in horizontal mode as it will be computed automatically
  54686. */
  54687. width: string | number;
  54688. /**
  54689. * Gets or sets panel height.
  54690. * This value should not be set when in vertical mode as it will be computed automatically
  54691. */
  54692. height: string | number;
  54693. /**
  54694. * Creates a new StackPanel
  54695. * @param name defines control name
  54696. */
  54697. constructor(name?: string | undefined);
  54698. protected _getTypeName(): string;
  54699. /** @hidden */
  54700. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  54701. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  54702. protected _postMeasure(): void;
  54703. }
  54704. }
  54705. declare module BABYLON.GUI {
  54706. /**
  54707. * Class used to represent a 2D checkbox
  54708. */
  54709. export class Checkbox extends Control {
  54710. name?: string | undefined;
  54711. private _isChecked;
  54712. private _background;
  54713. private _checkSizeRatio;
  54714. private _thickness;
  54715. /** Gets or sets border thickness */
  54716. thickness: number;
  54717. /**
  54718. * BABYLON.Observable raised when isChecked property changes
  54719. */
  54720. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  54721. /** Gets or sets a value indicating the ratio between overall size and check size */
  54722. checkSizeRatio: number;
  54723. /** Gets or sets background color */
  54724. background: string;
  54725. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  54726. isChecked: boolean;
  54727. /**
  54728. * Creates a new CheckBox
  54729. * @param name defines the control name
  54730. */
  54731. constructor(name?: string | undefined);
  54732. protected _getTypeName(): string;
  54733. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  54734. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  54735. /**
  54736. * Utility function to easily create a checkbox with a header
  54737. * @param title defines the label to use for the header
  54738. * @param onValueChanged defines the callback to call when value changes
  54739. * @returns a StackPanel containing the checkbox and a textBlock
  54740. */
  54741. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  54742. }
  54743. }
  54744. declare module BABYLON.GUI {
  54745. /**
  54746. * Class used to store key control properties
  54747. */
  54748. export class KeyPropertySet {
  54749. /** Width */
  54750. width?: string;
  54751. /** Height */
  54752. height?: string;
  54753. /** Left padding */
  54754. paddingLeft?: string;
  54755. /** Right padding */
  54756. paddingRight?: string;
  54757. /** Top padding */
  54758. paddingTop?: string;
  54759. /** Bottom padding */
  54760. paddingBottom?: string;
  54761. /** Foreground color */
  54762. color?: string;
  54763. /** Background color */
  54764. background?: string;
  54765. }
  54766. /**
  54767. * Class used to create virtual keyboard
  54768. */
  54769. export class VirtualKeyboard extends StackPanel {
  54770. /** BABYLON.Observable raised when a key is pressed */
  54771. onKeyPressObservable: BABYLON.Observable<string>;
  54772. /** Gets or sets default key button width */
  54773. defaultButtonWidth: string;
  54774. /** Gets or sets default key button height */
  54775. defaultButtonHeight: string;
  54776. /** Gets or sets default key button left padding */
  54777. defaultButtonPaddingLeft: string;
  54778. /** Gets or sets default key button right padding */
  54779. defaultButtonPaddingRight: string;
  54780. /** Gets or sets default key button top padding */
  54781. defaultButtonPaddingTop: string;
  54782. /** Gets or sets default key button bottom padding */
  54783. defaultButtonPaddingBottom: string;
  54784. /** Gets or sets default key button foreground color */
  54785. defaultButtonColor: string;
  54786. /** Gets or sets default key button background color */
  54787. defaultButtonBackground: string;
  54788. /** Gets or sets shift button foreground color */
  54789. shiftButtonColor: string;
  54790. /** Gets or sets shift button thickness*/
  54791. selectedShiftThickness: number;
  54792. /** Gets shift key state */
  54793. shiftState: number;
  54794. protected _getTypeName(): string;
  54795. private _createKey;
  54796. /**
  54797. * Adds a new row of keys
  54798. * @param keys defines the list of keys to add
  54799. * @param propertySets defines the associated property sets
  54800. */
  54801. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  54802. /**
  54803. * Set the shift key to a specific state
  54804. * @param shiftState defines the new shift state
  54805. */
  54806. applyShiftState(shiftState: number): void;
  54807. private _currentlyConnectedInputText;
  54808. private _connectedInputTexts;
  54809. private _onKeyPressObserver;
  54810. /** Gets the input text control currently attached to the keyboard */
  54811. readonly connectedInputText: BABYLON.Nullable<InputText>;
  54812. /**
  54813. * Connects the keyboard with an input text control
  54814. *
  54815. * @param input defines the target control
  54816. */
  54817. connect(input: InputText): void;
  54818. /**
  54819. * Disconnects the keyboard from connected InputText controls
  54820. *
  54821. * @param input optionally defines a target control, otherwise all are disconnected
  54822. */
  54823. disconnect(input?: InputText): void;
  54824. private _removeConnectedInputObservables;
  54825. /**
  54826. * Release all resources
  54827. */
  54828. dispose(): void;
  54829. /**
  54830. * Creates a new keyboard using a default layout
  54831. *
  54832. * @param name defines control name
  54833. * @returns a new VirtualKeyboard
  54834. */
  54835. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  54836. }
  54837. }
  54838. declare module BABYLON.GUI {
  54839. /**
  54840. * Class used to create input text control
  54841. */
  54842. export class InputText extends Control implements IFocusableControl {
  54843. name?: string | undefined;
  54844. private _text;
  54845. private _placeholderText;
  54846. private _background;
  54847. private _focusedBackground;
  54848. private _focusedColor;
  54849. private _placeholderColor;
  54850. private _thickness;
  54851. private _margin;
  54852. private _autoStretchWidth;
  54853. private _maxWidth;
  54854. private _isFocused;
  54855. private _blinkTimeout;
  54856. private _blinkIsEven;
  54857. private _cursorOffset;
  54858. private _scrollLeft;
  54859. private _textWidth;
  54860. private _clickedCoordinate;
  54861. private _deadKey;
  54862. private _addKey;
  54863. private _currentKey;
  54864. private _isTextHighlightOn;
  54865. private _textHighlightColor;
  54866. private _highligherOpacity;
  54867. private _highlightedText;
  54868. private _startHighlightIndex;
  54869. private _endHighlightIndex;
  54870. private _cursorIndex;
  54871. private _onFocusSelectAll;
  54872. private _isPointerDown;
  54873. private _onClipboardObserver;
  54874. private _onPointerDblTapObserver;
  54875. /** @hidden */ connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  54876. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  54877. promptMessage: string;
  54878. /** BABYLON.Observable raised when the text changes */
  54879. onTextChangedObservable: BABYLON.Observable<InputText>;
  54880. /** BABYLON.Observable raised just before an entered character is to be added */
  54881. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  54882. /** BABYLON.Observable raised when the control gets the focus */
  54883. onFocusObservable: BABYLON.Observable<InputText>;
  54884. /** BABYLON.Observable raised when the control loses the focus */
  54885. onBlurObservable: BABYLON.Observable<InputText>;
  54886. /**Observable raised when the text is highlighted */
  54887. onTextHighlightObservable: BABYLON.Observable<InputText>;
  54888. /**Observable raised when copy event is triggered */
  54889. onTextCopyObservable: BABYLON.Observable<InputText>;
  54890. /** BABYLON.Observable raised when cut event is triggered */
  54891. onTextCutObservable: BABYLON.Observable<InputText>;
  54892. /** BABYLON.Observable raised when paste event is triggered */
  54893. onTextPasteObservable: BABYLON.Observable<InputText>;
  54894. /** BABYLON.Observable raised when a key event was processed */
  54895. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  54896. /** Gets or sets the maximum width allowed by the control */
  54897. maxWidth: string | number;
  54898. /** Gets the maximum width allowed by the control in pixels */
  54899. readonly maxWidthInPixels: number;
  54900. /** Gets or sets the text highlighter transparency; default: 0.4 */
  54901. highligherOpacity: number;
  54902. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  54903. onFocusSelectAll: boolean;
  54904. /** Gets or sets the text hightlight color */
  54905. textHighlightColor: string;
  54906. /** Gets or sets control margin */
  54907. margin: string;
  54908. /** Gets control margin in pixels */
  54909. readonly marginInPixels: number;
  54910. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  54911. autoStretchWidth: boolean;
  54912. /** Gets or sets border thickness */
  54913. thickness: number;
  54914. /** Gets or sets the background color when focused */
  54915. focusedBackground: string;
  54916. /** Gets or sets the background color when focused */
  54917. focusedColor: string;
  54918. /** Gets or sets the background color */
  54919. background: string;
  54920. /** Gets or sets the placeholder color */
  54921. placeholderColor: string;
  54922. /** Gets or sets the text displayed when the control is empty */
  54923. placeholderText: string;
  54924. /** Gets or sets the dead key flag */
  54925. deadKey: boolean;
  54926. /** Gets or sets the highlight text */
  54927. highlightedText: string;
  54928. /** Gets or sets if the current key should be added */
  54929. addKey: boolean;
  54930. /** Gets or sets the value of the current key being entered */
  54931. currentKey: string;
  54932. /** Gets or sets the text displayed in the control */
  54933. text: string;
  54934. /** Gets or sets control width */
  54935. width: string | number;
  54936. /**
  54937. * Creates a new InputText
  54938. * @param name defines the control name
  54939. * @param text defines the text of the control
  54940. */
  54941. constructor(name?: string | undefined, text?: string);
  54942. /** @hidden */
  54943. onBlur(): void;
  54944. /** @hidden */
  54945. onFocus(): void;
  54946. protected _getTypeName(): string;
  54947. /**
  54948. * Function called to get the list of controls that should not steal the focus from this control
  54949. * @returns an array of controls
  54950. */
  54951. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  54952. /** @hidden */
  54953. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  54954. /** @hidden */
  54955. private _updateValueFromCursorIndex;
  54956. /** @hidden */
  54957. private _processDblClick;
  54958. /** @hidden */
  54959. private _selectAllText;
  54960. /**
  54961. * Handles the keyboard event
  54962. * @param evt Defines the KeyboardEvent
  54963. */
  54964. processKeyboard(evt: KeyboardEvent): void;
  54965. /** @hidden */
  54966. private _onCopyText;
  54967. /** @hidden */
  54968. private _onCutText;
  54969. /** @hidden */
  54970. 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;
  54971. protected _beforeRenderText(text: string): string;
  54972. dispose(): void;
  54973. }
  54974. }
  54975. declare module BABYLON.GUI {
  54976. /**
  54977. * Class used to create a 2D grid container
  54978. */
  54979. export class Grid extends Container {
  54980. name?: string | undefined;
  54981. private _rowDefinitions;
  54982. private _columnDefinitions;
  54983. private _cells;
  54984. private _childControls;
  54985. /**
  54986. * Gets the number of columns
  54987. */
  54988. readonly columnCount: number;
  54989. /**
  54990. * Gets the number of rows
  54991. */
  54992. readonly rowCount: number;
  54993. /** Gets the list of children */
  54994. readonly children: Control[];
  54995. /**
  54996. * Gets the definition of a specific row
  54997. * @param index defines the index of the row
  54998. * @returns the row definition
  54999. */
  55000. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  55001. /**
  55002. * Gets the definition of a specific column
  55003. * @param index defines the index of the column
  55004. * @returns the column definition
  55005. */
  55006. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  55007. /**
  55008. * Adds a new row to the grid
  55009. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  55010. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  55011. * @returns the current grid
  55012. */
  55013. addRowDefinition(height: number, isPixel?: boolean): Grid;
  55014. /**
  55015. * Adds a new column to the grid
  55016. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  55017. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  55018. * @returns the current grid
  55019. */
  55020. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  55021. /**
  55022. * Update a row definition
  55023. * @param index defines the index of the row to update
  55024. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  55025. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  55026. * @returns the current grid
  55027. */
  55028. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  55029. /**
  55030. * Update a column definition
  55031. * @param index defines the index of the column to update
  55032. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  55033. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  55034. * @returns the current grid
  55035. */
  55036. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  55037. /**
  55038. * Gets the list of children stored in a specific cell
  55039. * @param row defines the row to check
  55040. * @param column defines the column to check
  55041. * @returns the list of controls
  55042. */
  55043. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  55044. /**
  55045. * Gets a string representing the child cell info (row x column)
  55046. * @param child defines the control to get info from
  55047. * @returns a string containing the child cell info (row x column)
  55048. */
  55049. getChildCellInfo(child: Control): string;
  55050. private _removeCell;
  55051. private _offsetCell;
  55052. /**
  55053. * Remove a column definition at specified index
  55054. * @param index defines the index of the column to remove
  55055. * @returns the current grid
  55056. */
  55057. removeColumnDefinition(index: number): Grid;
  55058. /**
  55059. * Remove a row definition at specified index
  55060. * @param index defines the index of the row to remove
  55061. * @returns the current grid
  55062. */
  55063. removeRowDefinition(index: number): Grid;
  55064. /**
  55065. * Adds a new control to the current grid
  55066. * @param control defines the control to add
  55067. * @param row defines the row where to add the control (0 by default)
  55068. * @param column defines the column where to add the control (0 by default)
  55069. * @returns the current grid
  55070. */
  55071. addControl(control: Control, row?: number, column?: number): Grid;
  55072. /**
  55073. * Removes a control from the current container
  55074. * @param control defines the control to remove
  55075. * @returns the current container
  55076. */
  55077. removeControl(control: Control): Container;
  55078. /**
  55079. * Creates a new Grid
  55080. * @param name defines control name
  55081. */
  55082. constructor(name?: string | undefined);
  55083. protected _getTypeName(): string;
  55084. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  55085. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; flagDescendantsAsMatrixDirty(): void; renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  55086. /** Releases associated resources */
  55087. dispose(): void;
  55088. }
  55089. }
  55090. declare module BABYLON.GUI {
  55091. /** Class used to create color pickers */
  55092. export class ColorPicker extends Control {
  55093. name?: string | undefined;
  55094. private static _Epsilon;
  55095. private _colorWheelCanvas;
  55096. private _value;
  55097. private _tmpColor;
  55098. private _pointerStartedOnSquare;
  55099. private _pointerStartedOnWheel;
  55100. private _squareLeft;
  55101. private _squareTop;
  55102. private _squareSize;
  55103. private _h;
  55104. private _s;
  55105. private _v;
  55106. /**
  55107. * BABYLON.Observable raised when the value changes
  55108. */
  55109. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  55110. /** Gets or sets the color of the color picker */
  55111. value: BABYLON.Color3;
  55112. /**
  55113. * Gets or sets control width
  55114. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  55115. */
  55116. width: string | number;
  55117. /**
  55118. * Gets or sets control height
  55119. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  55120. */
  55121. /** Gets or sets control height */
  55122. height: string | number;
  55123. /** Gets or sets control size */
  55124. size: string | number;
  55125. /**
  55126. * Creates a new ColorPicker
  55127. * @param name defines the control name
  55128. */
  55129. constructor(name?: string | undefined);
  55130. protected _getTypeName(): string;
  55131. /** @hidden */
  55132. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  55133. private _updateSquareProps;
  55134. private _drawGradientSquare;
  55135. private _drawCircle;
  55136. private _createColorWheelCanvas;
  55137. private _RGBtoHSV;
  55138. private _HSVtoRGB;
  55139. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  55140. private _pointerIsDown;
  55141. private _updateValueFromPointer;
  55142. private _isPointOnSquare;
  55143. 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;
  55144. /**
  55145. * This function expands the color picker by creating a color picker dialog with manual
  55146. * color value input and the ability to save colors into an array to be used later in
  55147. * subsequent launches of the dialogue.
  55148. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  55149. * @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.
  55150. * @returns picked color as a hex string and the saved colors array as hex strings.
  55151. */
  55152. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  55153. pickerWidth?: string;
  55154. pickerHeight?: string;
  55155. headerHeight?: string;
  55156. lastColor?: string;
  55157. swatchLimit?: number;
  55158. numSwatchesPerLine?: number;
  55159. savedColors?: Array<string>;
  55160. }): Promise<{
  55161. savedColors?: string[];
  55162. pickedColor: string;
  55163. }>;
  55164. }
  55165. }
  55166. declare module BABYLON.GUI {
  55167. /** Class used to create 2D ellipse containers */
  55168. export class Ellipse extends Container {
  55169. name?: string | undefined;
  55170. private _thickness;
  55171. /** Gets or sets border thickness */
  55172. thickness: number;
  55173. /**
  55174. * Creates a new Ellipse
  55175. * @param name defines the control name
  55176. */
  55177. constructor(name?: string | undefined);
  55178. protected _getTypeName(): string;
  55179. protected _localDraw(context: CanvasRenderingContext2D): void;
  55180. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  55181. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  55182. }
  55183. }
  55184. declare module BABYLON.GUI {
  55185. /**
  55186. * Class used to create a password control
  55187. */
  55188. export class InputPassword extends InputText {
  55189. protected _beforeRenderText(text: string): string;
  55190. }
  55191. }
  55192. declare module BABYLON.GUI {
  55193. /** Class used to render 2D lines */
  55194. export class Line extends Control {
  55195. name?: string | undefined;
  55196. private _lineWidth;
  55197. private _x1;
  55198. private _y1;
  55199. private _x2;
  55200. private _y2;
  55201. private _dash;
  55202. private _connectedControl;
  55203. private _connectedControlDirtyObserver;
  55204. /** Gets or sets the dash pattern */
  55205. dash: Array<number>;
  55206. /** Gets or sets the control connected with the line end */
  55207. connectedControl: Control;
  55208. /** Gets or sets start coordinates on X axis */
  55209. x1: string | number;
  55210. /** Gets or sets start coordinates on Y axis */
  55211. y1: string | number;
  55212. /** Gets or sets end coordinates on X axis */
  55213. x2: string | number;
  55214. /** Gets or sets end coordinates on Y axis */
  55215. y2: string | number;
  55216. /** Gets or sets line width */
  55217. lineWidth: number;
  55218. /** Gets or sets horizontal alignment */
  55219. horizontalAlignment: number;
  55220. /** Gets or sets vertical alignment */
  55221. verticalAlignment: number;
  55222. private readonly _effectiveX2;
  55223. private readonly _effectiveY2;
  55224. /**
  55225. * Creates a new Line
  55226. * @param name defines the control name
  55227. */
  55228. constructor(name?: string | undefined);
  55229. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void; measure(): void;
  55230. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  55231. /**
  55232. * Move one end of the line given 3D cartesian coordinates.
  55233. * @param position Targeted world position
  55234. * @param scene BABYLON.Scene
  55235. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  55236. */
  55237. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  55238. /**
  55239. * Move one end of the line to a position in screen absolute space.
  55240. * @param projectedPosition Position in screen absolute space (X, Y)
  55241. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  55242. */ moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  55243. }
  55244. }
  55245. declare module BABYLON.GUI {
  55246. /**
  55247. * Class used to store a point for a MultiLine object.
  55248. * The point can be pure 2D coordinates, a mesh or a control
  55249. */
  55250. export class MultiLinePoint {
  55251. private _multiLine;
  55252. private _x;
  55253. private _y;
  55254. private _control;
  55255. private _mesh;
  55256. private _controlObserver;
  55257. private _meshObserver;
  55258. /** @hidden */ point: BABYLON.Vector2;
  55259. /**
  55260. * Creates a new MultiLinePoint
  55261. * @param multiLine defines the source MultiLine object
  55262. */
  55263. constructor(multiLine: MultiLine);
  55264. /** Gets or sets x coordinate */
  55265. x: string | number;
  55266. /** Gets or sets y coordinate */
  55267. y: string | number;
  55268. /** Gets or sets the control associated with this point */
  55269. control: BABYLON.Nullable<Control>;
  55270. /** Gets or sets the mesh associated with this point */
  55271. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  55272. /** Resets links */
  55273. resetLinks(): void;
  55274. /**
  55275. * Gets a translation vector
  55276. * @returns the translation vector
  55277. */
  55278. translate(): BABYLON.Vector2;
  55279. private _translatePoint;
  55280. /** Release associated resources */
  55281. dispose(): void;
  55282. }
  55283. }
  55284. declare module BABYLON.GUI {
  55285. /**
  55286. * Class used to create multi line control
  55287. */
  55288. export class MultiLine extends Control {
  55289. name?: string | undefined;
  55290. private _lineWidth;
  55291. private _dash;
  55292. private _points;
  55293. private _minX;
  55294. private _minY;
  55295. private _maxX;
  55296. private _maxY;
  55297. /**
  55298. * Creates a new MultiLine
  55299. * @param name defines the control name
  55300. */
  55301. constructor(name?: string | undefined);
  55302. /** Gets or sets dash pattern */
  55303. dash: Array<number>;
  55304. /**
  55305. * Gets point stored at specified index
  55306. * @param index defines the index to look for
  55307. * @returns the requested point if found
  55308. */
  55309. getAt(index: number): MultiLinePoint;
  55310. /** Function called when a point is updated */
  55311. onPointUpdate: () => void;
  55312. /**
  55313. * Adds new points to the point collection
  55314. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  55315. * @returns the list of created MultiLinePoint
  55316. */
  55317. add(...items: (AbstractMesh | Control | {
  55318. x: string | number;
  55319. y: string | number;
  55320. })[]): MultiLinePoint[];
  55321. /**
  55322. * Adds a new point to the point collection
  55323. * @param item defines the item (mesh, control or 2d coordiantes) to add
  55324. * @returns the created MultiLinePoint
  55325. */
  55326. push(item?: (AbstractMesh | Control | {
  55327. x: string | number;
  55328. y: string | number;
  55329. })): MultiLinePoint;
  55330. /**
  55331. * Remove a specific value or point from the active point collection
  55332. * @param value defines the value or point to remove
  55333. */
  55334. remove(value: number | MultiLinePoint): void;
  55335. /**
  55336. * Resets this object to initial state (no point)
  55337. */
  55338. reset(): void;
  55339. /**
  55340. * Resets all links
  55341. */
  55342. resetLinks(): void;
  55343. /** Gets or sets line width */
  55344. lineWidth: number;
  55345. horizontalAlignment: number;
  55346. verticalAlignment: number;
  55347. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  55348. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; measure(): void;
  55349. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  55350. dispose(): void;
  55351. }
  55352. }
  55353. declare module BABYLON.GUI {
  55354. /**
  55355. * Class used to create radio button controls
  55356. */
  55357. export class RadioButton extends Control {
  55358. name?: string | undefined;
  55359. private _isChecked;
  55360. private _background;
  55361. private _checkSizeRatio;
  55362. private _thickness;
  55363. /** Gets or sets border thickness */
  55364. thickness: number;
  55365. /** Gets or sets group name */
  55366. group: string;
  55367. /** BABYLON.Observable raised when isChecked is changed */
  55368. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  55369. /** Gets or sets a value indicating the ratio between overall size and check size */
  55370. checkSizeRatio: number;
  55371. /** Gets or sets background color */
  55372. background: string;
  55373. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  55374. isChecked: boolean;
  55375. /**
  55376. * Creates a new RadioButton
  55377. * @param name defines the control name
  55378. */
  55379. constructor(name?: string | undefined);
  55380. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  55381. /**
  55382. * Utility function to easily create a radio button with a header
  55383. * @param title defines the label to use for the header
  55384. * @param group defines the group to use for the radio button
  55385. * @param isChecked defines the initial state of the radio button
  55386. * @param onValueChanged defines the callback to call when value changes
  55387. * @returns a StackPanel containing the radio button and a textBlock
  55388. */
  55389. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  55390. }
  55391. }
  55392. declare module BABYLON.GUI {
  55393. /**
  55394. * Class used to create slider controls
  55395. */
  55396. export class BaseSlider extends Control {
  55397. name?: string | undefined;
  55398. protected _thumbWidth: ValueAndUnit;
  55399. private _minimum;
  55400. private _maximum;
  55401. private _value;
  55402. private _isVertical;
  55403. protected _barOffset: ValueAndUnit;
  55404. private _isThumbClamped;
  55405. protected _displayThumb: boolean;
  55406. protected _effectiveBarOffset: number;
  55407. protected _renderLeft: number;
  55408. protected _renderTop: number;
  55409. protected _renderWidth: number;
  55410. protected _renderHeight: number;
  55411. protected _backgroundBoxLength: number;
  55412. protected _backgroundBoxThickness: number;
  55413. protected _effectiveThumbThickness: number;
  55414. /** BABYLON.Observable raised when the sldier value changes */
  55415. onValueChangedObservable: BABYLON.Observable<number>;
  55416. /** Gets or sets a boolean indicating if the thumb must be rendered */
  55417. displayThumb: boolean;
  55418. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  55419. barOffset: string | number;
  55420. /** Gets main bar offset in pixels*/
  55421. readonly barOffsetInPixels: number;
  55422. /** Gets or sets thumb width */
  55423. thumbWidth: string | number;
  55424. /** Gets thumb width in pixels */
  55425. readonly thumbWidthInPixels: number;
  55426. /** Gets or sets minimum value */
  55427. minimum: number;
  55428. /** Gets or sets maximum value */
  55429. maximum: number;
  55430. /** Gets or sets current value */
  55431. value: number;
  55432. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  55433. isVertical: boolean;
  55434. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  55435. isThumbClamped: boolean;
  55436. /**
  55437. * Creates a new BaseSlider
  55438. * @param name defines the control name
  55439. */
  55440. constructor(name?: string | undefined);
  55441. protected _getTypeName(): string;
  55442. protected _getThumbPosition(): number;
  55443. protected _getThumbThickness(type: string): number;
  55444. protected _prepareRenderingData(type: string): void;
  55445. private _pointerIsDown;
  55446. /** @hidden */
  55447. 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;
  55448. }
  55449. }
  55450. declare module BABYLON.GUI {
  55451. /**
  55452. * Class used to create slider controls
  55453. */
  55454. export class Slider extends BaseSlider {
  55455. name?: string | undefined;
  55456. private _background;
  55457. private _borderColor;
  55458. private _isThumbCircle;
  55459. protected _displayValueBar: boolean;
  55460. /** Gets or sets a boolean indicating if the value bar must be rendered */
  55461. displayValueBar: boolean;
  55462. /** Gets or sets border color */
  55463. borderColor: string;
  55464. /** Gets or sets background color */
  55465. background: string;
  55466. /** Gets or sets a boolean indicating if the thumb should be round or square */
  55467. isThumbCircle: boolean;
  55468. /**
  55469. * Creates a new Slider
  55470. * @param name defines the control name
  55471. */
  55472. constructor(name?: string | undefined);
  55473. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  55474. }
  55475. }
  55476. declare module BABYLON.GUI {
  55477. /** Class used to create a RadioGroup
  55478. * which contains groups of radio buttons
  55479. */
  55480. export class SelectorGroup {
  55481. /** name of SelectorGroup */
  55482. name: string;
  55483. private _groupPanel;
  55484. private _selectors;
  55485. private _groupHeader;
  55486. /**
  55487. * Creates a new SelectorGroup
  55488. * @param name of group, used as a group heading
  55489. */
  55490. constructor(
  55491. /** name of SelectorGroup */
  55492. name: string);
  55493. /** Gets the groupPanel of the SelectorGroup */
  55494. readonly groupPanel: StackPanel;
  55495. /** Gets the selectors array */
  55496. readonly selectors: StackPanel[];
  55497. /** Gets and sets the group header */
  55498. header: string;
  55499. /** @hidden */
  55500. private _addGroupHeader;
  55501. /** @hidden*/ getSelector(selectorNb: number): StackPanel | undefined;
  55502. /** Removes the selector at the given position
  55503. * @param selectorNb the position of the selector within the group
  55504. */
  55505. removeSelector(selectorNb: number): void;
  55506. }
  55507. /** Class used to create a CheckboxGroup
  55508. * which contains groups of checkbox buttons
  55509. */
  55510. export class CheckboxGroup extends SelectorGroup {
  55511. /** Adds a checkbox as a control
  55512. * @param text is the label for the selector
  55513. * @param func is the function called when the Selector is checked
  55514. * @param checked is true when Selector is checked
  55515. */
  55516. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  55517. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  55518. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  55519. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  55520. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  55521. }
  55522. /** Class used to create a RadioGroup
  55523. * which contains groups of radio buttons
  55524. */
  55525. export class RadioGroup extends SelectorGroup {
  55526. private _selectNb;
  55527. /** Adds a radio button as a control
  55528. * @param label is the label for the selector
  55529. * @param func is the function called when the Selector is checked
  55530. * @param checked is true when Selector is checked
  55531. */
  55532. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  55533. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  55534. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  55535. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  55536. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  55537. }
  55538. /** Class used to create a SliderGroup
  55539. * which contains groups of slider buttons
  55540. */
  55541. export class SliderGroup extends SelectorGroup {
  55542. /**
  55543. * Adds a slider to the SelectorGroup
  55544. * @param label is the label for the SliderBar
  55545. * @param func is the function called when the Slider moves
  55546. * @param unit is a string describing the units used, eg degrees or metres
  55547. * @param min is the minimum value for the Slider
  55548. * @param max is the maximum value for the Slider
  55549. * @param value is the start value for the Slider between min and max
  55550. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  55551. */
  55552. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  55553. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  55554. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  55555. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  55556. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  55557. }
  55558. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  55559. * @see http://doc.babylonjs.com/how_to/selector
  55560. */
  55561. export class SelectionPanel extends Rectangle {
  55562. /** name of SelectionPanel */
  55563. name: string;
  55564. /** an array of SelectionGroups */
  55565. groups: SelectorGroup[];
  55566. private _panel;
  55567. private _buttonColor;
  55568. private _buttonBackground;
  55569. private _headerColor;
  55570. private _barColor;
  55571. private _barHeight;
  55572. private _spacerHeight;
  55573. private _labelColor;
  55574. private _groups;
  55575. private _bars;
  55576. /**
  55577. * Creates a new SelectionPanel
  55578. * @param name of SelectionPanel
  55579. * @param groups is an array of SelectionGroups
  55580. */
  55581. constructor(
  55582. /** name of SelectionPanel */
  55583. name: string,
  55584. /** an array of SelectionGroups */
  55585. groups?: SelectorGroup[]);
  55586. protected _getTypeName(): string;
  55587. /** Gets or sets the headerColor */
  55588. headerColor: string;
  55589. private _setHeaderColor;
  55590. /** Gets or sets the button color */
  55591. buttonColor: string;
  55592. private _setbuttonColor;
  55593. /** Gets or sets the label color */
  55594. labelColor: string;
  55595. private _setLabelColor;
  55596. /** Gets or sets the button background */
  55597. buttonBackground: string;
  55598. private _setButtonBackground;
  55599. /** Gets or sets the color of separator bar */
  55600. barColor: string;
  55601. private _setBarColor;
  55602. /** Gets or sets the height of separator bar */
  55603. barHeight: string;
  55604. private _setBarHeight;
  55605. /** Gets or sets the height of spacers*/
  55606. spacerHeight: string;
  55607. private _setSpacerHeight;
  55608. /** Adds a bar between groups */
  55609. private _addSpacer;
  55610. /** Add a group to the selection panel
  55611. * @param group is the selector group to add
  55612. */
  55613. addGroup(group: SelectorGroup): void;
  55614. /** Remove the group from the given position
  55615. * @param groupNb is the position of the group in the list
  55616. */
  55617. removeGroup(groupNb: number): void;
  55618. /** Change a group header label
  55619. * @param label is the new group header label
  55620. * @param groupNb is the number of the group to relabel
  55621. * */
  55622. setHeaderName(label: string, groupNb: number): void;
  55623. /** Change selector label to the one given
  55624. * @param label is the new selector label
  55625. * @param groupNb is the number of the groupcontaining the selector
  55626. * @param selectorNb is the number of the selector within a group to relabel
  55627. * */
  55628. relabel(label: string, groupNb: number, selectorNb: number): void;
  55629. /** For a given group position remove the selector at the given position
  55630. * @param groupNb is the number of the group to remove the selector from
  55631. * @param selectorNb is the number of the selector within the group
  55632. */
  55633. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  55634. /** For a given group position of correct type add a checkbox button
  55635. * @param groupNb is the number of the group to remove the selector from
  55636. * @param label is the label for the selector
  55637. * @param func is the function called when the Selector is checked
  55638. * @param checked is true when Selector is checked
  55639. */
  55640. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  55641. /** For a given group position of correct type add a radio button
  55642. * @param groupNb is the number of the group to remove the selector from
  55643. * @param label is the label for the selector
  55644. * @param func is the function called when the Selector is checked
  55645. * @param checked is true when Selector is checked
  55646. */
  55647. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  55648. /**
  55649. * For a given slider group add a slider
  55650. * @param groupNb is the number of the group to add the slider to
  55651. * @param label is the label for the Slider
  55652. * @param func is the function called when the Slider moves
  55653. * @param unit is a string describing the units used, eg degrees or metres
  55654. * @param min is the minimum value for the Slider
  55655. * @param max is the maximum value for the Slider
  55656. * @param value is the start value for the Slider between min and max
  55657. * @param onVal is the function used to format the value displayed, eg radians to degrees
  55658. */
  55659. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  55660. }
  55661. }
  55662. declare module BABYLON.GUI {
  55663. /**
  55664. * Class used to hold a the container for ScrollViewer
  55665. * @hidden
  55666. */
  55667. export class _ScrollViewerWindow extends Container {
  55668. parentClientWidth: number;
  55669. parentClientHeight: number;
  55670. /**
  55671. * Creates a new ScrollViewerWindow
  55672. * @param name of ScrollViewerWindow
  55673. */
  55674. constructor(name?: string);
  55675. protected _getTypeName(): string;
  55676. /** @hidden */
  55677. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  55678. protected _postMeasure(): void;
  55679. }
  55680. }
  55681. declare module BABYLON.GUI {
  55682. /**
  55683. * Class used to create slider controls
  55684. */
  55685. export class ScrollBar extends BaseSlider {
  55686. name?: string | undefined;
  55687. private _background;
  55688. private _borderColor;
  55689. private _thumbMeasure;
  55690. /** Gets or sets border color */
  55691. borderColor: string;
  55692. /** Gets or sets background color */
  55693. background: string;
  55694. /**
  55695. * Creates a new Slider
  55696. * @param name defines the control name
  55697. */
  55698. constructor(name?: string | undefined);
  55699. protected _getTypeName(): string;
  55700. protected _getThumbThickness(): number; draw(context: CanvasRenderingContext2D): void;
  55701. private _first;
  55702. private _originX;
  55703. private _originY;
  55704. /** @hidden */
  55705. protected _updateValueFromPointer(x: number, y: number): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  55706. }
  55707. }
  55708. declare module BABYLON.GUI {
  55709. /**
  55710. * Class used to hold a viewer window and sliders in a grid
  55711. */
  55712. export class ScrollViewer extends Rectangle {
  55713. private _grid;
  55714. private _horizontalBarSpace;
  55715. private _verticalBarSpace;
  55716. private _dragSpace;
  55717. private _horizontalBar;
  55718. private _verticalBar;
  55719. private _barColor;
  55720. private _barBackground;
  55721. private _barSize;
  55722. private _endLeft;
  55723. private _endTop;
  55724. private _window;
  55725. private _pointerIsOver;
  55726. private _wheelPrecision;
  55727. private _onPointerObserver;
  55728. private _clientWidth;
  55729. private _clientHeight;
  55730. /**
  55731. * Gets the horizontal scrollbar
  55732. */
  55733. readonly horizontalBar: ScrollBar;
  55734. /**
  55735. * Gets the vertical scrollbar
  55736. */
  55737. readonly verticalBar: ScrollBar;
  55738. /**
  55739. * Adds a new control to the current container
  55740. * @param control defines the control to add
  55741. * @returns the current container
  55742. */
  55743. addControl(control: BABYLON.Nullable<Control>): Container;
  55744. /**
  55745. * Removes a control from the current container
  55746. * @param control defines the control to remove
  55747. * @returns the current container
  55748. */
  55749. removeControl(control: Control): Container;
  55750. /** Gets the list of children */
  55751. readonly children: Control[]; flagDescendantsAsMatrixDirty(): void;
  55752. /**
  55753. * Creates a new ScrollViewer
  55754. * @param name of ScrollViewer
  55755. */
  55756. constructor(name?: string);
  55757. /** Reset the scroll viewer window to initial size */
  55758. resetWindow(): void;
  55759. protected _getTypeName(): string;
  55760. private _buildClientSizes;
  55761. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  55762. protected _postMeasure(): void;
  55763. /**
  55764. * Gets or sets the mouse wheel precision
  55765. * from 0 to 1 with a default value of 0.05
  55766. * */
  55767. wheelPrecision: number;
  55768. /** Gets or sets the bar color */
  55769. barColor: string;
  55770. /** Gets or sets the size of the bar */
  55771. barSize: number;
  55772. /** Gets or sets the bar background */
  55773. barBackground: string;
  55774. /** @hidden */
  55775. private _updateScroller; link(host: AdvancedDynamicTexture): void;
  55776. /** @hidden */
  55777. private _attachWheel; renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  55778. /** Releases associated resources */
  55779. dispose(): void;
  55780. }
  55781. }
  55782. declare module BABYLON.GUI {
  55783. /** Class used to render a grid */
  55784. export class DisplayGrid extends Control {
  55785. name?: string | undefined;
  55786. private _cellWidth;
  55787. private _cellHeight;
  55788. private _minorLineTickness;
  55789. private _minorLineColor;
  55790. private _majorLineTickness;
  55791. private _majorLineColor;
  55792. private _majorLineFrequency;
  55793. private _background;
  55794. private _displayMajorLines;
  55795. private _displayMinorLines;
  55796. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  55797. displayMinorLines: boolean;
  55798. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  55799. displayMajorLines: boolean;
  55800. /** Gets or sets background color (Black by default) */
  55801. background: string;
  55802. /** Gets or sets the width of each cell (20 by default) */
  55803. cellWidth: number;
  55804. /** Gets or sets the height of each cell (20 by default) */
  55805. cellHeight: number;
  55806. /** Gets or sets the tickness of minor lines (1 by default) */
  55807. minorLineTickness: number;
  55808. /** Gets or sets the color of minor lines (DarkGray by default) */
  55809. minorLineColor: string;
  55810. /** Gets or sets the tickness of major lines (2 by default) */
  55811. majorLineTickness: number;
  55812. /** Gets or sets the color of major lines (White by default) */
  55813. majorLineColor: string;
  55814. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  55815. majorLineFrequency: number;
  55816. /**
  55817. * Creates a new GridDisplayRectangle
  55818. * @param name defines the control name
  55819. */
  55820. constructor(name?: string | undefined); draw(context: CanvasRenderingContext2D): void;
  55821. protected _getTypeName(): string;
  55822. }
  55823. }
  55824. declare module BABYLON.GUI {
  55825. /**
  55826. * Class used to create slider controls based on images
  55827. */
  55828. export class ImageBasedSlider extends BaseSlider {
  55829. name?: string | undefined;
  55830. private _backgroundImage;
  55831. private _thumbImage;
  55832. private _valueBarImage;
  55833. private _tempMeasure;
  55834. displayThumb: boolean;
  55835. /**
  55836. * Gets or sets the image used to render the background
  55837. */
  55838. backgroundImage: Image;
  55839. /**
  55840. * Gets or sets the image used to render the value bar
  55841. */
  55842. valueBarImage: Image;
  55843. /**
  55844. * Gets or sets the image used to render the thumb
  55845. */
  55846. thumbImage: Image;
  55847. /**
  55848. * Creates a new ImageBasedSlider
  55849. * @param name defines the control name
  55850. */
  55851. constructor(name?: string | undefined);
  55852. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  55853. }
  55854. }
  55855. declare module BABYLON.GUI {
  55856. /**
  55857. * Forcing an export so that this code will execute
  55858. * @hidden
  55859. */
  55860. const name = "Statics";
  55861. }
  55862. declare module BABYLON.GUI {
  55863. /**
  55864. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  55865. */
  55866. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  55867. /**
  55868. * Define the instrumented AdvancedDynamicTexture.
  55869. */
  55870. texture: AdvancedDynamicTexture;
  55871. private _captureRenderTime;
  55872. private _renderTime;
  55873. private _captureLayoutTime;
  55874. private _layoutTime;
  55875. private _onBeginRenderObserver;
  55876. private _onEndRenderObserver;
  55877. private _onBeginLayoutObserver;
  55878. private _onEndLayoutObserver;
  55879. /**
  55880. * Gets the perf counter used to capture render time
  55881. */
  55882. readonly renderTimeCounter: BABYLON.PerfCounter;
  55883. /**
  55884. * Gets the perf counter used to capture layout time
  55885. */
  55886. readonly layoutTimeCounter: BABYLON.PerfCounter;
  55887. /**
  55888. * Enable or disable the render time capture
  55889. */
  55890. captureRenderTime: boolean;
  55891. /**
  55892. * Enable or disable the layout time capture
  55893. */
  55894. captureLayoutTime: boolean;
  55895. /**
  55896. * Instantiates a new advanced dynamic texture instrumentation.
  55897. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  55898. * @param texture Defines the AdvancedDynamicTexture to instrument
  55899. */
  55900. constructor(
  55901. /**
  55902. * Define the instrumented AdvancedDynamicTexture.
  55903. */
  55904. texture: AdvancedDynamicTexture);
  55905. /**
  55906. * Dispose and release associated resources.
  55907. */
  55908. dispose(): void;
  55909. }
  55910. }
  55911. declare module BABYLON.GUI {
  55912. /**
  55913. * Class used to create containers for controls
  55914. */
  55915. export class Container3D extends Control3D {
  55916. private _blockLayout;
  55917. /**
  55918. * Gets the list of child controls
  55919. */
  55920. protected _children: Control3D[];
  55921. /**
  55922. * Gets the list of child controls
  55923. */
  55924. readonly children: Array<Control3D>;
  55925. /**
  55926. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  55927. * This is helpful to optimize layout operation when adding multiple children in a row
  55928. */
  55929. blockLayout: boolean;
  55930. /**
  55931. * Creates a new container
  55932. * @param name defines the container name
  55933. */
  55934. constructor(name?: string);
  55935. /**
  55936. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  55937. * @returns the current container
  55938. */
  55939. updateLayout(): Container3D;
  55940. /**
  55941. * Gets a boolean indicating if the given control is in the children of this control
  55942. * @param control defines the control to check
  55943. * @returns true if the control is in the child list
  55944. */
  55945. containsControl(control: Control3D): boolean;
  55946. /**
  55947. * Adds a control to the children of this control
  55948. * @param control defines the control to add
  55949. * @returns the current container
  55950. */
  55951. addControl(control: Control3D): Container3D;
  55952. /**
  55953. * This function will be called everytime a new control is added
  55954. */
  55955. protected _arrangeChildren(): void;
  55956. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  55957. /**
  55958. * Removes a control from the children of this control
  55959. * @param control defines the control to remove
  55960. * @returns the current container
  55961. */
  55962. removeControl(control: Control3D): Container3D;
  55963. protected _getTypeName(): string;
  55964. /**
  55965. * Releases all associated resources
  55966. */
  55967. dispose(): void;
  55968. /** Control rotation will remain unchanged */
  55969. static readonly UNSET_ORIENTATION: number;
  55970. /** Control will rotate to make it look at sphere central axis */
  55971. static readonly FACEORIGIN_ORIENTATION: number;
  55972. /** Control will rotate to make it look back at sphere central axis */
  55973. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  55974. /** Control will rotate to look at z axis (0, 0, 1) */
  55975. static readonly FACEFORWARD_ORIENTATION: number;
  55976. /** Control will rotate to look at negative z axis (0, 0, -1) */
  55977. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  55978. }
  55979. }
  55980. declare module BABYLON.GUI {
  55981. /**
  55982. * Class used to manage 3D user interface
  55983. * @see http://doc.babylonjs.com/how_to/gui3d
  55984. */
  55985. export class GUI3DManager implements BABYLON.IDisposable {
  55986. private _scene;
  55987. private _sceneDisposeObserver;
  55988. private _utilityLayer;
  55989. private _rootContainer;
  55990. private _pointerObserver;
  55991. private _pointerOutObserver;
  55992. /** @hidden */ lastPickedControl: Control3D;
  55993. /** @hidden */ lastControlOver: {
  55994. [pointerId: number]: Control3D;
  55995. };
  55996. /** @hidden */ lastControlDown: {
  55997. [pointerId: number]: Control3D;
  55998. };
  55999. /**
  56000. * BABYLON.Observable raised when the point picked by the pointer events changed
  56001. */
  56002. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  56003. /** @hidden */ sharedMaterials: {
  56004. [key: string]: BABYLON.Material;
  56005. };
  56006. /** Gets the hosting scene */
  56007. readonly scene: BABYLON.Scene;
  56008. /** Gets associated utility layer */
  56009. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  56010. /**
  56011. * Creates a new GUI3DManager
  56012. * @param scene
  56013. */
  56014. constructor(scene?: BABYLON.Scene);
  56015. private _handlePointerOut;
  56016. private _doPicking;
  56017. /**
  56018. * Gets the root container
  56019. */
  56020. readonly rootContainer: Container3D;
  56021. /**
  56022. * Gets a boolean indicating if the given control is in the root child list
  56023. * @param control defines the control to check
  56024. * @returns true if the control is in the root child list
  56025. */
  56026. containsControl(control: Control3D): boolean;
  56027. /**
  56028. * Adds a control to the root child list
  56029. * @param control defines the control to add
  56030. * @returns the current manager
  56031. */
  56032. addControl(control: Control3D): GUI3DManager;
  56033. /**
  56034. * Removes a control from the root child list
  56035. * @param control defines the control to remove
  56036. * @returns the current container
  56037. */
  56038. removeControl(control: Control3D): GUI3DManager;
  56039. /**
  56040. * Releases all associated resources
  56041. */
  56042. dispose(): void;
  56043. }
  56044. }
  56045. declare module BABYLON.GUI {
  56046. /**
  56047. * Class used to transport BABYLON.Vector3 information for pointer events
  56048. */
  56049. export class Vector3WithInfo extends BABYLON.Vector3 {
  56050. /** defines the current mouse button index */
  56051. buttonIndex: number;
  56052. /**
  56053. * Creates a new Vector3WithInfo
  56054. * @param source defines the vector3 data to transport
  56055. * @param buttonIndex defines the current mouse button index
  56056. */
  56057. constructor(source: BABYLON.Vector3,
  56058. /** defines the current mouse button index */
  56059. buttonIndex?: number);
  56060. }
  56061. }
  56062. declare module BABYLON.GUI {
  56063. /**
  56064. * Class used as base class for controls
  56065. */
  56066. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  56067. /** Defines the control name */
  56068. name?: string | undefined;
  56069. /** @hidden */ host: GUI3DManager;
  56070. private _node;
  56071. private _downCount;
  56072. private _enterCount;
  56073. private _downPointerIds;
  56074. private _isVisible;
  56075. /** Gets or sets the control position in world space */
  56076. position: BABYLON.Vector3;
  56077. /** Gets or sets the control scaling in world space */
  56078. scaling: BABYLON.Vector3;
  56079. /** Callback used to start pointer enter animation */
  56080. pointerEnterAnimation: () => void;
  56081. /** Callback used to start pointer out animation */
  56082. pointerOutAnimation: () => void;
  56083. /** Callback used to start pointer down animation */
  56084. pointerDownAnimation: () => void;
  56085. /** Callback used to start pointer up animation */
  56086. pointerUpAnimation: () => void;
  56087. /**
  56088. * An event triggered when the pointer move over the control
  56089. */
  56090. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  56091. /**
  56092. * An event triggered when the pointer move out of the control
  56093. */
  56094. onPointerOutObservable: BABYLON.Observable<Control3D>;
  56095. /**
  56096. * An event triggered when the pointer taps the control
  56097. */
  56098. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  56099. /**
  56100. * An event triggered when pointer is up
  56101. */
  56102. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  56103. /**
  56104. * An event triggered when a control is clicked on (with a mouse)
  56105. */
  56106. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  56107. /**
  56108. * An event triggered when pointer enters the control
  56109. */
  56110. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  56111. /**
  56112. * Gets or sets the parent container
  56113. */
  56114. parent: BABYLON.Nullable<Container3D>;
  56115. private _behaviors;
  56116. /**
  56117. * Gets the list of attached behaviors
  56118. * @see http://doc.babylonjs.com/features/behaviour
  56119. */
  56120. readonly behaviors: BABYLON.Behavior<Control3D>[];
  56121. /**
  56122. * Attach a behavior to the control
  56123. * @see http://doc.babylonjs.com/features/behaviour
  56124. * @param behavior defines the behavior to attach
  56125. * @returns the current control
  56126. */
  56127. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  56128. /**
  56129. * Remove an attached behavior
  56130. * @see http://doc.babylonjs.com/features/behaviour
  56131. * @param behavior defines the behavior to attach
  56132. * @returns the current control
  56133. */
  56134. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  56135. /**
  56136. * Gets an attached behavior by name
  56137. * @param name defines the name of the behavior to look for
  56138. * @see http://doc.babylonjs.com/features/behaviour
  56139. * @returns null if behavior was not found else the requested behavior
  56140. */
  56141. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  56142. /** Gets or sets a boolean indicating if the control is visible */
  56143. isVisible: boolean;
  56144. /**
  56145. * Creates a new control
  56146. * @param name defines the control name
  56147. */
  56148. constructor(
  56149. /** Defines the control name */
  56150. name?: string | undefined);
  56151. /**
  56152. * Gets a string representing the class name
  56153. */
  56154. readonly typeName: string;
  56155. /**
  56156. * Get the current class name of the control.
  56157. * @returns current class name
  56158. */
  56159. getClassName(): string;
  56160. protected _getTypeName(): string;
  56161. /**
  56162. * Gets the transform node used by this control
  56163. */
  56164. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  56165. /**
  56166. * Gets the mesh used to render this control
  56167. */
  56168. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  56169. /**
  56170. * Link the control as child of the given node
  56171. * @param node defines the node to link to. Use null to unlink the control
  56172. * @returns the current control
  56173. */
  56174. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  56175. /** @hidden **/ prepareNode(scene: BABYLON.Scene): void;
  56176. /**
  56177. * Node creation.
  56178. * Can be overriden by children
  56179. * @param scene defines the scene where the node must be attached
  56180. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  56181. */
  56182. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  56183. /**
  56184. * Affect a material to the given mesh
  56185. * @param mesh defines the mesh which will represent the control
  56186. */
  56187. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  56188. /** @hidden */ onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  56189. /** @hidden */ onPointerEnter(target: Control3D): boolean;
  56190. /** @hidden */ onPointerOut(target: Control3D): void;
  56191. /** @hidden */ onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  56192. /** @hidden */ onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  56193. /** @hidden */
  56194. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  56195. /** @hidden */ processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  56196. /** @hidden */ disposeNode(): void;
  56197. /**
  56198. * Releases all associated resources
  56199. */
  56200. dispose(): void;
  56201. }
  56202. }
  56203. declare module BABYLON.GUI {
  56204. /**
  56205. * Class used as a root to all buttons
  56206. */
  56207. export class AbstractButton3D extends Control3D {
  56208. /**
  56209. * Creates a new button
  56210. * @param name defines the control name
  56211. */
  56212. constructor(name?: string);
  56213. protected _getTypeName(): string;
  56214. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  56215. }
  56216. }
  56217. declare module BABYLON.GUI {
  56218. /**
  56219. * Class used to create a button in 3D
  56220. */
  56221. export class Button3D extends AbstractButton3D {
  56222. /** @hidden */
  56223. protected _currentMaterial: BABYLON.Material;
  56224. private _facadeTexture;
  56225. private _content;
  56226. private _contentResolution;
  56227. private _contentScaleRatio;
  56228. /**
  56229. * Gets or sets the texture resolution used to render content (512 by default)
  56230. */
  56231. contentResolution: BABYLON.int;
  56232. /**
  56233. * Gets or sets the texture scale ratio used to render content (2 by default)
  56234. */
  56235. contentScaleRatio: number;
  56236. protected _disposeFacadeTexture(): void;
  56237. protected _resetContent(): void;
  56238. /**
  56239. * Creates a new button
  56240. * @param name defines the control name
  56241. */
  56242. constructor(name?: string);
  56243. /**
  56244. * Gets or sets the GUI 2D content used to display the button's facade
  56245. */
  56246. content: Control;
  56247. /**
  56248. * Apply the facade texture (created from the content property).
  56249. * This function can be overloaded by child classes
  56250. * @param facadeTexture defines the AdvancedDynamicTexture to use
  56251. */
  56252. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  56253. protected _getTypeName(): string;
  56254. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  56255. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  56256. /**
  56257. * Releases all associated resources
  56258. */
  56259. dispose(): void;
  56260. }
  56261. }
  56262. declare module BABYLON.GUI {
  56263. /**
  56264. * Abstract class used to create a container panel deployed on the surface of a volume
  56265. */
  56266. export abstract class VolumeBasedPanel extends Container3D {
  56267. private _columns;
  56268. private _rows;
  56269. private _rowThenColum;
  56270. private _orientation;
  56271. protected _cellWidth: number;
  56272. protected _cellHeight: number;
  56273. /**
  56274. * Gets or sets the distance between elements
  56275. */
  56276. margin: number;
  56277. /**
  56278. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  56279. * | Value | Type | Description |
  56280. * | ----- | ----------------------------------- | ----------- |
  56281. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  56282. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  56283. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  56284. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  56285. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  56286. */
  56287. orientation: number;
  56288. /**
  56289. * Gets or sets the number of columns requested (10 by default).
  56290. * The panel will automatically compute the number of rows based on number of child controls.
  56291. */
  56292. columns: BABYLON.int;
  56293. /**
  56294. * Gets or sets a the number of rows requested.
  56295. * The panel will automatically compute the number of columns based on number of child controls.
  56296. */
  56297. rows: BABYLON.int;
  56298. /**
  56299. * Creates new VolumeBasedPanel
  56300. */
  56301. constructor();
  56302. protected _arrangeChildren(): void;
  56303. /** Child classes must implement this function to provide correct control positioning */
  56304. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  56305. /** Child classes can implement this function to provide additional processing */
  56306. protected _finalProcessing(): void;
  56307. }
  56308. }
  56309. declare module BABYLON.GUI {
  56310. /**
  56311. * Class used to create a container panel deployed on the surface of a cylinder
  56312. */
  56313. export class CylinderPanel extends VolumeBasedPanel {
  56314. private _radius;
  56315. /**
  56316. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  56317. */
  56318. radius: BABYLON.float;
  56319. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  56320. private _cylindricalMapping;
  56321. }
  56322. }
  56323. declare module BABYLON.GUI {
  56324. /** @hidden */
  56325. export var fluentVertexShader: {
  56326. name: string;
  56327. shader: string;
  56328. };
  56329. }
  56330. declare module BABYLON.GUI {
  56331. /** @hidden */
  56332. export var fluentPixelShader: {
  56333. name: string;
  56334. shader: string;
  56335. };
  56336. }
  56337. declare module BABYLON.GUI {
  56338. /** @hidden */
  56339. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  56340. INNERGLOW: boolean;
  56341. BORDER: boolean;
  56342. HOVERLIGHT: boolean;
  56343. TEXTURE: boolean;
  56344. constructor();
  56345. }
  56346. /**
  56347. * Class used to render controls with fluent desgin
  56348. */
  56349. export class FluentMaterial extends BABYLON.PushMaterial {
  56350. /**
  56351. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  56352. */
  56353. innerGlowColorIntensity: number;
  56354. /**
  56355. * Gets or sets the inner glow color (white by default)
  56356. */
  56357. innerGlowColor: BABYLON.Color3;
  56358. /**
  56359. * Gets or sets alpha value (default is 1.0)
  56360. */
  56361. alpha: number;
  56362. /**
  56363. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  56364. */
  56365. albedoColor: BABYLON.Color3;
  56366. /**
  56367. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  56368. */
  56369. renderBorders: boolean;
  56370. /**
  56371. * Gets or sets border width (default is 0.5)
  56372. */
  56373. borderWidth: number;
  56374. /**
  56375. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  56376. */
  56377. edgeSmoothingValue: number;
  56378. /**
  56379. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  56380. */
  56381. borderMinValue: number;
  56382. /**
  56383. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  56384. */
  56385. renderHoverLight: boolean;
  56386. /**
  56387. * Gets or sets the radius used to render the hover light (default is 1.0)
  56388. */
  56389. hoverRadius: number;
  56390. /**
  56391. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  56392. */
  56393. hoverColor: BABYLON.Color4;
  56394. /**
  56395. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  56396. */
  56397. hoverPosition: BABYLON.Vector3;
  56398. private _albedoTexture;
  56399. /** Gets or sets the texture to use for albedo color */
  56400. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  56401. /**
  56402. * Creates a new Fluent material
  56403. * @param name defines the name of the material
  56404. * @param scene defines the hosting scene
  56405. */
  56406. constructor(name: string, scene: BABYLON.Scene);
  56407. needAlphaBlending(): boolean;
  56408. needAlphaTesting(): boolean;
  56409. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  56410. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  56411. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  56412. getActiveTextures(): BABYLON.BaseTexture[];
  56413. hasTexture(texture: BABYLON.BaseTexture): boolean;
  56414. dispose(forceDisposeEffect?: boolean): void;
  56415. clone(name: string): FluentMaterial;
  56416. serialize(): any;
  56417. getClassName(): string;
  56418. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  56419. }
  56420. }
  56421. declare module BABYLON.GUI {
  56422. /**
  56423. * Class used to create a holographic button in 3D
  56424. */
  56425. export class HolographicButton extends Button3D {
  56426. private _backPlate;
  56427. private _textPlate;
  56428. private _frontPlate;
  56429. private _text;
  56430. private _imageUrl;
  56431. private _shareMaterials;
  56432. private _frontMaterial;
  56433. private _backMaterial;
  56434. private _plateMaterial;
  56435. private _pickedPointObserver;
  56436. private _tooltipFade;
  56437. private _tooltipTextBlock;
  56438. private _tooltipTexture;
  56439. private _tooltipMesh;
  56440. private _tooltipHoverObserver;
  56441. private _tooltipOutObserver;
  56442. private _disposeTooltip;
  56443. /**
  56444. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  56445. */
  56446. tooltipText: BABYLON.Nullable<string>;
  56447. /**
  56448. * Gets or sets text for the button
  56449. */
  56450. text: string;
  56451. /**
  56452. * Gets or sets the image url for the button
  56453. */
  56454. imageUrl: string;
  56455. /**
  56456. * Gets the back material used by this button
  56457. */
  56458. readonly backMaterial: FluentMaterial;
  56459. /**
  56460. * Gets the front material used by this button
  56461. */
  56462. readonly frontMaterial: FluentMaterial;
  56463. /**
  56464. * Gets the plate material used by this button
  56465. */
  56466. readonly plateMaterial: BABYLON.StandardMaterial;
  56467. /**
  56468. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  56469. */
  56470. readonly shareMaterials: boolean;
  56471. /**
  56472. * Creates a new button
  56473. * @param name defines the control name
  56474. */
  56475. constructor(name?: string, shareMaterials?: boolean);
  56476. protected _getTypeName(): string;
  56477. private _rebuildContent;
  56478. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  56479. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  56480. private _createBackMaterial;
  56481. private _createFrontMaterial;
  56482. private _createPlateMaterial;
  56483. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  56484. /**
  56485. * Releases all associated resources
  56486. */
  56487. dispose(): void;
  56488. }
  56489. }
  56490. declare module BABYLON.GUI {
  56491. /**
  56492. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  56493. */
  56494. export class MeshButton3D extends Button3D {
  56495. /** @hidden */
  56496. protected _currentMesh: BABYLON.Mesh;
  56497. /**
  56498. * Creates a new 3D button based on a mesh
  56499. * @param mesh mesh to become a 3D button
  56500. * @param name defines the control name
  56501. */
  56502. constructor(mesh: BABYLON.Mesh, name?: string);
  56503. protected _getTypeName(): string;
  56504. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  56505. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  56506. }
  56507. }
  56508. declare module BABYLON.GUI {
  56509. /**
  56510. * Class used to create a container panel deployed on the surface of a plane
  56511. */
  56512. export class PlanePanel extends VolumeBasedPanel {
  56513. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  56514. }
  56515. }
  56516. declare module BABYLON.GUI {
  56517. /**
  56518. * Class used to create a container panel where items get randomized planar mapping
  56519. */
  56520. export class ScatterPanel extends VolumeBasedPanel {
  56521. private _iteration;
  56522. /**
  56523. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  56524. */
  56525. iteration: BABYLON.float;
  56526. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  56527. private _scatterMapping;
  56528. protected _finalProcessing(): void;
  56529. }
  56530. }
  56531. declare module BABYLON.GUI {
  56532. /**
  56533. * Class used to create a container panel deployed on the surface of a sphere
  56534. */
  56535. export class SpherePanel extends VolumeBasedPanel {
  56536. private _radius;
  56537. /**
  56538. * Gets or sets the radius of the sphere where to project controls (5 by default)
  56539. */
  56540. radius: BABYLON.float;
  56541. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  56542. private _sphericalMapping;
  56543. }
  56544. }
  56545. declare module BABYLON.GUI {
  56546. /**
  56547. * Class used to create a stack panel in 3D on XY plane
  56548. */
  56549. export class StackPanel3D extends Container3D {
  56550. private _isVertical;
  56551. /**
  56552. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  56553. */
  56554. isVertical: boolean;
  56555. /**
  56556. * Gets or sets the distance between elements
  56557. */
  56558. margin: number;
  56559. /**
  56560. * Creates new StackPanel
  56561. * @param isVertical
  56562. */
  56563. constructor(isVertical?: boolean);
  56564. protected _arrangeChildren(): void;
  56565. }
  56566. }
  56567. declare module BABYLON {
  56568. /**
  56569. * Mode that determines the coordinate system to use.
  56570. */
  56571. export enum GLTFLoaderCoordinateSystemMode {
  56572. /**
  56573. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  56574. */
  56575. AUTO = 0,
  56576. /**
  56577. * Sets the useRightHandedSystem flag on the scene.
  56578. */
  56579. FORCE_RIGHT_HANDED = 1
  56580. }
  56581. /**
  56582. * Mode that determines what animations will start.
  56583. */
  56584. export enum GLTFLoaderAnimationStartMode {
  56585. /**
  56586. * No animation will start.
  56587. */
  56588. NONE = 0,
  56589. /**
  56590. * The first animation will start.
  56591. */
  56592. FIRST = 1,
  56593. /**
  56594. * All animations will start.
  56595. */
  56596. ALL = 2
  56597. }
  56598. /**
  56599. * Interface that contains the data for the glTF asset.
  56600. */
  56601. export interface IGLTFLoaderData {
  56602. /**
  56603. * Object that represents the glTF JSON.
  56604. */
  56605. json: Object;
  56606. /**
  56607. * The BIN chunk of a binary glTF.
  56608. */
  56609. bin: Nullable<ArrayBufferView>;
  56610. }
  56611. /**
  56612. * Interface for extending the loader.
  56613. */
  56614. export interface IGLTFLoaderExtension {
  56615. /**
  56616. * The name of this extension.
  56617. */
  56618. readonly name: string;
  56619. /**
  56620. * Defines whether this extension is enabled.
  56621. */
  56622. enabled: boolean;
  56623. }
  56624. /**
  56625. * Loader state.
  56626. */
  56627. export enum GLTFLoaderState {
  56628. /**
  56629. * The asset is loading.
  56630. */
  56631. LOADING = 0,
  56632. /**
  56633. * The asset is ready for rendering.
  56634. */
  56635. READY = 1,
  56636. /**
  56637. * The asset is completely loaded.
  56638. */
  56639. COMPLETE = 2
  56640. }
  56641. /** @hidden */
  56642. export interface IGLTFLoader extends IDisposable {
  56643. readonly state: Nullable<GLTFLoaderState>;
  56644. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  56645. meshes: AbstractMesh[];
  56646. particleSystems: IParticleSystem[];
  56647. skeletons: Skeleton[];
  56648. animationGroups: AnimationGroup[];
  56649. }>;
  56650. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  56651. }
  56652. /**
  56653. * File loader for loading glTF files into a scene.
  56654. */
  56655. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  56656. /** @hidden */ private static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  56657. /** @hidden */ private static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  56658. /**
  56659. * Raised when the asset has been parsed
  56660. */
  56661. onParsedObservable: Observable<IGLTFLoaderData>;
  56662. private _onParsedObserver;
  56663. /**
  56664. * Raised when the asset has been parsed
  56665. */
  56666. onParsed: (loaderData: IGLTFLoaderData) => void;
  56667. /**
  56668. * 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.
  56669. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  56670. * Defaults to true.
  56671. * @hidden
  56672. */
  56673. static IncrementalLoading: boolean;
  56674. /**
  56675. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  56676. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  56677. * @hidden
  56678. */
  56679. static HomogeneousCoordinates: boolean;
  56680. /**
  56681. * The coordinate system mode. Defaults to AUTO.
  56682. */
  56683. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  56684. /**
  56685. * The animation start mode. Defaults to FIRST.
  56686. */
  56687. animationStartMode: GLTFLoaderAnimationStartMode;
  56688. /**
  56689. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  56690. */
  56691. compileMaterials: boolean;
  56692. /**
  56693. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  56694. */
  56695. useClipPlane: boolean;
  56696. /**
  56697. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  56698. */
  56699. compileShadowGenerators: boolean;
  56700. /**
  56701. * Defines if the Alpha blended materials are only applied as coverage.
  56702. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  56703. * If true, no extra effects are applied to transparent pixels.
  56704. */
  56705. transparencyAsCoverage: boolean;
  56706. /**
  56707. * Function called before loading a url referenced by the asset.
  56708. */
  56709. preprocessUrlAsync: (url: string) => Promise<string>;
  56710. /**
  56711. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  56712. */
  56713. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  56714. private _onMeshLoadedObserver;
  56715. /**
  56716. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  56717. */
  56718. onMeshLoaded: (mesh: AbstractMesh) => void;
  56719. /**
  56720. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  56721. */
  56722. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  56723. private _onTextureLoadedObserver;
  56724. /**
  56725. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  56726. */
  56727. onTextureLoaded: (texture: BaseTexture) => void;
  56728. /**
  56729. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  56730. */
  56731. readonly onMaterialLoadedObservable: Observable<Material>;
  56732. private _onMaterialLoadedObserver;
  56733. /**
  56734. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  56735. */
  56736. onMaterialLoaded: (material: Material) => void;
  56737. /**
  56738. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  56739. */
  56740. readonly onCameraLoadedObservable: Observable<Camera>;
  56741. private _onCameraLoadedObserver;
  56742. /**
  56743. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  56744. */
  56745. onCameraLoaded: (camera: Camera) => void;
  56746. /**
  56747. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  56748. * For assets with LODs, raised when all of the LODs are complete.
  56749. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  56750. */
  56751. readonly onCompleteObservable: Observable<void>;
  56752. private _onCompleteObserver;
  56753. /**
  56754. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  56755. * For assets with LODs, raised when all of the LODs are complete.
  56756. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  56757. */
  56758. onComplete: () => void;
  56759. /**
  56760. * Observable raised when an error occurs.
  56761. */
  56762. readonly onErrorObservable: Observable<any>;
  56763. private _onErrorObserver;
  56764. /**
  56765. * Callback raised when an error occurs.
  56766. */
  56767. onError: (reason: any) => void;
  56768. /**
  56769. * Observable raised after the loader is disposed.
  56770. */
  56771. readonly onDisposeObservable: Observable<void>;
  56772. private _onDisposeObserver;
  56773. /**
  56774. * Callback raised after the loader is disposed.
  56775. */
  56776. onDispose: () => void;
  56777. /**
  56778. * Observable raised after a loader extension is created.
  56779. * Set additional options for a loader extension in this event.
  56780. */
  56781. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  56782. private _onExtensionLoadedObserver;
  56783. /**
  56784. * Callback raised after a loader extension is created.
  56785. */
  56786. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  56787. /**
  56788. * Defines if the loader logging is enabled.
  56789. */
  56790. loggingEnabled: boolean;
  56791. /**
  56792. * Defines if the loader should capture performance counters.
  56793. */
  56794. capturePerformanceCounters: boolean;
  56795. /**
  56796. * Defines if the loader should validate the asset.
  56797. */
  56798. validate: boolean;
  56799. /**
  56800. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  56801. */
  56802. readonly onValidatedObservable: Observable<IGLTFValidationResults>;
  56803. private _onValidatedObserver;
  56804. /**
  56805. * Callback raised after a loader extension is created.
  56806. */
  56807. onValidated: (results: IGLTFValidationResults) => void;
  56808. private _loader;
  56809. /**
  56810. * Name of the loader ("gltf")
  56811. */
  56812. name: string;
  56813. /**
  56814. * Supported file extensions of the loader (.gltf, .glb)
  56815. */
  56816. extensions: ISceneLoaderPluginExtensions;
  56817. /**
  56818. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  56819. */
  56820. dispose(): void;
  56821. /** @hidden */ clear(): void;
  56822. /**
  56823. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  56824. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  56825. * @param scene the scene the meshes should be added to
  56826. * @param data the glTF data to load
  56827. * @param rootUrl root url to load from
  56828. * @param onProgress event that fires when loading progress has occured
  56829. * @param fileName Defines the name of the file to load
  56830. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  56831. */
  56832. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  56833. meshes: AbstractMesh[];
  56834. particleSystems: IParticleSystem[];
  56835. skeletons: Skeleton[];
  56836. animationGroups: AnimationGroup[];
  56837. }>;
  56838. /**
  56839. * Imports all objects from the loaded glTF data and adds them to the scene
  56840. * @param scene the scene the objects should be added to
  56841. * @param data the glTF data to load
  56842. * @param rootUrl root url to load from
  56843. * @param onProgress event that fires when loading progress has occured
  56844. * @param fileName Defines the name of the file to load
  56845. * @returns a promise which completes when objects have been loaded to the scene
  56846. */
  56847. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  56848. /**
  56849. * Load into an asset container.
  56850. * @param scene The scene to load into
  56851. * @param data The data to import
  56852. * @param rootUrl The root url for scene and resources
  56853. * @param onProgress The callback when the load progresses
  56854. * @param fileName Defines the name of the file to load
  56855. * @returns The loaded asset container
  56856. */
  56857. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  56858. /**
  56859. * If the data string can be loaded directly.
  56860. * @param data string contianing the file data
  56861. * @returns if the data can be loaded directly
  56862. */
  56863. canDirectLoad(data: string): boolean;
  56864. /**
  56865. * Rewrites a url by combining a root url and response url.
  56866. */
  56867. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  56868. /**
  56869. * Instantiates a glTF file loader plugin.
  56870. * @returns the created plugin
  56871. */
  56872. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  56873. /**
  56874. * The loader state or null if the loader is not active.
  56875. */
  56876. readonly loaderState: Nullable<GLTFLoaderState>;
  56877. /**
  56878. * Returns a promise that resolves when the asset is completely loaded.
  56879. * @returns a promise that resolves when the asset is completely loaded.
  56880. */
  56881. whenCompleteAsync(): Promise<void>;
  56882. private _parseAsync;
  56883. private _validateAsync;
  56884. private _getLoader;
  56885. private _unpackBinary;
  56886. private _unpackBinaryV1;
  56887. private _unpackBinaryV2;
  56888. private static _parseVersion;
  56889. private static _compareVersion;
  56890. private static _decodeBufferToText;
  56891. private static readonly _logSpaces;
  56892. private _logIndentLevel;
  56893. private _loggingEnabled;
  56894. /** @hidden */ log: (message: string) => void;
  56895. /** @hidden */ logOpen(message: string): void;
  56896. /** @hidden */ logClose(): void;
  56897. private _logEnabled;
  56898. private _logDisabled;
  56899. private _capturePerformanceCounters;
  56900. /** @hidden */ startPerformanceCounter: (counterName: string) => void;
  56901. /** @hidden */ endPerformanceCounter: (counterName: string) => void;
  56902. private _startPerformanceCounterEnabled;
  56903. private _startPerformanceCounterDisabled;
  56904. private _endPerformanceCounterEnabled;
  56905. private _endPerformanceCounterDisabled;
  56906. }
  56907. }
  56908. declare module BABYLON.GLTF1 {
  56909. /**
  56910. * Enums
  56911. * @hidden
  56912. */
  56913. export enum EComponentType {
  56914. BYTE = 5120,
  56915. UNSIGNED_BYTE = 5121,
  56916. SHORT = 5122,
  56917. UNSIGNED_SHORT = 5123,
  56918. FLOAT = 5126
  56919. }
  56920. /** @hidden */
  56921. export enum EShaderType {
  56922. FRAGMENT = 35632,
  56923. VERTEX = 35633
  56924. }
  56925. /** @hidden */
  56926. export enum EParameterType {
  56927. BYTE = 5120,
  56928. UNSIGNED_BYTE = 5121,
  56929. SHORT = 5122,
  56930. UNSIGNED_SHORT = 5123,
  56931. INT = 5124,
  56932. UNSIGNED_INT = 5125,
  56933. FLOAT = 5126,
  56934. FLOAT_VEC2 = 35664,
  56935. FLOAT_VEC3 = 35665,
  56936. FLOAT_VEC4 = 35666,
  56937. INT_VEC2 = 35667,
  56938. INT_VEC3 = 35668,
  56939. INT_VEC4 = 35669,
  56940. BOOL = 35670,
  56941. BOOL_VEC2 = 35671,
  56942. BOOL_VEC3 = 35672,
  56943. BOOL_VEC4 = 35673,
  56944. FLOAT_MAT2 = 35674,
  56945. FLOAT_MAT3 = 35675,
  56946. FLOAT_MAT4 = 35676,
  56947. SAMPLER_2D = 35678
  56948. }
  56949. /** @hidden */
  56950. export enum ETextureWrapMode {
  56951. CLAMP_TO_EDGE = 33071,
  56952. MIRRORED_REPEAT = 33648,
  56953. REPEAT = 10497
  56954. }
  56955. /** @hidden */
  56956. export enum ETextureFilterType {
  56957. NEAREST = 9728,
  56958. LINEAR = 9728,
  56959. NEAREST_MIPMAP_NEAREST = 9984,
  56960. LINEAR_MIPMAP_NEAREST = 9985,
  56961. NEAREST_MIPMAP_LINEAR = 9986,
  56962. LINEAR_MIPMAP_LINEAR = 9987
  56963. }
  56964. /** @hidden */
  56965. export enum ETextureFormat {
  56966. ALPHA = 6406,
  56967. RGB = 6407,
  56968. RGBA = 6408,
  56969. LUMINANCE = 6409,
  56970. LUMINANCE_ALPHA = 6410
  56971. }
  56972. /** @hidden */
  56973. export enum ECullingType {
  56974. FRONT = 1028,
  56975. BACK = 1029,
  56976. FRONT_AND_BACK = 1032
  56977. }
  56978. /** @hidden */
  56979. export enum EBlendingFunction {
  56980. ZERO = 0,
  56981. ONE = 1,
  56982. SRC_COLOR = 768,
  56983. ONE_MINUS_SRC_COLOR = 769,
  56984. DST_COLOR = 774,
  56985. ONE_MINUS_DST_COLOR = 775,
  56986. SRC_ALPHA = 770,
  56987. ONE_MINUS_SRC_ALPHA = 771,
  56988. DST_ALPHA = 772,
  56989. ONE_MINUS_DST_ALPHA = 773,
  56990. CONSTANT_COLOR = 32769,
  56991. ONE_MINUS_CONSTANT_COLOR = 32770,
  56992. CONSTANT_ALPHA = 32771,
  56993. ONE_MINUS_CONSTANT_ALPHA = 32772,
  56994. SRC_ALPHA_SATURATE = 776
  56995. }
  56996. /** @hidden */
  56997. export interface IGLTFProperty {
  56998. extensions?: {
  56999. [key: string]: any;
  57000. };
  57001. extras?: Object;
  57002. }
  57003. /** @hidden */
  57004. export interface IGLTFChildRootProperty extends IGLTFProperty {
  57005. name?: string;
  57006. }
  57007. /** @hidden */
  57008. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  57009. bufferView: string;
  57010. byteOffset: number;
  57011. byteStride: number;
  57012. count: number;
  57013. type: string;
  57014. componentType: EComponentType;
  57015. max?: number[];
  57016. min?: number[];
  57017. name?: string;
  57018. }
  57019. /** @hidden */
  57020. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  57021. buffer: string;
  57022. byteOffset: number;
  57023. byteLength: number;
  57024. byteStride: number;
  57025. target?: number;
  57026. }
  57027. /** @hidden */
  57028. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  57029. uri: string;
  57030. byteLength?: number;
  57031. type?: string;
  57032. }
  57033. /** @hidden */
  57034. export interface IGLTFShader extends IGLTFChildRootProperty {
  57035. uri: string;
  57036. type: EShaderType;
  57037. }
  57038. /** @hidden */
  57039. export interface IGLTFProgram extends IGLTFChildRootProperty {
  57040. attributes: string[];
  57041. fragmentShader: string;
  57042. vertexShader: string;
  57043. }
  57044. /** @hidden */
  57045. export interface IGLTFTechniqueParameter {
  57046. type: number;
  57047. count?: number;
  57048. semantic?: string;
  57049. node?: string;
  57050. value?: number | boolean | string | Array<any>;
  57051. source?: string;
  57052. babylonValue?: any;
  57053. }
  57054. /** @hidden */
  57055. export interface IGLTFTechniqueCommonProfile {
  57056. lightingModel: string;
  57057. texcoordBindings: Object;
  57058. parameters?: Array<any>;
  57059. }
  57060. /** @hidden */
  57061. export interface IGLTFTechniqueStatesFunctions {
  57062. blendColor?: number[];
  57063. blendEquationSeparate?: number[];
  57064. blendFuncSeparate?: number[];
  57065. colorMask: boolean[];
  57066. cullFace: number[];
  57067. }
  57068. /** @hidden */
  57069. export interface IGLTFTechniqueStates {
  57070. enable: number[];
  57071. functions: IGLTFTechniqueStatesFunctions;
  57072. }
  57073. /** @hidden */
  57074. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  57075. parameters: {
  57076. [key: string]: IGLTFTechniqueParameter;
  57077. };
  57078. program: string;
  57079. attributes: {
  57080. [key: string]: string;
  57081. };
  57082. uniforms: {
  57083. [key: string]: string;
  57084. };
  57085. states: IGLTFTechniqueStates;
  57086. }
  57087. /** @hidden */
  57088. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  57089. technique?: string;
  57090. values: string[];
  57091. }
  57092. /** @hidden */
  57093. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  57094. attributes: {
  57095. [key: string]: string;
  57096. };
  57097. indices: string;
  57098. material: string;
  57099. mode?: number;
  57100. }
  57101. /** @hidden */
  57102. export interface IGLTFMesh extends IGLTFChildRootProperty {
  57103. primitives: IGLTFMeshPrimitive[];
  57104. }
  57105. /** @hidden */
  57106. export interface IGLTFImage extends IGLTFChildRootProperty {
  57107. uri: string;
  57108. }
  57109. /** @hidden */
  57110. export interface IGLTFSampler extends IGLTFChildRootProperty {
  57111. magFilter?: number;
  57112. minFilter?: number;
  57113. wrapS?: number;
  57114. wrapT?: number;
  57115. }
  57116. /** @hidden */
  57117. export interface IGLTFTexture extends IGLTFChildRootProperty {
  57118. sampler: string;
  57119. source: string;
  57120. format?: ETextureFormat;
  57121. internalFormat?: ETextureFormat;
  57122. target?: number;
  57123. type?: number;
  57124. babylonTexture?: Texture;
  57125. }
  57126. /** @hidden */
  57127. export interface IGLTFAmbienLight {
  57128. color?: number[];
  57129. }
  57130. /** @hidden */
  57131. export interface IGLTFDirectionalLight {
  57132. color?: number[];
  57133. }
  57134. /** @hidden */
  57135. export interface IGLTFPointLight {
  57136. color?: number[];
  57137. constantAttenuation?: number;
  57138. linearAttenuation?: number;
  57139. quadraticAttenuation?: number;
  57140. }
  57141. /** @hidden */
  57142. export interface IGLTFSpotLight {
  57143. color?: number[];
  57144. constantAttenuation?: number;
  57145. fallOfAngle?: number;
  57146. fallOffExponent?: number;
  57147. linearAttenuation?: number;
  57148. quadraticAttenuation?: number;
  57149. }
  57150. /** @hidden */
  57151. export interface IGLTFLight extends IGLTFChildRootProperty {
  57152. type: string;
  57153. }
  57154. /** @hidden */
  57155. export interface IGLTFCameraOrthographic {
  57156. xmag: number;
  57157. ymag: number;
  57158. zfar: number;
  57159. znear: number;
  57160. }
  57161. /** @hidden */
  57162. export interface IGLTFCameraPerspective {
  57163. aspectRatio: number;
  57164. yfov: number;
  57165. zfar: number;
  57166. znear: number;
  57167. }
  57168. /** @hidden */
  57169. export interface IGLTFCamera extends IGLTFChildRootProperty {
  57170. type: string;
  57171. }
  57172. /** @hidden */
  57173. export interface IGLTFAnimationChannelTarget {
  57174. id: string;
  57175. path: string;
  57176. }
  57177. /** @hidden */
  57178. export interface IGLTFAnimationChannel {
  57179. sampler: string;
  57180. target: IGLTFAnimationChannelTarget;
  57181. }
  57182. /** @hidden */
  57183. export interface IGLTFAnimationSampler {
  57184. input: string;
  57185. output: string;
  57186. interpolation?: string;
  57187. }
  57188. /** @hidden */
  57189. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  57190. channels?: IGLTFAnimationChannel[];
  57191. parameters?: {
  57192. [key: string]: string;
  57193. };
  57194. samplers?: {
  57195. [key: string]: IGLTFAnimationSampler;
  57196. };
  57197. }
  57198. /** @hidden */
  57199. export interface IGLTFNodeInstanceSkin {
  57200. skeletons: string[];
  57201. skin: string;
  57202. meshes: string[];
  57203. }
  57204. /** @hidden */
  57205. export interface IGLTFSkins extends IGLTFChildRootProperty {
  57206. bindShapeMatrix: number[];
  57207. inverseBindMatrices: string;
  57208. jointNames: string[];
  57209. babylonSkeleton?: Skeleton;
  57210. }
  57211. /** @hidden */
  57212. export interface IGLTFNode extends IGLTFChildRootProperty {
  57213. camera?: string;
  57214. children: string[];
  57215. skin?: string;
  57216. jointName?: string;
  57217. light?: string;
  57218. matrix: number[];
  57219. mesh?: string;
  57220. meshes?: string[];
  57221. rotation?: number[];
  57222. scale?: number[];
  57223. translation?: number[];
  57224. babylonNode?: Node;
  57225. }
  57226. /** @hidden */
  57227. export interface IGLTFScene extends IGLTFChildRootProperty {
  57228. nodes: string[];
  57229. }
  57230. /** @hidden */
  57231. export interface IGLTFRuntime {
  57232. extensions: {
  57233. [key: string]: any;
  57234. };
  57235. accessors: {
  57236. [key: string]: IGLTFAccessor;
  57237. };
  57238. buffers: {
  57239. [key: string]: IGLTFBuffer;
  57240. };
  57241. bufferViews: {
  57242. [key: string]: IGLTFBufferView;
  57243. };
  57244. meshes: {
  57245. [key: string]: IGLTFMesh;
  57246. };
  57247. lights: {
  57248. [key: string]: IGLTFLight;
  57249. };
  57250. cameras: {
  57251. [key: string]: IGLTFCamera;
  57252. };
  57253. nodes: {
  57254. [key: string]: IGLTFNode;
  57255. };
  57256. images: {
  57257. [key: string]: IGLTFImage;
  57258. };
  57259. textures: {
  57260. [key: string]: IGLTFTexture;
  57261. };
  57262. shaders: {
  57263. [key: string]: IGLTFShader;
  57264. };
  57265. programs: {
  57266. [key: string]: IGLTFProgram;
  57267. };
  57268. samplers: {
  57269. [key: string]: IGLTFSampler;
  57270. };
  57271. techniques: {
  57272. [key: string]: IGLTFTechnique;
  57273. };
  57274. materials: {
  57275. [key: string]: IGLTFMaterial;
  57276. };
  57277. animations: {
  57278. [key: string]: IGLTFAnimation;
  57279. };
  57280. skins: {
  57281. [key: string]: IGLTFSkins;
  57282. };
  57283. currentScene?: Object;
  57284. scenes: {
  57285. [key: string]: IGLTFScene;
  57286. };
  57287. extensionsUsed: string[];
  57288. extensionsRequired?: string[];
  57289. buffersCount: number;
  57290. shaderscount: number;
  57291. scene: Scene;
  57292. rootUrl: string;
  57293. loadedBufferCount: number;
  57294. loadedBufferViews: {
  57295. [name: string]: ArrayBufferView;
  57296. };
  57297. loadedShaderCount: number;
  57298. importOnlyMeshes: boolean;
  57299. importMeshesNames?: string[];
  57300. dummyNodes: Node[];
  57301. }
  57302. /** @hidden */
  57303. export interface INodeToRoot {
  57304. bone: Bone;
  57305. node: IGLTFNode;
  57306. id: string;
  57307. }
  57308. /** @hidden */
  57309. export interface IJointNode {
  57310. node: IGLTFNode;
  57311. id: string;
  57312. }
  57313. }
  57314. declare module BABYLON.GLTF1 {
  57315. /**
  57316. * Utils functions for GLTF
  57317. * @hidden
  57318. */
  57319. export class GLTFUtils {
  57320. /**
  57321. * Sets the given "parameter" matrix
  57322. * @param scene: the Scene object
  57323. * @param source: the source node where to pick the matrix
  57324. * @param parameter: the GLTF technique parameter
  57325. * @param uniformName: the name of the shader's uniform
  57326. * @param shaderMaterial: the shader material
  57327. */
  57328. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  57329. /**
  57330. * Sets the given "parameter" matrix
  57331. * @param shaderMaterial: the shader material
  57332. * @param uniform: the name of the shader's uniform
  57333. * @param value: the value of the uniform
  57334. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  57335. */
  57336. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  57337. /**
  57338. * Returns the wrap mode of the texture
  57339. * @param mode: the mode value
  57340. */
  57341. static GetWrapMode(mode: number): number;
  57342. /**
  57343. * Returns the byte stride giving an accessor
  57344. * @param accessor: the GLTF accessor objet
  57345. */
  57346. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  57347. /**
  57348. * Returns the texture filter mode giving a mode value
  57349. * @param mode: the filter mode value
  57350. */
  57351. static GetTextureFilterMode(mode: number): ETextureFilterType;
  57352. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  57353. /**
  57354. * Returns a buffer from its accessor
  57355. * @param gltfRuntime: the GLTF runtime
  57356. * @param accessor: the GLTF accessor
  57357. */
  57358. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  57359. /**
  57360. * Decodes a buffer view into a string
  57361. * @param view: the buffer view
  57362. */
  57363. static DecodeBufferToText(view: ArrayBufferView): string;
  57364. /**
  57365. * Returns the default material of gltf. Related to
  57366. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  57367. * @param scene: the Babylon.js scene
  57368. */
  57369. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  57370. private static _DefaultMaterial;
  57371. }
  57372. }
  57373. declare module BABYLON.GLTF1 {
  57374. /**
  57375. * Implementation of the base glTF spec
  57376. * @hidden
  57377. */
  57378. export class GLTFLoaderBase {
  57379. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  57380. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  57381. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  57382. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  57383. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  57384. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  57385. }
  57386. /**
  57387. * glTF V1 Loader
  57388. * @hidden
  57389. */
  57390. export class GLTFLoader implements IGLTFLoader {
  57391. static Extensions: {
  57392. [name: string]: GLTFLoaderExtension;
  57393. };
  57394. static RegisterExtension(extension: GLTFLoaderExtension): void;
  57395. state: Nullable<GLTFLoaderState>;
  57396. dispose(): void;
  57397. private _importMeshAsync;
  57398. /**
  57399. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  57400. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  57401. * @param scene the scene the meshes should be added to
  57402. * @param data gltf data containing information of the meshes in a loaded file
  57403. * @param rootUrl root url to load from
  57404. * @param onProgress event that fires when loading progress has occured
  57405. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  57406. */
  57407. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  57408. meshes: AbstractMesh[];
  57409. particleSystems: IParticleSystem[];
  57410. skeletons: Skeleton[];
  57411. animationGroups: AnimationGroup[];
  57412. }>;
  57413. private _loadAsync;
  57414. /**
  57415. * Imports all objects from a loaded gltf file and adds them to the scene
  57416. * @param scene the scene the objects should be added to
  57417. * @param data gltf data containing information of the meshes in a loaded file
  57418. * @param rootUrl root url to load from
  57419. * @param onProgress event that fires when loading progress has occured
  57420. * @returns a promise which completes when objects have been loaded to the scene
  57421. */
  57422. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  57423. private _loadShadersAsync;
  57424. private _loadBuffersAsync;
  57425. private _createNodes;
  57426. }
  57427. /** @hidden */
  57428. export abstract class GLTFLoaderExtension {
  57429. private _name;
  57430. constructor(name: string);
  57431. readonly name: string;
  57432. /**
  57433. * Defines an override for loading the runtime
  57434. * Return true to stop further extensions from loading the runtime
  57435. */
  57436. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  57437. /**
  57438. * Defines an onverride for creating gltf runtime
  57439. * Return true to stop further extensions from creating the runtime
  57440. */
  57441. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  57442. /**
  57443. * Defines an override for loading buffers
  57444. * Return true to stop further extensions from loading this buffer
  57445. */
  57446. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  57447. /**
  57448. * Defines an override for loading texture buffers
  57449. * Return true to stop further extensions from loading this texture data
  57450. */
  57451. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  57452. /**
  57453. * Defines an override for creating textures
  57454. * Return true to stop further extensions from loading this texture
  57455. */
  57456. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  57457. /**
  57458. * Defines an override for loading shader strings
  57459. * Return true to stop further extensions from loading this shader data
  57460. */
  57461. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  57462. /**
  57463. * Defines an override for loading materials
  57464. * Return true to stop further extensions from loading this material
  57465. */
  57466. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  57467. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  57468. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  57469. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  57470. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  57471. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  57472. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  57473. private static LoadTextureBufferAsync;
  57474. private static CreateTextureAsync;
  57475. private static ApplyExtensions;
  57476. }
  57477. }
  57478. declare module BABYLON.GLTF1 {
  57479. /** @hidden */
  57480. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  57481. private _bin;
  57482. constructor();
  57483. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  57484. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  57485. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  57486. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  57487. }
  57488. }
  57489. declare module BABYLON.GLTF1 {
  57490. /** @hidden */
  57491. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  57492. constructor();
  57493. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  57494. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  57495. private _loadTexture;
  57496. }
  57497. }
  57498. declare module BABYLON.GLTF2.Loader {
  57499. /**
  57500. * Loader interface with an index field.
  57501. */
  57502. export interface IArrayItem {
  57503. /**
  57504. * The index of this item in the array.
  57505. */
  57506. index: number;
  57507. }
  57508. /**
  57509. * Loader interface with additional members.
  57510. */
  57511. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  57512. /** @hidden */ data?: Promise<ArrayBufferView>;
  57513. /** @hidden */ babylonVertexBuffer?: Promise<VertexBuffer>;
  57514. }
  57515. /**
  57516. * Loader interface with additional members.
  57517. */
  57518. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  57519. }
  57520. /** @hidden */
  57521. export interface _IAnimationSamplerData {
  57522. input: Float32Array;
  57523. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  57524. output: Float32Array;
  57525. }
  57526. /**
  57527. * Loader interface with additional members.
  57528. */
  57529. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  57530. /** @hidden */ data?: Promise<_IAnimationSamplerData>;
  57531. }
  57532. /**
  57533. * Loader interface with additional members.
  57534. */
  57535. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  57536. channels: IAnimationChannel[];
  57537. samplers: IAnimationSampler[];
  57538. /** @hidden */ babylonAnimationGroup?: AnimationGroup;
  57539. }
  57540. /**
  57541. * Loader interface with additional members.
  57542. */
  57543. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  57544. /** @hidden */ data?: Promise<ArrayBufferView>;
  57545. }
  57546. /**
  57547. * Loader interface with additional members.
  57548. */
  57549. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  57550. /** @hidden */ data?: Promise<ArrayBufferView>;
  57551. /** @hidden */ babylonBuffer?: Promise<Buffer>;
  57552. }
  57553. /**
  57554. * Loader interface with additional members.
  57555. */
  57556. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  57557. }
  57558. /**
  57559. * Loader interface with additional members.
  57560. */
  57561. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  57562. /** @hidden */ data?: Promise<ArrayBufferView>;
  57563. }
  57564. /**
  57565. * Loader interface with additional members.
  57566. */
  57567. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  57568. }
  57569. /**
  57570. * Loader interface with additional members.
  57571. */
  57572. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  57573. }
  57574. /**
  57575. * Loader interface with additional members.
  57576. */
  57577. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  57578. baseColorTexture?: ITextureInfo;
  57579. metallicRoughnessTexture?: ITextureInfo;
  57580. }
  57581. /**
  57582. * Loader interface with additional members.
  57583. */
  57584. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  57585. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  57586. normalTexture?: IMaterialNormalTextureInfo;
  57587. occlusionTexture?: IMaterialOcclusionTextureInfo;
  57588. emissiveTexture?: ITextureInfo;
  57589. /** @hidden */ data?: {
  57590. [babylonDrawMode: number]: {
  57591. babylonMaterial: Material;
  57592. babylonMeshes: AbstractMesh[];
  57593. promise: Promise<void>;
  57594. };
  57595. };
  57596. }
  57597. /**
  57598. * Loader interface with additional members.
  57599. */
  57600. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  57601. primitives: IMeshPrimitive[];
  57602. }
  57603. /**
  57604. * Loader interface with additional members.
  57605. */
  57606. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  57607. /** @hidden */ instanceData?: {
  57608. babylonSourceMesh: Mesh;
  57609. promise: Promise<any>;
  57610. };
  57611. }
  57612. /**
  57613. * Loader interface with additional members.
  57614. */
  57615. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  57616. /**
  57617. * The parent glTF node.
  57618. */
  57619. parent?: INode;
  57620. /** @hidden */ babylonTransformNode?: TransformNode;
  57621. /** @hidden */ primitiveBabylonMeshes?: AbstractMesh[];
  57622. /** @hidden */ babylonBones?: Bone[];
  57623. /** @hidden */ numMorphTargets?: number;
  57624. }
  57625. /** @hidden */
  57626. export interface _ISamplerData {
  57627. noMipMaps: boolean;
  57628. samplingMode: number;
  57629. wrapU: number;
  57630. wrapV: number;
  57631. }
  57632. /**
  57633. * Loader interface with additional members.
  57634. */
  57635. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  57636. /** @hidden */ data?: _ISamplerData;
  57637. }
  57638. /**
  57639. * Loader interface with additional members.
  57640. */
  57641. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  57642. }
  57643. /**
  57644. * Loader interface with additional members.
  57645. */
  57646. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  57647. /** @hidden */ data?: {
  57648. babylonSkeleton: Skeleton;
  57649. promise: Promise<void>;
  57650. };
  57651. }
  57652. /**
  57653. * Loader interface with additional members.
  57654. */
  57655. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  57656. }
  57657. /**
  57658. * Loader interface with additional members.
  57659. */
  57660. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  57661. }
  57662. /**
  57663. * Loader interface with additional members.
  57664. */
  57665. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  57666. accessors?: IAccessor[];
  57667. animations?: IAnimation[];
  57668. buffers?: IBuffer[];
  57669. bufferViews?: IBufferView[];
  57670. cameras?: ICamera[];
  57671. images?: IImage[];
  57672. materials?: IMaterial[];
  57673. meshes?: IMesh[];
  57674. nodes?: INode[];
  57675. samplers?: ISampler[];
  57676. scenes?: IScene[];
  57677. skins?: ISkin[];
  57678. textures?: ITexture[];
  57679. }
  57680. }
  57681. declare module BABYLON.GLTF2 {
  57682. /**
  57683. * Interface for a glTF loader extension.
  57684. */
  57685. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  57686. /**
  57687. * Called after the loader state changes to LOADING.
  57688. */
  57689. onLoading?(): void;
  57690. /**
  57691. * Called after the loader state changes to READY.
  57692. */
  57693. onReady?(): void;
  57694. /**
  57695. * Define this method to modify the default behavior when loading scenes.
  57696. * @param context The context when loading the asset
  57697. * @param scene The glTF scene property
  57698. * @returns A promise that resolves when the load is complete or null if not handled
  57699. */
  57700. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  57701. /**
  57702. * Define this method to modify the default behavior when loading nodes.
  57703. * @param context The context when loading the asset
  57704. * @param node The glTF node property
  57705. * @param assign A function called synchronously after parsing the glTF properties
  57706. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  57707. */
  57708. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  57709. /**
  57710. * Define this method to modify the default behavior when loading cameras.
  57711. * @param context The context when loading the asset
  57712. * @param camera The glTF camera property
  57713. * @param assign A function called synchronously after parsing the glTF properties
  57714. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  57715. */
  57716. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  57717. /**
  57718. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  57719. * @param context The context when loading the asset
  57720. * @param primitive The glTF mesh primitive property
  57721. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  57722. */ loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  57723. /**
  57724. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  57725. * @param context The context when loading the asset
  57726. * @param material The glTF material property
  57727. * @param assign A function called synchronously after parsing the glTF properties
  57728. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  57729. */ loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  57730. /**
  57731. * Define this method to modify the default behavior when creating materials.
  57732. * @param context The context when loading the asset
  57733. * @param material The glTF material property
  57734. * @param babylonDrawMode The draw mode for the Babylon material
  57735. * @returns The Babylon material or null if not handled
  57736. */
  57737. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  57738. /**
  57739. * Define this method to modify the default behavior when loading material properties.
  57740. * @param context The context when loading the asset
  57741. * @param material The glTF material property
  57742. * @param babylonMaterial The Babylon material
  57743. * @returns A promise that resolves when the load is complete or null if not handled
  57744. */
  57745. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  57746. /**
  57747. * Define this method to modify the default behavior when loading texture infos.
  57748. * @param context The context when loading the asset
  57749. * @param textureInfo The glTF texture info property
  57750. * @param assign A function called synchronously after parsing the glTF properties
  57751. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  57752. */
  57753. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  57754. /**
  57755. * Define this method to modify the default behavior when loading animations.
  57756. * @param context The context when loading the asset
  57757. * @param animation The glTF animation property
  57758. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  57759. */
  57760. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  57761. /**
  57762. * Define this method to modify the default behavior when loading uris.
  57763. * @param context The context when loading the asset
  57764. * @param uri The uri to load
  57765. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  57766. */ loadUriAsync?(context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
  57767. }
  57768. }
  57769. declare module BABYLON.GLTF2 {
  57770. /**
  57771. * Helper class for working with arrays when loading the glTF asset
  57772. */
  57773. export class ArrayItem {
  57774. /**
  57775. * Gets an item from the given array.
  57776. * @param context The context when loading the asset
  57777. * @param array The array to get the item from
  57778. * @param index The index to the array
  57779. * @returns The array item
  57780. */
  57781. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  57782. /**
  57783. * Assign an `index` field to each item of the given array.
  57784. * @param array The array of items
  57785. */
  57786. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  57787. }
  57788. /**
  57789. * The glTF 2.0 loader
  57790. */
  57791. export class GLTFLoader implements IGLTFLoader {
  57792. /** The glTF object parsed from the JSON. */
  57793. gltf: IGLTF;
  57794. /** The Babylon scene when loading the asset. */
  57795. babylonScene: Scene;
  57796. /** @hidden */ completePromises: Promise<any>[];
  57797. private _disposed;
  57798. private _parent;
  57799. private _state;
  57800. private _extensions;
  57801. private _rootUrl;
  57802. private _fileName;
  57803. private _uniqueRootUrl;
  57804. private _rootBabylonMesh;
  57805. private _defaultBabylonMaterialData;
  57806. private _progressCallback?;
  57807. private _requests;
  57808. private static readonly _DefaultSampler;
  57809. private static _ExtensionNames;
  57810. private static _ExtensionFactories;
  57811. /**
  57812. * Registers a loader extension.
  57813. * @param name The name of the loader extension.
  57814. * @param factory The factory function that creates the loader extension.
  57815. */
  57816. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  57817. /**
  57818. * Unregisters a loader extension.
  57819. * @param name The name of the loader extenion.
  57820. * @returns A boolean indicating whether the extension has been unregistered
  57821. */
  57822. static UnregisterExtension(name: string): boolean;
  57823. /**
  57824. * Gets the loader state.
  57825. */
  57826. readonly state: Nullable<GLTFLoaderState>;
  57827. /** @hidden */
  57828. constructor(parent: GLTFFileLoader);
  57829. /** @hidden */
  57830. dispose(): void;
  57831. /** @hidden */
  57832. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  57833. meshes: AbstractMesh[];
  57834. particleSystems: IParticleSystem[];
  57835. skeletons: Skeleton[];
  57836. animationGroups: AnimationGroup[];
  57837. }>;
  57838. /** @hidden */
  57839. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  57840. private _loadAsync;
  57841. private _loadData;
  57842. private _setupData;
  57843. private _loadExtensions;
  57844. private _checkExtensions;
  57845. private _setState;
  57846. private _createRootNode;
  57847. /**
  57848. * Loads a glTF scene.
  57849. * @param context The context when loading the asset
  57850. * @param scene The glTF scene property
  57851. * @returns A promise that resolves when the load is complete
  57852. */
  57853. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  57854. private _forEachPrimitive;
  57855. private _getMeshes;
  57856. private _getSkeletons;
  57857. private _getAnimationGroups;
  57858. private _startAnimations;
  57859. /**
  57860. * Loads a glTF node.
  57861. * @param context The context when loading the asset
  57862. * @param node The glTF node property
  57863. * @param assign A function called synchronously after parsing the glTF properties
  57864. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  57865. */
  57866. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  57867. private _loadMeshAsync;
  57868. private _loadMeshPrimitiveAsync;
  57869. private _loadVertexDataAsync;
  57870. private _createMorphTargets;
  57871. private _loadMorphTargetsAsync;
  57872. private _loadMorphTargetVertexDataAsync;
  57873. private static _LoadTransform;
  57874. private _loadSkinAsync;
  57875. private _loadBones;
  57876. private _loadBone;
  57877. private _loadSkinInverseBindMatricesDataAsync;
  57878. private _updateBoneMatrices;
  57879. private _getNodeMatrix;
  57880. /**
  57881. * Loads a glTF camera.
  57882. * @param context The context when loading the asset
  57883. * @param camera The glTF camera property
  57884. * @param assign A function called synchronously after parsing the glTF properties
  57885. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  57886. */
  57887. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  57888. private _loadAnimationsAsync;
  57889. /**
  57890. * Loads a glTF animation.
  57891. * @param context The context when loading the asset
  57892. * @param animation The glTF animation property
  57893. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  57894. */
  57895. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  57896. private _loadAnimationChannelAsync;
  57897. private _loadAnimationSamplerAsync;
  57898. private _loadBufferAsync;
  57899. /**
  57900. * Loads a glTF buffer view.
  57901. * @param context The context when loading the asset
  57902. * @param bufferView The glTF buffer view property
  57903. * @returns A promise that resolves with the loaded data when the load is complete
  57904. */
  57905. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  57906. private _loadIndicesAccessorAsync;
  57907. private _loadFloatAccessorAsync;
  57908. private _loadVertexBufferViewAsync;
  57909. private _loadVertexAccessorAsync;
  57910. private _loadMaterialMetallicRoughnessPropertiesAsync;
  57911. /** @hidden */ loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  57912. private _createDefaultMaterial;
  57913. /**
  57914. * Creates a Babylon material from a glTF material.
  57915. * @param context The context when loading the asset
  57916. * @param material The glTF material property
  57917. * @param babylonDrawMode The draw mode for the Babylon material
  57918. * @returns The Babylon material
  57919. */
  57920. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  57921. /**
  57922. * Loads properties from a glTF material into a Babylon material.
  57923. * @param context The context when loading the asset
  57924. * @param material The glTF material property
  57925. * @param babylonMaterial The Babylon material
  57926. * @returns A promise that resolves when the load is complete
  57927. */
  57928. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  57929. /**
  57930. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  57931. * @param context The context when loading the asset
  57932. * @param material The glTF material property
  57933. * @param babylonMaterial The Babylon material
  57934. * @returns A promise that resolves when the load is complete
  57935. */
  57936. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  57937. /**
  57938. * Loads the alpha properties from a glTF material into a Babylon material.
  57939. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  57940. * @param context The context when loading the asset
  57941. * @param material The glTF material property
  57942. * @param babylonMaterial The Babylon material
  57943. */
  57944. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  57945. /**
  57946. * Loads a glTF texture info.
  57947. * @param context The context when loading the asset
  57948. * @param textureInfo The glTF texture info property
  57949. * @param assign A function called synchronously after parsing the glTF properties
  57950. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  57951. */
  57952. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  57953. private _loadTextureAsync;
  57954. private _loadSampler;
  57955. /**
  57956. * Loads a glTF image.
  57957. * @param context The context when loading the asset
  57958. * @param image The glTF image property
  57959. * @returns A promise that resolves with the loaded data when the load is complete
  57960. */
  57961. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  57962. /**
  57963. * Loads a glTF uri.
  57964. * @param context The context when loading the asset
  57965. * @param uri The base64 or relative uri
  57966. * @returns A promise that resolves with the loaded data when the load is complete
  57967. */
  57968. loadUriAsync(context: string, uri: string): Promise<ArrayBufferView>;
  57969. private _onProgress;
  57970. /**
  57971. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  57972. * @param babylonObject the Babylon object with metadata
  57973. * @param pointer the JSON pointer
  57974. */
  57975. static AddPointerMetadata(babylonObject: {
  57976. metadata: any;
  57977. }, pointer: string): void;
  57978. private static _GetTextureWrapMode;
  57979. private static _GetTextureSamplingMode;
  57980. private static _GetTypedArray;
  57981. private static _GetNumComponents;
  57982. private static _ValidateUri;
  57983. private static _GetDrawMode;
  57984. private _compileMaterialsAsync;
  57985. private _compileShadowGeneratorsAsync;
  57986. private _forEachExtensions;
  57987. private _applyExtensions;
  57988. private _extensionsOnLoading;
  57989. private _extensionsOnReady;
  57990. private _extensionsLoadSceneAsync;
  57991. private _extensionsLoadNodeAsync;
  57992. private _extensionsLoadCameraAsync;
  57993. private _extensionsLoadVertexDataAsync;
  57994. private _extensionsLoadMaterialAsync;
  57995. private _extensionsCreateMaterial;
  57996. private _extensionsLoadMaterialPropertiesAsync;
  57997. private _extensionsLoadTextureInfoAsync;
  57998. private _extensionsLoadAnimationAsync;
  57999. private _extensionsLoadUriAsync;
  58000. /**
  58001. * Helper method called by a loader extension to load an glTF extension.
  58002. * @param context The context when loading the asset
  58003. * @param property The glTF property to load the extension from
  58004. * @param extensionName The name of the extension to load
  58005. * @param actionAsync The action to run
  58006. * @returns The promise returned by actionAsync or null if the extension does not exist
  58007. */
  58008. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  58009. /**
  58010. * Helper method called by a loader extension to load a glTF extra.
  58011. * @param context The context when loading the asset
  58012. * @param property The glTF property to load the extra from
  58013. * @param extensionName The name of the extension to load
  58014. * @param actionAsync The action to run
  58015. * @returns The promise returned by actionAsync or null if the extra does not exist
  58016. */
  58017. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  58018. /**
  58019. * Increments the indentation level and logs a message.
  58020. * @param message The message to log
  58021. */
  58022. logOpen(message: string): void;
  58023. /**
  58024. * Decrements the indentation level.
  58025. */
  58026. logClose(): void;
  58027. /**
  58028. * Logs a message
  58029. * @param message The message to log
  58030. */
  58031. log(message: string): void;
  58032. /**
  58033. * Starts a performance counter.
  58034. * @param counterName The name of the performance counter
  58035. */
  58036. startPerformanceCounter(counterName: string): void;
  58037. /**
  58038. * Ends a performance counter.
  58039. * @param counterName The name of the performance counter
  58040. */
  58041. endPerformanceCounter(counterName: string): void;
  58042. }
  58043. }
  58044. declare module BABYLON.GLTF2.Loader.Extensions {
  58045. /**
  58046. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  58047. */
  58048. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  58049. /** The name of this extension. */
  58050. readonly name: string;
  58051. /** Defines whether this extension is enabled. */
  58052. enabled: boolean;
  58053. private _loader;
  58054. private _lights?;
  58055. /** @hidden */
  58056. constructor(loader: GLTFLoader);
  58057. /** @hidden */
  58058. dispose(): void;
  58059. /** @hidden */
  58060. onLoading(): void;
  58061. /** @hidden */
  58062. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  58063. private _loadLightAsync;
  58064. }
  58065. }
  58066. declare module BABYLON.GLTF2.Loader.Extensions {
  58067. /**
  58068. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  58069. */
  58070. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  58071. /** The name of this extension. */
  58072. readonly name: string;
  58073. /** Defines whether this extension is enabled. */
  58074. enabled: boolean;
  58075. private _loader;
  58076. private _dracoCompression?;
  58077. /** @hidden */
  58078. constructor(loader: GLTFLoader);
  58079. /** @hidden */
  58080. dispose(): void;
  58081. /** @hidden */ loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  58082. }
  58083. }
  58084. declare module BABYLON.GLTF2.Loader.Extensions {
  58085. /**
  58086. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  58087. */
  58088. export class KHR_lights implements IGLTFLoaderExtension {
  58089. /** The name of this extension. */
  58090. readonly name: string;
  58091. /** Defines whether this extension is enabled. */
  58092. enabled: boolean;
  58093. private _loader;
  58094. private _lights?;
  58095. /** @hidden */
  58096. constructor(loader: GLTFLoader);
  58097. /** @hidden */
  58098. dispose(): void;
  58099. /** @hidden */
  58100. onLoading(): void;
  58101. /** @hidden */
  58102. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  58103. }
  58104. }
  58105. declare module BABYLON.GLTF2.Loader.Extensions {
  58106. /**
  58107. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  58108. */
  58109. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  58110. /** The name of this extension. */
  58111. readonly name: string;
  58112. /** Defines whether this extension is enabled. */
  58113. enabled: boolean;
  58114. private _loader;
  58115. /** @hidden */
  58116. constructor(loader: GLTFLoader);
  58117. /** @hidden */
  58118. dispose(): void;
  58119. /** @hidden */
  58120. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  58121. private _loadSpecularGlossinessPropertiesAsync;
  58122. }
  58123. }
  58124. declare module BABYLON.GLTF2.Loader.Extensions {
  58125. /**
  58126. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  58127. */
  58128. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  58129. /** The name of this extension. */
  58130. readonly name: string;
  58131. /** Defines whether this extension is enabled. */
  58132. enabled: boolean;
  58133. private _loader;
  58134. /** @hidden */
  58135. constructor(loader: GLTFLoader);
  58136. /** @hidden */
  58137. dispose(): void;
  58138. /** @hidden */
  58139. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  58140. private _loadUnlitPropertiesAsync;
  58141. }
  58142. }
  58143. declare module BABYLON.GLTF2.Loader.Extensions {
  58144. /**
  58145. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  58146. */
  58147. export class KHR_texture_transform implements IGLTFLoaderExtension {
  58148. /** The name of this extension. */
  58149. readonly name: string;
  58150. /** Defines whether this extension is enabled. */
  58151. enabled: boolean;
  58152. private _loader;
  58153. /** @hidden */
  58154. constructor(loader: GLTFLoader);
  58155. /** @hidden */
  58156. dispose(): void;
  58157. /** @hidden */
  58158. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  58159. }
  58160. }
  58161. declare module BABYLON.GLTF2.Loader.Extensions {
  58162. /**
  58163. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  58164. */
  58165. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  58166. /** The name of this extension. */
  58167. readonly name: string;
  58168. /** Defines whether this extension is enabled. */
  58169. enabled: boolean;
  58170. private _loader;
  58171. private _clips;
  58172. private _emitters;
  58173. /** @hidden */
  58174. constructor(loader: GLTFLoader);
  58175. /** @hidden */
  58176. dispose(): void;
  58177. /** @hidden */
  58178. onLoading(): void;
  58179. /** @hidden */
  58180. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  58181. /** @hidden */
  58182. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  58183. /** @hidden */
  58184. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  58185. private _loadClipAsync;
  58186. private _loadEmitterAsync;
  58187. private _getEventAction;
  58188. private _loadAnimationEventAsync;
  58189. }
  58190. }
  58191. declare module BABYLON.GLTF2.Loader.Extensions {
  58192. /**
  58193. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  58194. */
  58195. export class MSFT_lod implements IGLTFLoaderExtension {
  58196. /** The name of this extension. */
  58197. readonly name: string;
  58198. /** Defines whether this extension is enabled. */
  58199. enabled: boolean;
  58200. /**
  58201. * Maximum number of LODs to load, starting from the lowest LOD.
  58202. */
  58203. maxLODsToLoad: number;
  58204. /**
  58205. * Observable raised when all node LODs of one level are loaded.
  58206. * The event data is the index of the loaded LOD starting from zero.
  58207. * Dispose the loader to cancel the loading of the next level of LODs.
  58208. */
  58209. onNodeLODsLoadedObservable: Observable<number>;
  58210. /**
  58211. * Observable raised when all material LODs of one level are loaded.
  58212. * The event data is the index of the loaded LOD starting from zero.
  58213. * Dispose the loader to cancel the loading of the next level of LODs.
  58214. */
  58215. onMaterialLODsLoadedObservable: Observable<number>;
  58216. private _loader;
  58217. private _nodeIndexLOD;
  58218. private _nodeSignalLODs;
  58219. private _nodePromiseLODs;
  58220. private _materialIndexLOD;
  58221. private _materialSignalLODs;
  58222. private _materialPromiseLODs;
  58223. /** @hidden */
  58224. constructor(loader: GLTFLoader);
  58225. /** @hidden */
  58226. dispose(): void;
  58227. /** @hidden */
  58228. onReady(): void;
  58229. /** @hidden */
  58230. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  58231. /** @hidden */ loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  58232. /** @hidden */ loadUriAsync(context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
  58233. /**
  58234. * Gets an array of LOD properties from lowest to highest.
  58235. */
  58236. private _getLODs;
  58237. private _disposeUnusedMaterials;
  58238. }
  58239. }
  58240. declare module BABYLON.GLTF2.Loader.Extensions {
  58241. /** @hidden */
  58242. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  58243. readonly name: string;
  58244. enabled: boolean;
  58245. private _loader;
  58246. constructor(loader: GLTFLoader);
  58247. dispose(): void;
  58248. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  58249. }
  58250. }
  58251. declare module BABYLON.GLTF2.Loader.Extensions {
  58252. /** @hidden */
  58253. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  58254. readonly name: string;
  58255. enabled: boolean;
  58256. private _loader;
  58257. constructor(loader: GLTFLoader);
  58258. dispose(): void;
  58259. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  58260. }
  58261. }
  58262. declare module BABYLON {
  58263. /**
  58264. * Class reading and parsing the MTL file bundled with the obj file.
  58265. */
  58266. export class MTLFileLoader {
  58267. /**
  58268. * All material loaded from the mtl will be set here
  58269. */
  58270. materials: StandardMaterial[];
  58271. /**
  58272. * This function will read the mtl file and create each material described inside
  58273. * This function could be improve by adding :
  58274. * -some component missing (Ni, Tf...)
  58275. * -including the specific options available
  58276. *
  58277. * @param scene defines the scene the material will be created in
  58278. * @param data defines the mtl data to parse
  58279. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  58280. */
  58281. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  58282. /**
  58283. * Gets the texture for the material.
  58284. *
  58285. * If the material is imported from input file,
  58286. * We sanitize the url to ensure it takes the textre from aside the material.
  58287. *
  58288. * @param rootUrl The root url to load from
  58289. * @param value The value stored in the mtl
  58290. * @return The Texture
  58291. */
  58292. private static _getTexture;
  58293. }
  58294. /**
  58295. * OBJ file type loader.
  58296. * This is a babylon scene loader plugin.
  58297. */
  58298. export class OBJFileLoader implements ISceneLoaderPluginAsync {
  58299. /**
  58300. * Defines if UVs are optimized by default during load.
  58301. */
  58302. static OPTIMIZE_WITH_UV: boolean;
  58303. /**
  58304. * Invert model on y-axis (does a model scaling inversion)
  58305. */
  58306. static INVERT_Y: boolean;
  58307. /**
  58308. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  58309. */
  58310. static IMPORT_VERTEX_COLORS: boolean;
  58311. /**
  58312. * Compute the normals for the model, even if normals are present in the file
  58313. */
  58314. static COMPUTE_NORMALS: boolean;
  58315. /**
  58316. * Defines the name of the plugin.
  58317. */
  58318. name: string;
  58319. /**
  58320. * Defines the extension the plugin is able to load.
  58321. */
  58322. extensions: string;
  58323. /** @hidden */
  58324. obj: RegExp;
  58325. /** @hidden */
  58326. group: RegExp;
  58327. /** @hidden */
  58328. mtllib: RegExp;
  58329. /** @hidden */
  58330. usemtl: RegExp;
  58331. /** @hidden */
  58332. smooth: RegExp;
  58333. /** @hidden */
  58334. vertexPattern: RegExp;
  58335. /** @hidden */
  58336. normalPattern: RegExp;
  58337. /** @hidden */
  58338. uvPattern: RegExp;
  58339. /** @hidden */
  58340. facePattern1: RegExp;
  58341. /** @hidden */
  58342. facePattern2: RegExp;
  58343. /** @hidden */
  58344. facePattern3: RegExp;
  58345. /** @hidden */
  58346. facePattern4: RegExp;
  58347. /** @hidden */
  58348. facePattern5: RegExp;
  58349. /**
  58350. * Calls synchronously the MTL file attached to this obj.
  58351. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  58352. * Without this function materials are not displayed in the first frame (but displayed after).
  58353. * In consequence it is impossible to get material information in your HTML file
  58354. *
  58355. * @param url The URL of the MTL file
  58356. * @param rootUrl
  58357. * @param onSuccess Callback function to be called when the MTL file is loaded
  58358. * @private
  58359. */
  58360. private _loadMTL;
  58361. /**
  58362. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  58363. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  58364. * @param scene the scene the meshes should be added to
  58365. * @param data the OBJ data to load
  58366. * @param rootUrl root url to load from
  58367. * @param onProgress event that fires when loading progress has occured
  58368. * @param fileName Defines the name of the file to load
  58369. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  58370. */
  58371. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  58372. meshes: AbstractMesh[];
  58373. particleSystems: IParticleSystem[];
  58374. skeletons: Skeleton[];
  58375. animationGroups: AnimationGroup[];
  58376. }>;
  58377. /**
  58378. * Imports all objects from the loaded OBJ data and adds them to the scene
  58379. * @param scene the scene the objects should be added to
  58380. * @param data the OBJ data to load
  58381. * @param rootUrl root url to load from
  58382. * @param onProgress event that fires when loading progress has occured
  58383. * @param fileName Defines the name of the file to load
  58384. * @returns a promise which completes when objects have been loaded to the scene
  58385. */
  58386. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  58387. /**
  58388. * Load into an asset container.
  58389. * @param scene The scene to load into
  58390. * @param data The data to import
  58391. * @param rootUrl The root url for scene and resources
  58392. * @param onProgress The callback when the load progresses
  58393. * @param fileName Defines the name of the file to load
  58394. * @returns The loaded asset container
  58395. */
  58396. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  58397. /**
  58398. * Read the OBJ file and create an Array of meshes.
  58399. * Each mesh contains all information given by the OBJ and the MTL file.
  58400. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  58401. *
  58402. * @param meshesNames
  58403. * @param scene Scene The scene where are displayed the data
  58404. * @param data String The content of the obj file
  58405. * @param rootUrl String The path to the folder
  58406. * @returns Array<AbstractMesh>
  58407. * @private
  58408. */
  58409. private _parseSolid;
  58410. }
  58411. }
  58412. declare module BABYLON {
  58413. /**
  58414. * STL file type loader.
  58415. * This is a babylon scene loader plugin.
  58416. */
  58417. export class STLFileLoader implements ISceneLoaderPlugin {
  58418. /** @hidden */
  58419. solidPattern: RegExp;
  58420. /** @hidden */
  58421. facetsPattern: RegExp;
  58422. /** @hidden */
  58423. normalPattern: RegExp;
  58424. /** @hidden */
  58425. vertexPattern: RegExp;
  58426. /**
  58427. * Defines the name of the plugin.
  58428. */
  58429. name: string;
  58430. /**
  58431. * Defines the extensions the stl loader is able to load.
  58432. * force data to come in as an ArrayBuffer
  58433. * we'll convert to string if it looks like it's an ASCII .stl
  58434. */
  58435. extensions: ISceneLoaderPluginExtensions;
  58436. /**
  58437. * Import meshes into a scene.
  58438. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  58439. * @param scene The scene to import into
  58440. * @param data The data to import
  58441. * @param rootUrl The root url for scene and resources
  58442. * @param meshes The meshes array to import into
  58443. * @param particleSystems The particle systems array to import into
  58444. * @param skeletons The skeletons array to import into
  58445. * @param onError The callback when import fails
  58446. * @returns True if successful or false otherwise
  58447. */
  58448. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  58449. /**
  58450. * Load into a scene.
  58451. * @param scene The scene to load into
  58452. * @param data The data to import
  58453. * @param rootUrl The root url for scene and resources
  58454. * @param onError The callback when import fails
  58455. * @returns true if successful or false otherwise
  58456. */
  58457. load(scene: Scene, data: any, rootUrl: string): boolean;
  58458. /**
  58459. * Load into an asset container.
  58460. * @param scene The scene to load into
  58461. * @param data The data to import
  58462. * @param rootUrl The root url for scene and resources
  58463. * @param onError The callback when import fails
  58464. * @returns The loaded asset container
  58465. */
  58466. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  58467. private _isBinary;
  58468. private _parseBinary;
  58469. private _parseASCII;
  58470. }
  58471. }
  58472. declare module BABYLON {
  58473. /**
  58474. * Class for generating OBJ data from a Babylon scene.
  58475. */
  58476. export class OBJExport {
  58477. /**
  58478. * Exports the geometry of a Mesh array in .OBJ file format (text)
  58479. * @param mesh defines the list of meshes to serialize
  58480. * @param materials defines if materials should be exported
  58481. * @param matlibname defines the name of the associated mtl file
  58482. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  58483. * @returns the OBJ content
  58484. */
  58485. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  58486. /**
  58487. * Exports the material(s) of a mesh in .MTL file format (text)
  58488. * @param mesh defines the mesh to extract the material from
  58489. * @returns the mtl content
  58490. */
  58491. static MTL(mesh: Mesh): string;
  58492. }
  58493. }
  58494. declare module BABYLON {
  58495. /** @hidden */
  58496. export var __IGLTFExporterExtension: number;
  58497. /**
  58498. * Interface for extending the exporter
  58499. * @hidden
  58500. */
  58501. export interface IGLTFExporterExtension {
  58502. /**
  58503. * The name of this extension
  58504. */
  58505. readonly name: string;
  58506. /**
  58507. * Defines whether this extension is enabled
  58508. */
  58509. enabled: boolean;
  58510. /**
  58511. * Defines whether this extension is required
  58512. */
  58513. required: boolean;
  58514. }
  58515. }
  58516. declare module BABYLON.GLTF2.Exporter {
  58517. /** @hidden */
  58518. export var __IGLTFExporterExtensionV2: number;
  58519. /**
  58520. * Interface for a glTF exporter extension
  58521. * @hidden
  58522. */
  58523. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  58524. /**
  58525. * Define this method to modify the default behavior before exporting a texture
  58526. * @param context The context when loading the asset
  58527. * @param babylonTexture The glTF texture info property
  58528. * @param mimeType The mime-type of the generated image
  58529. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  58530. */
  58531. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  58532. /**
  58533. * Define this method to modify the default behavior when exporting texture info
  58534. * @param context The context when loading the asset
  58535. * @param meshPrimitive glTF mesh primitive
  58536. * @param babylonSubMesh Babylon submesh
  58537. * @param binaryWriter glTF serializer binary writer instance
  58538. */
  58539. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  58540. }
  58541. }
  58542. declare module BABYLON.GLTF2.Exporter {
  58543. /**
  58544. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  58545. * @hidden
  58546. */
  58547. export class _GLTFMaterialExporter {
  58548. /**
  58549. * Represents the dielectric specular values for R, G and B
  58550. */
  58551. private static readonly _DielectricSpecular;
  58552. /**
  58553. * Allows the maximum specular power to be defined for material calculations
  58554. */
  58555. private static readonly _MaxSpecularPower;
  58556. /**
  58557. * Mapping to store textures
  58558. */
  58559. private _textureMap;
  58560. /**
  58561. * Numeric tolerance value
  58562. */
  58563. private static readonly _Epsilon;
  58564. /**
  58565. * Reference to the glTF Exporter
  58566. */
  58567. private _exporter;
  58568. constructor(exporter: _Exporter);
  58569. /**
  58570. * Specifies if two colors are approximately equal in value
  58571. * @param color1 first color to compare to
  58572. * @param color2 second color to compare to
  58573. * @param epsilon threshold value
  58574. */
  58575. private static FuzzyEquals;
  58576. /**
  58577. * Gets the materials from a Babylon scene and converts them to glTF materials
  58578. * @param scene babylonjs scene
  58579. * @param mimeType texture mime type
  58580. * @param images array of images
  58581. * @param textures array of textures
  58582. * @param materials array of materials
  58583. * @param imageData mapping of texture names to base64 textures
  58584. * @param hasTextureCoords specifies if texture coordinates are present on the material
  58585. */ convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  58586. /**
  58587. * Makes a copy of the glTF material without the texture parameters
  58588. * @param originalMaterial original glTF material
  58589. * @returns glTF material without texture parameters
  58590. */ stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  58591. /**
  58592. * Specifies if the material has any texture parameters present
  58593. * @param material glTF Material
  58594. * @returns boolean specifying if texture parameters are present
  58595. */ hasTexturesPresent(material: IMaterial): boolean;
  58596. /**
  58597. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  58598. * @param babylonStandardMaterial
  58599. * @returns glTF Metallic Roughness Material representation
  58600. */ convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  58601. /**
  58602. * Computes the metallic factor
  58603. * @param diffuse diffused value
  58604. * @param specular specular value
  58605. * @param oneMinusSpecularStrength one minus the specular strength
  58606. * @returns metallic value
  58607. */ private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  58608. /**
  58609. * Gets the glTF alpha mode from the Babylon Material
  58610. * @param babylonMaterial Babylon Material
  58611. * @returns The Babylon alpha mode value
  58612. */ getAlphaMode(babylonMaterial: Material): MaterialAlphaMode;
  58613. /**
  58614. * Converts a Babylon Standard Material to a glTF Material
  58615. * @param babylonStandardMaterial BJS Standard Material
  58616. * @param mimeType mime type to use for the textures
  58617. * @param images array of glTF image interfaces
  58618. * @param textures array of glTF texture interfaces
  58619. * @param materials array of glTF material interfaces
  58620. * @param imageData map of image file name to data
  58621. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  58622. */ convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  58623. /**
  58624. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  58625. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  58626. * @param mimeType mime type to use for the textures
  58627. * @param images array of glTF image interfaces
  58628. * @param textures array of glTF texture interfaces
  58629. * @param materials array of glTF material interfaces
  58630. * @param imageData map of image file name to data
  58631. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  58632. */ convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  58633. /**
  58634. * Converts an image typed array buffer to a base64 image
  58635. * @param buffer typed array buffer
  58636. * @param width width of the image
  58637. * @param height height of the image
  58638. * @param mimeType mimetype of the image
  58639. * @returns base64 image string
  58640. */
  58641. private _createBase64FromCanvasAsync;
  58642. /**
  58643. * Generates a white texture based on the specified width and height
  58644. * @param width width of the texture in pixels
  58645. * @param height height of the texture in pixels
  58646. * @param scene babylonjs scene
  58647. * @returns white texture
  58648. */
  58649. private _createWhiteTexture;
  58650. /**
  58651. * 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
  58652. * @param texture1 first texture to resize
  58653. * @param texture2 second texture to resize
  58654. * @param scene babylonjs scene
  58655. * @returns resized textures or null
  58656. */
  58657. private _resizeTexturesToSameDimensions;
  58658. /**
  58659. * Converts an array of pixels to a Float32Array
  58660. * Throws an error if the pixel format is not supported
  58661. * @param pixels - array buffer containing pixel values
  58662. * @returns Float32 of pixels
  58663. */
  58664. private _convertPixelArrayToFloat32;
  58665. /**
  58666. * Convert Specular Glossiness Textures to Metallic Roughness
  58667. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  58668. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  58669. * @param diffuseTexture texture used to store diffuse information
  58670. * @param specularGlossinessTexture texture used to store specular and glossiness information
  58671. * @param factors specular glossiness material factors
  58672. * @param mimeType the mime type to use for the texture
  58673. * @returns pbr metallic roughness interface or null
  58674. */
  58675. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  58676. /**
  58677. * Converts specular glossiness material properties to metallic roughness
  58678. * @param specularGlossiness interface with specular glossiness material properties
  58679. * @returns interface with metallic roughness material properties
  58680. */
  58681. private _convertSpecularGlossinessToMetallicRoughness;
  58682. /**
  58683. * Calculates the surface reflectance, independent of lighting conditions
  58684. * @param color Color source to calculate brightness from
  58685. * @returns number representing the perceived brightness, or zero if color is undefined
  58686. */
  58687. private _getPerceivedBrightness;
  58688. /**
  58689. * Returns the maximum color component value
  58690. * @param color
  58691. * @returns maximum color component value, or zero if color is null or undefined
  58692. */
  58693. private _getMaxComponent;
  58694. /**
  58695. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  58696. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  58697. * @param mimeType mime type to use for the textures
  58698. * @param images array of glTF image interfaces
  58699. * @param textures array of glTF texture interfaces
  58700. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  58701. * @param imageData map of image file name to data
  58702. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  58703. * @returns glTF PBR Metallic Roughness factors
  58704. */
  58705. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  58706. private _getGLTFTextureSampler;
  58707. private _getGLTFTextureWrapMode;
  58708. private _getGLTFTextureWrapModesSampler;
  58709. /**
  58710. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  58711. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  58712. * @param mimeType mime type to use for the textures
  58713. * @param images array of glTF image interfaces
  58714. * @param textures array of glTF texture interfaces
  58715. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  58716. * @param imageData map of image file name to data
  58717. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  58718. * @returns glTF PBR Metallic Roughness factors
  58719. */
  58720. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  58721. /**
  58722. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  58723. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  58724. * @param mimeType mime type to use for the textures
  58725. * @param images array of glTF image interfaces
  58726. * @param textures array of glTF texture interfaces
  58727. * @param materials array of glTF material interfaces
  58728. * @param imageData map of image file name to data
  58729. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  58730. */ convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  58731. private setMetallicRoughnessPbrMaterial;
  58732. private getPixelsFromTexture;
  58733. /**
  58734. * Extracts a texture from a Babylon texture into file data and glTF data
  58735. * @param babylonTexture Babylon texture to extract
  58736. * @param mimeType Mime Type of the babylonTexture
  58737. * @return glTF texture info, or null if the texture format is not supported
  58738. */ exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>; exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  58739. /**
  58740. * Builds a texture from base64 string
  58741. * @param base64Texture base64 texture string
  58742. * @param baseTextureName Name to use for the texture
  58743. * @param mimeType image mime type for the texture
  58744. * @param images array of images
  58745. * @param textures array of textures
  58746. * @param imageData map of image data
  58747. * @returns glTF texture info, or null if the texture format is not supported
  58748. */
  58749. private _getTextureInfoFromBase64;
  58750. }
  58751. }
  58752. declare module BABYLON {
  58753. /**
  58754. * Class for holding and downloading glTF file data
  58755. */
  58756. export class GLTFData {
  58757. /**
  58758. * Object which contains the file name as the key and its data as the value
  58759. */
  58760. glTFFiles: {
  58761. [fileName: string]: string | Blob;
  58762. };
  58763. /**
  58764. * Initializes the glTF file object
  58765. */
  58766. constructor();
  58767. /**
  58768. * Downloads the glTF data as files based on their names and data
  58769. */
  58770. downloadFiles(): void;
  58771. }
  58772. }
  58773. declare module BABYLON {
  58774. /**
  58775. * Holds a collection of exporter options and parameters
  58776. */
  58777. export interface IExportOptions {
  58778. /**
  58779. * Function which indicates whether a babylon mesh should be exported or not
  58780. * @param transformNode source Babylon transform node. It is used to check whether it should be exported to glTF or not
  58781. * @returns boolean, which indicates whether the mesh should be exported (true) or not (false)
  58782. */
  58783. shouldExportTransformNode?(transformNode: TransformNode): boolean;
  58784. /**
  58785. * The sample rate to bake animation curves
  58786. */
  58787. animationSampleRate?: number;
  58788. /**
  58789. * Begin serialization without waiting for the scene to be ready
  58790. */
  58791. exportWithoutWaitingForScene?: boolean;
  58792. }
  58793. /**
  58794. * Class for generating glTF data from a Babylon scene.
  58795. */
  58796. export class GLTF2Export {
  58797. /**
  58798. * Exports the geometry of the scene to .gltf file format asynchronously
  58799. * @param scene Babylon scene with scene hierarchy information
  58800. * @param filePrefix File prefix to use when generating the glTF file
  58801. * @param options Exporter options
  58802. * @returns Returns an object with a .gltf file and associates texture names
  58803. * as keys and their data and paths as values
  58804. */
  58805. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  58806. private static _PreExportAsync;
  58807. private static _PostExportAsync;
  58808. /**
  58809. * Exports the geometry of the scene to .glb file format asychronously
  58810. * @param scene Babylon scene with scene hierarchy information
  58811. * @param filePrefix File prefix to use when generating glb file
  58812. * @param options Exporter options
  58813. * @returns Returns an object with a .glb filename as key and data as value
  58814. */
  58815. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  58816. }
  58817. }
  58818. declare module BABYLON.GLTF2.Exporter {
  58819. /**
  58820. * @hidden
  58821. */
  58822. export class _GLTFUtilities {
  58823. /**
  58824. * Creates a buffer view based on the supplied arguments
  58825. * @param bufferIndex index value of the specified buffer
  58826. * @param byteOffset byte offset value
  58827. * @param byteLength byte length of the bufferView
  58828. * @param byteStride byte distance between conequential elements
  58829. * @param name name of the buffer view
  58830. * @returns bufferView for glTF
  58831. */ private static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  58832. /**
  58833. * Creates an accessor based on the supplied arguments
  58834. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  58835. * @param name The name of the accessor
  58836. * @param type The type of the accessor
  58837. * @param componentType The datatype of components in the attribute
  58838. * @param count The number of attributes referenced by this accessor
  58839. * @param byteOffset The offset relative to the start of the bufferView in bytes
  58840. * @param min Minimum value of each component in this attribute
  58841. * @param max Maximum value of each component in this attribute
  58842. * @returns accessor for glTF
  58843. */ private static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  58844. /**
  58845. * Calculates the minimum and maximum values of an array of position floats
  58846. * @param positions Positions array of a mesh
  58847. * @param vertexStart Starting vertex offset to calculate min and max values
  58848. * @param vertexCount Number of vertices to check for min and max values
  58849. * @returns min number array and max number array
  58850. */ private static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  58851. min: number[];
  58852. max: number[];
  58853. };
  58854. /**
  58855. * Converts a new right-handed Vector3
  58856. * @param vector vector3 array
  58857. * @returns right-handed Vector3
  58858. */ private static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  58859. /**
  58860. * Converts a Vector3 to right-handed
  58861. * @param vector Vector3 to convert to right-handed
  58862. */ private static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  58863. /**
  58864. * Converts a three element number array to right-handed
  58865. * @param vector number array to convert to right-handed
  58866. */ private static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  58867. /**
  58868. * Converts a new right-handed Vector3
  58869. * @param vector vector3 array
  58870. * @returns right-handed Vector3
  58871. */ private static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  58872. /**
  58873. * Converts a Vector3 to right-handed
  58874. * @param vector Vector3 to convert to right-handed
  58875. */ private static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  58876. /**
  58877. * Converts a three element number array to right-handed
  58878. * @param vector number array to convert to right-handed
  58879. */ private static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  58880. /**
  58881. * Converts a Vector4 to right-handed
  58882. * @param vector Vector4 to convert to right-handed
  58883. */ private static _GetRightHandedVector4FromRef(vector: Vector4): void;
  58884. /**
  58885. * Converts a Vector4 to right-handed
  58886. * @param vector Vector4 to convert to right-handed
  58887. */ private static _GetRightHandedArray4FromRef(vector: number[]): void;
  58888. /**
  58889. * Converts a Quaternion to right-handed
  58890. * @param quaternion Source quaternion to convert to right-handed
  58891. */ private static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  58892. /**
  58893. * Converts a Quaternion to right-handed
  58894. * @param quaternion Source quaternion to convert to right-handed
  58895. */ private static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void; private static _NormalizeTangentFromRef(tangent: Vector4): void;
  58896. }
  58897. }
  58898. declare module BABYLON.GLTF2.Exporter {
  58899. /**
  58900. * Converts Babylon Scene into glTF 2.0.
  58901. * @hidden
  58902. */
  58903. export class _Exporter {
  58904. /**
  58905. * Stores all generated buffer views, which represents views into the main glTF buffer data
  58906. */ bufferViews: IBufferView[];
  58907. /**
  58908. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  58909. */ accessors: IAccessor[];
  58910. /**
  58911. * Stores all the generated nodes, which contains transform and/or mesh information per node
  58912. */
  58913. private _nodes;
  58914. /**
  58915. * Stores the glTF asset information, which represents the glTF version and this file generator
  58916. */
  58917. private _asset;
  58918. /**
  58919. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  58920. */
  58921. private _scenes;
  58922. /**
  58923. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  58924. */
  58925. private _meshes;
  58926. /**
  58927. * Stores all the generated material information, which represents the appearance of each primitive
  58928. */ materials: IMaterial[]; materialMap: {
  58929. [materialID: number]: number;
  58930. };
  58931. /**
  58932. * Stores all the generated texture information, which is referenced by glTF materials
  58933. */ textures: ITexture[];
  58934. /**
  58935. * Stores all the generated image information, which is referenced by glTF textures
  58936. */ images: IImage[];
  58937. /**
  58938. * Stores all the texture samplers
  58939. */ samplers: ISampler[];
  58940. /**
  58941. * Stores all the generated animation samplers, which is referenced by glTF animations
  58942. */
  58943. /**
  58944. * Stores the animations for glTF models
  58945. */
  58946. private _animations;
  58947. /**
  58948. * Stores the total amount of bytes stored in the glTF buffer
  58949. */
  58950. private _totalByteLength;
  58951. /**
  58952. * Stores a reference to the Babylon scene containing the source geometry and material information
  58953. */
  58954. private _babylonScene;
  58955. /**
  58956. * Stores a map of the image data, where the key is the file name and the value
  58957. * is the image data
  58958. */ imageData: {
  58959. [fileName: string]: {
  58960. data: Uint8Array;
  58961. mimeType: ImageMimeType;
  58962. };
  58963. };
  58964. /**
  58965. * Stores a map of the unique id of a node to its index in the node array
  58966. */
  58967. private _nodeMap;
  58968. /**
  58969. * Specifies if the Babylon scene should be converted to right-handed on export
  58970. */
  58971. private _convertToRightHandedSystem;
  58972. /**
  58973. * Baked animation sample rate
  58974. */
  58975. private _animationSampleRate;
  58976. /**
  58977. * Callback which specifies if a transform node should be exported or not
  58978. */
  58979. private _shouldExportTransformNode;
  58980. private _localEngine; glTFMaterialExporter: _GLTFMaterialExporter;
  58981. private _extensions;
  58982. private _extensionsUsed;
  58983. private _extensionsRequired;
  58984. private static _ExtensionNames;
  58985. private static _ExtensionFactories;
  58986. private _applyExtensions; extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>; extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  58987. /**
  58988. * Load glTF serializer extensions
  58989. */
  58990. private _loadExtensions;
  58991. /**
  58992. * Creates a glTF Exporter instance, which can accept optional exporter options
  58993. * @param babylonScene Babylon scene object
  58994. * @param options Options to modify the behavior of the exporter
  58995. */
  58996. constructor(babylonScene: Scene, options?: IExportOptions);
  58997. /**
  58998. * Registers a glTF exporter extension
  58999. * @param name Name of the extension to export
  59000. * @param factory The factory function that creates the exporter extension
  59001. */
  59002. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  59003. /**
  59004. * Un-registers an exporter extension
  59005. * @param name The name fo the exporter extension
  59006. * @returns A boolean indicating whether the extension has been un-registered
  59007. */
  59008. static UnregisterExtension(name: string): boolean;
  59009. /**
  59010. * Lazy load a local engine with premultiplied alpha set to false
  59011. */ getLocalEngine(): Engine;
  59012. private reorderIndicesBasedOnPrimitiveMode;
  59013. /**
  59014. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  59015. * clock-wise during export to glTF
  59016. * @param submesh BabylonJS submesh
  59017. * @param primitiveMode Primitive mode of the mesh
  59018. * @param sideOrientation the winding order of the submesh
  59019. * @param vertexBufferKind The type of vertex attribute
  59020. * @param meshAttributeArray The vertex attribute data
  59021. * @param byteOffset The offset to the binary data
  59022. * @param binaryWriter The binary data for the glTF file
  59023. */
  59024. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  59025. /**
  59026. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  59027. * clock-wise during export to glTF
  59028. * @param submesh BabylonJS submesh
  59029. * @param primitiveMode Primitive mode of the mesh
  59030. * @param sideOrientation the winding order of the submesh
  59031. * @param vertexBufferKind The type of vertex attribute
  59032. * @param meshAttributeArray The vertex attribute data
  59033. * @param byteOffset The offset to the binary data
  59034. * @param binaryWriter The binary data for the glTF file
  59035. */
  59036. private reorderTriangleFillMode;
  59037. /**
  59038. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  59039. * clock-wise during export to glTF
  59040. * @param submesh BabylonJS submesh
  59041. * @param primitiveMode Primitive mode of the mesh
  59042. * @param sideOrientation the winding order of the submesh
  59043. * @param vertexBufferKind The type of vertex attribute
  59044. * @param meshAttributeArray The vertex attribute data
  59045. * @param byteOffset The offset to the binary data
  59046. * @param binaryWriter The binary data for the glTF file
  59047. */
  59048. private reorderTriangleStripDrawMode;
  59049. /**
  59050. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  59051. * clock-wise during export to glTF
  59052. * @param submesh BabylonJS submesh
  59053. * @param primitiveMode Primitive mode of the mesh
  59054. * @param sideOrientation the winding order of the submesh
  59055. * @param vertexBufferKind The type of vertex attribute
  59056. * @param meshAttributeArray The vertex attribute data
  59057. * @param byteOffset The offset to the binary data
  59058. * @param binaryWriter The binary data for the glTF file
  59059. */
  59060. private reorderTriangleFanMode;
  59061. /**
  59062. * Writes the vertex attribute data to binary
  59063. * @param vertices The vertices to write to the binary writer
  59064. * @param byteOffset The offset into the binary writer to overwrite binary data
  59065. * @param vertexAttributeKind The vertex attribute type
  59066. * @param meshAttributeArray The vertex attribute data
  59067. * @param binaryWriter The writer containing the binary data
  59068. */
  59069. private writeVertexAttributeData;
  59070. /**
  59071. * Writes mesh attribute data to a data buffer
  59072. * Returns the bytelength of the data
  59073. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  59074. * @param meshAttributeArray Array containing the attribute data
  59075. * @param binaryWriter The buffer to write the binary data to
  59076. * @param indices Used to specify the order of the vertex data
  59077. */
  59078. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  59079. /**
  59080. * Generates glTF json data
  59081. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  59082. * @param glTFPrefix Text to use when prefixing a glTF file
  59083. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  59084. * @returns json data as string
  59085. */
  59086. private generateJSON;
  59087. /**
  59088. * Generates data for .gltf and .bin files based on the glTF prefix string
  59089. * @param glTFPrefix Text to use when prefixing a glTF file
  59090. * @returns GLTFData with glTF file data
  59091. */ generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  59092. /**
  59093. * Creates a binary buffer for glTF
  59094. * @returns array buffer for binary data
  59095. */
  59096. private _generateBinaryAsync;
  59097. /**
  59098. * Pads the number to a multiple of 4
  59099. * @param num number to pad
  59100. * @returns padded number
  59101. */
  59102. private _getPadding;
  59103. /**
  59104. * Generates a glb file from the json and binary data
  59105. * Returns an object with the glb file name as the key and data as the value
  59106. * @param glTFPrefix
  59107. * @returns object with glb filename as key and data as value
  59108. */ generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  59109. /**
  59110. * Sets the TRS for each node
  59111. * @param node glTF Node for storing the transformation data
  59112. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  59113. */
  59114. private setNodeTransformation;
  59115. private getVertexBufferFromMesh;
  59116. /**
  59117. * Creates a bufferview based on the vertices type for the Babylon mesh
  59118. * @param kind Indicates the type of vertices data
  59119. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  59120. * @param binaryWriter The buffer to write the bufferview data to
  59121. */
  59122. private createBufferViewKind;
  59123. /**
  59124. * The primitive mode of the Babylon mesh
  59125. * @param babylonMesh The BabylonJS mesh
  59126. */
  59127. private getMeshPrimitiveMode;
  59128. /**
  59129. * Sets the primitive mode of the glTF mesh primitive
  59130. * @param meshPrimitive glTF mesh primitive
  59131. * @param primitiveMode The primitive mode
  59132. */
  59133. private setPrimitiveMode;
  59134. /**
  59135. * Sets the vertex attribute accessor based of the glTF mesh primitive
  59136. * @param meshPrimitive glTF mesh primitive
  59137. * @param attributeKind vertex attribute
  59138. * @returns boolean specifying if uv coordinates are present
  59139. */
  59140. private setAttributeKind;
  59141. /**
  59142. * Sets data for the primitive attributes of each submesh
  59143. * @param mesh glTF Mesh object to store the primitive attribute information
  59144. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  59145. * @param binaryWriter Buffer to write the attribute data to
  59146. */
  59147. private setPrimitiveAttributesAsync;
  59148. /**
  59149. * Creates a glTF scene based on the array of meshes
  59150. * Returns the the total byte offset
  59151. * @param babylonScene Babylon scene to get the mesh data from
  59152. * @param binaryWriter Buffer to write binary data to
  59153. */
  59154. private createSceneAsync;
  59155. /**
  59156. * Creates a mapping of Node unique id to node index and handles animations
  59157. * @param babylonScene Babylon Scene
  59158. * @param nodes Babylon transform nodes
  59159. * @param shouldExportTransformNode Callback specifying if a transform node should be exported
  59160. * @param binaryWriter Buffer to write binary data to
  59161. * @returns Node mapping of unique id to index
  59162. */
  59163. private createNodeMapAndAnimationsAsync;
  59164. /**
  59165. * Creates a glTF node from a Babylon mesh
  59166. * @param babylonMesh Source Babylon mesh
  59167. * @param binaryWriter Buffer for storing geometry data
  59168. * @returns glTF node
  59169. */
  59170. private createNodeAsync;
  59171. }
  59172. /**
  59173. * @hidden
  59174. *
  59175. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  59176. */
  59177. export class _BinaryWriter {
  59178. /**
  59179. * Array buffer which stores all binary data
  59180. */
  59181. private _arrayBuffer;
  59182. /**
  59183. * View of the array buffer
  59184. */
  59185. private _dataView;
  59186. /**
  59187. * byte offset of data in array buffer
  59188. */
  59189. private _byteOffset;
  59190. /**
  59191. * Initialize binary writer with an initial byte length
  59192. * @param byteLength Initial byte length of the array buffer
  59193. */
  59194. constructor(byteLength: number);
  59195. /**
  59196. * Resize the array buffer to the specified byte length
  59197. * @param byteLength
  59198. */
  59199. private resizeBuffer;
  59200. /**
  59201. * Get an array buffer with the length of the byte offset
  59202. * @returns ArrayBuffer resized to the byte offset
  59203. */
  59204. getArrayBuffer(): ArrayBuffer;
  59205. /**
  59206. * Get the byte offset of the array buffer
  59207. * @returns byte offset
  59208. */
  59209. getByteOffset(): number;
  59210. /**
  59211. * Stores an UInt8 in the array buffer
  59212. * @param entry
  59213. * @param byteOffset If defined, specifies where to set the value as an offset.
  59214. */
  59215. setUInt8(entry: number, byteOffset?: number): void;
  59216. /**
  59217. * Gets an UInt32 in the array buffer
  59218. * @param entry
  59219. * @param byteOffset If defined, specifies where to set the value as an offset.
  59220. */
  59221. getUInt32(byteOffset: number): number;
  59222. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  59223. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  59224. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  59225. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  59226. /**
  59227. * Stores a Float32 in the array buffer
  59228. * @param entry
  59229. */
  59230. setFloat32(entry: number, byteOffset?: number): void;
  59231. /**
  59232. * Stores an UInt32 in the array buffer
  59233. * @param entry
  59234. * @param byteOffset If defined, specifies where to set the value as an offset.
  59235. */
  59236. setUInt32(entry: number, byteOffset?: number): void;
  59237. }
  59238. }
  59239. declare module BABYLON.GLTF2.Exporter {
  59240. /**
  59241. * @hidden
  59242. * Interface to store animation data.
  59243. */
  59244. export interface _IAnimationData {
  59245. /**
  59246. * Keyframe data.
  59247. */
  59248. inputs: number[];
  59249. /**
  59250. * Value data.
  59251. */
  59252. outputs: number[][];
  59253. /**
  59254. * Animation interpolation data.
  59255. */
  59256. samplerInterpolation: AnimationSamplerInterpolation;
  59257. /**
  59258. * Minimum keyframe value.
  59259. */
  59260. inputsMin: number;
  59261. /**
  59262. * Maximum keyframe value.
  59263. */
  59264. inputsMax: number;
  59265. }
  59266. /**
  59267. * @hidden
  59268. */
  59269. export interface _IAnimationInfo {
  59270. /**
  59271. * The target channel for the animation
  59272. */
  59273. animationChannelTargetPath: AnimationChannelTargetPath;
  59274. /**
  59275. * The glTF accessor type for the data.
  59276. */
  59277. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  59278. /**
  59279. * Specifies if quaternions should be used.
  59280. */
  59281. useQuaternion: boolean;
  59282. }
  59283. /**
  59284. * @hidden
  59285. * Utility class for generating glTF animation data from BabylonJS.
  59286. */
  59287. export class _GLTFAnimation {
  59288. /**
  59289. * @ignore
  59290. *
  59291. * Creates glTF channel animation from BabylonJS animation.
  59292. * @param babylonTransformNode - BabylonJS mesh.
  59293. * @param animation - animation.
  59294. * @param animationChannelTargetPath - The target animation channel.
  59295. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  59296. * @param useQuaternion - Specifies if quaternions are used.
  59297. * @returns nullable IAnimationData
  59298. */ private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  59299. private static _DeduceAnimationInfo;
  59300. /**
  59301. * @ignore
  59302. * Create node animations from the transform node animations
  59303. * @param babylonTransformNode
  59304. * @param runtimeGLTFAnimation
  59305. * @param idleGLTFAnimations
  59306. * @param nodeMap
  59307. * @param nodes
  59308. * @param binaryWriter
  59309. * @param bufferViews
  59310. * @param accessors
  59311. * @param convertToRightHandedSystem
  59312. */ private static _CreateNodeAnimationFromTransformNodeAnimations(babylonTransformNode: TransformNode, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  59313. [key: number]: number;
  59314. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  59315. /**
  59316. * @ignore
  59317. * Create node animations from the animation groups
  59318. * @param babylonScene
  59319. * @param glTFAnimations
  59320. * @param nodeMap
  59321. * @param nodes
  59322. * @param binaryWriter
  59323. * @param bufferViews
  59324. * @param accessors
  59325. * @param convertToRightHandedSystem
  59326. */ private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  59327. [key: number]: number;
  59328. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  59329. private static AddAnimation;
  59330. /**
  59331. * Create a baked animation
  59332. * @param babylonTransformNode BabylonJS mesh
  59333. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  59334. * @param animationChannelTargetPath animation target channel
  59335. * @param minFrame minimum animation frame
  59336. * @param maxFrame maximum animation frame
  59337. * @param fps frames per second of the animation
  59338. * @param inputs input key frames of the animation
  59339. * @param outputs output key frame data of the animation
  59340. * @param convertToRightHandedSystem converts the values to right-handed
  59341. * @param useQuaternion specifies if quaternions should be used
  59342. */
  59343. private static _CreateBakedAnimation;
  59344. private static _ConvertFactorToVector3OrQuaternion;
  59345. private static _SetInterpolatedValue;
  59346. /**
  59347. * Creates linear animation from the animation key frames
  59348. * @param babylonTransformNode BabylonJS mesh
  59349. * @param animation BabylonJS animation
  59350. * @param animationChannelTargetPath The target animation channel
  59351. * @param frameDelta The difference between the last and first frame of the animation
  59352. * @param inputs Array to store the key frame times
  59353. * @param outputs Array to store the key frame data
  59354. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  59355. * @param useQuaternion Specifies if quaternions are used in the animation
  59356. */
  59357. private static _CreateLinearOrStepAnimation;
  59358. /**
  59359. * Creates cubic spline animation from the animation key frames
  59360. * @param babylonTransformNode BabylonJS mesh
  59361. * @param animation BabylonJS animation
  59362. * @param animationChannelTargetPath The target animation channel
  59363. * @param frameDelta The difference between the last and first frame of the animation
  59364. * @param inputs Array to store the key frame times
  59365. * @param outputs Array to store the key frame data
  59366. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  59367. * @param useQuaternion Specifies if quaternions are used in the animation
  59368. */
  59369. private static _CreateCubicSplineAnimation;
  59370. private static _GetBasePositionRotationOrScale;
  59371. /**
  59372. * Adds a key frame value
  59373. * @param keyFrame
  59374. * @param animation
  59375. * @param outputs
  59376. * @param animationChannelTargetPath
  59377. * @param basePositionRotationOrScale
  59378. * @param convertToRightHandedSystem
  59379. * @param useQuaternion
  59380. */
  59381. private static _AddKeyframeValue;
  59382. /**
  59383. * Determine the interpolation based on the key frames
  59384. * @param keyFrames
  59385. * @param animationChannelTargetPath
  59386. * @param useQuaternion
  59387. */
  59388. private static _DeduceInterpolation;
  59389. /**
  59390. * Adds an input tangent or output tangent to the output data
  59391. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  59392. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  59393. * @param outputs The animation data by keyframe
  59394. * @param animationChannelTargetPath The target animation channel
  59395. * @param interpolation The interpolation type
  59396. * @param keyFrame The key frame with the animation data
  59397. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  59398. * @param useQuaternion Specifies if quaternions are used
  59399. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  59400. */
  59401. private static AddSplineTangent;
  59402. /**
  59403. * Get the minimum and maximum key frames' frame values
  59404. * @param keyFrames animation key frames
  59405. * @returns the minimum and maximum key frame value
  59406. */
  59407. private static calculateMinMaxKeyFrames;
  59408. }
  59409. }
  59410. declare module BABYLON.GLTF2.Exporter {
  59411. /** @hidden */
  59412. export var textureTransformPixelShader: {
  59413. name: string;
  59414. shader: string;
  59415. };
  59416. }
  59417. declare module BABYLON.GLTF2.Exporter.Extensions {
  59418. /**
  59419. * @hidden
  59420. */
  59421. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  59422. /** Name of this extension */
  59423. readonly name: string;
  59424. /** Defines whether this extension is enabled */
  59425. enabled: boolean;
  59426. /** Defines whether this extension is required */
  59427. required: boolean;
  59428. /** Reference to the glTF exporter */
  59429. private _exporter;
  59430. constructor(exporter: _Exporter);
  59431. dispose(): void;
  59432. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  59433. /**
  59434. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  59435. * @param babylonTexture
  59436. * @param offset
  59437. * @param rotation
  59438. * @param scale
  59439. * @param scene
  59440. */
  59441. textureTransformTextureAsync(babylonTexture: Texture, offset: Vector2, rotation: number, scale: Vector2, scene: Scene): Promise<BaseTexture>;
  59442. }
  59443. }
  59444. /**
  59445. * @ignoreChildren
  59446. * @ignore
  59447. */
  59448. declare module "babylonjs-gltf2interface" {
  59449. export = BABYLON.GLTF2;
  59450. }
  59451. /**
  59452. * Module for glTF 2.0 Interface
  59453. * @ignoreChildren
  59454. * @ignore
  59455. */
  59456. declare module BABYLON.GLTF2 {
  59457. /**
  59458. * The datatype of the components in the attribute
  59459. */
  59460. const enum AccessorComponentType {
  59461. /**
  59462. * Byte
  59463. */
  59464. BYTE = 5120,
  59465. /**
  59466. * Unsigned Byte
  59467. */
  59468. UNSIGNED_BYTE = 5121,
  59469. /**
  59470. * Short
  59471. */
  59472. SHORT = 5122,
  59473. /**
  59474. * Unsigned Short
  59475. */
  59476. UNSIGNED_SHORT = 5123,
  59477. /**
  59478. * Unsigned Int
  59479. */
  59480. UNSIGNED_INT = 5125,
  59481. /**
  59482. * Float
  59483. */
  59484. FLOAT = 5126,
  59485. }
  59486. /**
  59487. * Specifies if the attirbute is a scalar, vector, or matrix
  59488. */
  59489. const enum AccessorType {
  59490. /**
  59491. * Scalar
  59492. */
  59493. SCALAR = "SCALAR",
  59494. /**
  59495. * Vector2
  59496. */
  59497. VEC2 = "VEC2",
  59498. /**
  59499. * Vector3
  59500. */
  59501. VEC3 = "VEC3",
  59502. /**
  59503. * Vector4
  59504. */
  59505. VEC4 = "VEC4",
  59506. /**
  59507. * Matrix2x2
  59508. */
  59509. MAT2 = "MAT2",
  59510. /**
  59511. * Matrix3x3
  59512. */
  59513. MAT3 = "MAT3",
  59514. /**
  59515. * Matrix4x4
  59516. */
  59517. MAT4 = "MAT4",
  59518. }
  59519. /**
  59520. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  59521. */
  59522. const enum AnimationChannelTargetPath {
  59523. /**
  59524. * Translation
  59525. */
  59526. TRANSLATION = "translation",
  59527. /**
  59528. * Rotation
  59529. */
  59530. ROTATION = "rotation",
  59531. /**
  59532. * Scale
  59533. */
  59534. SCALE = "scale",
  59535. /**
  59536. * Weights
  59537. */
  59538. WEIGHTS = "weights",
  59539. }
  59540. /**
  59541. * Interpolation algorithm
  59542. */
  59543. const enum AnimationSamplerInterpolation {
  59544. /**
  59545. * The animated values are linearly interpolated between keyframes
  59546. */
  59547. LINEAR = "LINEAR",
  59548. /**
  59549. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  59550. */
  59551. STEP = "STEP",
  59552. /**
  59553. * The animation's interpolation is computed using a cubic spline with specified tangents
  59554. */
  59555. CUBICSPLINE = "CUBICSPLINE",
  59556. }
  59557. /**
  59558. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  59559. */
  59560. const enum CameraType {
  59561. /**
  59562. * A perspective camera containing properties to create a perspective projection matrix
  59563. */
  59564. PERSPECTIVE = "perspective",
  59565. /**
  59566. * An orthographic camera containing properties to create an orthographic projection matrix
  59567. */
  59568. ORTHOGRAPHIC = "orthographic",
  59569. }
  59570. /**
  59571. * The mime-type of the image
  59572. */
  59573. const enum ImageMimeType {
  59574. /**
  59575. * JPEG Mime-type
  59576. */
  59577. JPEG = "image/jpeg",
  59578. /**
  59579. * PNG Mime-type
  59580. */
  59581. PNG = "image/png",
  59582. }
  59583. /**
  59584. * The alpha rendering mode of the material
  59585. */
  59586. const enum MaterialAlphaMode {
  59587. /**
  59588. * The alpha value is ignored and the rendered output is fully opaque
  59589. */
  59590. OPAQUE = "OPAQUE",
  59591. /**
  59592. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  59593. */
  59594. MASK = "MASK",
  59595. /**
  59596. * 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)
  59597. */
  59598. BLEND = "BLEND",
  59599. }
  59600. /**
  59601. * The type of the primitives to render
  59602. */
  59603. const enum MeshPrimitiveMode {
  59604. /**
  59605. * Points
  59606. */
  59607. POINTS = 0,
  59608. /**
  59609. * Lines
  59610. */
  59611. LINES = 1,
  59612. /**
  59613. * Line Loop
  59614. */
  59615. LINE_LOOP = 2,
  59616. /**
  59617. * Line Strip
  59618. */
  59619. LINE_STRIP = 3,
  59620. /**
  59621. * Triangles
  59622. */
  59623. TRIANGLES = 4,
  59624. /**
  59625. * Triangle Strip
  59626. */
  59627. TRIANGLE_STRIP = 5,
  59628. /**
  59629. * Triangle Fan
  59630. */
  59631. TRIANGLE_FAN = 6,
  59632. }
  59633. /**
  59634. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  59635. */
  59636. const enum TextureMagFilter {
  59637. /**
  59638. * Nearest
  59639. */
  59640. NEAREST = 9728,
  59641. /**
  59642. * Linear
  59643. */
  59644. LINEAR = 9729,
  59645. }
  59646. /**
  59647. * Minification filter. All valid values correspond to WebGL enums
  59648. */
  59649. const enum TextureMinFilter {
  59650. /**
  59651. * Nearest
  59652. */
  59653. NEAREST = 9728,
  59654. /**
  59655. * Linear
  59656. */
  59657. LINEAR = 9729,
  59658. /**
  59659. * Nearest Mip-Map Nearest
  59660. */
  59661. NEAREST_MIPMAP_NEAREST = 9984,
  59662. /**
  59663. * Linear Mipmap Nearest
  59664. */
  59665. LINEAR_MIPMAP_NEAREST = 9985,
  59666. /**
  59667. * Nearest Mipmap Linear
  59668. */
  59669. NEAREST_MIPMAP_LINEAR = 9986,
  59670. /**
  59671. * Linear Mipmap Linear
  59672. */
  59673. LINEAR_MIPMAP_LINEAR = 9987,
  59674. }
  59675. /**
  59676. * S (U) wrapping mode. All valid values correspond to WebGL enums
  59677. */
  59678. const enum TextureWrapMode {
  59679. /**
  59680. * Clamp to Edge
  59681. */
  59682. CLAMP_TO_EDGE = 33071,
  59683. /**
  59684. * Mirrored Repeat
  59685. */
  59686. MIRRORED_REPEAT = 33648,
  59687. /**
  59688. * Repeat
  59689. */
  59690. REPEAT = 10497,
  59691. }
  59692. /**
  59693. * glTF Property
  59694. */
  59695. interface IProperty {
  59696. /**
  59697. * Dictionary object with extension-specific objects
  59698. */
  59699. extensions?: {
  59700. [key: string]: any;
  59701. };
  59702. /**
  59703. * Application-Specific data
  59704. */
  59705. extras?: any;
  59706. }
  59707. /**
  59708. * glTF Child of Root Property
  59709. */
  59710. interface IChildRootProperty extends IProperty {
  59711. /**
  59712. * The user-defined name of this object
  59713. */
  59714. name?: string;
  59715. }
  59716. /**
  59717. * Indices of those attributes that deviate from their initialization value
  59718. */
  59719. interface IAccessorSparseIndices extends IProperty {
  59720. /**
  59721. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  59722. */
  59723. bufferView: number;
  59724. /**
  59725. * The offset relative to the start of the bufferView in bytes. Must be aligned
  59726. */
  59727. byteOffset?: number;
  59728. /**
  59729. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  59730. */
  59731. componentType: AccessorComponentType;
  59732. }
  59733. /**
  59734. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  59735. */
  59736. interface IAccessorSparseValues extends IProperty {
  59737. /**
  59738. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  59739. */
  59740. bufferView: number;
  59741. /**
  59742. * The offset relative to the start of the bufferView in bytes. Must be aligned
  59743. */
  59744. byteOffset?: number;
  59745. }
  59746. /**
  59747. * Sparse storage of attributes that deviate from their initialization value
  59748. */
  59749. interface IAccessorSparse extends IProperty {
  59750. /**
  59751. * The number of attributes encoded in this sparse accessor
  59752. */
  59753. count: number;
  59754. /**
  59755. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  59756. */
  59757. indices: IAccessorSparseIndices;
  59758. /**
  59759. * 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
  59760. */
  59761. values: IAccessorSparseValues;
  59762. }
  59763. /**
  59764. * 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
  59765. */
  59766. interface IAccessor extends IChildRootProperty {
  59767. /**
  59768. * The index of the bufferview
  59769. */
  59770. bufferView?: number;
  59771. /**
  59772. * The offset relative to the start of the bufferView in bytes
  59773. */
  59774. byteOffset?: number;
  59775. /**
  59776. * The datatype of components in the attribute
  59777. */
  59778. componentType: AccessorComponentType;
  59779. /**
  59780. * Specifies whether integer data values should be normalized
  59781. */
  59782. normalized?: boolean;
  59783. /**
  59784. * The number of attributes referenced by this accessor
  59785. */
  59786. count: number;
  59787. /**
  59788. * Specifies if the attribute is a scalar, vector, or matrix
  59789. */
  59790. type: AccessorType;
  59791. /**
  59792. * Maximum value of each component in this attribute
  59793. */
  59794. max?: number[];
  59795. /**
  59796. * Minimum value of each component in this attribute
  59797. */
  59798. min?: number[];
  59799. /**
  59800. * Sparse storage of attributes that deviate from their initialization value
  59801. */
  59802. sparse?: IAccessorSparse;
  59803. }
  59804. /**
  59805. * Targets an animation's sampler at a node's property
  59806. */
  59807. interface IAnimationChannel extends IProperty {
  59808. /**
  59809. * The index of a sampler in this animation used to compute the value for the target
  59810. */
  59811. sampler: number;
  59812. /**
  59813. * The index of the node and TRS property to target
  59814. */
  59815. target: IAnimationChannelTarget;
  59816. }
  59817. /**
  59818. * The index of the node and TRS property that an animation channel targets
  59819. */
  59820. interface IAnimationChannelTarget extends IProperty {
  59821. /**
  59822. * The index of the node to target
  59823. */
  59824. node: number;
  59825. /**
  59826. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  59827. */
  59828. path: AnimationChannelTargetPath;
  59829. }
  59830. /**
  59831. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  59832. */
  59833. interface IAnimationSampler extends IProperty {
  59834. /**
  59835. * The index of an accessor containing keyframe input values, e.g., time
  59836. */
  59837. input: number;
  59838. /**
  59839. * Interpolation algorithm
  59840. */
  59841. interpolation?: AnimationSamplerInterpolation;
  59842. /**
  59843. * The index of an accessor, containing keyframe output values
  59844. */
  59845. output: number;
  59846. }
  59847. /**
  59848. * A keyframe animation
  59849. */
  59850. interface IAnimation extends IChildRootProperty {
  59851. /**
  59852. * An array of channels, each of which targets an animation's sampler at a node's property
  59853. */
  59854. channels: IAnimationChannel[];
  59855. /**
  59856. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  59857. */
  59858. samplers: IAnimationSampler[];
  59859. }
  59860. /**
  59861. * Metadata about the glTF asset
  59862. */
  59863. interface IAsset extends IChildRootProperty {
  59864. /**
  59865. * A copyright message suitable for display to credit the content creator
  59866. */
  59867. copyright?: string;
  59868. /**
  59869. * Tool that generated this glTF model. Useful for debugging
  59870. */
  59871. generator?: string;
  59872. /**
  59873. * The glTF version that this asset targets
  59874. */
  59875. version: string;
  59876. /**
  59877. * The minimum glTF version that this asset targets
  59878. */
  59879. minVersion?: string;
  59880. }
  59881. /**
  59882. * A buffer points to binary geometry, animation, or skins
  59883. */
  59884. interface IBuffer extends IChildRootProperty {
  59885. /**
  59886. * 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
  59887. */
  59888. uri?: string;
  59889. /**
  59890. * The length of the buffer in bytes
  59891. */
  59892. byteLength: number;
  59893. }
  59894. /**
  59895. * A view into a buffer generally representing a subset of the buffer
  59896. */
  59897. interface IBufferView extends IChildRootProperty {
  59898. /**
  59899. * The index of the buffer
  59900. */
  59901. buffer: number;
  59902. /**
  59903. * The offset into the buffer in bytes
  59904. */
  59905. byteOffset?: number;
  59906. /**
  59907. * The lenth of the bufferView in bytes
  59908. */
  59909. byteLength: number;
  59910. /**
  59911. * The stride, in bytes
  59912. */
  59913. byteStride?: number;
  59914. }
  59915. /**
  59916. * An orthographic camera containing properties to create an orthographic projection matrix
  59917. */
  59918. interface ICameraOrthographic extends IProperty {
  59919. /**
  59920. * The floating-point horizontal magnification of the view. Must not be zero
  59921. */
  59922. xmag: number;
  59923. /**
  59924. * The floating-point vertical magnification of the view. Must not be zero
  59925. */
  59926. ymag: number;
  59927. /**
  59928. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  59929. */
  59930. zfar: number;
  59931. /**
  59932. * The floating-point distance to the near clipping plane
  59933. */
  59934. znear: number;
  59935. }
  59936. /**
  59937. * A perspective camera containing properties to create a perspective projection matrix
  59938. */
  59939. interface ICameraPerspective extends IProperty {
  59940. /**
  59941. * The floating-point aspect ratio of the field of view
  59942. */
  59943. aspectRatio?: number;
  59944. /**
  59945. * The floating-point vertical field of view in radians
  59946. */
  59947. yfov: number;
  59948. /**
  59949. * The floating-point distance to the far clipping plane
  59950. */
  59951. zfar?: number;
  59952. /**
  59953. * The floating-point distance to the near clipping plane
  59954. */
  59955. znear: number;
  59956. }
  59957. /**
  59958. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  59959. */
  59960. interface ICamera extends IChildRootProperty {
  59961. /**
  59962. * An orthographic camera containing properties to create an orthographic projection matrix
  59963. */
  59964. orthographic?: ICameraOrthographic;
  59965. /**
  59966. * A perspective camera containing properties to create a perspective projection matrix
  59967. */
  59968. perspective?: ICameraPerspective;
  59969. /**
  59970. * Specifies if the camera uses a perspective or orthographic projection
  59971. */
  59972. type: CameraType;
  59973. }
  59974. /**
  59975. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  59976. */
  59977. interface IImage extends IChildRootProperty {
  59978. /**
  59979. * 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
  59980. */
  59981. uri?: string;
  59982. /**
  59983. * The image's MIME type
  59984. */
  59985. mimeType?: ImageMimeType;
  59986. /**
  59987. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  59988. */
  59989. bufferView?: number;
  59990. }
  59991. /**
  59992. * Material Normal Texture Info
  59993. */
  59994. interface IMaterialNormalTextureInfo extends ITextureInfo {
  59995. /**
  59996. * The scalar multiplier applied to each normal vector of the normal texture
  59997. */
  59998. scale?: number;
  59999. }
  60000. /**
  60001. * Material Occlusion Texture Info
  60002. */
  60003. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  60004. /**
  60005. * A scalar multiplier controlling the amount of occlusion applied
  60006. */
  60007. strength?: number;
  60008. }
  60009. /**
  60010. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  60011. */
  60012. interface IMaterialPbrMetallicRoughness {
  60013. /**
  60014. * The material's base color factor
  60015. */
  60016. baseColorFactor?: number[];
  60017. /**
  60018. * The base color texture
  60019. */
  60020. baseColorTexture?: ITextureInfo;
  60021. /**
  60022. * The metalness of the material
  60023. */
  60024. metallicFactor?: number;
  60025. /**
  60026. * The roughness of the material
  60027. */
  60028. roughnessFactor?: number;
  60029. /**
  60030. * The metallic-roughness texture
  60031. */
  60032. metallicRoughnessTexture?: ITextureInfo;
  60033. }
  60034. /**
  60035. * The material appearance of a primitive
  60036. */
  60037. interface IMaterial extends IChildRootProperty {
  60038. /**
  60039. * 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
  60040. */
  60041. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  60042. /**
  60043. * The normal map texture
  60044. */
  60045. normalTexture?: IMaterialNormalTextureInfo;
  60046. /**
  60047. * The occlusion map texture
  60048. */
  60049. occlusionTexture?: IMaterialOcclusionTextureInfo;
  60050. /**
  60051. * The emissive map texture
  60052. */
  60053. emissiveTexture?: ITextureInfo;
  60054. /**
  60055. * 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
  60056. */
  60057. emissiveFactor?: number[];
  60058. /**
  60059. * The alpha rendering mode of the material
  60060. */
  60061. alphaMode?: MaterialAlphaMode;
  60062. /**
  60063. * The alpha cutoff value of the material
  60064. */
  60065. alphaCutoff?: number;
  60066. /**
  60067. * Specifies whether the material is double sided
  60068. */
  60069. doubleSided?: boolean;
  60070. }
  60071. /**
  60072. * Geometry to be rendered with the given material
  60073. */
  60074. interface IMeshPrimitive extends IProperty {
  60075. /**
  60076. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  60077. */
  60078. attributes: {
  60079. [name: string]: number;
  60080. };
  60081. /**
  60082. * The index of the accessor that contains the indices
  60083. */
  60084. indices?: number;
  60085. /**
  60086. * The index of the material to apply to this primitive when rendering
  60087. */
  60088. material?: number;
  60089. /**
  60090. * The type of primitives to render. All valid values correspond to WebGL enums
  60091. */
  60092. mode?: MeshPrimitiveMode;
  60093. /**
  60094. * 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
  60095. */
  60096. targets?: {
  60097. [name: string]: number;
  60098. }[];
  60099. }
  60100. /**
  60101. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  60102. */
  60103. interface IMesh extends IChildRootProperty {
  60104. /**
  60105. * An array of primitives, each defining geometry to be rendered with a material
  60106. */
  60107. primitives: IMeshPrimitive[];
  60108. /**
  60109. * Array of weights to be applied to the Morph Targets
  60110. */
  60111. weights?: number[];
  60112. }
  60113. /**
  60114. * A node in the node hierarchy
  60115. */
  60116. interface INode extends IChildRootProperty {
  60117. /**
  60118. * The index of the camera referenced by this node
  60119. */
  60120. camera?: number;
  60121. /**
  60122. * The indices of this node's children
  60123. */
  60124. children?: number[];
  60125. /**
  60126. * The index of the skin referenced by this node
  60127. */
  60128. skin?: number;
  60129. /**
  60130. * A floating-point 4x4 transformation matrix stored in column-major order
  60131. */
  60132. matrix?: number[];
  60133. /**
  60134. * The index of the mesh in this node
  60135. */
  60136. mesh?: number;
  60137. /**
  60138. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  60139. */
  60140. rotation?: number[];
  60141. /**
  60142. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  60143. */
  60144. scale?: number[];
  60145. /**
  60146. * The node's translation along the x, y, and z axes
  60147. */
  60148. translation?: number[];
  60149. /**
  60150. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  60151. */
  60152. weights?: number[];
  60153. }
  60154. /**
  60155. * Texture sampler properties for filtering and wrapping modes
  60156. */
  60157. interface ISampler extends IChildRootProperty {
  60158. /**
  60159. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  60160. */
  60161. magFilter?: TextureMagFilter;
  60162. /**
  60163. * Minification filter. All valid values correspond to WebGL enums
  60164. */
  60165. minFilter?: TextureMinFilter;
  60166. /**
  60167. * S (U) wrapping mode. All valid values correspond to WebGL enums
  60168. */
  60169. wrapS?: TextureWrapMode;
  60170. /**
  60171. * T (V) wrapping mode. All valid values correspond to WebGL enums
  60172. */
  60173. wrapT?: TextureWrapMode;
  60174. }
  60175. /**
  60176. * The root nodes of a scene
  60177. */
  60178. interface IScene extends IChildRootProperty {
  60179. /**
  60180. * The indices of each root node
  60181. */
  60182. nodes: number[];
  60183. }
  60184. /**
  60185. * Joints and matrices defining a skin
  60186. */
  60187. interface ISkin extends IChildRootProperty {
  60188. /**
  60189. * 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
  60190. */
  60191. inverseBindMatrices?: number;
  60192. /**
  60193. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  60194. */
  60195. skeleton?: number;
  60196. /**
  60197. * 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)
  60198. */
  60199. joints: number[];
  60200. }
  60201. /**
  60202. * A texture and its sampler
  60203. */
  60204. interface ITexture extends IChildRootProperty {
  60205. /**
  60206. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  60207. */
  60208. sampler?: number;
  60209. /**
  60210. * The index of the image used by this texture
  60211. */
  60212. source: number;
  60213. }
  60214. /**
  60215. * Reference to a texture
  60216. */
  60217. interface ITextureInfo extends IProperty {
  60218. /**
  60219. * The index of the texture
  60220. */
  60221. index: number;
  60222. /**
  60223. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  60224. */
  60225. texCoord?: number;
  60226. }
  60227. /**
  60228. * The root object for a glTF asset
  60229. */
  60230. interface IGLTF extends IProperty {
  60231. /**
  60232. * An array of accessors. An accessor is a typed view into a bufferView
  60233. */
  60234. accessors?: IAccessor[];
  60235. /**
  60236. * An array of keyframe animations
  60237. */
  60238. animations?: IAnimation[];
  60239. /**
  60240. * Metadata about the glTF asset
  60241. */
  60242. asset: IAsset;
  60243. /**
  60244. * An array of buffers. A buffer points to binary geometry, animation, or skins
  60245. */
  60246. buffers?: IBuffer[];
  60247. /**
  60248. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  60249. */
  60250. bufferViews?: IBufferView[];
  60251. /**
  60252. * An array of cameras
  60253. */
  60254. cameras?: ICamera[];
  60255. /**
  60256. * Names of glTF extensions used somewhere in this asset
  60257. */
  60258. extensionsUsed?: string[];
  60259. /**
  60260. * Names of glTF extensions required to properly load this asset
  60261. */
  60262. extensionsRequired?: string[];
  60263. /**
  60264. * An array of images. An image defines data used to create a texture
  60265. */
  60266. images?: IImage[];
  60267. /**
  60268. * An array of materials. A material defines the appearance of a primitive
  60269. */
  60270. materials?: IMaterial[];
  60271. /**
  60272. * An array of meshes. A mesh is a set of primitives to be rendered
  60273. */
  60274. meshes?: IMesh[];
  60275. /**
  60276. * An array of nodes
  60277. */
  60278. nodes?: INode[];
  60279. /**
  60280. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  60281. */
  60282. samplers?: ISampler[];
  60283. /**
  60284. * The index of the default scene
  60285. */
  60286. scene?: number;
  60287. /**
  60288. * An array of scenes
  60289. */
  60290. scenes?: IScene[];
  60291. /**
  60292. * An array of skins. A skin is defined by joints and matrices
  60293. */
  60294. skins?: ISkin[];
  60295. /**
  60296. * An array of textures
  60297. */
  60298. textures?: ITexture[];
  60299. }
  60300. /**
  60301. * Interface for glTF validation results
  60302. */
  60303. interface IGLTFValidationResults {
  60304. info: {
  60305. generator: string;
  60306. hasAnimations: boolean;
  60307. hasDefaultScene: boolean;
  60308. hasMaterials: boolean;
  60309. hasMorphTargets: boolean;
  60310. hasSkins: boolean;
  60311. hasTextures: boolean;
  60312. maxAttributesUsed: number;
  60313. primitivesCount: number
  60314. };
  60315. issues: {
  60316. messages: Array<string>;
  60317. numErrors: number;
  60318. numHints: number;
  60319. numInfos: number;
  60320. numWarnings: number;
  60321. truncated: boolean
  60322. };
  60323. mimeType: string;
  60324. uri: string;
  60325. validatedAt: string;
  60326. validatorVersion: string;
  60327. }
  60328. /**
  60329. * Interface for glTF validation options
  60330. */
  60331. interface IGLTFValidationOptions {
  60332. uri?: string;
  60333. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  60334. validateAccessorData?: boolean;
  60335. maxIssues?: number;
  60336. ignoredIssues?: Array<string>;
  60337. severityOverrides?: Object;
  60338. }
  60339. /**
  60340. * glTF validator object Tyyings
  60341. */
  60342. interface IGLTFValidatorTypings {
  60343. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  60344. }
  60345. }
  60346. /**
  60347. * Interface for glTF validation results
  60348. */
  60349. interface IGLTFValidationResults {
  60350. info: {
  60351. generator: string;
  60352. hasAnimations: boolean;
  60353. hasDefaultScene: boolean;
  60354. hasMaterials: boolean;
  60355. hasMorphTargets: boolean;
  60356. hasSkins: boolean;
  60357. hasTextures: boolean;
  60358. maxAttributesUsed: number;
  60359. primitivesCount: number
  60360. };
  60361. issues: {
  60362. messages: Array<string>;
  60363. numErrors: number;
  60364. numHints: number;
  60365. numInfos: number;
  60366. numWarnings: number;
  60367. truncated: boolean
  60368. };
  60369. mimeType: string;
  60370. uri: string;
  60371. validatedAt: string;
  60372. validatorVersion: string;
  60373. }
  60374. /**
  60375. * Interface for glTF validation options
  60376. */
  60377. interface IGLTFValidationOptions {
  60378. uri?: string;
  60379. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  60380. validateAccessorData?: boolean;
  60381. maxIssues?: number;
  60382. ignoredIssues?: Array<string>;
  60383. severityOverrides?: Object;
  60384. }
  60385. /**
  60386. * glTF validator object Tyyings
  60387. */
  60388. interface IGLTFValidatorTypings {
  60389. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  60390. }
  60391. declare module BABYLON {
  60392. /** @hidden */
  60393. export var cellPixelShader: {
  60394. name: string;
  60395. shader: string;
  60396. };
  60397. }
  60398. declare module BABYLON {
  60399. /** @hidden */
  60400. export var cellVertexShader: {
  60401. name: string;
  60402. shader: string;
  60403. };
  60404. }
  60405. declare module BABYLON {
  60406. export class CellMaterial extends BABYLON.PushMaterial {
  60407. private _diffuseTexture;
  60408. diffuseTexture: BABYLON.BaseTexture;
  60409. diffuseColor: BABYLON.Color3; computeHighLevel: boolean;
  60410. computeHighLevel: boolean;
  60411. private _disableLighting;
  60412. disableLighting: boolean;
  60413. private _maxSimultaneousLights;
  60414. maxSimultaneousLights: number;
  60415. private _renderId;
  60416. constructor(name: string, scene: BABYLON.Scene);
  60417. needAlphaBlending(): boolean;
  60418. needAlphaTesting(): boolean;
  60419. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  60420. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  60421. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  60422. getAnimatables(): BABYLON.IAnimatable[];
  60423. getActiveTextures(): BABYLON.BaseTexture[];
  60424. hasTexture(texture: BABYLON.BaseTexture): boolean;
  60425. dispose(forceDisposeEffect?: boolean): void;
  60426. getClassName(): string;
  60427. clone(name: string): CellMaterial;
  60428. serialize(): any;
  60429. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  60430. }
  60431. }
  60432. declare module BABYLON {
  60433. export class CustomShaderStructure {
  60434. FragmentStore: string;
  60435. VertexStore: string;
  60436. constructor();
  60437. }
  60438. export class ShaderSpecialParts {
  60439. constructor();
  60440. Fragment_Begin: string;
  60441. Fragment_Definitions: string;
  60442. Fragment_MainBegin: string;
  60443. Fragment_Custom_Diffuse: string;
  60444. Fragment_Custom_Alpha: string;
  60445. Fragment_Before_FragColor: string;
  60446. Vertex_Begin: string;
  60447. Vertex_Definitions: string;
  60448. Vertex_MainBegin: string;
  60449. Vertex_Before_PositionUpdated: string;
  60450. Vertex_Before_NormalUpdated: string;
  60451. }
  60452. export class CustomMaterial extends BABYLON.StandardMaterial {
  60453. static ShaderIndexer: number;
  60454. CustomParts: ShaderSpecialParts; isCreatedShader: boolean; createdShaderName: string; customUniform: string[]; newUniforms: string[]; newUniformInstances: any[]; newSamplerInstances: BABYLON.Texture[];
  60455. FragmentShader: string;
  60456. VertexShader: string;
  60457. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  60458. ReviewUniform(name: string, arr: string[]): string[];
  60459. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  60460. constructor(name: string, scene: BABYLON.Scene);
  60461. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  60462. Fragment_Begin(shaderPart: string): CustomMaterial;
  60463. Fragment_Definitions(shaderPart: string): CustomMaterial;
  60464. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  60465. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  60466. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  60467. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  60468. Vertex_Begin(shaderPart: string): CustomMaterial;
  60469. Vertex_Definitions(shaderPart: string): CustomMaterial;
  60470. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  60471. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  60472. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  60473. }
  60474. }
  60475. declare module BABYLON {
  60476. /** @hidden */
  60477. export var firePixelShader: {
  60478. name: string;
  60479. shader: string;
  60480. };
  60481. }
  60482. declare module BABYLON {
  60483. /** @hidden */
  60484. export var fireVertexShader: {
  60485. name: string;
  60486. shader: string;
  60487. };
  60488. }
  60489. declare module BABYLON {
  60490. export class FireMaterial extends BABYLON.PushMaterial {
  60491. private _diffuseTexture;
  60492. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  60493. private _distortionTexture;
  60494. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  60495. private _opacityTexture;
  60496. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  60497. diffuseColor: BABYLON.Color3;
  60498. speed: number;
  60499. private _scaledDiffuse;
  60500. private _renderId;
  60501. private _lastTime;
  60502. constructor(name: string, scene: BABYLON.Scene);
  60503. needAlphaBlending(): boolean;
  60504. needAlphaTesting(): boolean;
  60505. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  60506. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  60507. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  60508. getAnimatables(): BABYLON.IAnimatable[];
  60509. getActiveTextures(): BABYLON.BaseTexture[];
  60510. hasTexture(texture: BABYLON.BaseTexture): boolean;
  60511. getClassName(): string;
  60512. dispose(forceDisposeEffect?: boolean): void;
  60513. clone(name: string): FireMaterial;
  60514. serialize(): any;
  60515. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  60516. }
  60517. }
  60518. declare module BABYLON {
  60519. /** @hidden */
  60520. export var furPixelShader: {
  60521. name: string;
  60522. shader: string;
  60523. };
  60524. }
  60525. declare module BABYLON {
  60526. /** @hidden */
  60527. export var furVertexShader: {
  60528. name: string;
  60529. shader: string;
  60530. };
  60531. }
  60532. declare module BABYLON {
  60533. export class FurMaterial extends BABYLON.PushMaterial {
  60534. private _diffuseTexture;
  60535. diffuseTexture: BABYLON.BaseTexture;
  60536. private _heightTexture;
  60537. heightTexture: BABYLON.BaseTexture;
  60538. diffuseColor: BABYLON.Color3;
  60539. furLength: number;
  60540. furAngle: number;
  60541. furColor: BABYLON.Color3;
  60542. furOffset: number;
  60543. furSpacing: number;
  60544. furGravity: BABYLON.Vector3;
  60545. furSpeed: number;
  60546. furDensity: number;
  60547. furOcclusion: number;
  60548. furTexture: BABYLON.DynamicTexture;
  60549. private _disableLighting;
  60550. disableLighting: boolean;
  60551. private _maxSimultaneousLights;
  60552. maxSimultaneousLights: number;
  60553. highLevelFur: boolean; meshes: BABYLON.AbstractMesh[];
  60554. private _renderId;
  60555. private _furTime;
  60556. constructor(name: string, scene: BABYLON.Scene);
  60557. furTime: number;
  60558. needAlphaBlending(): boolean;
  60559. needAlphaTesting(): boolean;
  60560. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  60561. updateFur(): void;
  60562. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  60563. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  60564. getAnimatables(): BABYLON.IAnimatable[];
  60565. getActiveTextures(): BABYLON.BaseTexture[];
  60566. hasTexture(texture: BABYLON.BaseTexture): boolean;
  60567. dispose(forceDisposeEffect?: boolean): void;
  60568. clone(name: string): FurMaterial;
  60569. serialize(): any;
  60570. getClassName(): string;
  60571. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  60572. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  60573. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  60574. }
  60575. }
  60576. declare module BABYLON {
  60577. /** @hidden */
  60578. export var gradientPixelShader: {
  60579. name: string;
  60580. shader: string;
  60581. };
  60582. }
  60583. declare module BABYLON {
  60584. /** @hidden */
  60585. export var gradientVertexShader: {
  60586. name: string;
  60587. shader: string;
  60588. };
  60589. }
  60590. declare module BABYLON {
  60591. export class GradientMaterial extends BABYLON.PushMaterial {
  60592. private _maxSimultaneousLights;
  60593. maxSimultaneousLights: number;
  60594. topColor: BABYLON.Color3;
  60595. topColorAlpha: number;
  60596. bottomColor: BABYLON.Color3;
  60597. bottomColorAlpha: number;
  60598. offset: number;
  60599. scale: number;
  60600. smoothness: number;
  60601. private _disableLighting;
  60602. disableLighting: boolean;
  60603. private _renderId;
  60604. constructor(name: string, scene: BABYLON.Scene);
  60605. needAlphaBlending(): boolean;
  60606. needAlphaTesting(): boolean;
  60607. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  60608. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  60609. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  60610. getAnimatables(): BABYLON.IAnimatable[];
  60611. dispose(forceDisposeEffect?: boolean): void;
  60612. clone(name: string): GradientMaterial;
  60613. serialize(): any;
  60614. getClassName(): string;
  60615. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  60616. }
  60617. }
  60618. declare module BABYLON {
  60619. /** @hidden */
  60620. export var gridPixelShader: {
  60621. name: string;
  60622. shader: string;
  60623. };
  60624. }
  60625. declare module BABYLON {
  60626. /** @hidden */
  60627. export var gridVertexShader: {
  60628. name: string;
  60629. shader: string;
  60630. };
  60631. }
  60632. declare module BABYLON {
  60633. /**
  60634. * The grid materials allows you to wrap any shape with a grid.
  60635. * Colors are customizable.
  60636. */
  60637. export class GridMaterial extends BABYLON.PushMaterial {
  60638. /**
  60639. * Main color of the grid (e.g. between lines)
  60640. */
  60641. mainColor: BABYLON.Color3;
  60642. /**
  60643. * Color of the grid lines.
  60644. */
  60645. lineColor: BABYLON.Color3;
  60646. /**
  60647. * The scale of the grid compared to unit.
  60648. */
  60649. gridRatio: number;
  60650. /**
  60651. * Allows setting an offset for the grid lines.
  60652. */
  60653. gridOffset: BABYLON.Vector3;
  60654. /**
  60655. * The frequency of thicker lines.
  60656. */
  60657. majorUnitFrequency: number;
  60658. /**
  60659. * The visibility of minor units in the grid.
  60660. */
  60661. minorUnitVisibility: number;
  60662. /**
  60663. * The grid opacity outside of the lines.
  60664. */
  60665. opacity: number;
  60666. /**
  60667. * Determine RBG output is premultiplied by alpha value.
  60668. */
  60669. preMultiplyAlpha: boolean;
  60670. private _opacityTexture;
  60671. opacityTexture: BABYLON.BaseTexture;
  60672. private _gridControl;
  60673. private _renderId;
  60674. /**
  60675. * constructor
  60676. * @param name The name given to the material in order to identify it afterwards.
  60677. * @param scene The scene the material is used in.
  60678. */
  60679. constructor(name: string, scene: BABYLON.Scene);
  60680. /**
  60681. * Returns wehter or not the grid requires alpha blending.
  60682. */
  60683. needAlphaBlending(): boolean;
  60684. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  60685. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  60686. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  60687. /**
  60688. * Dispose the material and its associated resources.
  60689. * @param forceDisposeEffect will also dispose the used effect when true
  60690. */
  60691. dispose(forceDisposeEffect?: boolean): void;
  60692. clone(name: string): GridMaterial;
  60693. serialize(): any;
  60694. getClassName(): string;
  60695. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  60696. }
  60697. }
  60698. declare module BABYLON {
  60699. /** @hidden */
  60700. export var lavaPixelShader: {
  60701. name: string;
  60702. shader: string;
  60703. };
  60704. }
  60705. declare module BABYLON {
  60706. /** @hidden */
  60707. export var lavaVertexShader: {
  60708. name: string;
  60709. shader: string;
  60710. };
  60711. }
  60712. declare module BABYLON {
  60713. export class LavaMaterial extends BABYLON.PushMaterial {
  60714. private _diffuseTexture;
  60715. diffuseTexture: BABYLON.BaseTexture;
  60716. noiseTexture: BABYLON.BaseTexture;
  60717. fogColor: BABYLON.Color3;
  60718. speed: number;
  60719. movingSpeed: number;
  60720. lowFrequencySpeed: number;
  60721. fogDensity: number;
  60722. private _lastTime;
  60723. diffuseColor: BABYLON.Color3;
  60724. private _disableLighting;
  60725. disableLighting: boolean;
  60726. private _unlit;
  60727. unlit: boolean;
  60728. private _maxSimultaneousLights;
  60729. maxSimultaneousLights: number;
  60730. private _scaledDiffuse;
  60731. private _renderId;
  60732. constructor(name: string, scene: BABYLON.Scene);
  60733. needAlphaBlending(): boolean;
  60734. needAlphaTesting(): boolean;
  60735. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  60736. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  60737. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  60738. getAnimatables(): BABYLON.IAnimatable[];
  60739. getActiveTextures(): BABYLON.BaseTexture[];
  60740. hasTexture(texture: BABYLON.BaseTexture): boolean;
  60741. dispose(forceDisposeEffect?: boolean): void;
  60742. clone(name: string): LavaMaterial;
  60743. serialize(): any;
  60744. getClassName(): string;
  60745. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  60746. }
  60747. }
  60748. declare module BABYLON {
  60749. /** @hidden */
  60750. export var mixPixelShader: {
  60751. name: string;
  60752. shader: string;
  60753. };
  60754. }
  60755. declare module BABYLON {
  60756. /** @hidden */
  60757. export var mixVertexShader: {
  60758. name: string;
  60759. shader: string;
  60760. };
  60761. }
  60762. declare module BABYLON {
  60763. export class MixMaterial extends BABYLON.PushMaterial {
  60764. /**
  60765. * Mix textures
  60766. */
  60767. private _mixTexture1;
  60768. mixTexture1: BABYLON.BaseTexture;
  60769. private _mixTexture2;
  60770. mixTexture2: BABYLON.BaseTexture;
  60771. /**
  60772. * Diffuse textures
  60773. */
  60774. private _diffuseTexture1;
  60775. diffuseTexture1: BABYLON.Texture;
  60776. private _diffuseTexture2;
  60777. diffuseTexture2: BABYLON.Texture;
  60778. private _diffuseTexture3;
  60779. diffuseTexture3: BABYLON.Texture;
  60780. private _diffuseTexture4;
  60781. diffuseTexture4: BABYLON.Texture;
  60782. private _diffuseTexture5;
  60783. diffuseTexture5: BABYLON.Texture;
  60784. private _diffuseTexture6;
  60785. diffuseTexture6: BABYLON.Texture;
  60786. private _diffuseTexture7;
  60787. diffuseTexture7: BABYLON.Texture;
  60788. private _diffuseTexture8;
  60789. diffuseTexture8: BABYLON.Texture;
  60790. /**
  60791. * Uniforms
  60792. */
  60793. diffuseColor: BABYLON.Color3;
  60794. specularColor: BABYLON.Color3;
  60795. specularPower: number;
  60796. private _disableLighting;
  60797. disableLighting: boolean;
  60798. private _maxSimultaneousLights;
  60799. maxSimultaneousLights: number;
  60800. private _renderId;
  60801. constructor(name: string, scene: BABYLON.Scene);
  60802. needAlphaBlending(): boolean;
  60803. needAlphaTesting(): boolean;
  60804. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  60805. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  60806. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  60807. getAnimatables(): BABYLON.IAnimatable[];
  60808. getActiveTextures(): BABYLON.BaseTexture[];
  60809. hasTexture(texture: BABYLON.BaseTexture): boolean;
  60810. dispose(forceDisposeEffect?: boolean): void;
  60811. clone(name: string): MixMaterial;
  60812. serialize(): any;
  60813. getClassName(): string;
  60814. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  60815. }
  60816. }
  60817. declare module BABYLON {
  60818. /** @hidden */
  60819. export var normalPixelShader: {
  60820. name: string;
  60821. shader: string;
  60822. };
  60823. }
  60824. declare module BABYLON {
  60825. /** @hidden */
  60826. export var normalVertexShader: {
  60827. name: string;
  60828. shader: string;
  60829. };
  60830. }
  60831. declare module BABYLON {
  60832. export class NormalMaterial extends BABYLON.PushMaterial {
  60833. private _diffuseTexture;
  60834. diffuseTexture: BABYLON.BaseTexture;
  60835. diffuseColor: BABYLON.Color3;
  60836. private _disableLighting;
  60837. disableLighting: boolean;
  60838. private _maxSimultaneousLights;
  60839. maxSimultaneousLights: number;
  60840. private _renderId;
  60841. constructor(name: string, scene: BABYLON.Scene);
  60842. needAlphaBlending(): boolean;
  60843. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  60844. needAlphaTesting(): boolean;
  60845. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  60846. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  60847. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  60848. getAnimatables(): BABYLON.IAnimatable[];
  60849. getActiveTextures(): BABYLON.BaseTexture[];
  60850. hasTexture(texture: BABYLON.BaseTexture): boolean;
  60851. dispose(forceDisposeEffect?: boolean): void;
  60852. clone(name: string): NormalMaterial;
  60853. serialize(): any;
  60854. getClassName(): string;
  60855. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  60856. }
  60857. }
  60858. declare module BABYLON {
  60859. /** @hidden */
  60860. export var shadowOnlyPixelShader: {
  60861. name: string;
  60862. shader: string;
  60863. };
  60864. }
  60865. declare module BABYLON {
  60866. /** @hidden */
  60867. export var shadowOnlyVertexShader: {
  60868. name: string;
  60869. shader: string;
  60870. };
  60871. }
  60872. declare module BABYLON {
  60873. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  60874. private _renderId;
  60875. private _activeLight;
  60876. constructor(name: string, scene: BABYLON.Scene);
  60877. shadowColor: BABYLON.Color3;
  60878. needAlphaBlending(): boolean;
  60879. needAlphaTesting(): boolean;
  60880. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  60881. activeLight: BABYLON.IShadowLight;
  60882. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  60883. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  60884. clone(name: string): ShadowOnlyMaterial;
  60885. serialize(): any;
  60886. getClassName(): string;
  60887. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  60888. }
  60889. }
  60890. declare module BABYLON {
  60891. /** @hidden */
  60892. export var simplePixelShader: {
  60893. name: string;
  60894. shader: string;
  60895. };
  60896. }
  60897. declare module BABYLON {
  60898. /** @hidden */
  60899. export var simpleVertexShader: {
  60900. name: string;
  60901. shader: string;
  60902. };
  60903. }
  60904. declare module BABYLON {
  60905. export class SimpleMaterial extends BABYLON.PushMaterial {
  60906. private _diffuseTexture;
  60907. diffuseTexture: BABYLON.BaseTexture;
  60908. diffuseColor: BABYLON.Color3;
  60909. private _disableLighting;
  60910. disableLighting: boolean;
  60911. private _maxSimultaneousLights;
  60912. maxSimultaneousLights: number;
  60913. private _renderId;
  60914. constructor(name: string, scene: BABYLON.Scene);
  60915. needAlphaBlending(): boolean;
  60916. needAlphaTesting(): boolean;
  60917. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  60918. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  60919. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  60920. getAnimatables(): BABYLON.IAnimatable[];
  60921. getActiveTextures(): BABYLON.BaseTexture[];
  60922. hasTexture(texture: BABYLON.BaseTexture): boolean;
  60923. dispose(forceDisposeEffect?: boolean): void;
  60924. clone(name: string): SimpleMaterial;
  60925. serialize(): any;
  60926. getClassName(): string;
  60927. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  60928. }
  60929. }
  60930. declare module BABYLON {
  60931. /** @hidden */
  60932. export var skyPixelShader: {
  60933. name: string;
  60934. shader: string;
  60935. };
  60936. }
  60937. declare module BABYLON {
  60938. /** @hidden */
  60939. export var skyVertexShader: {
  60940. name: string;
  60941. shader: string;
  60942. };
  60943. }
  60944. declare module BABYLON {
  60945. /**
  60946. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  60947. * @see https://doc.babylonjs.com/extensions/sky
  60948. */
  60949. export class SkyMaterial extends BABYLON.PushMaterial {
  60950. /**
  60951. * Defines the overall luminance of sky in interval ]0, 1[.
  60952. */
  60953. luminance: number;
  60954. /**
  60955. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  60956. */
  60957. turbidity: number;
  60958. /**
  60959. * Defines the sky appearance (light intensity).
  60960. */
  60961. rayleigh: number;
  60962. /**
  60963. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  60964. */
  60965. mieCoefficient: number;
  60966. /**
  60967. * Defines the amount of haze particles following the Mie scattering theory.
  60968. */
  60969. mieDirectionalG: number;
  60970. /**
  60971. * Defines the distance of the sun according to the active scene camera.
  60972. */
  60973. distance: number;
  60974. /**
  60975. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  60976. * "inclined".
  60977. */
  60978. inclination: number;
  60979. /**
  60980. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  60981. * an object direction and a reference direction.
  60982. */
  60983. azimuth: number;
  60984. /**
  60985. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  60986. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  60987. */
  60988. sunPosition: BABYLON.Vector3;
  60989. /**
  60990. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  60991. * .sunPosition property.
  60992. */
  60993. useSunPosition: boolean;
  60994. /**
  60995. * Defines an offset vector used to get a horizon offset.
  60996. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  60997. */
  60998. cameraOffset: BABYLON.Vector3;
  60999. private _cameraPosition;
  61000. private _renderId;
  61001. /**
  61002. * Instantiates a new sky material.
  61003. * This material allows to create dynamic and texture free
  61004. * effects for skyboxes by taking care of the atmosphere state.
  61005. * @see https://doc.babylonjs.com/extensions/sky
  61006. * @param name Define the name of the material in the scene
  61007. * @param scene Define the scene the material belong to
  61008. */
  61009. constructor(name: string, scene: BABYLON.Scene);
  61010. /**
  61011. * Specifies if the material will require alpha blending
  61012. * @returns a boolean specifying if alpha blending is needed
  61013. */
  61014. needAlphaBlending(): boolean;
  61015. /**
  61016. * Specifies if this material should be rendered in alpha test mode
  61017. * @returns false as the sky material doesn't need alpha testing.
  61018. */
  61019. needAlphaTesting(): boolean;
  61020. /**
  61021. * Get the texture used for alpha test purpose.
  61022. * @returns null as the sky material has no texture.
  61023. */
  61024. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  61025. /**
  61026. * Get if the submesh is ready to be used and all its information available.
  61027. * Child classes can use it to update shaders
  61028. * @param mesh defines the mesh to check
  61029. * @param subMesh defines which submesh to check
  61030. * @param useInstances specifies that instances should be used
  61031. * @returns a boolean indicating that the submesh is ready or not
  61032. */
  61033. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  61034. /**
  61035. * Binds the submesh to this material by preparing the effect and shader to draw
  61036. * @param world defines the world transformation matrix
  61037. * @param mesh defines the mesh containing the submesh
  61038. * @param subMesh defines the submesh to bind the material to
  61039. */
  61040. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  61041. /**
  61042. * Get the list of animatables in the material.
  61043. * @returns the list of animatables object used in the material
  61044. */
  61045. getAnimatables(): BABYLON.IAnimatable[];
  61046. /**
  61047. * Disposes the material
  61048. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  61049. */
  61050. dispose(forceDisposeEffect?: boolean): void;
  61051. /**
  61052. * Makes a duplicate of the material, and gives it a new name
  61053. * @param name defines the new name for the duplicated material
  61054. * @returns the cloned material
  61055. */
  61056. clone(name: string): SkyMaterial;
  61057. /**
  61058. * Serializes this material in a JSON representation
  61059. * @returns the serialized material object
  61060. */
  61061. serialize(): any;
  61062. /**
  61063. * Gets the current class name of the material e.g. "SkyMaterial"
  61064. * Mainly use in serialization.
  61065. * @returns the class name
  61066. */
  61067. getClassName(): string;
  61068. /**
  61069. * Creates a sky material from parsed material data
  61070. * @param source defines the JSON representation of the material
  61071. * @param scene defines the hosting scene
  61072. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  61073. * @returns a new sky material
  61074. */
  61075. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  61076. }
  61077. }
  61078. declare module BABYLON {
  61079. /** @hidden */
  61080. export var terrainPixelShader: {
  61081. name: string;
  61082. shader: string;
  61083. };
  61084. }
  61085. declare module BABYLON {
  61086. /** @hidden */
  61087. export var terrainVertexShader: {
  61088. name: string;
  61089. shader: string;
  61090. };
  61091. }
  61092. declare module BABYLON {
  61093. export class TerrainMaterial extends BABYLON.PushMaterial {
  61094. private _mixTexture;
  61095. mixTexture: BABYLON.BaseTexture;
  61096. private _diffuseTexture1;
  61097. diffuseTexture1: BABYLON.Texture;
  61098. private _diffuseTexture2;
  61099. diffuseTexture2: BABYLON.Texture;
  61100. private _diffuseTexture3;
  61101. diffuseTexture3: BABYLON.Texture;
  61102. private _bumpTexture1;
  61103. bumpTexture1: BABYLON.Texture;
  61104. private _bumpTexture2;
  61105. bumpTexture2: BABYLON.Texture;
  61106. private _bumpTexture3;
  61107. bumpTexture3: BABYLON.Texture;
  61108. diffuseColor: BABYLON.Color3;
  61109. specularColor: BABYLON.Color3;
  61110. specularPower: number;
  61111. private _disableLighting;
  61112. disableLighting: boolean;
  61113. private _maxSimultaneousLights;
  61114. maxSimultaneousLights: number;
  61115. private _renderId;
  61116. constructor(name: string, scene: BABYLON.Scene);
  61117. needAlphaBlending(): boolean;
  61118. needAlphaTesting(): boolean;
  61119. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  61120. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  61121. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  61122. getAnimatables(): BABYLON.IAnimatable[];
  61123. getActiveTextures(): BABYLON.BaseTexture[];
  61124. hasTexture(texture: BABYLON.BaseTexture): boolean;
  61125. dispose(forceDisposeEffect?: boolean): void;
  61126. clone(name: string): TerrainMaterial;
  61127. serialize(): any;
  61128. getClassName(): string;
  61129. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  61130. }
  61131. }
  61132. declare module BABYLON {
  61133. /** @hidden */
  61134. export var triplanarPixelShader: {
  61135. name: string;
  61136. shader: string;
  61137. };
  61138. }
  61139. declare module BABYLON {
  61140. /** @hidden */
  61141. export var triplanarVertexShader: {
  61142. name: string;
  61143. shader: string;
  61144. };
  61145. }
  61146. declare module BABYLON {
  61147. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  61148. mixTexture: BABYLON.BaseTexture;
  61149. private _diffuseTextureX;
  61150. diffuseTextureX: BABYLON.BaseTexture;
  61151. private _diffuseTextureY;
  61152. diffuseTextureY: BABYLON.BaseTexture;
  61153. private _diffuseTextureZ;
  61154. diffuseTextureZ: BABYLON.BaseTexture;
  61155. private _normalTextureX;
  61156. normalTextureX: BABYLON.BaseTexture;
  61157. private _normalTextureY;
  61158. normalTextureY: BABYLON.BaseTexture;
  61159. private _normalTextureZ;
  61160. normalTextureZ: BABYLON.BaseTexture;
  61161. tileSize: number;
  61162. diffuseColor: BABYLON.Color3;
  61163. specularColor: BABYLON.Color3;
  61164. specularPower: number;
  61165. private _disableLighting;
  61166. disableLighting: boolean;
  61167. private _maxSimultaneousLights;
  61168. maxSimultaneousLights: number;
  61169. private _renderId;
  61170. constructor(name: string, scene: BABYLON.Scene);
  61171. needAlphaBlending(): boolean;
  61172. needAlphaTesting(): boolean;
  61173. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  61174. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  61175. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  61176. getAnimatables(): BABYLON.IAnimatable[];
  61177. getActiveTextures(): BABYLON.BaseTexture[];
  61178. hasTexture(texture: BABYLON.BaseTexture): boolean;
  61179. dispose(forceDisposeEffect?: boolean): void;
  61180. clone(name: string): TriPlanarMaterial;
  61181. serialize(): any;
  61182. getClassName(): string;
  61183. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  61184. }
  61185. }
  61186. declare module BABYLON {
  61187. /** @hidden */
  61188. export var waterPixelShader: {
  61189. name: string;
  61190. shader: string;
  61191. };
  61192. }
  61193. declare module BABYLON {
  61194. /** @hidden */
  61195. export var waterVertexShader: {
  61196. name: string;
  61197. shader: string;
  61198. };
  61199. }
  61200. declare module BABYLON {
  61201. export class WaterMaterial extends BABYLON.PushMaterial {
  61202. renderTargetSize: BABYLON.Vector2;
  61203. private _bumpTexture;
  61204. bumpTexture: BABYLON.BaseTexture;
  61205. diffuseColor: BABYLON.Color3;
  61206. specularColor: BABYLON.Color3;
  61207. specularPower: number;
  61208. private _disableLighting;
  61209. disableLighting: boolean;
  61210. private _maxSimultaneousLights;
  61211. maxSimultaneousLights: number;
  61212. /**
  61213. * @param {number}: Represents the wind force
  61214. */
  61215. windForce: number;
  61216. /**
  61217. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  61218. */
  61219. windDirection: BABYLON.Vector2;
  61220. /**
  61221. * @param {number}: Wave height, represents the height of the waves
  61222. */
  61223. waveHeight: number;
  61224. /**
  61225. * @param {number}: Bump height, represents the bump height related to the bump map
  61226. */
  61227. bumpHeight: number;
  61228. /**
  61229. * @param {boolean}: Add a smaller moving bump to less steady waves.
  61230. */
  61231. private _bumpSuperimpose;
  61232. bumpSuperimpose: boolean;
  61233. /**
  61234. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  61235. */
  61236. private _fresnelSeparate;
  61237. fresnelSeparate: boolean;
  61238. /**
  61239. * @param {boolean}: bump Waves modify the reflection.
  61240. */
  61241. private _bumpAffectsReflection;
  61242. bumpAffectsReflection: boolean;
  61243. /**
  61244. * @param {number}: The water color blended with the refraction (near)
  61245. */
  61246. waterColor: BABYLON.Color3;
  61247. /**
  61248. * @param {number}: The blend factor related to the water color
  61249. */
  61250. colorBlendFactor: number;
  61251. /**
  61252. * @param {number}: The water color blended with the reflection (far)
  61253. */
  61254. waterColor2: BABYLON.Color3;
  61255. /**
  61256. * @param {number}: The blend factor related to the water color (reflection, far)
  61257. */
  61258. colorBlendFactor2: number;
  61259. /**
  61260. * @param {number}: Represents the maximum length of a wave
  61261. */
  61262. waveLength: number;
  61263. /**
  61264. * @param {number}: Defines the waves speed
  61265. */
  61266. waveSpeed: number;
  61267. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  61268. private _mesh;
  61269. private _refractionRTT;
  61270. private _reflectionRTT;
  61271. private _reflectionTransform;
  61272. private _lastTime;
  61273. private _lastDeltaTime;
  61274. private _renderId;
  61275. private _useLogarithmicDepth;
  61276. private _waitingRenderList;
  61277. /**
  61278. * Gets a boolean indicating that current material needs to register RTT
  61279. */
  61280. readonly hasRenderTargetTextures: boolean;
  61281. /**
  61282. * Constructor
  61283. */
  61284. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  61285. useLogarithmicDepth: boolean;
  61286. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  61287. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  61288. addToRenderList(node: any): void;
  61289. enableRenderTargets(enable: boolean): void;
  61290. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  61291. readonly renderTargetsEnabled: boolean;
  61292. needAlphaBlending(): boolean;
  61293. needAlphaTesting(): boolean;
  61294. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  61295. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  61296. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  61297. private _createRenderTargets;
  61298. getAnimatables(): BABYLON.IAnimatable[];
  61299. getActiveTextures(): BABYLON.BaseTexture[];
  61300. hasTexture(texture: BABYLON.BaseTexture): boolean;
  61301. dispose(forceDisposeEffect?: boolean): void;
  61302. clone(name: string): WaterMaterial;
  61303. serialize(): any;
  61304. getClassName(): string;
  61305. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  61306. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  61307. }
  61308. }
  61309. declare module BABYLON {
  61310. /** @hidden */
  61311. export var asciiartPixelShader: {
  61312. name: string;
  61313. shader: string;
  61314. };
  61315. }
  61316. declare module BABYLON {
  61317. /**
  61318. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  61319. *
  61320. * It basically takes care rendering the font front the given font size to a texture.
  61321. * This is used later on in the postprocess.
  61322. */
  61323. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  61324. private _font;
  61325. private _text;
  61326. private _charSize;
  61327. /**
  61328. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  61329. */
  61330. readonly charSize: number;
  61331. /**
  61332. * Create a new instance of the Ascii Art FontTexture class
  61333. * @param name the name of the texture
  61334. * @param font the font to use, use the W3C CSS notation
  61335. * @param text the caracter set to use in the rendering.
  61336. * @param scene the scene that owns the texture
  61337. */
  61338. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  61339. /**
  61340. * Gets the max char width of a font.
  61341. * @param font the font to use, use the W3C CSS notation
  61342. * @return the max char width
  61343. */
  61344. private getFontWidth;
  61345. /**
  61346. * Gets the max char height of a font.
  61347. * @param font the font to use, use the W3C CSS notation
  61348. * @return the max char height
  61349. */
  61350. private getFontHeight;
  61351. /**
  61352. * Clones the current AsciiArtTexture.
  61353. * @return the clone of the texture.
  61354. */
  61355. clone(): AsciiArtFontTexture;
  61356. /**
  61357. * Parses a json object representing the texture and returns an instance of it.
  61358. * @param source the source JSON representation
  61359. * @param scene the scene to create the texture for
  61360. * @return the parsed texture
  61361. */
  61362. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  61363. }
  61364. /**
  61365. * Option available in the Ascii Art Post Process.
  61366. */
  61367. export interface IAsciiArtPostProcessOptions {
  61368. /**
  61369. * The font to use following the w3c font definition.
  61370. */
  61371. font?: string;
  61372. /**
  61373. * The character set to use in the postprocess.
  61374. */
  61375. characterSet?: string;
  61376. /**
  61377. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  61378. * This number is defined between 0 and 1;
  61379. */
  61380. mixToTile?: number;
  61381. /**
  61382. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  61383. * This number is defined between 0 and 1;
  61384. */
  61385. mixToNormal?: number;
  61386. }
  61387. /**
  61388. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  61389. *
  61390. * Simmply add it to your scene and let the nerd that lives in you have fun.
  61391. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  61392. */
  61393. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  61394. /**
  61395. * The font texture used to render the char in the post process.
  61396. */
  61397. private _asciiArtFontTexture;
  61398. /**
  61399. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  61400. * This number is defined between 0 and 1;
  61401. */
  61402. mixToTile: number;
  61403. /**
  61404. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  61405. * This number is defined between 0 and 1;
  61406. */
  61407. mixToNormal: number;
  61408. /**
  61409. * Instantiates a new Ascii Art Post Process.
  61410. * @param name the name to give to the postprocess
  61411. * @camera the camera to apply the post process to.
  61412. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  61413. */
  61414. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  61415. }
  61416. }
  61417. declare module BABYLON {
  61418. /** @hidden */
  61419. export var digitalrainPixelShader: {
  61420. name: string;
  61421. shader: string;
  61422. };
  61423. }
  61424. declare module BABYLON {
  61425. /**
  61426. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  61427. *
  61428. * It basically takes care rendering the font front the given font size to a texture.
  61429. * This is used later on in the postprocess.
  61430. */
  61431. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  61432. private _font;
  61433. private _text;
  61434. private _charSize;
  61435. /**
  61436. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  61437. */
  61438. readonly charSize: number;
  61439. /**
  61440. * Create a new instance of the Digital Rain FontTexture class
  61441. * @param name the name of the texture
  61442. * @param font the font to use, use the W3C CSS notation
  61443. * @param text the caracter set to use in the rendering.
  61444. * @param scene the scene that owns the texture
  61445. */
  61446. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  61447. /**
  61448. * Gets the max char width of a font.
  61449. * @param font the font to use, use the W3C CSS notation
  61450. * @return the max char width
  61451. */
  61452. private getFontWidth;
  61453. /**
  61454. * Gets the max char height of a font.
  61455. * @param font the font to use, use the W3C CSS notation
  61456. * @return the max char height
  61457. */
  61458. private getFontHeight;
  61459. /**
  61460. * Clones the current DigitalRainFontTexture.
  61461. * @return the clone of the texture.
  61462. */
  61463. clone(): DigitalRainFontTexture;
  61464. /**
  61465. * Parses a json object representing the texture and returns an instance of it.
  61466. * @param source the source JSON representation
  61467. * @param scene the scene to create the texture for
  61468. * @return the parsed texture
  61469. */
  61470. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  61471. }
  61472. /**
  61473. * Option available in the Digital Rain Post Process.
  61474. */
  61475. export interface IDigitalRainPostProcessOptions {
  61476. /**
  61477. * The font to use following the w3c font definition.
  61478. */
  61479. font?: string;
  61480. /**
  61481. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  61482. * This number is defined between 0 and 1;
  61483. */
  61484. mixToTile?: number;
  61485. /**
  61486. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  61487. * This number is defined between 0 and 1;
  61488. */
  61489. mixToNormal?: number;
  61490. }
  61491. /**
  61492. * DigitalRainPostProcess helps rendering everithing in digital rain.
  61493. *
  61494. * Simmply add it to your scene and let the nerd that lives in you have fun.
  61495. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  61496. */
  61497. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  61498. /**
  61499. * The font texture used to render the char in the post process.
  61500. */
  61501. private _digitalRainFontTexture;
  61502. /**
  61503. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  61504. * This number is defined between 0 and 1;
  61505. */
  61506. mixToTile: number;
  61507. /**
  61508. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  61509. * This number is defined between 0 and 1;
  61510. */
  61511. mixToNormal: number;
  61512. /**
  61513. * Instantiates a new Digital Rain Post Process.
  61514. * @param name the name to give to the postprocess
  61515. * @camera the camera to apply the post process to.
  61516. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  61517. */
  61518. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  61519. }
  61520. }
  61521. declare module BABYLON {
  61522. /** @hidden */
  61523. export var brickProceduralTexturePixelShader: {
  61524. name: string;
  61525. shader: string;
  61526. };
  61527. }
  61528. declare module BABYLON {
  61529. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  61530. private _numberOfBricksHeight;
  61531. private _numberOfBricksWidth;
  61532. private _jointColor;
  61533. private _brickColor;
  61534. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  61535. updateShaderUniforms(): void;
  61536. numberOfBricksHeight: number;
  61537. numberOfBricksWidth: number;
  61538. jointColor: BABYLON.Color3;
  61539. brickColor: BABYLON.Color3;
  61540. /**
  61541. * Serializes this brick procedural texture
  61542. * @returns a serialized brick procedural texture object
  61543. */
  61544. serialize(): any;
  61545. /**
  61546. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  61547. * @param parsedTexture defines parsed texture data
  61548. * @param scene defines the current scene
  61549. * @param rootUrl defines the root URL containing brick procedural texture information
  61550. * @returns a parsed Brick Procedural BABYLON.Texture
  61551. */
  61552. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  61553. }
  61554. }
  61555. declare module BABYLON {
  61556. /** @hidden */
  61557. export var cloudProceduralTexturePixelShader: {
  61558. name: string;
  61559. shader: string;
  61560. };
  61561. }
  61562. declare module BABYLON {
  61563. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  61564. private _skyColor;
  61565. private _cloudColor;
  61566. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  61567. updateShaderUniforms(): void;
  61568. skyColor: BABYLON.Color4;
  61569. cloudColor: BABYLON.Color4;
  61570. /**
  61571. * Serializes this cloud procedural texture
  61572. * @returns a serialized cloud procedural texture object
  61573. */
  61574. serialize(): any;
  61575. /**
  61576. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  61577. * @param parsedTexture defines parsed texture data
  61578. * @param scene defines the current scene
  61579. * @param rootUrl defines the root URL containing cloud procedural texture information
  61580. * @returns a parsed Cloud Procedural BABYLON.Texture
  61581. */
  61582. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  61583. }
  61584. }
  61585. declare module BABYLON {
  61586. /** @hidden */
  61587. export var fireProceduralTexturePixelShader: {
  61588. name: string;
  61589. shader: string;
  61590. };
  61591. }
  61592. declare module BABYLON {
  61593. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  61594. private _time;
  61595. private _speed;
  61596. private _autoGenerateTime;
  61597. private _fireColors;
  61598. private _alphaThreshold;
  61599. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  61600. updateShaderUniforms(): void;
  61601. render(useCameraPostProcess?: boolean): void;
  61602. static readonly PurpleFireColors: BABYLON.Color3[];
  61603. static readonly GreenFireColors: BABYLON.Color3[];
  61604. static readonly RedFireColors: BABYLON.Color3[];
  61605. static readonly BlueFireColors: BABYLON.Color3[];
  61606. autoGenerateTime: boolean;
  61607. fireColors: BABYLON.Color3[];
  61608. time: number;
  61609. speed: BABYLON.Vector2;
  61610. alphaThreshold: number;
  61611. /**
  61612. * Serializes this fire procedural texture
  61613. * @returns a serialized fire procedural texture object
  61614. */
  61615. serialize(): any;
  61616. /**
  61617. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  61618. * @param parsedTexture defines parsed texture data
  61619. * @param scene defines the current scene
  61620. * @param rootUrl defines the root URL containing fire procedural texture information
  61621. * @returns a parsed Fire Procedural BABYLON.Texture
  61622. */
  61623. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  61624. }
  61625. }
  61626. declare module BABYLON {
  61627. /** @hidden */
  61628. export var grassProceduralTexturePixelShader: {
  61629. name: string;
  61630. shader: string;
  61631. };
  61632. }
  61633. declare module BABYLON {
  61634. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  61635. private _grassColors;
  61636. private _groundColor;
  61637. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  61638. updateShaderUniforms(): void;
  61639. grassColors: BABYLON.Color3[];
  61640. groundColor: BABYLON.Color3;
  61641. /**
  61642. * Serializes this grass procedural texture
  61643. * @returns a serialized grass procedural texture object
  61644. */
  61645. serialize(): any;
  61646. /**
  61647. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  61648. * @param parsedTexture defines parsed texture data
  61649. * @param scene defines the current scene
  61650. * @param rootUrl defines the root URL containing grass procedural texture information
  61651. * @returns a parsed Grass Procedural BABYLON.Texture
  61652. */
  61653. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  61654. }
  61655. }
  61656. declare module BABYLON {
  61657. /** @hidden */
  61658. export var marbleProceduralTexturePixelShader: {
  61659. name: string;
  61660. shader: string;
  61661. };
  61662. }
  61663. declare module BABYLON {
  61664. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  61665. private _numberOfTilesHeight;
  61666. private _numberOfTilesWidth;
  61667. private _amplitude;
  61668. private _jointColor;
  61669. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  61670. updateShaderUniforms(): void;
  61671. numberOfTilesHeight: number;
  61672. amplitude: number;
  61673. numberOfTilesWidth: number;
  61674. jointColor: BABYLON.Color3;
  61675. /**
  61676. * Serializes this marble procedural texture
  61677. * @returns a serialized marble procedural texture object
  61678. */
  61679. serialize(): any;
  61680. /**
  61681. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  61682. * @param parsedTexture defines parsed texture data
  61683. * @param scene defines the current scene
  61684. * @param rootUrl defines the root URL containing marble procedural texture information
  61685. * @returns a parsed Marble Procedural BABYLON.Texture
  61686. */
  61687. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  61688. }
  61689. }
  61690. declare module BABYLON {
  61691. /** @hidden */
  61692. export var normalMapProceduralTexturePixelShader: {
  61693. name: string;
  61694. shader: string;
  61695. };
  61696. }
  61697. declare module BABYLON {
  61698. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  61699. private _baseTexture;
  61700. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  61701. updateShaderUniforms(): void;
  61702. render(useCameraPostProcess?: boolean): void;
  61703. resize(size: any, generateMipMaps: any): void;
  61704. baseTexture: BABYLON.Texture;
  61705. /**
  61706. * Serializes this normal map procedural texture
  61707. * @returns a serialized normal map procedural texture object
  61708. */
  61709. serialize(): any;
  61710. /**
  61711. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  61712. * @param parsedTexture defines parsed texture data
  61713. * @param scene defines the current scene
  61714. * @param rootUrl defines the root URL containing normal map procedural texture information
  61715. * @returns a parsed Normal Map Procedural BABYLON.Texture
  61716. */
  61717. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  61718. }
  61719. }
  61720. declare module BABYLON {
  61721. /** @hidden */
  61722. export var perlinNoiseProceduralTexturePixelShader: {
  61723. name: string;
  61724. shader: string;
  61725. };
  61726. }
  61727. declare module BABYLON {
  61728. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  61729. time: number;
  61730. timeScale: number;
  61731. translationSpeed: number;
  61732. private _currentTranslation;
  61733. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  61734. updateShaderUniforms(): void;
  61735. render(useCameraPostProcess?: boolean): void;
  61736. resize(size: any, generateMipMaps: any): void;
  61737. /**
  61738. * Serializes this perlin noise procedural texture
  61739. * @returns a serialized perlin noise procedural texture object
  61740. */
  61741. serialize(): any;
  61742. /**
  61743. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  61744. * @param parsedTexture defines parsed texture data
  61745. * @param scene defines the current scene
  61746. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  61747. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  61748. */
  61749. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  61750. }
  61751. }
  61752. declare module BABYLON {
  61753. /** @hidden */
  61754. export var roadProceduralTexturePixelShader: {
  61755. name: string;
  61756. shader: string;
  61757. };
  61758. }
  61759. declare module BABYLON {
  61760. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  61761. private _roadColor;
  61762. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  61763. updateShaderUniforms(): void;
  61764. roadColor: BABYLON.Color3;
  61765. /**
  61766. * Serializes this road procedural texture
  61767. * @returns a serialized road procedural texture object
  61768. */
  61769. serialize(): any;
  61770. /**
  61771. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  61772. * @param parsedTexture defines parsed texture data
  61773. * @param scene defines the current scene
  61774. * @param rootUrl defines the root URL containing road procedural texture information
  61775. * @returns a parsed Road Procedural BABYLON.Texture
  61776. */
  61777. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  61778. }
  61779. }
  61780. declare module BABYLON {
  61781. /** @hidden */
  61782. export var starfieldProceduralTexturePixelShader: {
  61783. name: string;
  61784. shader: string;
  61785. };
  61786. }
  61787. declare module BABYLON {
  61788. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  61789. private _time;
  61790. private _alpha;
  61791. private _beta;
  61792. private _zoom;
  61793. private _formuparam;
  61794. private _stepsize;
  61795. private _tile;
  61796. private _brightness;
  61797. private _darkmatter;
  61798. private _distfading;
  61799. private _saturation;
  61800. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  61801. updateShaderUniforms(): void;
  61802. time: number;
  61803. alpha: number;
  61804. beta: number;
  61805. formuparam: number;
  61806. stepsize: number;
  61807. zoom: number;
  61808. tile: number;
  61809. brightness: number;
  61810. darkmatter: number;
  61811. distfading: number;
  61812. saturation: number;
  61813. /**
  61814. * Serializes this starfield procedural texture
  61815. * @returns a serialized starfield procedural texture object
  61816. */
  61817. serialize(): any;
  61818. /**
  61819. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  61820. * @param parsedTexture defines parsed texture data
  61821. * @param scene defines the current scene
  61822. * @param rootUrl defines the root URL containing startfield procedural texture information
  61823. * @returns a parsed Starfield Procedural BABYLON.Texture
  61824. */
  61825. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  61826. }
  61827. }
  61828. declare module BABYLON {
  61829. /** @hidden */
  61830. export var woodProceduralTexturePixelShader: {
  61831. name: string;
  61832. shader: string;
  61833. };
  61834. }
  61835. declare module BABYLON {
  61836. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  61837. private _ampScale;
  61838. private _woodColor;
  61839. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  61840. updateShaderUniforms(): void;
  61841. ampScale: number;
  61842. woodColor: BABYLON.Color3;
  61843. /**
  61844. * Serializes this wood procedural texture
  61845. * @returns a serialized wood procedural texture object
  61846. */
  61847. serialize(): any;
  61848. /**
  61849. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  61850. * @param parsedTexture defines parsed texture data
  61851. * @param scene defines the current scene
  61852. * @param rootUrl defines the root URL containing wood procedural texture information
  61853. * @returns a parsed Wood Procedural BABYLON.Texture
  61854. */
  61855. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  61856. }
  61857. }