babylon.d.txt 3.0 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148
  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. * A class serves as a medium between the observable and its observers
  52. */
  53. export class EventState {
  54. /**
  55. * Create a new EventState
  56. * @param mask defines the mask associated with this state
  57. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  58. * @param target defines the original target of the state
  59. * @param currentTarget defines the current target of the state
  60. */
  61. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  62. /**
  63. * Initialize the current event state
  64. * @param mask defines the mask associated with this state
  65. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66. * @param target defines the original target of the state
  67. * @param currentTarget defines the current target of the state
  68. * @returns the current event state
  69. */
  70. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  71. /**
  72. * An Observer can set this property to true to prevent subsequent observers of being notified
  73. */
  74. skipNextObservers: boolean;
  75. /**
  76. * Get the mask value that were used to trigger the event corresponding to this EventState object
  77. */
  78. mask: number;
  79. /**
  80. * The object that originally notified the event
  81. */
  82. target?: any;
  83. /**
  84. * The current object in the bubbling phase
  85. */
  86. currentTarget?: any;
  87. /**
  88. * This will be populated with the return value of the last function that was executed.
  89. * If it is the first function in the callback chain it will be the event data.
  90. */
  91. lastReturnValue?: any;
  92. }
  93. /**
  94. * Represent an Observer registered to a given Observable object.
  95. */
  96. export class Observer<T> {
  97. /**
  98. * Defines the callback to call when the observer is notified
  99. */
  100. callback: (eventData: T, eventState: EventState) => void;
  101. /**
  102. * Defines the mask of the observer (used to filter notifications)
  103. */
  104. mask: number;
  105. /**
  106. * Defines the current scope used to restore the JS context
  107. */
  108. scope: any;
  109. /** @hidden */ private _willBeUnregistered: boolean;
  110. /**
  111. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  112. */
  113. unregisterOnNextCall: boolean;
  114. /**
  115. * Creates a new observer
  116. * @param callback defines the callback to call when the observer is notified
  117. * @param mask defines the mask of the observer (used to filter notifications)
  118. * @param scope defines the current scope used to restore the JS context
  119. */
  120. constructor(
  121. /**
  122. * Defines the callback to call when the observer is notified
  123. */
  124. callback: (eventData: T, eventState: EventState) => void,
  125. /**
  126. * Defines the mask of the observer (used to filter notifications)
  127. */
  128. mask: number,
  129. /**
  130. * Defines the current scope used to restore the JS context
  131. */
  132. scope?: any);
  133. }
  134. /**
  135. * Represent a list of observers registered to multiple Observables object.
  136. */
  137. export class MultiObserver<T> {
  138. private _observers;
  139. private _observables;
  140. /**
  141. * Release associated resources
  142. */
  143. dispose(): void;
  144. /**
  145. * Raise a callback when one of the observable will notify
  146. * @param observables defines a list of observables to watch
  147. * @param callback defines the callback to call on notification
  148. * @param mask defines the mask used to filter notifications
  149. * @param scope defines the current scope used to restore the JS context
  150. * @returns the new MultiObserver
  151. */
  152. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  153. }
  154. /**
  155. * The Observable class is a simple implementation of the Observable pattern.
  156. *
  157. * 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.
  158. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  159. * 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).
  160. * 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.
  161. */
  162. export class Observable<T> {
  163. private _observers;
  164. private _eventState;
  165. private _onObserverAdded;
  166. /**
  167. * Gets the list of observers
  168. */
  169. readonly observers: Array<Observer<T>>;
  170. /**
  171. * Creates a new observable
  172. * @param onObserverAdded defines a callback to call when a new observer is added
  173. */
  174. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  175. /**
  176. * Create a new Observer with the specified callback
  177. * @param callback the callback that will be executed for that Observer
  178. * @param mask the mask used to filter observers
  179. * @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.
  180. * @param scope optional scope for the callback to be called from
  181. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  182. * @returns the new observer created for the callback
  183. */
  184. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  185. /**
  186. * Create a new Observer with the specified callback and unregisters after the next notification
  187. * @param callback the callback that will be executed for that Observer
  188. * @returns the new observer created for the callback
  189. */
  190. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  191. /**
  192. * Remove an Observer from the Observable object
  193. * @param observer the instance of the Observer to remove
  194. * @returns false if it doesn't belong to this Observable
  195. */
  196. remove(observer: Nullable<Observer<T>>): boolean;
  197. /**
  198. * Remove a callback from the Observable object
  199. * @param callback the callback to remove
  200. * @param scope optional scope. If used only the callbacks with this scope will be removed
  201. * @returns false if it doesn't belong to this Observable
  202. */
  203. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  204. private _deferUnregister;
  205. private _remove;
  206. /**
  207. * Moves the observable to the top of the observer list making it get called first when notified
  208. * @param observer the observer to move
  209. */
  210. makeObserverTopPriority(observer: Observer<T>): void;
  211. /**
  212. * Moves the observable to the bottom of the observer list making it get called last when notified
  213. * @param observer the observer to move
  214. */
  215. makeObserverBottomPriority(observer: Observer<T>): void;
  216. /**
  217. * Notify all Observers by calling their respective callback with the given data
  218. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  219. * @param eventData defines the data to send to all observers
  220. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  221. * @param target defines the original target of the state
  222. * @param currentTarget defines the current target of the state
  223. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  224. */
  225. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  226. /**
  227. * Calling this will execute each callback, expecting it to be a promise or return a value.
  228. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  229. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  230. * and it is crucial that all callbacks will be executed.
  231. * The order of the callbacks is kept, callbacks are not executed parallel.
  232. *
  233. * @param eventData The data to be sent to each callback
  234. * @param mask is used to filter observers defaults to -1
  235. * @param target defines the callback target (see EventState)
  236. * @param currentTarget defines he current object in the bubbling phase
  237. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  238. */
  239. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  240. /**
  241. * Notify a specific observer
  242. * @param observer defines the observer to notify
  243. * @param eventData defines the data to be sent to each callback
  244. * @param mask is used to filter observers defaults to -1
  245. */
  246. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  247. /**
  248. * Gets a boolean indicating if the observable has at least one observer
  249. * @returns true is the Observable has at least one Observer registered
  250. */
  251. hasObservers(): boolean;
  252. /**
  253. * Clear the list of observers
  254. */
  255. clear(): void;
  256. /**
  257. * Clone the current observable
  258. * @returns a new observable
  259. */
  260. clone(): Observable<T>;
  261. /**
  262. * Does this observable handles observer registered with a given mask
  263. * @param mask defines the mask to be tested
  264. * @return whether or not one observer registered with the given mask is handeled
  265. **/
  266. hasSpecificMask(mask?: number): boolean;
  267. }
  268. }
  269. declare module BABYLON {
  270. /**
  271. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  272. * Babylon.js
  273. */
  274. export class DomManagement {
  275. /**
  276. * Checks if the window object exists
  277. * @returns true if the window object exists
  278. */
  279. static IsWindowObjectExist(): boolean;
  280. /**
  281. * Extracts text content from a DOM element hierarchy
  282. * @param element defines the root element
  283. * @returns a string
  284. */
  285. static GetDOMTextContent(element: HTMLElement): string;
  286. }
  287. }
  288. declare module BABYLON {
  289. /**
  290. * Logger used througouht the application to allow configuration of
  291. * the log level required for the messages.
  292. */
  293. export class Logger {
  294. /**
  295. * No log
  296. */
  297. static readonly NoneLogLevel: number;
  298. /**
  299. * Only message logs
  300. */
  301. static readonly MessageLogLevel: number;
  302. /**
  303. * Only warning logs
  304. */
  305. static readonly WarningLogLevel: number;
  306. /**
  307. * Only error logs
  308. */
  309. static readonly ErrorLogLevel: number;
  310. /**
  311. * All logs
  312. */
  313. static readonly AllLogLevel: number;
  314. private static _LogCache;
  315. /**
  316. * Gets a value indicating the number of loading errors
  317. * @ignorenaming
  318. */
  319. static errorsCount: number;
  320. /**
  321. * Callback called when a new log is added
  322. */
  323. static OnNewCacheEntry: (entry: string) => void;
  324. private static _AddLogEntry;
  325. private static _FormatMessage;
  326. private static _LogDisabled;
  327. private static _LogEnabled;
  328. private static _WarnDisabled;
  329. private static _WarnEnabled;
  330. private static _ErrorDisabled;
  331. private static _ErrorEnabled;
  332. /**
  333. * Log a message to the console
  334. */
  335. static Log: (message: string) => void;
  336. /**
  337. * Write a warning message to the console
  338. */
  339. static Warn: (message: string) => void;
  340. /**
  341. * Write an error message to the console
  342. */
  343. static Error: (message: string) => void;
  344. /**
  345. * Gets current log cache (list of logs)
  346. */
  347. static readonly LogCache: string;
  348. /**
  349. * Clears the log cache
  350. */
  351. static ClearLogCache(): void;
  352. /**
  353. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  354. */
  355. static LogLevels: number;
  356. }
  357. }
  358. declare module BABYLON {
  359. /** @hidden */
  360. export class _TypeStore {
  361. /** @hidden */
  362. static RegisteredTypes: {
  363. [key: string]: Object;
  364. };
  365. /** @hidden */
  366. static GetClass(fqdn: string): any;
  367. }
  368. }
  369. declare module BABYLON {
  370. /**
  371. * Class containing a set of static utilities functions for deep copy.
  372. */
  373. export class DeepCopier {
  374. /**
  375. * Tries to copy an object by duplicating every property
  376. * @param source defines the source object
  377. * @param destination defines the target object
  378. * @param doNotCopyList defines a list of properties to avoid
  379. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  380. */
  381. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  382. }
  383. }
  384. declare module BABYLON {
  385. /**
  386. * Class containing a set of static utilities functions for precision date
  387. */
  388. export class PrecisionDate {
  389. /**
  390. * Gets either window.performance.now() if supported or Date.now() else
  391. */
  392. static readonly Now: number;
  393. }
  394. }
  395. declare module BABYLON {
  396. /** @hidden */
  397. export class _DevTools {
  398. static WarnImport(name: string): string;
  399. }
  400. }
  401. declare module BABYLON {
  402. /**
  403. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  404. */
  405. export class WebRequest {
  406. private _xhr;
  407. /**
  408. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  409. * i.e. when loading files, where the server/service expects an Authorization header
  410. */
  411. static CustomRequestHeaders: {
  412. [key: string]: string;
  413. };
  414. /**
  415. * Add callback functions in this array to update all the requests before they get sent to the network
  416. */
  417. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  418. private _injectCustomRequestHeaders;
  419. /**
  420. * Gets or sets a function to be called when loading progress changes
  421. */
  422. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  423. /**
  424. * Returns client's state
  425. */
  426. readonly readyState: number;
  427. /**
  428. * Returns client's status
  429. */
  430. readonly status: number;
  431. /**
  432. * Returns client's status as a text
  433. */
  434. readonly statusText: string;
  435. /**
  436. * Returns client's response
  437. */
  438. readonly response: any;
  439. /**
  440. * Returns client's response url
  441. */
  442. readonly responseURL: string;
  443. /**
  444. * Returns client's response as text
  445. */
  446. readonly responseText: string;
  447. /**
  448. * Gets or sets the expected response type
  449. */
  450. responseType: XMLHttpRequestResponseType;
  451. /** @hidden */
  452. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  453. /** @hidden */
  454. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  455. /**
  456. * Cancels any network activity
  457. */
  458. abort(): void;
  459. /**
  460. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  461. * @param body defines an optional request body
  462. */
  463. send(body?: Document | BodyInit | null): void;
  464. /**
  465. * Sets the request method, request URL
  466. * @param method defines the method to use (GET, POST, etc..)
  467. * @param url defines the url to connect with
  468. */
  469. open(method: string, url: string): void;
  470. }
  471. }
  472. declare module BABYLON {
  473. /**
  474. * File request interface
  475. */
  476. export interface IFileRequest {
  477. /**
  478. * Raised when the request is complete (success or error).
  479. */
  480. onCompleteObservable: Observable<IFileRequest>;
  481. /**
  482. * Aborts the request for a file.
  483. */
  484. abort: () => void;
  485. }
  486. }
  487. declare module BABYLON {
  488. /**
  489. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  490. */
  491. export class PerformanceMonitor {
  492. private _enabled;
  493. private _rollingFrameTime;
  494. private _lastFrameTimeMs;
  495. /**
  496. * constructor
  497. * @param frameSampleSize The number of samples required to saturate the sliding window
  498. */
  499. constructor(frameSampleSize?: number);
  500. /**
  501. * Samples current frame
  502. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  503. */
  504. sampleFrame(timeMs?: number): void;
  505. /**
  506. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  507. */
  508. readonly averageFrameTime: number;
  509. /**
  510. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  511. */
  512. readonly averageFrameTimeVariance: number;
  513. /**
  514. * Returns the frame time of the most recent frame
  515. */
  516. readonly instantaneousFrameTime: number;
  517. /**
  518. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  519. */
  520. readonly averageFPS: number;
  521. /**
  522. * Returns the average framerate in frames per second using the most recent frame time
  523. */
  524. readonly instantaneousFPS: number;
  525. /**
  526. * Returns true if enough samples have been taken to completely fill the sliding window
  527. */
  528. readonly isSaturated: boolean;
  529. /**
  530. * Enables contributions to the sliding window sample set
  531. */
  532. enable(): void;
  533. /**
  534. * Disables contributions to the sliding window sample set
  535. * Samples will not be interpolated over the disabled period
  536. */
  537. disable(): void;
  538. /**
  539. * Returns true if sampling is enabled
  540. */
  541. readonly isEnabled: boolean;
  542. /**
  543. * Resets performance monitor
  544. */
  545. reset(): void;
  546. }
  547. /**
  548. * RollingAverage
  549. *
  550. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  551. */
  552. export class RollingAverage {
  553. /**
  554. * Current average
  555. */
  556. average: number;
  557. /**
  558. * Current variance
  559. */
  560. variance: number;
  561. protected _samples: Array<number>;
  562. protected _sampleCount: number;
  563. protected _pos: number;
  564. protected _m2: number;
  565. /**
  566. * constructor
  567. * @param length The number of samples required to saturate the sliding window
  568. */
  569. constructor(length: number);
  570. /**
  571. * Adds a sample to the sample set
  572. * @param v The sample value
  573. */
  574. add(v: number): void;
  575. /**
  576. * Returns previously added values or null if outside of history or outside the sliding window domain
  577. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  578. * @return Value previously recorded with add() or null if outside of range
  579. */
  580. history(i: number): number;
  581. /**
  582. * Returns true if enough samples have been taken to completely fill the sliding window
  583. * @return true if sample-set saturated
  584. */
  585. isSaturated(): boolean;
  586. /**
  587. * Resets the rolling average (equivalent to 0 samples taken so far)
  588. */
  589. reset(): void;
  590. /**
  591. * Wraps a value around the sample range boundaries
  592. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  593. * @return Wrapped position in sample range
  594. */
  595. protected _wrapPosition(i: number): number;
  596. }
  597. }
  598. declare module BABYLON {
  599. /**
  600. * This class implement a typical dictionary using a string as key and the generic type T as value.
  601. * The underlying implementation relies on an associative array to ensure the best performances.
  602. * The value can be anything including 'null' but except 'undefined'
  603. */
  604. export class StringDictionary<T> {
  605. /**
  606. * This will clear this dictionary and copy the content from the 'source' one.
  607. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  608. * @param source the dictionary to take the content from and copy to this dictionary
  609. */
  610. copyFrom(source: StringDictionary<T>): void;
  611. /**
  612. * Get a value based from its key
  613. * @param key the given key to get the matching value from
  614. * @return the value if found, otherwise undefined is returned
  615. */
  616. get(key: string): T | undefined;
  617. /**
  618. * Get a value from its key or add it if it doesn't exist.
  619. * This method will ensure you that a given key/data will be present in the dictionary.
  620. * @param key the given key to get the matching value from
  621. * @param factory the factory that will create the value if the key is not present in the dictionary.
  622. * The factory will only be invoked if there's no data for the given key.
  623. * @return the value corresponding to the key.
  624. */
  625. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  626. /**
  627. * Get a value from its key if present in the dictionary otherwise add it
  628. * @param key the key to get the value from
  629. * @param val if there's no such key/value pair in the dictionary add it with this value
  630. * @return the value corresponding to the key
  631. */
  632. getOrAdd(key: string, val: T): T;
  633. /**
  634. * Check if there's a given key in the dictionary
  635. * @param key the key to check for
  636. * @return true if the key is present, false otherwise
  637. */
  638. contains(key: string): boolean;
  639. /**
  640. * Add a new key and its corresponding value
  641. * @param key the key to add
  642. * @param value the value corresponding to the key
  643. * @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
  644. */
  645. add(key: string, value: T): boolean;
  646. /**
  647. * Update a specific value associated to a key
  648. * @param key defines the key to use
  649. * @param value defines the value to store
  650. * @returns true if the value was updated (or false if the key was not found)
  651. */
  652. set(key: string, value: T): boolean;
  653. /**
  654. * Get the element of the given key and remove it from the dictionary
  655. * @param key defines the key to search
  656. * @returns the value associated with the key or null if not found
  657. */
  658. getAndRemove(key: string): Nullable<T>;
  659. /**
  660. * Remove a key/value from the dictionary.
  661. * @param key the key to remove
  662. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  663. */
  664. remove(key: string): boolean;
  665. /**
  666. * Clear the whole content of the dictionary
  667. */
  668. clear(): void;
  669. /**
  670. * Gets the current count
  671. */
  672. readonly count: number;
  673. /**
  674. * Execute a callback on each key/val of the dictionary.
  675. * Note that you can remove any element in this dictionary in the callback implementation
  676. * @param callback the callback to execute on a given key/value pair
  677. */
  678. forEach(callback: (key: string, val: T) => void): void;
  679. /**
  680. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  681. * If the callback returns null or undefined the method will iterate to the next key/value pair
  682. * Note that you can remove any element in this dictionary in the callback implementation
  683. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  684. * @returns the first item
  685. */
  686. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  687. private _count;
  688. private _data;
  689. }
  690. }
  691. declare module BABYLON {
  692. /**
  693. * Class used to store gfx data (like WebGLBuffer)
  694. */
  695. export class DataBuffer {
  696. /**
  697. * Gets or sets the number of objects referencing this buffer
  698. */
  699. references: number;
  700. /** Gets or sets the size of the underlying buffer */
  701. capacity: number;
  702. /**
  703. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  704. */
  705. is32Bits: boolean;
  706. /**
  707. * Gets the underlying buffer
  708. */
  709. readonly underlyingResource: any;
  710. }
  711. }
  712. declare module BABYLON {
  713. /**
  714. * Class used to store data that will be store in GPU memory
  715. */
  716. export class Buffer {
  717. private _engine;
  718. private _buffer;
  719. /** @hidden */ private _data: Nullable<DataArray>;
  720. private _updatable;
  721. private _instanced;
  722. /**
  723. * Gets the byte stride.
  724. */
  725. readonly byteStride: number;
  726. /**
  727. * Constructor
  728. * @param engine the engine
  729. * @param data the data to use for this buffer
  730. * @param updatable whether the data is updatable
  731. * @param stride the stride (optional)
  732. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  733. * @param instanced whether the buffer is instanced (optional)
  734. * @param useBytes set to true if the stride in in bytes (optional)
  735. */
  736. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  737. /**
  738. * Create a new VertexBuffer based on the current buffer
  739. * @param kind defines the vertex buffer kind (position, normal, etc.)
  740. * @param offset defines offset in the buffer (0 by default)
  741. * @param size defines the size in floats of attributes (position is 3 for instance)
  742. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  743. * @param instanced defines if the vertex buffer contains indexed data
  744. * @param useBytes defines if the offset and stride are in bytes
  745. * @returns the new vertex buffer
  746. */
  747. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  748. /**
  749. * Gets a boolean indicating if the Buffer is updatable?
  750. * @returns true if the buffer is updatable
  751. */
  752. isUpdatable(): boolean;
  753. /**
  754. * Gets current buffer's data
  755. * @returns a DataArray or null
  756. */
  757. getData(): Nullable<DataArray>;
  758. /**
  759. * Gets underlying native buffer
  760. * @returns underlying native buffer
  761. */
  762. getBuffer(): Nullable<DataBuffer>;
  763. /**
  764. * Gets the stride in float32 units (i.e. byte stride / 4).
  765. * May not be an integer if the byte stride is not divisible by 4.
  766. * DEPRECATED. Use byteStride instead.
  767. * @returns the stride in float32 units
  768. */
  769. getStrideSize(): number;
  770. /**
  771. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  772. * @param data defines the data to store
  773. */
  774. create(data?: Nullable<DataArray>): void;
  775. /** @hidden */ private _rebuild(): void;
  776. /**
  777. * Update current buffer data
  778. * @param data defines the data to store
  779. */
  780. update(data: DataArray): void;
  781. /**
  782. * Updates the data directly.
  783. * @param data the new data
  784. * @param offset the new offset
  785. * @param vertexCount the vertex count (optional)
  786. * @param useBytes set to true if the offset is in bytes
  787. */
  788. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  789. /**
  790. * Release all resources
  791. */
  792. dispose(): void;
  793. }
  794. /**
  795. * Specialized buffer used to store vertex data
  796. */
  797. export class VertexBuffer {
  798. /** @hidden */ private _buffer: Buffer;
  799. private _kind;
  800. private _size;
  801. private _ownsBuffer;
  802. private _instanced;
  803. private _instanceDivisor;
  804. /**
  805. * The byte type.
  806. */
  807. static readonly BYTE: number;
  808. /**
  809. * The unsigned byte type.
  810. */
  811. static readonly UNSIGNED_BYTE: number;
  812. /**
  813. * The short type.
  814. */
  815. static readonly SHORT: number;
  816. /**
  817. * The unsigned short type.
  818. */
  819. static readonly UNSIGNED_SHORT: number;
  820. /**
  821. * The integer type.
  822. */
  823. static readonly INT: number;
  824. /**
  825. * The unsigned integer type.
  826. */
  827. static readonly UNSIGNED_INT: number;
  828. /**
  829. * The float type.
  830. */
  831. static readonly FLOAT: number;
  832. /**
  833. * Gets or sets the instance divisor when in instanced mode
  834. */
  835. instanceDivisor: number;
  836. /**
  837. * Gets the byte stride.
  838. */
  839. readonly byteStride: number;
  840. /**
  841. * Gets the byte offset.
  842. */
  843. readonly byteOffset: number;
  844. /**
  845. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  846. */
  847. readonly normalized: boolean;
  848. /**
  849. * Gets the data type of each component in the array.
  850. */
  851. readonly type: number;
  852. /**
  853. * Constructor
  854. * @param engine the engine
  855. * @param data the data to use for this vertex buffer
  856. * @param kind the vertex buffer kind
  857. * @param updatable whether the data is updatable
  858. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  859. * @param stride the stride (optional)
  860. * @param instanced whether the buffer is instanced (optional)
  861. * @param offset the offset of the data (optional)
  862. * @param size the number of components (optional)
  863. * @param type the type of the component (optional)
  864. * @param normalized whether the data contains normalized data (optional)
  865. * @param useBytes set to true if stride and offset are in bytes (optional)
  866. */
  867. 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);
  868. /** @hidden */ private _rebuild(): void;
  869. /**
  870. * Returns the kind of the VertexBuffer (string)
  871. * @returns a string
  872. */
  873. getKind(): string;
  874. /**
  875. * Gets a boolean indicating if the VertexBuffer is updatable?
  876. * @returns true if the buffer is updatable
  877. */
  878. isUpdatable(): boolean;
  879. /**
  880. * Gets current buffer's data
  881. * @returns a DataArray or null
  882. */
  883. getData(): Nullable<DataArray>;
  884. /**
  885. * Gets underlying native buffer
  886. * @returns underlying native buffer
  887. */
  888. getBuffer(): Nullable<DataBuffer>;
  889. /**
  890. * Gets the stride in float32 units (i.e. byte stride / 4).
  891. * May not be an integer if the byte stride is not divisible by 4.
  892. * DEPRECATED. Use byteStride instead.
  893. * @returns the stride in float32 units
  894. */
  895. getStrideSize(): number;
  896. /**
  897. * Returns the offset as a multiple of the type byte length.
  898. * DEPRECATED. Use byteOffset instead.
  899. * @returns the offset in bytes
  900. */
  901. getOffset(): number;
  902. /**
  903. * Returns the number of components per vertex attribute (integer)
  904. * @returns the size in float
  905. */
  906. getSize(): number;
  907. /**
  908. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  909. * @returns true if this buffer is instanced
  910. */
  911. getIsInstanced(): boolean;
  912. /**
  913. * Returns the instancing divisor, zero for non-instanced (integer).
  914. * @returns a number
  915. */
  916. getInstanceDivisor(): number;
  917. /**
  918. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  919. * @param data defines the data to store
  920. */
  921. create(data?: DataArray): void;
  922. /**
  923. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  924. * This function will create a new buffer if the current one is not updatable
  925. * @param data defines the data to store
  926. */
  927. update(data: DataArray): void;
  928. /**
  929. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  930. * Returns the directly updated WebGLBuffer.
  931. * @param data the new data
  932. * @param offset the new offset
  933. * @param useBytes set to true if the offset is in bytes
  934. */
  935. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  936. /**
  937. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  938. */
  939. dispose(): void;
  940. /**
  941. * Enumerates each value of this vertex buffer as numbers.
  942. * @param count the number of values to enumerate
  943. * @param callback the callback function called for each value
  944. */
  945. forEach(count: number, callback: (value: number, index: number) => void): void;
  946. /**
  947. * Positions
  948. */
  949. static readonly PositionKind: string;
  950. /**
  951. * Normals
  952. */
  953. static readonly NormalKind: string;
  954. /**
  955. * Tangents
  956. */
  957. static readonly TangentKind: string;
  958. /**
  959. * Texture coordinates
  960. */
  961. static readonly UVKind: string;
  962. /**
  963. * Texture coordinates 2
  964. */
  965. static readonly UV2Kind: string;
  966. /**
  967. * Texture coordinates 3
  968. */
  969. static readonly UV3Kind: string;
  970. /**
  971. * Texture coordinates 4
  972. */
  973. static readonly UV4Kind: string;
  974. /**
  975. * Texture coordinates 5
  976. */
  977. static readonly UV5Kind: string;
  978. /**
  979. * Texture coordinates 6
  980. */
  981. static readonly UV6Kind: string;
  982. /**
  983. * Colors
  984. */
  985. static readonly ColorKind: string;
  986. /**
  987. * Matrix indices (for bones)
  988. */
  989. static readonly MatricesIndicesKind: string;
  990. /**
  991. * Matrix weights (for bones)
  992. */
  993. static readonly MatricesWeightsKind: string;
  994. /**
  995. * Additional matrix indices (for bones)
  996. */
  997. static readonly MatricesIndicesExtraKind: string;
  998. /**
  999. * Additional matrix weights (for bones)
  1000. */
  1001. static readonly MatricesWeightsExtraKind: string;
  1002. /**
  1003. * Deduces the stride given a kind.
  1004. * @param kind The kind string to deduce
  1005. * @returns The deduced stride
  1006. */
  1007. static DeduceStride(kind: string): number;
  1008. /**
  1009. * Gets the byte length of the given type.
  1010. * @param type the type
  1011. * @returns the number of bytes
  1012. */
  1013. static GetTypeByteLength(type: number): number;
  1014. /**
  1015. * Enumerates each value of the given parameters as numbers.
  1016. * @param data the data to enumerate
  1017. * @param byteOffset the byte offset of the data
  1018. * @param byteStride the byte stride of the data
  1019. * @param componentCount the number of components per element
  1020. * @param componentType the type of the component
  1021. * @param count the number of values to enumerate
  1022. * @param normalized whether the data is normalized
  1023. * @param callback the callback function called for each value
  1024. */
  1025. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1026. private static _GetFloatValue;
  1027. }
  1028. }
  1029. declare module BABYLON {
  1030. /**
  1031. * Scalar computation library
  1032. */
  1033. export class Scalar {
  1034. /**
  1035. * Two pi constants convenient for computation.
  1036. */
  1037. static TwoPi: number;
  1038. /**
  1039. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1040. * @param a number
  1041. * @param b number
  1042. * @param epsilon (default = 1.401298E-45)
  1043. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1044. */
  1045. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1046. /**
  1047. * Returns a string : the upper case translation of the number i to hexadecimal.
  1048. * @param i number
  1049. * @returns the upper case translation of the number i to hexadecimal.
  1050. */
  1051. static ToHex(i: number): string;
  1052. /**
  1053. * Returns -1 if value is negative and +1 is value is positive.
  1054. * @param value the value
  1055. * @returns the value itself if it's equal to zero.
  1056. */
  1057. static Sign(value: number): number;
  1058. /**
  1059. * Returns the value itself if it's between min and max.
  1060. * Returns min if the value is lower than min.
  1061. * Returns max if the value is greater than max.
  1062. * @param value the value to clmap
  1063. * @param min the min value to clamp to (default: 0)
  1064. * @param max the max value to clamp to (default: 1)
  1065. * @returns the clamped value
  1066. */
  1067. static Clamp(value: number, min?: number, max?: number): number;
  1068. /**
  1069. * the log2 of value.
  1070. * @param value the value to compute log2 of
  1071. * @returns the log2 of value.
  1072. */
  1073. static Log2(value: number): number;
  1074. /**
  1075. * Loops the value, so that it is never larger than length and never smaller than 0.
  1076. *
  1077. * This is similar to the modulo operator but it works with floating point numbers.
  1078. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1079. * With t = 5 and length = 2.5, the result would be 0.0.
  1080. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1081. * @param value the value
  1082. * @param length the length
  1083. * @returns the looped value
  1084. */
  1085. static Repeat(value: number, length: number): number;
  1086. /**
  1087. * Normalize the value between 0.0 and 1.0 using min and max values
  1088. * @param value value to normalize
  1089. * @param min max to normalize between
  1090. * @param max min to normalize between
  1091. * @returns the normalized value
  1092. */
  1093. static Normalize(value: number, min: number, max: number): number;
  1094. /**
  1095. * Denormalize the value from 0.0 and 1.0 using min and max values
  1096. * @param normalized value to denormalize
  1097. * @param min max to denormalize between
  1098. * @param max min to denormalize between
  1099. * @returns the denormalized value
  1100. */
  1101. static Denormalize(normalized: number, min: number, max: number): number;
  1102. /**
  1103. * Calculates the shortest difference between two given angles given in degrees.
  1104. * @param current current angle in degrees
  1105. * @param target target angle in degrees
  1106. * @returns the delta
  1107. */
  1108. static DeltaAngle(current: number, target: number): number;
  1109. /**
  1110. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1111. * @param tx value
  1112. * @param length length
  1113. * @returns The returned value will move back and forth between 0 and length
  1114. */
  1115. static PingPong(tx: number, length: number): number;
  1116. /**
  1117. * Interpolates between min and max with smoothing at the limits.
  1118. *
  1119. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1120. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1121. * @param from from
  1122. * @param to to
  1123. * @param tx value
  1124. * @returns the smooth stepped value
  1125. */
  1126. static SmoothStep(from: number, to: number, tx: number): number;
  1127. /**
  1128. * Moves a value current towards target.
  1129. *
  1130. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1131. * Negative values of maxDelta pushes the value away from target.
  1132. * @param current current value
  1133. * @param target target value
  1134. * @param maxDelta max distance to move
  1135. * @returns resulting value
  1136. */
  1137. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1138. /**
  1139. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1140. *
  1141. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1142. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1143. * @param current current value
  1144. * @param target target value
  1145. * @param maxDelta max distance to move
  1146. * @returns resulting angle
  1147. */
  1148. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1149. /**
  1150. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1151. * @param start start value
  1152. * @param end target value
  1153. * @param amount amount to lerp between
  1154. * @returns the lerped value
  1155. */
  1156. static Lerp(start: number, end: number, amount: number): number;
  1157. /**
  1158. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1159. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1160. * @param start start value
  1161. * @param end target value
  1162. * @param amount amount to lerp between
  1163. * @returns the lerped value
  1164. */
  1165. static LerpAngle(start: number, end: number, amount: number): number;
  1166. /**
  1167. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1168. * @param a start value
  1169. * @param b target value
  1170. * @param value value between a and b
  1171. * @returns the inverseLerp value
  1172. */
  1173. static InverseLerp(a: number, b: number, value: number): number;
  1174. /**
  1175. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1176. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1177. * @param value1 spline value
  1178. * @param tangent1 spline value
  1179. * @param value2 spline value
  1180. * @param tangent2 spline value
  1181. * @param amount input value
  1182. * @returns hermite result
  1183. */
  1184. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1185. /**
  1186. * Returns a random float number between and min and max values
  1187. * @param min min value of random
  1188. * @param max max value of random
  1189. * @returns random value
  1190. */
  1191. static RandomRange(min: number, max: number): number;
  1192. /**
  1193. * This function returns percentage of a number in a given range.
  1194. *
  1195. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1196. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1197. * @param number to convert to percentage
  1198. * @param min min range
  1199. * @param max max range
  1200. * @returns the percentage
  1201. */
  1202. static RangeToPercent(number: number, min: number, max: number): number;
  1203. /**
  1204. * This function returns number that corresponds to the percentage in a given range.
  1205. *
  1206. * PercentToRange(0.34,0,100) will return 34.
  1207. * @param percent to convert to number
  1208. * @param min min range
  1209. * @param max max range
  1210. * @returns the number
  1211. */
  1212. static PercentToRange(percent: number, min: number, max: number): number;
  1213. /**
  1214. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1215. * @param angle The angle to normalize in radian.
  1216. * @return The converted angle.
  1217. */
  1218. static NormalizeRadians(angle: number): number;
  1219. }
  1220. }
  1221. declare module BABYLON {
  1222. /**
  1223. * Constant used to convert a value to gamma space
  1224. * @ignorenaming
  1225. */
  1226. export const ToGammaSpace: number;
  1227. /**
  1228. * Constant used to convert a value to linear space
  1229. * @ignorenaming
  1230. */
  1231. export const ToLinearSpace = 2.2;
  1232. /**
  1233. * Constant used to define the minimal number value in Babylon.js
  1234. * @ignorenaming
  1235. */
  1236. let Epsilon: number;
  1237. }
  1238. declare module BABYLON {
  1239. /**
  1240. * Class used to represent a viewport on screen
  1241. */
  1242. export class Viewport {
  1243. /** viewport left coordinate */
  1244. x: number;
  1245. /** viewport top coordinate */
  1246. y: number;
  1247. /**viewport width */
  1248. width: number;
  1249. /** viewport height */
  1250. height: number;
  1251. /**
  1252. * Creates a Viewport object located at (x, y) and sized (width, height)
  1253. * @param x defines viewport left coordinate
  1254. * @param y defines viewport top coordinate
  1255. * @param width defines the viewport width
  1256. * @param height defines the viewport height
  1257. */
  1258. constructor(
  1259. /** viewport left coordinate */
  1260. x: number,
  1261. /** viewport top coordinate */
  1262. y: number,
  1263. /**viewport width */
  1264. width: number,
  1265. /** viewport height */
  1266. height: number);
  1267. /**
  1268. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1269. * @param renderWidth defines the rendering width
  1270. * @param renderHeight defines the rendering height
  1271. * @returns a new Viewport
  1272. */
  1273. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1274. /**
  1275. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1276. * @param renderWidth defines the rendering width
  1277. * @param renderHeight defines the rendering height
  1278. * @param ref defines the target viewport
  1279. * @returns the current viewport
  1280. */
  1281. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1282. /**
  1283. * Returns a new Viewport copied from the current one
  1284. * @returns a new Viewport
  1285. */
  1286. clone(): Viewport;
  1287. }
  1288. }
  1289. declare module BABYLON {
  1290. /**
  1291. * Class containing a set of static utilities functions for arrays.
  1292. */
  1293. export class ArrayTools {
  1294. /**
  1295. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1296. * @param size the number of element to construct and put in the array
  1297. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1298. * @returns a new array filled with new objects
  1299. */
  1300. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1301. }
  1302. }
  1303. declare module BABYLON {
  1304. /**
  1305. * @hidden
  1306. */
  1307. export interface IColor4Like {
  1308. r: float;
  1309. g: float;
  1310. b: float;
  1311. a: float;
  1312. }
  1313. /**
  1314. * @hidden
  1315. */
  1316. export interface IColor3Like {
  1317. r: float;
  1318. g: float;
  1319. b: float;
  1320. }
  1321. /**
  1322. * @hidden
  1323. */
  1324. export interface IVector4Like {
  1325. x: float;
  1326. y: float;
  1327. z: float;
  1328. w: float;
  1329. }
  1330. /**
  1331. * @hidden
  1332. */
  1333. export interface IVector3Like {
  1334. x: float;
  1335. y: float;
  1336. z: float;
  1337. }
  1338. /**
  1339. * @hidden
  1340. */
  1341. export interface IVector2Like {
  1342. x: float;
  1343. y: float;
  1344. }
  1345. /**
  1346. * @hidden
  1347. */
  1348. export interface IMatrixLike {
  1349. toArray(): DeepImmutable<Float32Array>;
  1350. updateFlag: int;
  1351. }
  1352. /**
  1353. * @hidden
  1354. */
  1355. export interface IViewportLike {
  1356. x: float;
  1357. y: float;
  1358. width: float;
  1359. height: float;
  1360. }
  1361. /**
  1362. * @hidden
  1363. */
  1364. export interface IPlaneLike {
  1365. normal: IVector3Like;
  1366. d: float;
  1367. normalize(): void;
  1368. }
  1369. }
  1370. declare module BABYLON {
  1371. /**
  1372. * Class representing a vector containing 2 coordinates
  1373. */
  1374. export class Vector2 {
  1375. /** defines the first coordinate */
  1376. x: number;
  1377. /** defines the second coordinate */
  1378. y: number;
  1379. /**
  1380. * Creates a new Vector2 from the given x and y coordinates
  1381. * @param x defines the first coordinate
  1382. * @param y defines the second coordinate
  1383. */
  1384. constructor(
  1385. /** defines the first coordinate */
  1386. x?: number,
  1387. /** defines the second coordinate */
  1388. y?: number);
  1389. /**
  1390. * Gets a string with the Vector2 coordinates
  1391. * @returns a string with the Vector2 coordinates
  1392. */
  1393. toString(): string;
  1394. /**
  1395. * Gets class name
  1396. * @returns the string "Vector2"
  1397. */
  1398. getClassName(): string;
  1399. /**
  1400. * Gets current vector hash code
  1401. * @returns the Vector2 hash code as a number
  1402. */
  1403. getHashCode(): number;
  1404. /**
  1405. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1406. * @param array defines the source array
  1407. * @param index defines the offset in source array
  1408. * @returns the current Vector2
  1409. */
  1410. toArray(array: FloatArray, index?: number): Vector2;
  1411. /**
  1412. * Copy the current vector to an array
  1413. * @returns a new array with 2 elements: the Vector2 coordinates.
  1414. */
  1415. asArray(): number[];
  1416. /**
  1417. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1418. * @param source defines the source Vector2
  1419. * @returns the current updated Vector2
  1420. */
  1421. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1422. /**
  1423. * Sets the Vector2 coordinates with the given floats
  1424. * @param x defines the first coordinate
  1425. * @param y defines the second coordinate
  1426. * @returns the current updated Vector2
  1427. */
  1428. copyFromFloats(x: number, y: number): Vector2;
  1429. /**
  1430. * Sets the Vector2 coordinates with the given floats
  1431. * @param x defines the first coordinate
  1432. * @param y defines the second coordinate
  1433. * @returns the current updated Vector2
  1434. */
  1435. set(x: number, y: number): Vector2;
  1436. /**
  1437. * Add another vector with the current one
  1438. * @param otherVector defines the other vector
  1439. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1440. */
  1441. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1442. /**
  1443. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1444. * @param otherVector defines the other vector
  1445. * @param result defines the target vector
  1446. * @returns the unmodified current Vector2
  1447. */
  1448. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1449. /**
  1450. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1451. * @param otherVector defines the other vector
  1452. * @returns the current updated Vector2
  1453. */
  1454. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1455. /**
  1456. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1457. * @param otherVector defines the other vector
  1458. * @returns a new Vector2
  1459. */
  1460. addVector3(otherVector: Vector3): Vector2;
  1461. /**
  1462. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1463. * @param otherVector defines the other vector
  1464. * @returns a new Vector2
  1465. */
  1466. subtract(otherVector: Vector2): Vector2;
  1467. /**
  1468. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1469. * @param otherVector defines the other vector
  1470. * @param result defines the target vector
  1471. * @returns the unmodified current Vector2
  1472. */
  1473. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1474. /**
  1475. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1476. * @param otherVector defines the other vector
  1477. * @returns the current updated Vector2
  1478. */
  1479. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1480. /**
  1481. * Multiplies in place the current Vector2 coordinates by the given ones
  1482. * @param otherVector defines the other vector
  1483. * @returns the current updated Vector2
  1484. */
  1485. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1486. /**
  1487. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1488. * @param otherVector defines the other vector
  1489. * @returns a new Vector2
  1490. */
  1491. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1492. /**
  1493. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1494. * @param otherVector defines the other vector
  1495. * @param result defines the target vector
  1496. * @returns the unmodified current Vector2
  1497. */
  1498. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1499. /**
  1500. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1501. * @param x defines the first coordinate
  1502. * @param y defines the second coordinate
  1503. * @returns a new Vector2
  1504. */
  1505. multiplyByFloats(x: number, y: number): Vector2;
  1506. /**
  1507. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1508. * @param otherVector defines the other vector
  1509. * @returns a new Vector2
  1510. */
  1511. divide(otherVector: Vector2): Vector2;
  1512. /**
  1513. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1514. * @param otherVector defines the other vector
  1515. * @param result defines the target vector
  1516. * @returns the unmodified current Vector2
  1517. */
  1518. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1519. /**
  1520. * Divides the current Vector2 coordinates by the given ones
  1521. * @param otherVector defines the other vector
  1522. * @returns the current updated Vector2
  1523. */
  1524. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1525. /**
  1526. * Gets a new Vector2 with current Vector2 negated coordinates
  1527. * @returns a new Vector2
  1528. */
  1529. negate(): Vector2;
  1530. /**
  1531. * Multiply the Vector2 coordinates by scale
  1532. * @param scale defines the scaling factor
  1533. * @returns the current updated Vector2
  1534. */
  1535. scaleInPlace(scale: number): Vector2;
  1536. /**
  1537. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1538. * @param scale defines the scaling factor
  1539. * @returns a new Vector2
  1540. */
  1541. scale(scale: number): Vector2;
  1542. /**
  1543. * Scale the current Vector2 values by a factor to a given Vector2
  1544. * @param scale defines the scale factor
  1545. * @param result defines the Vector2 object where to store the result
  1546. * @returns the unmodified current Vector2
  1547. */
  1548. scaleToRef(scale: number, result: Vector2): Vector2;
  1549. /**
  1550. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1551. * @param scale defines the scale factor
  1552. * @param result defines the Vector2 object where to store the result
  1553. * @returns the unmodified current Vector2
  1554. */
  1555. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1556. /**
  1557. * Gets a boolean if two vectors are equals
  1558. * @param otherVector defines the other vector
  1559. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1560. */
  1561. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1562. /**
  1563. * Gets a boolean if two vectors are equals (using an epsilon value)
  1564. * @param otherVector defines the other vector
  1565. * @param epsilon defines the minimal distance to consider equality
  1566. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1567. */
  1568. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1569. /**
  1570. * Gets a new Vector2 from current Vector2 floored values
  1571. * @returns a new Vector2
  1572. */
  1573. floor(): Vector2;
  1574. /**
  1575. * Gets a new Vector2 from current Vector2 floored values
  1576. * @returns a new Vector2
  1577. */
  1578. fract(): Vector2;
  1579. /**
  1580. * Gets the length of the vector
  1581. * @returns the vector length (float)
  1582. */
  1583. length(): number;
  1584. /**
  1585. * Gets the vector squared length
  1586. * @returns the vector squared length (float)
  1587. */
  1588. lengthSquared(): number;
  1589. /**
  1590. * Normalize the vector
  1591. * @returns the current updated Vector2
  1592. */
  1593. normalize(): Vector2;
  1594. /**
  1595. * Gets a new Vector2 copied from the Vector2
  1596. * @returns a new Vector2
  1597. */
  1598. clone(): Vector2;
  1599. /**
  1600. * Gets a new Vector2(0, 0)
  1601. * @returns a new Vector2
  1602. */
  1603. static Zero(): Vector2;
  1604. /**
  1605. * Gets a new Vector2(1, 1)
  1606. * @returns a new Vector2
  1607. */
  1608. static One(): Vector2;
  1609. /**
  1610. * Gets a new Vector2 set from the given index element of the given array
  1611. * @param array defines the data source
  1612. * @param offset defines the offset in the data source
  1613. * @returns a new Vector2
  1614. */
  1615. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1616. /**
  1617. * Sets "result" from the given index element of the given array
  1618. * @param array defines the data source
  1619. * @param offset defines the offset in the data source
  1620. * @param result defines the target vector
  1621. */
  1622. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1623. /**
  1624. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1625. * @param value1 defines 1st point of control
  1626. * @param value2 defines 2nd point of control
  1627. * @param value3 defines 3rd point of control
  1628. * @param value4 defines 4th point of control
  1629. * @param amount defines the interpolation factor
  1630. * @returns a new Vector2
  1631. */
  1632. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1633. /**
  1634. * 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".
  1635. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1636. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1637. * @param value defines the value to clamp
  1638. * @param min defines the lower limit
  1639. * @param max defines the upper limit
  1640. * @returns a new Vector2
  1641. */
  1642. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1643. /**
  1644. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1645. * @param value1 defines the 1st control point
  1646. * @param tangent1 defines the outgoing tangent
  1647. * @param value2 defines the 2nd control point
  1648. * @param tangent2 defines the incoming tangent
  1649. * @param amount defines the interpolation factor
  1650. * @returns a new Vector2
  1651. */
  1652. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1653. /**
  1654. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1655. * @param start defines the start vector
  1656. * @param end defines the end vector
  1657. * @param amount defines the interpolation factor
  1658. * @returns a new Vector2
  1659. */
  1660. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1661. /**
  1662. * Gets the dot product of the vector "left" and the vector "right"
  1663. * @param left defines first vector
  1664. * @param right defines second vector
  1665. * @returns the dot product (float)
  1666. */
  1667. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1668. /**
  1669. * Returns a new Vector2 equal to the normalized given vector
  1670. * @param vector defines the vector to normalize
  1671. * @returns a new Vector2
  1672. */
  1673. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1674. /**
  1675. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1676. * @param left defines 1st vector
  1677. * @param right defines 2nd vector
  1678. * @returns a new Vector2
  1679. */
  1680. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1681. /**
  1682. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1683. * @param left defines 1st vector
  1684. * @param right defines 2nd vector
  1685. * @returns a new Vector2
  1686. */
  1687. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1688. /**
  1689. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1690. * @param vector defines the vector to transform
  1691. * @param transformation defines the matrix to apply
  1692. * @returns a new Vector2
  1693. */
  1694. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1695. /**
  1696. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1697. * @param vector defines the vector to transform
  1698. * @param transformation defines the matrix to apply
  1699. * @param result defines the target vector
  1700. */
  1701. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1702. /**
  1703. * Determines if a given vector is included in a triangle
  1704. * @param p defines the vector to test
  1705. * @param p0 defines 1st triangle point
  1706. * @param p1 defines 2nd triangle point
  1707. * @param p2 defines 3rd triangle point
  1708. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1709. */
  1710. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1711. /**
  1712. * Gets the distance between the vectors "value1" and "value2"
  1713. * @param value1 defines first vector
  1714. * @param value2 defines second vector
  1715. * @returns the distance between vectors
  1716. */
  1717. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1718. /**
  1719. * Returns the squared distance between the vectors "value1" and "value2"
  1720. * @param value1 defines first vector
  1721. * @param value2 defines second vector
  1722. * @returns the squared distance between vectors
  1723. */
  1724. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1725. /**
  1726. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1727. * @param value1 defines first vector
  1728. * @param value2 defines second vector
  1729. * @returns a new Vector2
  1730. */
  1731. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1732. /**
  1733. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1734. * @param p defines the middle point
  1735. * @param segA defines one point of the segment
  1736. * @param segB defines the other point of the segment
  1737. * @returns the shortest distance
  1738. */
  1739. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1740. }
  1741. /**
  1742. * Classed used to store (x,y,z) vector representation
  1743. * A Vector3 is the main object used in 3D geometry
  1744. * It can represent etiher the coordinates of a point the space, either a direction
  1745. * Reminder: js uses a left handed forward facing system
  1746. */
  1747. export class Vector3 {
  1748. /**
  1749. * Defines the first coordinates (on X axis)
  1750. */
  1751. x: number;
  1752. /**
  1753. * Defines the second coordinates (on Y axis)
  1754. */
  1755. y: number;
  1756. /**
  1757. * Defines the third coordinates (on Z axis)
  1758. */
  1759. z: number;
  1760. private static _UpReadOnly;
  1761. private static _ZeroReadOnly;
  1762. /**
  1763. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1764. * @param x defines the first coordinates (on X axis)
  1765. * @param y defines the second coordinates (on Y axis)
  1766. * @param z defines the third coordinates (on Z axis)
  1767. */
  1768. constructor(
  1769. /**
  1770. * Defines the first coordinates (on X axis)
  1771. */
  1772. x?: number,
  1773. /**
  1774. * Defines the second coordinates (on Y axis)
  1775. */
  1776. y?: number,
  1777. /**
  1778. * Defines the third coordinates (on Z axis)
  1779. */
  1780. z?: number);
  1781. /**
  1782. * Creates a string representation of the Vector3
  1783. * @returns a string with the Vector3 coordinates.
  1784. */
  1785. toString(): string;
  1786. /**
  1787. * Gets the class name
  1788. * @returns the string "Vector3"
  1789. */
  1790. getClassName(): string;
  1791. /**
  1792. * Creates the Vector3 hash code
  1793. * @returns a number which tends to be unique between Vector3 instances
  1794. */
  1795. getHashCode(): number;
  1796. /**
  1797. * Creates an array containing three elements : the coordinates of the Vector3
  1798. * @returns a new array of numbers
  1799. */
  1800. asArray(): number[];
  1801. /**
  1802. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1803. * @param array defines the destination array
  1804. * @param index defines the offset in the destination array
  1805. * @returns the current Vector3
  1806. */
  1807. toArray(array: FloatArray, index?: number): Vector3;
  1808. /**
  1809. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1810. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1811. */
  1812. toQuaternion(): Quaternion;
  1813. /**
  1814. * Adds the given vector to the current Vector3
  1815. * @param otherVector defines the second operand
  1816. * @returns the current updated Vector3
  1817. */
  1818. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1819. /**
  1820. * Adds the given coordinates to the current Vector3
  1821. * @param x defines the x coordinate of the operand
  1822. * @param y defines the y coordinate of the operand
  1823. * @param z defines the z coordinate of the operand
  1824. * @returns the current updated Vector3
  1825. */
  1826. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1827. /**
  1828. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1829. * @param otherVector defines the second operand
  1830. * @returns the resulting Vector3
  1831. */
  1832. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1833. /**
  1834. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1835. * @param otherVector defines the second operand
  1836. * @param result defines the Vector3 object where to store the result
  1837. * @returns the current Vector3
  1838. */
  1839. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1840. /**
  1841. * Subtract the given vector from the current Vector3
  1842. * @param otherVector defines the second operand
  1843. * @returns the current updated Vector3
  1844. */
  1845. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1846. /**
  1847. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1848. * @param otherVector defines the second operand
  1849. * @returns the resulting Vector3
  1850. */
  1851. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1852. /**
  1853. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1854. * @param otherVector defines the second operand
  1855. * @param result defines the Vector3 object where to store the result
  1856. * @returns the current Vector3
  1857. */
  1858. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1859. /**
  1860. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1861. * @param x defines the x coordinate of the operand
  1862. * @param y defines the y coordinate of the operand
  1863. * @param z defines the z coordinate of the operand
  1864. * @returns the resulting Vector3
  1865. */
  1866. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1867. /**
  1868. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1869. * @param x defines the x coordinate of the operand
  1870. * @param y defines the y coordinate of the operand
  1871. * @param z defines the z coordinate of the operand
  1872. * @param result defines the Vector3 object where to store the result
  1873. * @returns the current Vector3
  1874. */
  1875. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1876. /**
  1877. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1878. * @returns a new Vector3
  1879. */
  1880. negate(): Vector3;
  1881. /**
  1882. * Multiplies the Vector3 coordinates by the float "scale"
  1883. * @param scale defines the multiplier factor
  1884. * @returns the current updated Vector3
  1885. */
  1886. scaleInPlace(scale: number): Vector3;
  1887. /**
  1888. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1889. * @param scale defines the multiplier factor
  1890. * @returns a new Vector3
  1891. */
  1892. scale(scale: number): Vector3;
  1893. /**
  1894. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1895. * @param scale defines the multiplier factor
  1896. * @param result defines the Vector3 object where to store the result
  1897. * @returns the current Vector3
  1898. */
  1899. scaleToRef(scale: number, result: Vector3): Vector3;
  1900. /**
  1901. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1902. * @param scale defines the scale factor
  1903. * @param result defines the Vector3 object where to store the result
  1904. * @returns the unmodified current Vector3
  1905. */
  1906. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1907. /**
  1908. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1909. * @param otherVector defines the second operand
  1910. * @returns true if both vectors are equals
  1911. */
  1912. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1913. /**
  1914. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1915. * @param otherVector defines the second operand
  1916. * @param epsilon defines the minimal distance to define values as equals
  1917. * @returns true if both vectors are distant less than epsilon
  1918. */
  1919. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1920. /**
  1921. * Returns true if the current Vector3 coordinates equals the given floats
  1922. * @param x defines the x coordinate of the operand
  1923. * @param y defines the y coordinate of the operand
  1924. * @param z defines the z coordinate of the operand
  1925. * @returns true if both vectors are equals
  1926. */
  1927. equalsToFloats(x: number, y: number, z: number): boolean;
  1928. /**
  1929. * Multiplies the current Vector3 coordinates by the given ones
  1930. * @param otherVector defines the second operand
  1931. * @returns the current updated Vector3
  1932. */
  1933. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1934. /**
  1935. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1936. * @param otherVector defines the second operand
  1937. * @returns the new Vector3
  1938. */
  1939. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1940. /**
  1941. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1942. * @param otherVector defines the second operand
  1943. * @param result defines the Vector3 object where to store the result
  1944. * @returns the current Vector3
  1945. */
  1946. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1947. /**
  1948. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1949. * @param x defines the x coordinate of the operand
  1950. * @param y defines the y coordinate of the operand
  1951. * @param z defines the z coordinate of the operand
  1952. * @returns the new Vector3
  1953. */
  1954. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1955. /**
  1956. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1957. * @param otherVector defines the second operand
  1958. * @returns the new Vector3
  1959. */
  1960. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1961. /**
  1962. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1963. * @param otherVector defines the second operand
  1964. * @param result defines the Vector3 object where to store the result
  1965. * @returns the current Vector3
  1966. */
  1967. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1968. /**
  1969. * Divides the current Vector3 coordinates by the given ones.
  1970. * @param otherVector defines the second operand
  1971. * @returns the current updated Vector3
  1972. */
  1973. divideInPlace(otherVector: Vector3): Vector3;
  1974. /**
  1975. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1976. * @param other defines the second operand
  1977. * @returns the current updated Vector3
  1978. */
  1979. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1980. /**
  1981. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1982. * @param other defines the second operand
  1983. * @returns the current updated Vector3
  1984. */
  1985. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1986. /**
  1987. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1988. * @param x defines the x coordinate of the operand
  1989. * @param y defines the y coordinate of the operand
  1990. * @param z defines the z coordinate of the operand
  1991. * @returns the current updated Vector3
  1992. */
  1993. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1994. /**
  1995. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1996. * @param x defines the x coordinate of the operand
  1997. * @param y defines the y coordinate of the operand
  1998. * @param z defines the z coordinate of the operand
  1999. * @returns the current updated Vector3
  2000. */
  2001. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2002. /**
  2003. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2004. * Check if is non uniform within a certain amount of decimal places to account for this
  2005. * @param epsilon the amount the values can differ
  2006. * @returns if the the vector is non uniform to a certain number of decimal places
  2007. */
  2008. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2009. /**
  2010. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2011. */
  2012. readonly isNonUniform: boolean;
  2013. /**
  2014. * Gets a new Vector3 from current Vector3 floored values
  2015. * @returns a new Vector3
  2016. */
  2017. floor(): Vector3;
  2018. /**
  2019. * Gets a new Vector3 from current Vector3 floored values
  2020. * @returns a new Vector3
  2021. */
  2022. fract(): Vector3;
  2023. /**
  2024. * Gets the length of the Vector3
  2025. * @returns the length of the Vector3
  2026. */
  2027. length(): number;
  2028. /**
  2029. * Gets the squared length of the Vector3
  2030. * @returns squared length of the Vector3
  2031. */
  2032. lengthSquared(): number;
  2033. /**
  2034. * Normalize the current Vector3.
  2035. * Please note that this is an in place operation.
  2036. * @returns the current updated Vector3
  2037. */
  2038. normalize(): Vector3;
  2039. /**
  2040. * Reorders the x y z properties of the vector in place
  2041. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2042. * @returns the current updated vector
  2043. */
  2044. reorderInPlace(order: string): this;
  2045. /**
  2046. * Rotates the vector around 0,0,0 by a quaternion
  2047. * @param quaternion the rotation quaternion
  2048. * @param result vector to store the result
  2049. * @returns the resulting vector
  2050. */
  2051. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2052. /**
  2053. * Rotates a vector around a given point
  2054. * @param quaternion the rotation quaternion
  2055. * @param point the point to rotate around
  2056. * @param result vector to store the result
  2057. * @returns the resulting vector
  2058. */
  2059. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2060. /**
  2061. * Normalize the current Vector3 with the given input length.
  2062. * Please note that this is an in place operation.
  2063. * @param len the length of the vector
  2064. * @returns the current updated Vector3
  2065. */
  2066. normalizeFromLength(len: number): Vector3;
  2067. /**
  2068. * Normalize the current Vector3 to a new vector
  2069. * @returns the new Vector3
  2070. */
  2071. normalizeToNew(): Vector3;
  2072. /**
  2073. * Normalize the current Vector3 to the reference
  2074. * @param reference define the Vector3 to update
  2075. * @returns the updated Vector3
  2076. */
  2077. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2078. /**
  2079. * Creates a new Vector3 copied from the current Vector3
  2080. * @returns the new Vector3
  2081. */
  2082. clone(): Vector3;
  2083. /**
  2084. * Copies the given vector coordinates to the current Vector3 ones
  2085. * @param source defines the source Vector3
  2086. * @returns the current updated Vector3
  2087. */
  2088. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2089. /**
  2090. * Copies the given floats to the current Vector3 coordinates
  2091. * @param x defines the x coordinate of the operand
  2092. * @param y defines the y coordinate of the operand
  2093. * @param z defines the z coordinate of the operand
  2094. * @returns the current updated Vector3
  2095. */
  2096. copyFromFloats(x: number, y: number, z: number): Vector3;
  2097. /**
  2098. * Copies the given floats to the current Vector3 coordinates
  2099. * @param x defines the x coordinate of the operand
  2100. * @param y defines the y coordinate of the operand
  2101. * @param z defines the z coordinate of the operand
  2102. * @returns the current updated Vector3
  2103. */
  2104. set(x: number, y: number, z: number): Vector3;
  2105. /**
  2106. * Copies the given float to the current Vector3 coordinates
  2107. * @param v defines the x, y and z coordinates of the operand
  2108. * @returns the current updated Vector3
  2109. */
  2110. setAll(v: number): Vector3;
  2111. /**
  2112. * Get the clip factor between two vectors
  2113. * @param vector0 defines the first operand
  2114. * @param vector1 defines the second operand
  2115. * @param axis defines the axis to use
  2116. * @param size defines the size along the axis
  2117. * @returns the clip factor
  2118. */
  2119. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2120. /**
  2121. * Get angle between two vectors
  2122. * @param vector0 angle between vector0 and vector1
  2123. * @param vector1 angle between vector0 and vector1
  2124. * @param normal direction of the normal
  2125. * @return the angle between vector0 and vector1
  2126. */
  2127. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2128. /**
  2129. * Returns a new Vector3 set from the index "offset" of the given array
  2130. * @param array defines the source array
  2131. * @param offset defines the offset in the source array
  2132. * @returns the new Vector3
  2133. */
  2134. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2135. /**
  2136. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2137. * This function is deprecated. Use FromArray instead
  2138. * @param array defines the source array
  2139. * @param offset defines the offset in the source array
  2140. * @returns the new Vector3
  2141. */
  2142. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2143. /**
  2144. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2145. * @param array defines the source array
  2146. * @param offset defines the offset in the source array
  2147. * @param result defines the Vector3 where to store the result
  2148. */
  2149. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2150. /**
  2151. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2152. * This function is deprecated. Use FromArrayToRef instead.
  2153. * @param array defines the source array
  2154. * @param offset defines the offset in the source array
  2155. * @param result defines the Vector3 where to store the result
  2156. */
  2157. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2158. /**
  2159. * Sets the given vector "result" with the given floats.
  2160. * @param x defines the x coordinate of the source
  2161. * @param y defines the y coordinate of the source
  2162. * @param z defines the z coordinate of the source
  2163. * @param result defines the Vector3 where to store the result
  2164. */
  2165. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2166. /**
  2167. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2168. * @returns a new empty Vector3
  2169. */
  2170. static Zero(): Vector3;
  2171. /**
  2172. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2173. * @returns a new unit Vector3
  2174. */
  2175. static One(): Vector3;
  2176. /**
  2177. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2178. * @returns a new up Vector3
  2179. */
  2180. static Up(): Vector3;
  2181. /**
  2182. * Gets a up Vector3 that must not be updated
  2183. */
  2184. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2185. /**
  2186. * Gets a zero Vector3 that must not be updated
  2187. */
  2188. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2189. /**
  2190. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2191. * @returns a new down Vector3
  2192. */
  2193. static Down(): Vector3;
  2194. /**
  2195. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2196. * @returns a new forward Vector3
  2197. */
  2198. static Forward(): Vector3;
  2199. /**
  2200. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2201. * @returns a new forward Vector3
  2202. */
  2203. static Backward(): Vector3;
  2204. /**
  2205. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2206. * @returns a new right Vector3
  2207. */
  2208. static Right(): Vector3;
  2209. /**
  2210. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2211. * @returns a new left Vector3
  2212. */
  2213. static Left(): Vector3;
  2214. /**
  2215. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2216. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2217. * @param vector defines the Vector3 to transform
  2218. * @param transformation defines the transformation matrix
  2219. * @returns the transformed Vector3
  2220. */
  2221. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2222. /**
  2223. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2224. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2225. * @param vector defines the Vector3 to transform
  2226. * @param transformation defines the transformation matrix
  2227. * @param result defines the Vector3 where to store the result
  2228. */
  2229. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2230. /**
  2231. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2232. * This method computes tranformed coordinates only, not transformed direction vectors
  2233. * @param x define the x coordinate of the source vector
  2234. * @param y define the y coordinate of the source vector
  2235. * @param z define the z coordinate of the source vector
  2236. * @param transformation defines the transformation matrix
  2237. * @param result defines the Vector3 where to store the result
  2238. */
  2239. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2240. /**
  2241. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2242. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2243. * @param vector defines the Vector3 to transform
  2244. * @param transformation defines the transformation matrix
  2245. * @returns the new Vector3
  2246. */
  2247. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2248. /**
  2249. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2250. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2251. * @param vector defines the Vector3 to transform
  2252. * @param transformation defines the transformation matrix
  2253. * @param result defines the Vector3 where to store the result
  2254. */
  2255. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2256. /**
  2257. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2258. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2259. * @param x define the x coordinate of the source vector
  2260. * @param y define the y coordinate of the source vector
  2261. * @param z define the z coordinate of the source vector
  2262. * @param transformation defines the transformation matrix
  2263. * @param result defines the Vector3 where to store the result
  2264. */
  2265. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2266. /**
  2267. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2268. * @param value1 defines the first control point
  2269. * @param value2 defines the second control point
  2270. * @param value3 defines the third control point
  2271. * @param value4 defines the fourth control point
  2272. * @param amount defines the amount on the spline to use
  2273. * @returns the new Vector3
  2274. */
  2275. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2276. /**
  2277. * 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"
  2278. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2279. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2280. * @param value defines the current value
  2281. * @param min defines the lower range value
  2282. * @param max defines the upper range value
  2283. * @returns the new Vector3
  2284. */
  2285. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2286. /**
  2287. * 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"
  2288. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2289. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2290. * @param value defines the current value
  2291. * @param min defines the lower range value
  2292. * @param max defines the upper range value
  2293. * @param result defines the Vector3 where to store the result
  2294. */
  2295. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2296. /**
  2297. * Checks if a given vector is inside a specific range
  2298. * @param v defines the vector to test
  2299. * @param min defines the minimum range
  2300. * @param max defines the maximum range
  2301. */
  2302. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2303. /**
  2304. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2305. * @param value1 defines the first control point
  2306. * @param tangent1 defines the first tangent vector
  2307. * @param value2 defines the second control point
  2308. * @param tangent2 defines the second tangent vector
  2309. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2310. * @returns the new Vector3
  2311. */
  2312. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2313. /**
  2314. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2315. * @param start defines the start value
  2316. * @param end defines the end value
  2317. * @param amount max defines amount between both (between 0 and 1)
  2318. * @returns the new Vector3
  2319. */
  2320. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2321. /**
  2322. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2323. * @param start defines the start value
  2324. * @param end defines the end value
  2325. * @param amount max defines amount between both (between 0 and 1)
  2326. * @param result defines the Vector3 where to store the result
  2327. */
  2328. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2329. /**
  2330. * Returns the dot product (float) between the vectors "left" and "right"
  2331. * @param left defines the left operand
  2332. * @param right defines the right operand
  2333. * @returns the dot product
  2334. */
  2335. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2336. /**
  2337. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2338. * The cross product is then orthogonal to both "left" and "right"
  2339. * @param left defines the left operand
  2340. * @param right defines the right operand
  2341. * @returns the cross product
  2342. */
  2343. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2344. /**
  2345. * Sets the given vector "result" with the cross product of "left" and "right"
  2346. * The cross product is then orthogonal to both "left" and "right"
  2347. * @param left defines the left operand
  2348. * @param right defines the right operand
  2349. * @param result defines the Vector3 where to store the result
  2350. */
  2351. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2352. /**
  2353. * Returns a new Vector3 as the normalization of the given vector
  2354. * @param vector defines the Vector3 to normalize
  2355. * @returns the new Vector3
  2356. */
  2357. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2358. /**
  2359. * Sets the given vector "result" with the normalization of the given first vector
  2360. * @param vector defines the Vector3 to normalize
  2361. * @param result defines the Vector3 where to store the result
  2362. */
  2363. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2364. /**
  2365. * Project a Vector3 onto screen space
  2366. * @param vector defines the Vector3 to project
  2367. * @param world defines the world matrix to use
  2368. * @param transform defines the transform (view x projection) matrix to use
  2369. * @param viewport defines the screen viewport to use
  2370. * @returns the new Vector3
  2371. */
  2372. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2373. /** @hidden */ private static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2374. /**
  2375. * Unproject from screen space to object space
  2376. * @param source defines the screen space Vector3 to use
  2377. * @param viewportWidth defines the current width of the viewport
  2378. * @param viewportHeight defines the current height of the viewport
  2379. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2380. * @param transform defines the transform (view x projection) matrix to use
  2381. * @returns the new Vector3
  2382. */
  2383. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2384. /**
  2385. * Unproject from screen space to object space
  2386. * @param source defines the screen space Vector3 to use
  2387. * @param viewportWidth defines the current width of the viewport
  2388. * @param viewportHeight defines the current height of the viewport
  2389. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2390. * @param view defines the view matrix to use
  2391. * @param projection defines the projection matrix to use
  2392. * @returns the new Vector3
  2393. */
  2394. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2395. /**
  2396. * Unproject from screen space to object space
  2397. * @param source defines the screen space Vector3 to use
  2398. * @param viewportWidth defines the current width of the viewport
  2399. * @param viewportHeight defines the current height of the viewport
  2400. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2401. * @param view defines the view matrix to use
  2402. * @param projection defines the projection matrix to use
  2403. * @param result defines the Vector3 where to store the result
  2404. */
  2405. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2406. /**
  2407. * Unproject from screen space to object space
  2408. * @param sourceX defines the screen space x coordinate to use
  2409. * @param sourceY defines the screen space y coordinate to use
  2410. * @param sourceZ defines the screen space z coordinate to use
  2411. * @param viewportWidth defines the current width of the viewport
  2412. * @param viewportHeight defines the current height of the viewport
  2413. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2414. * @param view defines the view matrix to use
  2415. * @param projection defines the projection matrix to use
  2416. * @param result defines the Vector3 where to store the result
  2417. */
  2418. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2419. /**
  2420. * Gets the minimal coordinate values between two Vector3
  2421. * @param left defines the first operand
  2422. * @param right defines the second operand
  2423. * @returns the new Vector3
  2424. */
  2425. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2426. /**
  2427. * Gets the maximal coordinate values between two Vector3
  2428. * @param left defines the first operand
  2429. * @param right defines the second operand
  2430. * @returns the new Vector3
  2431. */
  2432. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2433. /**
  2434. * Returns the distance between the vectors "value1" and "value2"
  2435. * @param value1 defines the first operand
  2436. * @param value2 defines the second operand
  2437. * @returns the distance
  2438. */
  2439. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2440. /**
  2441. * Returns the squared distance between the vectors "value1" and "value2"
  2442. * @param value1 defines the first operand
  2443. * @param value2 defines the second operand
  2444. * @returns the squared distance
  2445. */
  2446. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2447. /**
  2448. * Returns a new Vector3 located at the center between "value1" and "value2"
  2449. * @param value1 defines the first operand
  2450. * @param value2 defines the second operand
  2451. * @returns the new Vector3
  2452. */
  2453. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2454. /**
  2455. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2456. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2457. * to something in order to rotate it from its local system to the given target system
  2458. * Note: axis1, axis2 and axis3 are normalized during this operation
  2459. * @param axis1 defines the first axis
  2460. * @param axis2 defines the second axis
  2461. * @param axis3 defines the third axis
  2462. * @returns a new Vector3
  2463. */
  2464. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2465. /**
  2466. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2467. * @param axis1 defines the first axis
  2468. * @param axis2 defines the second axis
  2469. * @param axis3 defines the third axis
  2470. * @param ref defines the Vector3 where to store the result
  2471. */
  2472. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2473. }
  2474. /**
  2475. * Vector4 class created for EulerAngle class conversion to Quaternion
  2476. */
  2477. export class Vector4 {
  2478. /** x value of the vector */
  2479. x: number;
  2480. /** y value of the vector */
  2481. y: number;
  2482. /** z value of the vector */
  2483. z: number;
  2484. /** w value of the vector */
  2485. w: number;
  2486. /**
  2487. * Creates a Vector4 object from the given floats.
  2488. * @param x x value of the vector
  2489. * @param y y value of the vector
  2490. * @param z z value of the vector
  2491. * @param w w value of the vector
  2492. */
  2493. constructor(
  2494. /** x value of the vector */
  2495. x: number,
  2496. /** y value of the vector */
  2497. y: number,
  2498. /** z value of the vector */
  2499. z: number,
  2500. /** w value of the vector */
  2501. w: number);
  2502. /**
  2503. * Returns the string with the Vector4 coordinates.
  2504. * @returns a string containing all the vector values
  2505. */
  2506. toString(): string;
  2507. /**
  2508. * Returns the string "Vector4".
  2509. * @returns "Vector4"
  2510. */
  2511. getClassName(): string;
  2512. /**
  2513. * Returns the Vector4 hash code.
  2514. * @returns a unique hash code
  2515. */
  2516. getHashCode(): number;
  2517. /**
  2518. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2519. * @returns the resulting array
  2520. */
  2521. asArray(): number[];
  2522. /**
  2523. * Populates the given array from the given index with the Vector4 coordinates.
  2524. * @param array array to populate
  2525. * @param index index of the array to start at (default: 0)
  2526. * @returns the Vector4.
  2527. */
  2528. toArray(array: FloatArray, index?: number): Vector4;
  2529. /**
  2530. * Adds the given vector to the current Vector4.
  2531. * @param otherVector the vector to add
  2532. * @returns the updated Vector4.
  2533. */
  2534. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2535. /**
  2536. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2537. * @param otherVector the vector to add
  2538. * @returns the resulting vector
  2539. */
  2540. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2541. /**
  2542. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2543. * @param otherVector the vector to add
  2544. * @param result the vector to store the result
  2545. * @returns the current Vector4.
  2546. */
  2547. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2548. /**
  2549. * Subtract in place the given vector from the current Vector4.
  2550. * @param otherVector the vector to subtract
  2551. * @returns the updated Vector4.
  2552. */
  2553. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2554. /**
  2555. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2556. * @param otherVector the vector to add
  2557. * @returns the new vector with the result
  2558. */
  2559. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2560. /**
  2561. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2562. * @param otherVector the vector to subtract
  2563. * @param result the vector to store the result
  2564. * @returns the current Vector4.
  2565. */
  2566. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2567. /**
  2568. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2569. */
  2570. /**
  2571. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2572. * @param x value to subtract
  2573. * @param y value to subtract
  2574. * @param z value to subtract
  2575. * @param w value to subtract
  2576. * @returns new vector containing the result
  2577. */
  2578. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2579. /**
  2580. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2581. * @param x value to subtract
  2582. * @param y value to subtract
  2583. * @param z value to subtract
  2584. * @param w value to subtract
  2585. * @param result the vector to store the result in
  2586. * @returns the current Vector4.
  2587. */
  2588. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2589. /**
  2590. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2591. * @returns a new vector with the negated values
  2592. */
  2593. negate(): Vector4;
  2594. /**
  2595. * Multiplies the current Vector4 coordinates by scale (float).
  2596. * @param scale the number to scale with
  2597. * @returns the updated Vector4.
  2598. */
  2599. scaleInPlace(scale: number): Vector4;
  2600. /**
  2601. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2602. * @param scale the number to scale with
  2603. * @returns a new vector with the result
  2604. */
  2605. scale(scale: number): Vector4;
  2606. /**
  2607. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2608. * @param scale the number to scale with
  2609. * @param result a vector to store the result in
  2610. * @returns the current Vector4.
  2611. */
  2612. scaleToRef(scale: number, result: Vector4): Vector4;
  2613. /**
  2614. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2615. * @param scale defines the scale factor
  2616. * @param result defines the Vector4 object where to store the result
  2617. * @returns the unmodified current Vector4
  2618. */
  2619. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2620. /**
  2621. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2622. * @param otherVector the vector to compare against
  2623. * @returns true if they are equal
  2624. */
  2625. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2626. /**
  2627. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2628. * @param otherVector vector to compare against
  2629. * @param epsilon (Default: very small number)
  2630. * @returns true if they are equal
  2631. */
  2632. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2633. /**
  2634. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2635. * @param x x value to compare against
  2636. * @param y y value to compare against
  2637. * @param z z value to compare against
  2638. * @param w w value to compare against
  2639. * @returns true if equal
  2640. */
  2641. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2642. /**
  2643. * Multiplies in place the current Vector4 by the given one.
  2644. * @param otherVector vector to multiple with
  2645. * @returns the updated Vector4.
  2646. */
  2647. multiplyInPlace(otherVector: Vector4): Vector4;
  2648. /**
  2649. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2650. * @param otherVector vector to multiple with
  2651. * @returns resulting new vector
  2652. */
  2653. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2654. /**
  2655. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2656. * @param otherVector vector to multiple with
  2657. * @param result vector to store the result
  2658. * @returns the current Vector4.
  2659. */
  2660. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2661. /**
  2662. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2663. * @param x x value multiply with
  2664. * @param y y value multiply with
  2665. * @param z z value multiply with
  2666. * @param w w value multiply with
  2667. * @returns resulting new vector
  2668. */
  2669. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2670. /**
  2671. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2672. * @param otherVector vector to devide with
  2673. * @returns resulting new vector
  2674. */
  2675. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2676. /**
  2677. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2678. * @param otherVector vector to devide with
  2679. * @param result vector to store the result
  2680. * @returns the current Vector4.
  2681. */
  2682. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2683. /**
  2684. * Divides the current Vector3 coordinates by the given ones.
  2685. * @param otherVector vector to devide with
  2686. * @returns the updated Vector3.
  2687. */
  2688. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2689. /**
  2690. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2691. * @param other defines the second operand
  2692. * @returns the current updated Vector4
  2693. */
  2694. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2695. /**
  2696. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2697. * @param other defines the second operand
  2698. * @returns the current updated Vector4
  2699. */
  2700. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2701. /**
  2702. * Gets a new Vector4 from current Vector4 floored values
  2703. * @returns a new Vector4
  2704. */
  2705. floor(): Vector4;
  2706. /**
  2707. * Gets a new Vector4 from current Vector3 floored values
  2708. * @returns a new Vector4
  2709. */
  2710. fract(): Vector4;
  2711. /**
  2712. * Returns the Vector4 length (float).
  2713. * @returns the length
  2714. */
  2715. length(): number;
  2716. /**
  2717. * Returns the Vector4 squared length (float).
  2718. * @returns the length squared
  2719. */
  2720. lengthSquared(): number;
  2721. /**
  2722. * Normalizes in place the Vector4.
  2723. * @returns the updated Vector4.
  2724. */
  2725. normalize(): Vector4;
  2726. /**
  2727. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2728. * @returns this converted to a new vector3
  2729. */
  2730. toVector3(): Vector3;
  2731. /**
  2732. * Returns a new Vector4 copied from the current one.
  2733. * @returns the new cloned vector
  2734. */
  2735. clone(): Vector4;
  2736. /**
  2737. * Updates the current Vector4 with the given one coordinates.
  2738. * @param source the source vector to copy from
  2739. * @returns the updated Vector4.
  2740. */
  2741. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2742. /**
  2743. * Updates the current Vector4 coordinates with the given floats.
  2744. * @param x float to copy from
  2745. * @param y float to copy from
  2746. * @param z float to copy from
  2747. * @param w float to copy from
  2748. * @returns the updated Vector4.
  2749. */
  2750. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2751. /**
  2752. * Updates the current Vector4 coordinates with the given floats.
  2753. * @param x float to set from
  2754. * @param y float to set from
  2755. * @param z float to set from
  2756. * @param w float to set from
  2757. * @returns the updated Vector4.
  2758. */
  2759. set(x: number, y: number, z: number, w: number): Vector4;
  2760. /**
  2761. * Copies the given float to the current Vector3 coordinates
  2762. * @param v defines the x, y, z and w coordinates of the operand
  2763. * @returns the current updated Vector3
  2764. */
  2765. setAll(v: number): Vector4;
  2766. /**
  2767. * Returns a new Vector4 set from the starting index of the given array.
  2768. * @param array the array to pull values from
  2769. * @param offset the offset into the array to start at
  2770. * @returns the new vector
  2771. */
  2772. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2773. /**
  2774. * Updates the given vector "result" from the starting index of the given array.
  2775. * @param array the array to pull values from
  2776. * @param offset the offset into the array to start at
  2777. * @param result the vector to store the result in
  2778. */
  2779. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2780. /**
  2781. * Updates the given vector "result" from the starting index of the given Float32Array.
  2782. * @param array the array to pull values from
  2783. * @param offset the offset into the array to start at
  2784. * @param result the vector to store the result in
  2785. */
  2786. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2787. /**
  2788. * Updates the given vector "result" coordinates from the given floats.
  2789. * @param x float to set from
  2790. * @param y float to set from
  2791. * @param z float to set from
  2792. * @param w float to set from
  2793. * @param result the vector to the floats in
  2794. */
  2795. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2796. /**
  2797. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2798. * @returns the new vector
  2799. */
  2800. static Zero(): Vector4;
  2801. /**
  2802. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2803. * @returns the new vector
  2804. */
  2805. static One(): Vector4;
  2806. /**
  2807. * Returns a new normalized Vector4 from the given one.
  2808. * @param vector the vector to normalize
  2809. * @returns the vector
  2810. */
  2811. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2812. /**
  2813. * Updates the given vector "result" from the normalization of the given one.
  2814. * @param vector the vector to normalize
  2815. * @param result the vector to store the result in
  2816. */
  2817. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2818. /**
  2819. * Returns a vector with the minimum values from the left and right vectors
  2820. * @param left left vector to minimize
  2821. * @param right right vector to minimize
  2822. * @returns a new vector with the minimum of the left and right vector values
  2823. */
  2824. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2825. /**
  2826. * Returns a vector with the maximum values from the left and right vectors
  2827. * @param left left vector to maximize
  2828. * @param right right vector to maximize
  2829. * @returns a new vector with the maximum of the left and right vector values
  2830. */
  2831. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2832. /**
  2833. * Returns the distance (float) between the vectors "value1" and "value2".
  2834. * @param value1 value to calulate the distance between
  2835. * @param value2 value to calulate the distance between
  2836. * @return the distance between the two vectors
  2837. */
  2838. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2839. /**
  2840. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2841. * @param value1 value to calulate the distance between
  2842. * @param value2 value to calulate the distance between
  2843. * @return the distance between the two vectors squared
  2844. */
  2845. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2846. /**
  2847. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2848. * @param value1 value to calulate the center between
  2849. * @param value2 value to calulate the center between
  2850. * @return the center between the two vectors
  2851. */
  2852. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2853. /**
  2854. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2855. * This methods computes transformed normalized direction vectors only.
  2856. * @param vector the vector to transform
  2857. * @param transformation the transformation matrix to apply
  2858. * @returns the new vector
  2859. */
  2860. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2861. /**
  2862. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2863. * This methods computes transformed normalized direction vectors only.
  2864. * @param vector the vector to transform
  2865. * @param transformation the transformation matrix to apply
  2866. * @param result the vector to store the result in
  2867. */
  2868. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2869. /**
  2870. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2871. * This methods computes transformed normalized direction vectors only.
  2872. * @param x value to transform
  2873. * @param y value to transform
  2874. * @param z value to transform
  2875. * @param w value to transform
  2876. * @param transformation the transformation matrix to apply
  2877. * @param result the vector to store the results in
  2878. */
  2879. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2880. /**
  2881. * Creates a new Vector4 from a Vector3
  2882. * @param source defines the source data
  2883. * @param w defines the 4th component (default is 0)
  2884. * @returns a new Vector4
  2885. */
  2886. static FromVector3(source: Vector3, w?: number): Vector4;
  2887. }
  2888. /**
  2889. * Class used to store quaternion data
  2890. * @see https://en.wikipedia.org/wiki/Quaternion
  2891. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2892. */
  2893. export class Quaternion {
  2894. /** defines the first component (0 by default) */
  2895. x: number;
  2896. /** defines the second component (0 by default) */
  2897. y: number;
  2898. /** defines the third component (0 by default) */
  2899. z: number;
  2900. /** defines the fourth component (1.0 by default) */
  2901. w: number;
  2902. /**
  2903. * Creates a new Quaternion from the given floats
  2904. * @param x defines the first component (0 by default)
  2905. * @param y defines the second component (0 by default)
  2906. * @param z defines the third component (0 by default)
  2907. * @param w defines the fourth component (1.0 by default)
  2908. */
  2909. constructor(
  2910. /** defines the first component (0 by default) */
  2911. x?: number,
  2912. /** defines the second component (0 by default) */
  2913. y?: number,
  2914. /** defines the third component (0 by default) */
  2915. z?: number,
  2916. /** defines the fourth component (1.0 by default) */
  2917. w?: number);
  2918. /**
  2919. * Gets a string representation for the current quaternion
  2920. * @returns a string with the Quaternion coordinates
  2921. */
  2922. toString(): string;
  2923. /**
  2924. * Gets the class name of the quaternion
  2925. * @returns the string "Quaternion"
  2926. */
  2927. getClassName(): string;
  2928. /**
  2929. * Gets a hash code for this quaternion
  2930. * @returns the quaternion hash code
  2931. */
  2932. getHashCode(): number;
  2933. /**
  2934. * Copy the quaternion to an array
  2935. * @returns a new array populated with 4 elements from the quaternion coordinates
  2936. */
  2937. asArray(): number[];
  2938. /**
  2939. * Check if two quaternions are equals
  2940. * @param otherQuaternion defines the second operand
  2941. * @return true if the current quaternion and the given one coordinates are strictly equals
  2942. */
  2943. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2944. /**
  2945. * Clone the current quaternion
  2946. * @returns a new quaternion copied from the current one
  2947. */
  2948. clone(): Quaternion;
  2949. /**
  2950. * Copy a quaternion to the current one
  2951. * @param other defines the other quaternion
  2952. * @returns the updated current quaternion
  2953. */
  2954. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2955. /**
  2956. * Updates the current quaternion with the given float coordinates
  2957. * @param x defines the x coordinate
  2958. * @param y defines the y coordinate
  2959. * @param z defines the z coordinate
  2960. * @param w defines the w coordinate
  2961. * @returns the updated current quaternion
  2962. */
  2963. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2964. /**
  2965. * Updates the current quaternion from the given float coordinates
  2966. * @param x defines the x coordinate
  2967. * @param y defines the y coordinate
  2968. * @param z defines the z coordinate
  2969. * @param w defines the w coordinate
  2970. * @returns the updated current quaternion
  2971. */
  2972. set(x: number, y: number, z: number, w: number): Quaternion;
  2973. /**
  2974. * Adds two quaternions
  2975. * @param other defines the second operand
  2976. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2977. */
  2978. add(other: DeepImmutable<Quaternion>): Quaternion;
  2979. /**
  2980. * Add a quaternion to the current one
  2981. * @param other defines the quaternion to add
  2982. * @returns the current quaternion
  2983. */
  2984. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2985. /**
  2986. * Subtract two quaternions
  2987. * @param other defines the second operand
  2988. * @returns a new quaternion as the subtraction result of the given one from the current one
  2989. */
  2990. subtract(other: Quaternion): Quaternion;
  2991. /**
  2992. * Multiplies the current quaternion by a scale factor
  2993. * @param value defines the scale factor
  2994. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2995. */
  2996. scale(value: number): Quaternion;
  2997. /**
  2998. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2999. * @param scale defines the scale factor
  3000. * @param result defines the Quaternion object where to store the result
  3001. * @returns the unmodified current quaternion
  3002. */
  3003. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3004. /**
  3005. * Multiplies in place the current quaternion by a scale factor
  3006. * @param value defines the scale factor
  3007. * @returns the current modified quaternion
  3008. */
  3009. scaleInPlace(value: number): Quaternion;
  3010. /**
  3011. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3012. * @param scale defines the scale factor
  3013. * @param result defines the Quaternion object where to store the result
  3014. * @returns the unmodified current quaternion
  3015. */
  3016. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3017. /**
  3018. * Multiplies two quaternions
  3019. * @param q1 defines the second operand
  3020. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3021. */
  3022. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3023. /**
  3024. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3025. * @param q1 defines the second operand
  3026. * @param result defines the target quaternion
  3027. * @returns the current quaternion
  3028. */
  3029. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3030. /**
  3031. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3032. * @param q1 defines the second operand
  3033. * @returns the currentupdated quaternion
  3034. */
  3035. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3036. /**
  3037. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3038. * @param ref defines the target quaternion
  3039. * @returns the current quaternion
  3040. */
  3041. conjugateToRef(ref: Quaternion): Quaternion;
  3042. /**
  3043. * Conjugates in place (1-q) the current quaternion
  3044. * @returns the current updated quaternion
  3045. */
  3046. conjugateInPlace(): Quaternion;
  3047. /**
  3048. * Conjugates in place (1-q) the current quaternion
  3049. * @returns a new quaternion
  3050. */
  3051. conjugate(): Quaternion;
  3052. /**
  3053. * Gets length of current quaternion
  3054. * @returns the quaternion length (float)
  3055. */
  3056. length(): number;
  3057. /**
  3058. * Normalize in place the current quaternion
  3059. * @returns the current updated quaternion
  3060. */
  3061. normalize(): Quaternion;
  3062. /**
  3063. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3064. * @param order is a reserved parameter and is ignore for now
  3065. * @returns a new Vector3 containing the Euler angles
  3066. */
  3067. toEulerAngles(order?: string): Vector3;
  3068. /**
  3069. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3070. * @param result defines the vector which will be filled with the Euler angles
  3071. * @param order is a reserved parameter and is ignore for now
  3072. * @returns the current unchanged quaternion
  3073. */
  3074. toEulerAnglesToRef(result: Vector3): Quaternion;
  3075. /**
  3076. * Updates the given rotation matrix with the current quaternion values
  3077. * @param result defines the target matrix
  3078. * @returns the current unchanged quaternion
  3079. */
  3080. toRotationMatrix(result: Matrix): Quaternion;
  3081. /**
  3082. * Updates the current quaternion from the given rotation matrix values
  3083. * @param matrix defines the source matrix
  3084. * @returns the current updated quaternion
  3085. */
  3086. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3087. /**
  3088. * Creates a new quaternion from a rotation matrix
  3089. * @param matrix defines the source matrix
  3090. * @returns a new quaternion created from the given rotation matrix values
  3091. */
  3092. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3093. /**
  3094. * Updates the given quaternion with the given rotation matrix values
  3095. * @param matrix defines the source matrix
  3096. * @param result defines the target quaternion
  3097. */
  3098. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3099. /**
  3100. * Returns the dot product (float) between the quaternions "left" and "right"
  3101. * @param left defines the left operand
  3102. * @param right defines the right operand
  3103. * @returns the dot product
  3104. */
  3105. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3106. /**
  3107. * Checks if the two quaternions are close to each other
  3108. * @param quat0 defines the first quaternion to check
  3109. * @param quat1 defines the second quaternion to check
  3110. * @returns true if the two quaternions are close to each other
  3111. */
  3112. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3113. /**
  3114. * Creates an empty quaternion
  3115. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3116. */
  3117. static Zero(): Quaternion;
  3118. /**
  3119. * Inverse a given quaternion
  3120. * @param q defines the source quaternion
  3121. * @returns a new quaternion as the inverted current quaternion
  3122. */
  3123. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3124. /**
  3125. * Inverse a given quaternion
  3126. * @param q defines the source quaternion
  3127. * @param result the quaternion the result will be stored in
  3128. * @returns the result quaternion
  3129. */
  3130. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3131. /**
  3132. * Creates an identity quaternion
  3133. * @returns the identity quaternion
  3134. */
  3135. static Identity(): Quaternion;
  3136. /**
  3137. * Gets a boolean indicating if the given quaternion is identity
  3138. * @param quaternion defines the quaternion to check
  3139. * @returns true if the quaternion is identity
  3140. */
  3141. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3142. /**
  3143. * Creates a quaternion from a rotation around an axis
  3144. * @param axis defines the axis to use
  3145. * @param angle defines the angle to use
  3146. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3147. */
  3148. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3149. /**
  3150. * Creates a rotation around an axis and stores it into the given quaternion
  3151. * @param axis defines the axis to use
  3152. * @param angle defines the angle to use
  3153. * @param result defines the target quaternion
  3154. * @returns the target quaternion
  3155. */
  3156. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3157. /**
  3158. * Creates a new quaternion from data stored into an array
  3159. * @param array defines the data source
  3160. * @param offset defines the offset in the source array where the data starts
  3161. * @returns a new quaternion
  3162. */
  3163. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3164. /**
  3165. * Create a quaternion from Euler rotation angles
  3166. * @param x Pitch
  3167. * @param y Yaw
  3168. * @param z Roll
  3169. * @returns the new Quaternion
  3170. */
  3171. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3172. /**
  3173. * Updates a quaternion from Euler rotation angles
  3174. * @param x Pitch
  3175. * @param y Yaw
  3176. * @param z Roll
  3177. * @param result the quaternion to store the result
  3178. * @returns the updated quaternion
  3179. */
  3180. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3181. /**
  3182. * Create a quaternion from Euler rotation vector
  3183. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3184. * @returns the new Quaternion
  3185. */
  3186. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3187. /**
  3188. * Updates a quaternion from Euler rotation vector
  3189. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3190. * @param result the quaternion to store the result
  3191. * @returns the updated quaternion
  3192. */
  3193. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3194. /**
  3195. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3196. * @param yaw defines the rotation around Y axis
  3197. * @param pitch defines the rotation around X axis
  3198. * @param roll defines the rotation around Z axis
  3199. * @returns the new quaternion
  3200. */
  3201. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3202. /**
  3203. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3204. * @param yaw defines the rotation around Y axis
  3205. * @param pitch defines the rotation around X axis
  3206. * @param roll defines the rotation around Z axis
  3207. * @param result defines the target quaternion
  3208. */
  3209. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3210. /**
  3211. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3212. * @param alpha defines the rotation around first axis
  3213. * @param beta defines the rotation around second axis
  3214. * @param gamma defines the rotation around third axis
  3215. * @returns the new quaternion
  3216. */
  3217. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3218. /**
  3219. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3220. * @param alpha defines the rotation around first axis
  3221. * @param beta defines the rotation around second axis
  3222. * @param gamma defines the rotation around third axis
  3223. * @param result defines the target quaternion
  3224. */
  3225. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3226. /**
  3227. * 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)
  3228. * @param axis1 defines the first axis
  3229. * @param axis2 defines the second axis
  3230. * @param axis3 defines the third axis
  3231. * @returns the new quaternion
  3232. */
  3233. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3234. /**
  3235. * 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
  3236. * @param axis1 defines the first axis
  3237. * @param axis2 defines the second axis
  3238. * @param axis3 defines the third axis
  3239. * @param ref defines the target quaternion
  3240. */
  3241. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3242. /**
  3243. * Interpolates between two quaternions
  3244. * @param left defines first quaternion
  3245. * @param right defines second quaternion
  3246. * @param amount defines the gradient to use
  3247. * @returns the new interpolated quaternion
  3248. */
  3249. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3250. /**
  3251. * Interpolates between two quaternions and stores it into a target quaternion
  3252. * @param left defines first quaternion
  3253. * @param right defines second quaternion
  3254. * @param amount defines the gradient to use
  3255. * @param result defines the target quaternion
  3256. */
  3257. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3258. /**
  3259. * Interpolate between two quaternions using Hermite interpolation
  3260. * @param value1 defines first quaternion
  3261. * @param tangent1 defines the incoming tangent
  3262. * @param value2 defines second quaternion
  3263. * @param tangent2 defines the outgoing tangent
  3264. * @param amount defines the target quaternion
  3265. * @returns the new interpolated quaternion
  3266. */
  3267. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3268. }
  3269. /**
  3270. * Class used to store matrix data (4x4)
  3271. */
  3272. export class Matrix {
  3273. private static _updateFlagSeed;
  3274. private static _identityReadOnly;
  3275. private _isIdentity;
  3276. private _isIdentityDirty;
  3277. private _isIdentity3x2;
  3278. private _isIdentity3x2Dirty;
  3279. /**
  3280. * Gets the update flag of the matrix which is an unique number for the matrix.
  3281. * It will be incremented every time the matrix data change.
  3282. * You can use it to speed the comparison between two versions of the same matrix.
  3283. */
  3284. updateFlag: number;
  3285. private readonly _m;
  3286. /**
  3287. * Gets the internal data of the matrix
  3288. */
  3289. readonly m: DeepImmutable<Float32Array>;
  3290. /** @hidden */ private _markAsUpdated(): void;
  3291. /** @hidden */
  3292. private _updateIdentityStatus;
  3293. /**
  3294. * Creates an empty matrix (filled with zeros)
  3295. */
  3296. constructor();
  3297. /**
  3298. * Check if the current matrix is identity
  3299. * @returns true is the matrix is the identity matrix
  3300. */
  3301. isIdentity(): boolean;
  3302. /**
  3303. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3304. * @returns true is the matrix is the identity matrix
  3305. */
  3306. isIdentityAs3x2(): boolean;
  3307. /**
  3308. * Gets the determinant of the matrix
  3309. * @returns the matrix determinant
  3310. */
  3311. determinant(): number;
  3312. /**
  3313. * Returns the matrix as a Float32Array
  3314. * @returns the matrix underlying array
  3315. */
  3316. toArray(): DeepImmutable<Float32Array>;
  3317. /**
  3318. * Returns the matrix as a Float32Array
  3319. * @returns the matrix underlying array.
  3320. */
  3321. asArray(): DeepImmutable<Float32Array>;
  3322. /**
  3323. * Inverts the current matrix in place
  3324. * @returns the current inverted matrix
  3325. */
  3326. invert(): Matrix;
  3327. /**
  3328. * Sets all the matrix elements to zero
  3329. * @returns the current matrix
  3330. */
  3331. reset(): Matrix;
  3332. /**
  3333. * Adds the current matrix with a second one
  3334. * @param other defines the matrix to add
  3335. * @returns a new matrix as the addition of the current matrix and the given one
  3336. */
  3337. add(other: DeepImmutable<Matrix>): Matrix;
  3338. /**
  3339. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3340. * @param other defines the matrix to add
  3341. * @param result defines the target matrix
  3342. * @returns the current matrix
  3343. */
  3344. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3345. /**
  3346. * Adds in place the given matrix to the current matrix
  3347. * @param other defines the second operand
  3348. * @returns the current updated matrix
  3349. */
  3350. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3351. /**
  3352. * Sets the given matrix to the current inverted Matrix
  3353. * @param other defines the target matrix
  3354. * @returns the unmodified current matrix
  3355. */
  3356. invertToRef(other: Matrix): Matrix;
  3357. /**
  3358. * add a value at the specified position in the current Matrix
  3359. * @param index the index of the value within the matrix. between 0 and 15.
  3360. * @param value the value to be added
  3361. * @returns the current updated matrix
  3362. */
  3363. addAtIndex(index: number, value: number): Matrix;
  3364. /**
  3365. * mutiply the specified position in the current Matrix by a value
  3366. * @param index the index of the value within the matrix. between 0 and 15.
  3367. * @param value the value to be added
  3368. * @returns the current updated matrix
  3369. */
  3370. multiplyAtIndex(index: number, value: number): Matrix;
  3371. /**
  3372. * Inserts the translation vector (using 3 floats) in the current matrix
  3373. * @param x defines the 1st component of the translation
  3374. * @param y defines the 2nd component of the translation
  3375. * @param z defines the 3rd component of the translation
  3376. * @returns the current updated matrix
  3377. */
  3378. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3379. /**
  3380. * Adds the translation vector (using 3 floats) in the current matrix
  3381. * @param x defines the 1st component of the translation
  3382. * @param y defines the 2nd component of the translation
  3383. * @param z defines the 3rd component of the translation
  3384. * @returns the current updated matrix
  3385. */
  3386. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3387. /**
  3388. * Inserts the translation vector in the current matrix
  3389. * @param vector3 defines the translation to insert
  3390. * @returns the current updated matrix
  3391. */
  3392. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3393. /**
  3394. * Gets the translation value of the current matrix
  3395. * @returns a new Vector3 as the extracted translation from the matrix
  3396. */
  3397. getTranslation(): Vector3;
  3398. /**
  3399. * Fill a Vector3 with the extracted translation from the matrix
  3400. * @param result defines the Vector3 where to store the translation
  3401. * @returns the current matrix
  3402. */
  3403. getTranslationToRef(result: Vector3): Matrix;
  3404. /**
  3405. * Remove rotation and scaling part from the matrix
  3406. * @returns the updated matrix
  3407. */
  3408. removeRotationAndScaling(): Matrix;
  3409. /**
  3410. * Multiply two matrices
  3411. * @param other defines the second operand
  3412. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3413. */
  3414. multiply(other: DeepImmutable<Matrix>): Matrix;
  3415. /**
  3416. * Copy the current matrix from the given one
  3417. * @param other defines the source matrix
  3418. * @returns the current updated matrix
  3419. */
  3420. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3421. /**
  3422. * Populates the given array from the starting index with the current matrix values
  3423. * @param array defines the target array
  3424. * @param offset defines the offset in the target array where to start storing values
  3425. * @returns the current matrix
  3426. */
  3427. copyToArray(array: Float32Array, offset?: number): Matrix;
  3428. /**
  3429. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3430. * @param other defines the second operand
  3431. * @param result defines the matrix where to store the multiplication
  3432. * @returns the current matrix
  3433. */
  3434. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3435. /**
  3436. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3437. * @param other defines the second operand
  3438. * @param result defines the array where to store the multiplication
  3439. * @param offset defines the offset in the target array where to start storing values
  3440. * @returns the current matrix
  3441. */
  3442. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3443. /**
  3444. * Check equality between this matrix and a second one
  3445. * @param value defines the second matrix to compare
  3446. * @returns true is the current matrix and the given one values are strictly equal
  3447. */
  3448. equals(value: DeepImmutable<Matrix>): boolean;
  3449. /**
  3450. * Clone the current matrix
  3451. * @returns a new matrix from the current matrix
  3452. */
  3453. clone(): Matrix;
  3454. /**
  3455. * Returns the name of the current matrix class
  3456. * @returns the string "Matrix"
  3457. */
  3458. getClassName(): string;
  3459. /**
  3460. * Gets the hash code of the current matrix
  3461. * @returns the hash code
  3462. */
  3463. getHashCode(): number;
  3464. /**
  3465. * Decomposes the current Matrix into a translation, rotation and scaling components
  3466. * @param scale defines the scale vector3 given as a reference to update
  3467. * @param rotation defines the rotation quaternion given as a reference to update
  3468. * @param translation defines the translation vector3 given as a reference to update
  3469. * @returns true if operation was successful
  3470. */
  3471. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3472. /**
  3473. * Gets specific row of the matrix
  3474. * @param index defines the number of the row to get
  3475. * @returns the index-th row of the current matrix as a new Vector4
  3476. */
  3477. getRow(index: number): Nullable<Vector4>;
  3478. /**
  3479. * Sets the index-th row of the current matrix to the vector4 values
  3480. * @param index defines the number of the row to set
  3481. * @param row defines the target vector4
  3482. * @returns the updated current matrix
  3483. */
  3484. setRow(index: number, row: Vector4): Matrix;
  3485. /**
  3486. * Compute the transpose of the matrix
  3487. * @returns the new transposed matrix
  3488. */
  3489. transpose(): Matrix;
  3490. /**
  3491. * Compute the transpose of the matrix and store it in a given matrix
  3492. * @param result defines the target matrix
  3493. * @returns the current matrix
  3494. */
  3495. transposeToRef(result: Matrix): Matrix;
  3496. /**
  3497. * Sets the index-th row of the current matrix with the given 4 x float values
  3498. * @param index defines the row index
  3499. * @param x defines the x component to set
  3500. * @param y defines the y component to set
  3501. * @param z defines the z component to set
  3502. * @param w defines the w component to set
  3503. * @returns the updated current matrix
  3504. */
  3505. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3506. /**
  3507. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3508. * @param scale defines the scale factor
  3509. * @returns a new matrix
  3510. */
  3511. scale(scale: number): Matrix;
  3512. /**
  3513. * Scale the current matrix values by a factor to a given result matrix
  3514. * @param scale defines the scale factor
  3515. * @param result defines the matrix to store the result
  3516. * @returns the current matrix
  3517. */
  3518. scaleToRef(scale: number, result: Matrix): Matrix;
  3519. /**
  3520. * Scale the current matrix values by a factor and add the result to a given matrix
  3521. * @param scale defines the scale factor
  3522. * @param result defines the Matrix to store the result
  3523. * @returns the current matrix
  3524. */
  3525. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3526. /**
  3527. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3528. * @param ref matrix to store the result
  3529. */
  3530. toNormalMatrix(ref: Matrix): void;
  3531. /**
  3532. * Gets only rotation part of the current matrix
  3533. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3534. */
  3535. getRotationMatrix(): Matrix;
  3536. /**
  3537. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3538. * @param result defines the target matrix to store data to
  3539. * @returns the current matrix
  3540. */
  3541. getRotationMatrixToRef(result: Matrix): Matrix;
  3542. /**
  3543. * Toggles model matrix from being right handed to left handed in place and vice versa
  3544. */
  3545. toggleModelMatrixHandInPlace(): void;
  3546. /**
  3547. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3548. */
  3549. toggleProjectionMatrixHandInPlace(): void;
  3550. /**
  3551. * Creates a matrix from an array
  3552. * @param array defines the source array
  3553. * @param offset defines an offset in the source array
  3554. * @returns a new Matrix set from the starting index of the given array
  3555. */
  3556. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3557. /**
  3558. * Copy the content of an array into a given matrix
  3559. * @param array defines the source array
  3560. * @param offset defines an offset in the source array
  3561. * @param result defines the target matrix
  3562. */
  3563. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3564. /**
  3565. * Stores an array into a matrix after having multiplied each component by a given factor
  3566. * @param array defines the source array
  3567. * @param offset defines the offset in the source array
  3568. * @param scale defines the scaling factor
  3569. * @param result defines the target matrix
  3570. */
  3571. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3572. /**
  3573. * Gets an identity matrix that must not be updated
  3574. */
  3575. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3576. /**
  3577. * Stores a list of values (16) inside a given matrix
  3578. * @param initialM11 defines 1st value of 1st row
  3579. * @param initialM12 defines 2nd value of 1st row
  3580. * @param initialM13 defines 3rd value of 1st row
  3581. * @param initialM14 defines 4th value of 1st row
  3582. * @param initialM21 defines 1st value of 2nd row
  3583. * @param initialM22 defines 2nd value of 2nd row
  3584. * @param initialM23 defines 3rd value of 2nd row
  3585. * @param initialM24 defines 4th value of 2nd row
  3586. * @param initialM31 defines 1st value of 3rd row
  3587. * @param initialM32 defines 2nd value of 3rd row
  3588. * @param initialM33 defines 3rd value of 3rd row
  3589. * @param initialM34 defines 4th value of 3rd row
  3590. * @param initialM41 defines 1st value of 4th row
  3591. * @param initialM42 defines 2nd value of 4th row
  3592. * @param initialM43 defines 3rd value of 4th row
  3593. * @param initialM44 defines 4th value of 4th row
  3594. * @param result defines the target matrix
  3595. */
  3596. 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;
  3597. /**
  3598. * Creates new matrix from a list of values (16)
  3599. * @param initialM11 defines 1st value of 1st row
  3600. * @param initialM12 defines 2nd value of 1st row
  3601. * @param initialM13 defines 3rd value of 1st row
  3602. * @param initialM14 defines 4th value of 1st row
  3603. * @param initialM21 defines 1st value of 2nd row
  3604. * @param initialM22 defines 2nd value of 2nd row
  3605. * @param initialM23 defines 3rd value of 2nd row
  3606. * @param initialM24 defines 4th value of 2nd row
  3607. * @param initialM31 defines 1st value of 3rd row
  3608. * @param initialM32 defines 2nd value of 3rd row
  3609. * @param initialM33 defines 3rd value of 3rd row
  3610. * @param initialM34 defines 4th value of 3rd row
  3611. * @param initialM41 defines 1st value of 4th row
  3612. * @param initialM42 defines 2nd value of 4th row
  3613. * @param initialM43 defines 3rd value of 4th row
  3614. * @param initialM44 defines 4th value of 4th row
  3615. * @returns the new matrix
  3616. */
  3617. 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;
  3618. /**
  3619. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3620. * @param scale defines the scale vector3
  3621. * @param rotation defines the rotation quaternion
  3622. * @param translation defines the translation vector3
  3623. * @returns a new matrix
  3624. */
  3625. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3626. /**
  3627. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3628. * @param scale defines the scale vector3
  3629. * @param rotation defines the rotation quaternion
  3630. * @param translation defines the translation vector3
  3631. * @param result defines the target matrix
  3632. */
  3633. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3634. /**
  3635. * Creates a new identity matrix
  3636. * @returns a new identity matrix
  3637. */
  3638. static Identity(): Matrix;
  3639. /**
  3640. * Creates a new identity matrix and stores the result in a given matrix
  3641. * @param result defines the target matrix
  3642. */
  3643. static IdentityToRef(result: Matrix): void;
  3644. /**
  3645. * Creates a new zero matrix
  3646. * @returns a new zero matrix
  3647. */
  3648. static Zero(): Matrix;
  3649. /**
  3650. * Creates a new rotation matrix for "angle" radians around the X axis
  3651. * @param angle defines the angle (in radians) to use
  3652. * @return the new matrix
  3653. */
  3654. static RotationX(angle: number): Matrix;
  3655. /**
  3656. * Creates a new matrix as the invert of a given matrix
  3657. * @param source defines the source matrix
  3658. * @returns the new matrix
  3659. */
  3660. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3661. /**
  3662. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3663. * @param angle defines the angle (in radians) to use
  3664. * @param result defines the target matrix
  3665. */
  3666. static RotationXToRef(angle: number, result: Matrix): void;
  3667. /**
  3668. * Creates a new rotation matrix for "angle" radians around the Y axis
  3669. * @param angle defines the angle (in radians) to use
  3670. * @return the new matrix
  3671. */
  3672. static RotationY(angle: number): Matrix;
  3673. /**
  3674. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3675. * @param angle defines the angle (in radians) to use
  3676. * @param result defines the target matrix
  3677. */
  3678. static RotationYToRef(angle: number, result: Matrix): void;
  3679. /**
  3680. * Creates a new rotation matrix for "angle" radians around the Z axis
  3681. * @param angle defines the angle (in radians) to use
  3682. * @return the new matrix
  3683. */
  3684. static RotationZ(angle: number): Matrix;
  3685. /**
  3686. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3687. * @param angle defines the angle (in radians) to use
  3688. * @param result defines the target matrix
  3689. */
  3690. static RotationZToRef(angle: number, result: Matrix): void;
  3691. /**
  3692. * Creates a new rotation matrix for "angle" radians around the given axis
  3693. * @param axis defines the axis to use
  3694. * @param angle defines the angle (in radians) to use
  3695. * @return the new matrix
  3696. */
  3697. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3698. /**
  3699. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3700. * @param axis defines the axis to use
  3701. * @param angle defines the angle (in radians) to use
  3702. * @param result defines the target matrix
  3703. */
  3704. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3705. /**
  3706. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3707. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3708. * @param from defines the vector to align
  3709. * @param to defines the vector to align to
  3710. * @param result defines the target matrix
  3711. */
  3712. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3713. /**
  3714. * Creates a rotation matrix
  3715. * @param yaw defines the yaw angle in radians (Y axis)
  3716. * @param pitch defines the pitch angle in radians (X axis)
  3717. * @param roll defines the roll angle in radians (X axis)
  3718. * @returns the new rotation matrix
  3719. */
  3720. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3721. /**
  3722. * Creates a rotation matrix and stores it in a given matrix
  3723. * @param yaw defines the yaw angle in radians (Y axis)
  3724. * @param pitch defines the pitch angle in radians (X axis)
  3725. * @param roll defines the roll angle in radians (X axis)
  3726. * @param result defines the target matrix
  3727. */
  3728. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3729. /**
  3730. * Creates a scaling matrix
  3731. * @param x defines the scale factor on X axis
  3732. * @param y defines the scale factor on Y axis
  3733. * @param z defines the scale factor on Z axis
  3734. * @returns the new matrix
  3735. */
  3736. static Scaling(x: number, y: number, z: number): Matrix;
  3737. /**
  3738. * Creates a scaling matrix and stores it in a given matrix
  3739. * @param x defines the scale factor on X axis
  3740. * @param y defines the scale factor on Y axis
  3741. * @param z defines the scale factor on Z axis
  3742. * @param result defines the target matrix
  3743. */
  3744. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3745. /**
  3746. * Creates a translation matrix
  3747. * @param x defines the translation on X axis
  3748. * @param y defines the translation on Y axis
  3749. * @param z defines the translationon Z axis
  3750. * @returns the new matrix
  3751. */
  3752. static Translation(x: number, y: number, z: number): Matrix;
  3753. /**
  3754. * Creates a translation matrix and stores it in a given matrix
  3755. * @param x defines the translation on X axis
  3756. * @param y defines the translation on Y axis
  3757. * @param z defines the translationon Z axis
  3758. * @param result defines the target matrix
  3759. */
  3760. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3761. /**
  3762. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3763. * @param startValue defines the start value
  3764. * @param endValue defines the end value
  3765. * @param gradient defines the gradient factor
  3766. * @returns the new matrix
  3767. */
  3768. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3769. /**
  3770. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3771. * @param startValue defines the start value
  3772. * @param endValue defines the end value
  3773. * @param gradient defines the gradient factor
  3774. * @param result defines the Matrix object where to store data
  3775. */
  3776. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3777. /**
  3778. * Builds a new matrix whose values are computed by:
  3779. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3780. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3781. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3782. * @param startValue defines the first matrix
  3783. * @param endValue defines the second matrix
  3784. * @param gradient defines the gradient between the two matrices
  3785. * @returns the new matrix
  3786. */
  3787. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3788. /**
  3789. * Update a matrix to values which are computed by:
  3790. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3791. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3792. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3793. * @param startValue defines the first matrix
  3794. * @param endValue defines the second matrix
  3795. * @param gradient defines the gradient between the two matrices
  3796. * @param result defines the target matrix
  3797. */
  3798. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3799. /**
  3800. * 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"
  3801. * This function works in left handed mode
  3802. * @param eye defines the final position of the entity
  3803. * @param target defines where the entity should look at
  3804. * @param up defines the up vector for the entity
  3805. * @returns the new matrix
  3806. */
  3807. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3808. /**
  3809. * 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".
  3810. * This function works in left handed mode
  3811. * @param eye defines the final position of the entity
  3812. * @param target defines where the entity should look at
  3813. * @param up defines the up vector for the entity
  3814. * @param result defines the target matrix
  3815. */
  3816. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3817. /**
  3818. * 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"
  3819. * This function works in right handed mode
  3820. * @param eye defines the final position of the entity
  3821. * @param target defines where the entity should look at
  3822. * @param up defines the up vector for the entity
  3823. * @returns the new matrix
  3824. */
  3825. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3826. /**
  3827. * 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".
  3828. * This function works in right handed mode
  3829. * @param eye defines the final position of the entity
  3830. * @param target defines where the entity should look at
  3831. * @param up defines the up vector for the entity
  3832. * @param result defines the target matrix
  3833. */
  3834. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3835. /**
  3836. * Create a left-handed orthographic projection matrix
  3837. * @param width defines the viewport width
  3838. * @param height defines the viewport height
  3839. * @param znear defines the near clip plane
  3840. * @param zfar defines the far clip plane
  3841. * @returns a new matrix as a left-handed orthographic projection matrix
  3842. */
  3843. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3844. /**
  3845. * Store a left-handed orthographic projection to a given matrix
  3846. * @param width defines the viewport width
  3847. * @param height defines the viewport height
  3848. * @param znear defines the near clip plane
  3849. * @param zfar defines the far clip plane
  3850. * @param result defines the target matrix
  3851. */
  3852. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3853. /**
  3854. * Create a left-handed orthographic projection matrix
  3855. * @param left defines the viewport left coordinate
  3856. * @param right defines the viewport right coordinate
  3857. * @param bottom defines the viewport bottom coordinate
  3858. * @param top defines the viewport top coordinate
  3859. * @param znear defines the near clip plane
  3860. * @param zfar defines the far clip plane
  3861. * @returns a new matrix as a left-handed orthographic projection matrix
  3862. */
  3863. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3864. /**
  3865. * Stores a left-handed orthographic projection into a given matrix
  3866. * @param left defines the viewport left coordinate
  3867. * @param right defines the viewport right coordinate
  3868. * @param bottom defines the viewport bottom coordinate
  3869. * @param top defines the viewport top coordinate
  3870. * @param znear defines the near clip plane
  3871. * @param zfar defines the far clip plane
  3872. * @param result defines the target matrix
  3873. */
  3874. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3875. /**
  3876. * Creates a right-handed orthographic projection matrix
  3877. * @param left defines the viewport left coordinate
  3878. * @param right defines the viewport right coordinate
  3879. * @param bottom defines the viewport bottom coordinate
  3880. * @param top defines the viewport top coordinate
  3881. * @param znear defines the near clip plane
  3882. * @param zfar defines the far clip plane
  3883. * @returns a new matrix as a right-handed orthographic projection matrix
  3884. */
  3885. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3886. /**
  3887. * Stores a right-handed orthographic projection into a given matrix
  3888. * @param left defines the viewport left coordinate
  3889. * @param right defines the viewport right coordinate
  3890. * @param bottom defines the viewport bottom coordinate
  3891. * @param top defines the viewport top coordinate
  3892. * @param znear defines the near clip plane
  3893. * @param zfar defines the far clip plane
  3894. * @param result defines the target matrix
  3895. */
  3896. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3897. /**
  3898. * Creates a left-handed perspective projection matrix
  3899. * @param width defines the viewport width
  3900. * @param height defines the viewport height
  3901. * @param znear defines the near clip plane
  3902. * @param zfar defines the far clip plane
  3903. * @returns a new matrix as a left-handed perspective projection matrix
  3904. */
  3905. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3906. /**
  3907. * Creates a left-handed perspective projection matrix
  3908. * @param fov defines the horizontal field of view
  3909. * @param aspect defines the aspect ratio
  3910. * @param znear defines the near clip plane
  3911. * @param zfar defines the far clip plane
  3912. * @returns a new matrix as a left-handed perspective projection matrix
  3913. */
  3914. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3915. /**
  3916. * Stores a left-handed perspective projection into a given matrix
  3917. * @param fov defines the horizontal field of view
  3918. * @param aspect defines the aspect ratio
  3919. * @param znear defines the near clip plane
  3920. * @param zfar defines the far clip plane
  3921. * @param result defines the target matrix
  3922. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3923. */
  3924. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3925. /**
  3926. * Creates a right-handed perspective projection matrix
  3927. * @param fov defines the horizontal field of view
  3928. * @param aspect defines the aspect ratio
  3929. * @param znear defines the near clip plane
  3930. * @param zfar defines the far clip plane
  3931. * @returns a new matrix as a right-handed perspective projection matrix
  3932. */
  3933. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3934. /**
  3935. * Stores a right-handed perspective projection into a given matrix
  3936. * @param fov defines the horizontal field of view
  3937. * @param aspect defines the aspect ratio
  3938. * @param znear defines the near clip plane
  3939. * @param zfar defines the far clip plane
  3940. * @param result defines the target matrix
  3941. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3942. */
  3943. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3944. /**
  3945. * Stores a perspective projection for WebVR info a given matrix
  3946. * @param fov defines the field of view
  3947. * @param znear defines the near clip plane
  3948. * @param zfar defines the far clip plane
  3949. * @param result defines the target matrix
  3950. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3951. */
  3952. static PerspectiveFovWebVRToRef(fov: {
  3953. upDegrees: number;
  3954. downDegrees: number;
  3955. leftDegrees: number;
  3956. rightDegrees: number;
  3957. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3958. /**
  3959. * Computes a complete transformation matrix
  3960. * @param viewport defines the viewport to use
  3961. * @param world defines the world matrix
  3962. * @param view defines the view matrix
  3963. * @param projection defines the projection matrix
  3964. * @param zmin defines the near clip plane
  3965. * @param zmax defines the far clip plane
  3966. * @returns the transformation matrix
  3967. */
  3968. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3969. /**
  3970. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3971. * @param matrix defines the matrix to use
  3972. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3973. */
  3974. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3975. /**
  3976. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3977. * @param matrix defines the matrix to use
  3978. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3979. */
  3980. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3981. /**
  3982. * Compute the transpose of a given matrix
  3983. * @param matrix defines the matrix to transpose
  3984. * @returns the new matrix
  3985. */
  3986. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3987. /**
  3988. * Compute the transpose of a matrix and store it in a target matrix
  3989. * @param matrix defines the matrix to transpose
  3990. * @param result defines the target matrix
  3991. */
  3992. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3993. /**
  3994. * Computes a reflection matrix from a plane
  3995. * @param plane defines the reflection plane
  3996. * @returns a new matrix
  3997. */
  3998. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  3999. /**
  4000. * Computes a reflection matrix from a plane
  4001. * @param plane defines the reflection plane
  4002. * @param result defines the target matrix
  4003. */
  4004. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4005. /**
  4006. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4007. * @param xaxis defines the value of the 1st axis
  4008. * @param yaxis defines the value of the 2nd axis
  4009. * @param zaxis defines the value of the 3rd axis
  4010. * @param result defines the target matrix
  4011. */
  4012. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4013. /**
  4014. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4015. * @param quat defines the quaternion to use
  4016. * @param result defines the target matrix
  4017. */
  4018. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4019. }
  4020. /**
  4021. * @hidden
  4022. */
  4023. export class TmpVectors {
  4024. static Vector2: Vector2[];
  4025. static Vector3: Vector3[];
  4026. static Vector4: Vector4[];
  4027. static Quaternion: Quaternion[];
  4028. static Matrix: Matrix[];
  4029. }
  4030. }
  4031. declare module BABYLON {
  4032. /** Defines the cross module used constants to avoid circular dependncies */
  4033. export class Constants {
  4034. /** Defines that alpha blending is disabled */
  4035. static readonly ALPHA_DISABLE: number;
  4036. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4037. static readonly ALPHA_ADD: number;
  4038. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4039. static readonly ALPHA_COMBINE: number;
  4040. /** Defines that alpha blending to DEST - SRC * DEST */
  4041. static readonly ALPHA_SUBTRACT: number;
  4042. /** Defines that alpha blending to SRC * DEST */
  4043. static readonly ALPHA_MULTIPLY: number;
  4044. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4045. static readonly ALPHA_MAXIMIZED: number;
  4046. /** Defines that alpha blending to SRC + DEST */
  4047. static readonly ALPHA_ONEONE: number;
  4048. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4049. static readonly ALPHA_PREMULTIPLIED: number;
  4050. /**
  4051. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4052. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4053. */
  4054. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4055. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4056. static readonly ALPHA_INTERPOLATE: number;
  4057. /**
  4058. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4059. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4060. */
  4061. static readonly ALPHA_SCREENMODE: number;
  4062. /** Defines that the ressource is not delayed*/
  4063. static readonly DELAYLOADSTATE_NONE: number;
  4064. /** Defines that the ressource was successfully delay loaded */
  4065. static readonly DELAYLOADSTATE_LOADED: number;
  4066. /** Defines that the ressource is currently delay loading */
  4067. static readonly DELAYLOADSTATE_LOADING: number;
  4068. /** Defines that the ressource is delayed and has not started loading */
  4069. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4070. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4071. static readonly NEVER: number;
  4072. /** 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 */
  4073. static readonly ALWAYS: number;
  4074. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4075. static readonly LESS: number;
  4076. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4077. static readonly EQUAL: number;
  4078. /** 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 */
  4079. static readonly LEQUAL: number;
  4080. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4081. static readonly GREATER: number;
  4082. /** 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 */
  4083. static readonly GEQUAL: number;
  4084. /** 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 */
  4085. static readonly NOTEQUAL: number;
  4086. /** Passed to stencilOperation to specify that stencil value must be kept */
  4087. static readonly KEEP: number;
  4088. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4089. static readonly REPLACE: number;
  4090. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4091. static readonly INCR: number;
  4092. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4093. static readonly DECR: number;
  4094. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4095. static readonly INVERT: number;
  4096. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4097. static readonly INCR_WRAP: number;
  4098. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4099. static readonly DECR_WRAP: number;
  4100. /** Texture is not repeating outside of 0..1 UVs */
  4101. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4102. /** Texture is repeating outside of 0..1 UVs */
  4103. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4104. /** Texture is repeating and mirrored */
  4105. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4106. /** ALPHA */
  4107. static readonly TEXTUREFORMAT_ALPHA: number;
  4108. /** LUMINANCE */
  4109. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4110. /** LUMINANCE_ALPHA */
  4111. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4112. /** RGB */
  4113. static readonly TEXTUREFORMAT_RGB: number;
  4114. /** RGBA */
  4115. static readonly TEXTUREFORMAT_RGBA: number;
  4116. /** RED */
  4117. static readonly TEXTUREFORMAT_RED: number;
  4118. /** RED (2nd reference) */
  4119. static readonly TEXTUREFORMAT_R: number;
  4120. /** RG */
  4121. static readonly TEXTUREFORMAT_RG: number;
  4122. /** RED_INTEGER */
  4123. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4124. /** RED_INTEGER (2nd reference) */
  4125. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4126. /** RG_INTEGER */
  4127. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4128. /** RGB_INTEGER */
  4129. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4130. /** RGBA_INTEGER */
  4131. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4132. /** UNSIGNED_BYTE */
  4133. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4134. /** UNSIGNED_BYTE (2nd reference) */
  4135. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4136. /** FLOAT */
  4137. static readonly TEXTURETYPE_FLOAT: number;
  4138. /** HALF_FLOAT */
  4139. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4140. /** BYTE */
  4141. static readonly TEXTURETYPE_BYTE: number;
  4142. /** SHORT */
  4143. static readonly TEXTURETYPE_SHORT: number;
  4144. /** UNSIGNED_SHORT */
  4145. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4146. /** INT */
  4147. static readonly TEXTURETYPE_INT: number;
  4148. /** UNSIGNED_INT */
  4149. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4150. /** UNSIGNED_SHORT_4_4_4_4 */
  4151. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4152. /** UNSIGNED_SHORT_5_5_5_1 */
  4153. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4154. /** UNSIGNED_SHORT_5_6_5 */
  4155. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4156. /** UNSIGNED_INT_2_10_10_10_REV */
  4157. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4158. /** UNSIGNED_INT_24_8 */
  4159. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4160. /** UNSIGNED_INT_10F_11F_11F_REV */
  4161. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4162. /** UNSIGNED_INT_5_9_9_9_REV */
  4163. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4164. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4165. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4166. /** nearest is mag = nearest and min = nearest and mip = linear */
  4167. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4168. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4169. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4170. /** Trilinear is mag = linear and min = linear and mip = linear */
  4171. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4172. /** nearest is mag = nearest and min = nearest and mip = linear */
  4173. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4174. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4175. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4176. /** Trilinear is mag = linear and min = linear and mip = linear */
  4177. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4178. /** mag = nearest and min = nearest and mip = nearest */
  4179. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4180. /** mag = nearest and min = linear and mip = nearest */
  4181. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4182. /** mag = nearest and min = linear and mip = linear */
  4183. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4184. /** mag = nearest and min = linear and mip = none */
  4185. static readonly TEXTURE_NEAREST_LINEAR: number;
  4186. /** mag = nearest and min = nearest and mip = none */
  4187. static readonly TEXTURE_NEAREST_NEAREST: number;
  4188. /** mag = linear and min = nearest and mip = nearest */
  4189. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4190. /** mag = linear and min = nearest and mip = linear */
  4191. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4192. /** mag = linear and min = linear and mip = none */
  4193. static readonly TEXTURE_LINEAR_LINEAR: number;
  4194. /** mag = linear and min = nearest and mip = none */
  4195. static readonly TEXTURE_LINEAR_NEAREST: number;
  4196. /** Explicit coordinates mode */
  4197. static readonly TEXTURE_EXPLICIT_MODE: number;
  4198. /** Spherical coordinates mode */
  4199. static readonly TEXTURE_SPHERICAL_MODE: number;
  4200. /** Planar coordinates mode */
  4201. static readonly TEXTURE_PLANAR_MODE: number;
  4202. /** Cubic coordinates mode */
  4203. static readonly TEXTURE_CUBIC_MODE: number;
  4204. /** Projection coordinates mode */
  4205. static readonly TEXTURE_PROJECTION_MODE: number;
  4206. /** Skybox coordinates mode */
  4207. static readonly TEXTURE_SKYBOX_MODE: number;
  4208. /** Inverse Cubic coordinates mode */
  4209. static readonly TEXTURE_INVCUBIC_MODE: number;
  4210. /** Equirectangular coordinates mode */
  4211. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4212. /** Equirectangular Fixed coordinates mode */
  4213. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4214. /** Equirectangular Fixed Mirrored coordinates mode */
  4215. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4216. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4217. static readonly SCALEMODE_FLOOR: number;
  4218. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4219. static readonly SCALEMODE_NEAREST: number;
  4220. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4221. static readonly SCALEMODE_CEILING: number;
  4222. /**
  4223. * The dirty texture flag value
  4224. */
  4225. static readonly MATERIAL_TextureDirtyFlag: number;
  4226. /**
  4227. * The dirty light flag value
  4228. */
  4229. static readonly MATERIAL_LightDirtyFlag: number;
  4230. /**
  4231. * The dirty fresnel flag value
  4232. */
  4233. static readonly MATERIAL_FresnelDirtyFlag: number;
  4234. /**
  4235. * The dirty attribute flag value
  4236. */
  4237. static readonly MATERIAL_AttributesDirtyFlag: number;
  4238. /**
  4239. * The dirty misc flag value
  4240. */
  4241. static readonly MATERIAL_MiscDirtyFlag: number;
  4242. /**
  4243. * The all dirty flag value
  4244. */
  4245. static readonly MATERIAL_AllDirtyFlag: number;
  4246. /**
  4247. * Returns the triangle fill mode
  4248. */
  4249. static readonly MATERIAL_TriangleFillMode: number;
  4250. /**
  4251. * Returns the wireframe mode
  4252. */
  4253. static readonly MATERIAL_WireFrameFillMode: number;
  4254. /**
  4255. * Returns the point fill mode
  4256. */
  4257. static readonly MATERIAL_PointFillMode: number;
  4258. /**
  4259. * Returns the point list draw mode
  4260. */
  4261. static readonly MATERIAL_PointListDrawMode: number;
  4262. /**
  4263. * Returns the line list draw mode
  4264. */
  4265. static readonly MATERIAL_LineListDrawMode: number;
  4266. /**
  4267. * Returns the line loop draw mode
  4268. */
  4269. static readonly MATERIAL_LineLoopDrawMode: number;
  4270. /**
  4271. * Returns the line strip draw mode
  4272. */
  4273. static readonly MATERIAL_LineStripDrawMode: number;
  4274. /**
  4275. * Returns the triangle strip draw mode
  4276. */
  4277. static readonly MATERIAL_TriangleStripDrawMode: number;
  4278. /**
  4279. * Returns the triangle fan draw mode
  4280. */
  4281. static readonly MATERIAL_TriangleFanDrawMode: number;
  4282. /**
  4283. * Stores the clock-wise side orientation
  4284. */
  4285. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4286. /**
  4287. * Stores the counter clock-wise side orientation
  4288. */
  4289. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4290. /**
  4291. * Nothing
  4292. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4293. */
  4294. static readonly ACTION_NothingTrigger: number;
  4295. /**
  4296. * On pick
  4297. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4298. */
  4299. static readonly ACTION_OnPickTrigger: number;
  4300. /**
  4301. * On left pick
  4302. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4303. */
  4304. static readonly ACTION_OnLeftPickTrigger: number;
  4305. /**
  4306. * On right pick
  4307. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4308. */
  4309. static readonly ACTION_OnRightPickTrigger: number;
  4310. /**
  4311. * On center pick
  4312. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4313. */
  4314. static readonly ACTION_OnCenterPickTrigger: number;
  4315. /**
  4316. * On pick down
  4317. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4318. */
  4319. static readonly ACTION_OnPickDownTrigger: number;
  4320. /**
  4321. * On double pick
  4322. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4323. */
  4324. static readonly ACTION_OnDoublePickTrigger: number;
  4325. /**
  4326. * On pick up
  4327. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4328. */
  4329. static readonly ACTION_OnPickUpTrigger: number;
  4330. /**
  4331. * On pick out.
  4332. * This trigger will only be raised if you also declared a OnPickDown
  4333. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4334. */
  4335. static readonly ACTION_OnPickOutTrigger: number;
  4336. /**
  4337. * On long press
  4338. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4339. */
  4340. static readonly ACTION_OnLongPressTrigger: number;
  4341. /**
  4342. * On pointer over
  4343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4344. */
  4345. static readonly ACTION_OnPointerOverTrigger: number;
  4346. /**
  4347. * On pointer out
  4348. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4349. */
  4350. static readonly ACTION_OnPointerOutTrigger: number;
  4351. /**
  4352. * On every frame
  4353. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4354. */
  4355. static readonly ACTION_OnEveryFrameTrigger: number;
  4356. /**
  4357. * On intersection enter
  4358. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4359. */
  4360. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4361. /**
  4362. * On intersection exit
  4363. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4364. */
  4365. static readonly ACTION_OnIntersectionExitTrigger: number;
  4366. /**
  4367. * On key down
  4368. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4369. */
  4370. static readonly ACTION_OnKeyDownTrigger: number;
  4371. /**
  4372. * On key up
  4373. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4374. */
  4375. static readonly ACTION_OnKeyUpTrigger: number;
  4376. /**
  4377. * Billboard mode will only apply to Y axis
  4378. */
  4379. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4380. /**
  4381. * Billboard mode will apply to all axes
  4382. */
  4383. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4384. /**
  4385. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4386. */
  4387. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4388. /**
  4389. * Gets or sets base Assets URL
  4390. */
  4391. static PARTICLES_BaseAssetsUrl: string;
  4392. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4393. * Test order :
  4394. * Is the bounding sphere outside the frustum ?
  4395. * If not, are the bounding box vertices outside the frustum ?
  4396. * It not, then the cullable object is in the frustum.
  4397. */
  4398. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4399. /** Culling strategy : Bounding Sphere Only.
  4400. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4401. * It's also less accurate than the standard because some not visible objects can still be selected.
  4402. * Test : is the bounding sphere outside the frustum ?
  4403. * If not, then the cullable object is in the frustum.
  4404. */
  4405. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4406. /** Culling strategy : Optimistic Inclusion.
  4407. * This in an inclusion test first, then the standard exclusion test.
  4408. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4409. * 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.
  4410. * Anyway, it's as accurate as the standard strategy.
  4411. * Test :
  4412. * Is the cullable object bounding sphere center in the frustum ?
  4413. * If not, apply the default culling strategy.
  4414. */
  4415. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4416. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4417. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4418. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4419. * 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.
  4420. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4421. * Test :
  4422. * Is the cullable object bounding sphere center in the frustum ?
  4423. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4424. */
  4425. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4426. /**
  4427. * No logging while loading
  4428. */
  4429. static readonly SCENELOADER_NO_LOGGING: number;
  4430. /**
  4431. * Minimal logging while loading
  4432. */
  4433. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4434. /**
  4435. * Summary logging while loading
  4436. */
  4437. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4438. /**
  4439. * Detailled logging while loading
  4440. */
  4441. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4442. }
  4443. }
  4444. declare module BABYLON {
  4445. /**
  4446. * Class used to store and describe the pipeline context associated with an effect
  4447. */
  4448. export interface IPipelineContext {
  4449. /**
  4450. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4451. */
  4452. isAsync: boolean;
  4453. /**
  4454. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4455. */
  4456. isReady: boolean;
  4457. /** @hidden */ private _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4458. }
  4459. }
  4460. declare module BABYLON {
  4461. /** @hidden */
  4462. export interface IShaderProcessor {
  4463. attributeProcessor?: (attribute: string) => string;
  4464. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4465. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4466. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4467. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4468. lineProcessor?: (line: string, isFragment: boolean) => string;
  4469. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4470. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4471. }
  4472. }
  4473. declare module BABYLON {
  4474. /** @hidden */
  4475. export interface ProcessingOptions {
  4476. defines: string[];
  4477. indexParameters: any;
  4478. isFragment: boolean;
  4479. shouldUseHighPrecisionShader: boolean;
  4480. supportsUniformBuffers: boolean;
  4481. shadersRepository: string;
  4482. includesShadersStore: {
  4483. [key: string]: string;
  4484. };
  4485. processor?: IShaderProcessor;
  4486. version: string;
  4487. platformName: string;
  4488. lookForClosingBracketForUniformBuffer?: boolean;
  4489. }
  4490. }
  4491. declare module BABYLON {
  4492. /**
  4493. * Helper to manipulate strings
  4494. */
  4495. export class StringTools {
  4496. /**
  4497. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4498. * @param str Source string
  4499. * @param suffix Suffix to search for in the source string
  4500. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4501. */
  4502. static EndsWith(str: string, suffix: string): boolean;
  4503. /**
  4504. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4505. * @param str Source string
  4506. * @param suffix Suffix to search for in the source string
  4507. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4508. */
  4509. static StartsWith(str: string, suffix: string): boolean;
  4510. }
  4511. }
  4512. declare module BABYLON {
  4513. /** @hidden */
  4514. export class ShaderCodeNode {
  4515. line: string;
  4516. children: ShaderCodeNode[];
  4517. additionalDefineKey?: string;
  4518. additionalDefineValue?: string;
  4519. isValid(preprocessors: {
  4520. [key: string]: string;
  4521. }): boolean;
  4522. process(preprocessors: {
  4523. [key: string]: string;
  4524. }, options: ProcessingOptions): string;
  4525. }
  4526. }
  4527. declare module BABYLON {
  4528. /** @hidden */
  4529. export class ShaderCodeCursor {
  4530. private _lines;
  4531. lineIndex: number;
  4532. readonly currentLine: string;
  4533. readonly canRead: boolean;
  4534. lines: string[];
  4535. }
  4536. }
  4537. declare module BABYLON {
  4538. /** @hidden */
  4539. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4540. process(preprocessors: {
  4541. [key: string]: string;
  4542. }, options: ProcessingOptions): string;
  4543. }
  4544. }
  4545. declare module BABYLON {
  4546. /** @hidden */
  4547. export class ShaderDefineExpression {
  4548. isTrue(preprocessors: {
  4549. [key: string]: string;
  4550. }): boolean;
  4551. }
  4552. }
  4553. declare module BABYLON {
  4554. /** @hidden */
  4555. export class ShaderCodeTestNode extends ShaderCodeNode {
  4556. testExpression: ShaderDefineExpression;
  4557. isValid(preprocessors: {
  4558. [key: string]: string;
  4559. }): boolean;
  4560. }
  4561. }
  4562. declare module BABYLON {
  4563. /** @hidden */
  4564. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4565. define: string;
  4566. not: boolean;
  4567. constructor(define: string, not?: boolean);
  4568. isTrue(preprocessors: {
  4569. [key: string]: string;
  4570. }): boolean;
  4571. }
  4572. }
  4573. declare module BABYLON {
  4574. /** @hidden */
  4575. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4576. leftOperand: ShaderDefineExpression;
  4577. rightOperand: ShaderDefineExpression;
  4578. isTrue(preprocessors: {
  4579. [key: string]: string;
  4580. }): boolean;
  4581. }
  4582. }
  4583. declare module BABYLON {
  4584. /** @hidden */
  4585. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4586. leftOperand: ShaderDefineExpression;
  4587. rightOperand: ShaderDefineExpression;
  4588. isTrue(preprocessors: {
  4589. [key: string]: string;
  4590. }): boolean;
  4591. }
  4592. }
  4593. declare module BABYLON {
  4594. /** @hidden */
  4595. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4596. define: string;
  4597. operand: string;
  4598. testValue: string;
  4599. constructor(define: string, operand: string, testValue: string);
  4600. isTrue(preprocessors: {
  4601. [key: string]: string;
  4602. }): boolean;
  4603. }
  4604. }
  4605. declare module BABYLON {
  4606. /**
  4607. * @ignore
  4608. * Application error to support additional information when loading a file
  4609. */
  4610. export class LoadFileError extends Error {
  4611. /** defines the optional web request */
  4612. request?: WebRequest | undefined;
  4613. private static _setPrototypeOf;
  4614. /**
  4615. * Creates a new LoadFileError
  4616. * @param message defines the message of the error
  4617. * @param request defines the optional web request
  4618. */
  4619. constructor(message: string,
  4620. /** defines the optional web request */
  4621. request?: WebRequest | undefined);
  4622. }
  4623. }
  4624. declare module BABYLON {
  4625. /**
  4626. * Class used to enable access to offline support
  4627. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4628. */
  4629. export interface IOfflineProvider {
  4630. /**
  4631. * Gets a boolean indicating if scene must be saved in the database
  4632. */
  4633. enableSceneOffline: boolean;
  4634. /**
  4635. * Gets a boolean indicating if textures must be saved in the database
  4636. */
  4637. enableTexturesOffline: boolean;
  4638. /**
  4639. * Open the offline support and make it available
  4640. * @param successCallback defines the callback to call on success
  4641. * @param errorCallback defines the callback to call on error
  4642. */
  4643. open(successCallback: () => void, errorCallback: () => void): void;
  4644. /**
  4645. * Loads an image from the offline support
  4646. * @param url defines the url to load from
  4647. * @param image defines the target DOM image
  4648. */
  4649. loadImage(url: string, image: HTMLImageElement): void;
  4650. /**
  4651. * Loads a file from offline support
  4652. * @param url defines the URL to load from
  4653. * @param sceneLoaded defines a callback to call on success
  4654. * @param progressCallBack defines a callback to call when progress changed
  4655. * @param errorCallback defines a callback to call on error
  4656. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4657. */
  4658. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4659. }
  4660. }
  4661. declare module BABYLON {
  4662. /**
  4663. * Class used to help managing file picking and drag'n'drop
  4664. * File Storage
  4665. */
  4666. export class FilesInputStore {
  4667. /**
  4668. * List of files ready to be loaded
  4669. */
  4670. static FilesToLoad: {
  4671. [key: string]: File;
  4672. };
  4673. }
  4674. }
  4675. declare module BABYLON {
  4676. /**
  4677. * Class used to define a retry strategy when error happens while loading assets
  4678. */
  4679. export class RetryStrategy {
  4680. /**
  4681. * Function used to defines an exponential back off strategy
  4682. * @param maxRetries defines the maximum number of retries (3 by default)
  4683. * @param baseInterval defines the interval between retries
  4684. * @returns the strategy function to use
  4685. */
  4686. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4687. }
  4688. }
  4689. declare module BABYLON {
  4690. /**
  4691. * @hidden
  4692. */
  4693. export class FileTools {
  4694. /**
  4695. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4696. */
  4697. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4698. /**
  4699. * Gets or sets the base URL to use to load assets
  4700. */
  4701. static BaseUrl: string;
  4702. /**
  4703. * Default behaviour for cors in the application.
  4704. * It can be a string if the expected behavior is identical in the entire app.
  4705. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4706. */
  4707. static CorsBehavior: string | ((url: string | string[]) => string);
  4708. /**
  4709. * Gets or sets a function used to pre-process url before using them to load assets
  4710. */
  4711. static PreprocessUrl: (url: string) => string;
  4712. /**
  4713. * Removes unwanted characters from an url
  4714. * @param url defines the url to clean
  4715. * @returns the cleaned url
  4716. */
  4717. private static _CleanUrl;
  4718. /**
  4719. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4720. * @param url define the url we are trying
  4721. * @param element define the dom element where to configure the cors policy
  4722. */
  4723. static SetCorsBehavior(url: string | string[], element: {
  4724. crossOrigin: string | null;
  4725. }): void;
  4726. /**
  4727. * Loads an image as an HTMLImageElement.
  4728. * @param input url string, ArrayBuffer, or Blob to load
  4729. * @param onLoad callback called when the image successfully loads
  4730. * @param onError callback called when the image fails to load
  4731. * @param offlineProvider offline provider for caching
  4732. * @returns the HTMLImageElement of the loaded image
  4733. */
  4734. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4735. /**
  4736. * Loads a file
  4737. * @param fileToLoad defines the file to load
  4738. * @param callback defines the callback to call when data is loaded
  4739. * @param progressCallBack defines the callback to call during loading process
  4740. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4741. * @returns a file request object
  4742. */
  4743. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4744. /**
  4745. * Loads a file
  4746. * @param url url string, ArrayBuffer, or Blob to load
  4747. * @param onSuccess callback called when the file successfully loads
  4748. * @param onProgress callback called while file is loading (if the server supports this mode)
  4749. * @param offlineProvider defines the offline provider for caching
  4750. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4751. * @param onError callback called when the file fails to load
  4752. * @returns a file request object
  4753. */
  4754. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  4755. /**
  4756. * Checks if the loaded document was accessed via `file:`-Protocol.
  4757. * @returns boolean
  4758. */
  4759. static IsFileURL(): boolean;
  4760. }
  4761. }
  4762. declare module BABYLON {
  4763. /** @hidden */
  4764. export class ShaderProcessor {
  4765. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4766. private static _ProcessPrecision;
  4767. private static _ExtractOperation;
  4768. private static _BuildSubExpression;
  4769. private static _BuildExpression;
  4770. private static _MoveCursorWithinIf;
  4771. private static _MoveCursor;
  4772. private static _EvaluatePreProcessors;
  4773. private static _PreparePreProcessors;
  4774. private static _ProcessShaderConversion;
  4775. private static _ProcessIncludes;
  4776. }
  4777. }
  4778. declare module BABYLON {
  4779. /**
  4780. * Class used to hold a RBG color
  4781. */
  4782. export class Color3 {
  4783. /**
  4784. * Defines the red component (between 0 and 1, default is 0)
  4785. */
  4786. r: number;
  4787. /**
  4788. * Defines the green component (between 0 and 1, default is 0)
  4789. */
  4790. g: number;
  4791. /**
  4792. * Defines the blue component (between 0 and 1, default is 0)
  4793. */
  4794. b: number;
  4795. /**
  4796. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4797. * @param r defines the red component (between 0 and 1, default is 0)
  4798. * @param g defines the green component (between 0 and 1, default is 0)
  4799. * @param b defines the blue component (between 0 and 1, default is 0)
  4800. */
  4801. constructor(
  4802. /**
  4803. * Defines the red component (between 0 and 1, default is 0)
  4804. */
  4805. r?: number,
  4806. /**
  4807. * Defines the green component (between 0 and 1, default is 0)
  4808. */
  4809. g?: number,
  4810. /**
  4811. * Defines the blue component (between 0 and 1, default is 0)
  4812. */
  4813. b?: number);
  4814. /**
  4815. * Creates a string with the Color3 current values
  4816. * @returns the string representation of the Color3 object
  4817. */
  4818. toString(): string;
  4819. /**
  4820. * Returns the string "Color3"
  4821. * @returns "Color3"
  4822. */
  4823. getClassName(): string;
  4824. /**
  4825. * Compute the Color3 hash code
  4826. * @returns an unique number that can be used to hash Color3 objects
  4827. */
  4828. getHashCode(): number;
  4829. /**
  4830. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4831. * @param array defines the array where to store the r,g,b components
  4832. * @param index defines an optional index in the target array to define where to start storing values
  4833. * @returns the current Color3 object
  4834. */
  4835. toArray(array: FloatArray, index?: number): Color3;
  4836. /**
  4837. * Returns a new Color4 object from the current Color3 and the given alpha
  4838. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4839. * @returns a new Color4 object
  4840. */
  4841. toColor4(alpha?: number): Color4;
  4842. /**
  4843. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4844. * @returns the new array
  4845. */
  4846. asArray(): number[];
  4847. /**
  4848. * Returns the luminance value
  4849. * @returns a float value
  4850. */
  4851. toLuminance(): number;
  4852. /**
  4853. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4854. * @param otherColor defines the second operand
  4855. * @returns the new Color3 object
  4856. */
  4857. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4858. /**
  4859. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4860. * @param otherColor defines the second operand
  4861. * @param result defines the Color3 object where to store the result
  4862. * @returns the current Color3
  4863. */
  4864. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4865. /**
  4866. * Determines equality between Color3 objects
  4867. * @param otherColor defines the second operand
  4868. * @returns true if the rgb values are equal to the given ones
  4869. */
  4870. equals(otherColor: DeepImmutable<Color3>): boolean;
  4871. /**
  4872. * Determines equality between the current Color3 object and a set of r,b,g values
  4873. * @param r defines the red component to check
  4874. * @param g defines the green component to check
  4875. * @param b defines the blue component to check
  4876. * @returns true if the rgb values are equal to the given ones
  4877. */
  4878. equalsFloats(r: number, g: number, b: number): boolean;
  4879. /**
  4880. * Multiplies in place each rgb value by scale
  4881. * @param scale defines the scaling factor
  4882. * @returns the updated Color3
  4883. */
  4884. scale(scale: number): Color3;
  4885. /**
  4886. * Multiplies the rgb values by scale and stores the result into "result"
  4887. * @param scale defines the scaling factor
  4888. * @param result defines the Color3 object where to store the result
  4889. * @returns the unmodified current Color3
  4890. */
  4891. scaleToRef(scale: number, result: Color3): Color3;
  4892. /**
  4893. * Scale the current Color3 values by a factor and add the result to a given Color3
  4894. * @param scale defines the scale factor
  4895. * @param result defines color to store the result into
  4896. * @returns the unmodified current Color3
  4897. */
  4898. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4899. /**
  4900. * Clamps the rgb values by the min and max values and stores the result into "result"
  4901. * @param min defines minimum clamping value (default is 0)
  4902. * @param max defines maximum clamping value (default is 1)
  4903. * @param result defines color to store the result into
  4904. * @returns the original Color3
  4905. */
  4906. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4907. /**
  4908. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4909. * @param otherColor defines the second operand
  4910. * @returns the new Color3
  4911. */
  4912. add(otherColor: DeepImmutable<Color3>): Color3;
  4913. /**
  4914. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4915. * @param otherColor defines the second operand
  4916. * @param result defines Color3 object to store the result into
  4917. * @returns the unmodified current Color3
  4918. */
  4919. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4920. /**
  4921. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4922. * @param otherColor defines the second operand
  4923. * @returns the new Color3
  4924. */
  4925. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4926. /**
  4927. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4928. * @param otherColor defines the second operand
  4929. * @param result defines Color3 object to store the result into
  4930. * @returns the unmodified current Color3
  4931. */
  4932. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4933. /**
  4934. * Copy the current object
  4935. * @returns a new Color3 copied the current one
  4936. */
  4937. clone(): Color3;
  4938. /**
  4939. * Copies the rgb values from the source in the current Color3
  4940. * @param source defines the source Color3 object
  4941. * @returns the updated Color3 object
  4942. */
  4943. copyFrom(source: DeepImmutable<Color3>): Color3;
  4944. /**
  4945. * Updates the Color3 rgb values from the given floats
  4946. * @param r defines the red component to read from
  4947. * @param g defines the green component to read from
  4948. * @param b defines the blue component to read from
  4949. * @returns the current Color3 object
  4950. */
  4951. copyFromFloats(r: number, g: number, b: number): Color3;
  4952. /**
  4953. * Updates the Color3 rgb values from the given floats
  4954. * @param r defines the red component to read from
  4955. * @param g defines the green component to read from
  4956. * @param b defines the blue component to read from
  4957. * @returns the current Color3 object
  4958. */
  4959. set(r: number, g: number, b: number): Color3;
  4960. /**
  4961. * Compute the Color3 hexadecimal code as a string
  4962. * @returns a string containing the hexadecimal representation of the Color3 object
  4963. */
  4964. toHexString(): string;
  4965. /**
  4966. * Computes a new Color3 converted from the current one to linear space
  4967. * @returns a new Color3 object
  4968. */
  4969. toLinearSpace(): Color3;
  4970. /**
  4971. * Converts current color in rgb space to HSV values
  4972. * @returns a new color3 representing the HSV values
  4973. */
  4974. toHSV(): Color3;
  4975. /**
  4976. * Converts current color in rgb space to HSV values
  4977. * @param result defines the Color3 where to store the HSV values
  4978. */
  4979. toHSVToRef(result: Color3): void;
  4980. /**
  4981. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  4982. * @param convertedColor defines the Color3 object where to store the linear space version
  4983. * @returns the unmodified Color3
  4984. */
  4985. toLinearSpaceToRef(convertedColor: Color3): Color3;
  4986. /**
  4987. * Computes a new Color3 converted from the current one to gamma space
  4988. * @returns a new Color3 object
  4989. */
  4990. toGammaSpace(): Color3;
  4991. /**
  4992. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  4993. * @param convertedColor defines the Color3 object where to store the gamma space version
  4994. * @returns the unmodified Color3
  4995. */
  4996. toGammaSpaceToRef(convertedColor: Color3): Color3;
  4997. private static _BlackReadOnly;
  4998. /**
  4999. * Convert Hue, saturation and value to a Color3 (RGB)
  5000. * @param hue defines the hue
  5001. * @param saturation defines the saturation
  5002. * @param value defines the value
  5003. * @param result defines the Color3 where to store the RGB values
  5004. */
  5005. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5006. /**
  5007. * Creates a new Color3 from the string containing valid hexadecimal values
  5008. * @param hex defines a string containing valid hexadecimal values
  5009. * @returns a new Color3 object
  5010. */
  5011. static FromHexString(hex: string): Color3;
  5012. /**
  5013. * Creates a new Color3 from the starting index of the given array
  5014. * @param array defines the source array
  5015. * @param offset defines an offset in the source array
  5016. * @returns a new Color3 object
  5017. */
  5018. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5019. /**
  5020. * Creates a new Color3 from integer values (< 256)
  5021. * @param r defines the red component to read from (value between 0 and 255)
  5022. * @param g defines the green component to read from (value between 0 and 255)
  5023. * @param b defines the blue component to read from (value between 0 and 255)
  5024. * @returns a new Color3 object
  5025. */
  5026. static FromInts(r: number, g: number, b: number): Color3;
  5027. /**
  5028. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5029. * @param start defines the start Color3 value
  5030. * @param end defines the end Color3 value
  5031. * @param amount defines the gradient value between start and end
  5032. * @returns a new Color3 object
  5033. */
  5034. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5035. /**
  5036. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5037. * @param left defines the start value
  5038. * @param right defines the end value
  5039. * @param amount defines the gradient factor
  5040. * @param result defines the Color3 object where to store the result
  5041. */
  5042. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5043. /**
  5044. * Returns a Color3 value containing a red color
  5045. * @returns a new Color3 object
  5046. */
  5047. static Red(): Color3;
  5048. /**
  5049. * Returns a Color3 value containing a green color
  5050. * @returns a new Color3 object
  5051. */
  5052. static Green(): Color3;
  5053. /**
  5054. * Returns a Color3 value containing a blue color
  5055. * @returns a new Color3 object
  5056. */
  5057. static Blue(): Color3;
  5058. /**
  5059. * Returns a Color3 value containing a black color
  5060. * @returns a new Color3 object
  5061. */
  5062. static Black(): Color3;
  5063. /**
  5064. * Gets a Color3 value containing a black color that must not be updated
  5065. */
  5066. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5067. /**
  5068. * Returns a Color3 value containing a white color
  5069. * @returns a new Color3 object
  5070. */
  5071. static White(): Color3;
  5072. /**
  5073. * Returns a Color3 value containing a purple color
  5074. * @returns a new Color3 object
  5075. */
  5076. static Purple(): Color3;
  5077. /**
  5078. * Returns a Color3 value containing a magenta color
  5079. * @returns a new Color3 object
  5080. */
  5081. static Magenta(): Color3;
  5082. /**
  5083. * Returns a Color3 value containing a yellow color
  5084. * @returns a new Color3 object
  5085. */
  5086. static Yellow(): Color3;
  5087. /**
  5088. * Returns a Color3 value containing a gray color
  5089. * @returns a new Color3 object
  5090. */
  5091. static Gray(): Color3;
  5092. /**
  5093. * Returns a Color3 value containing a teal color
  5094. * @returns a new Color3 object
  5095. */
  5096. static Teal(): Color3;
  5097. /**
  5098. * Returns a Color3 value containing a random color
  5099. * @returns a new Color3 object
  5100. */
  5101. static Random(): Color3;
  5102. }
  5103. /**
  5104. * Class used to hold a RBGA color
  5105. */
  5106. export class Color4 {
  5107. /**
  5108. * Defines the red component (between 0 and 1, default is 0)
  5109. */
  5110. r: number;
  5111. /**
  5112. * Defines the green component (between 0 and 1, default is 0)
  5113. */
  5114. g: number;
  5115. /**
  5116. * Defines the blue component (between 0 and 1, default is 0)
  5117. */
  5118. b: number;
  5119. /**
  5120. * Defines the alpha component (between 0 and 1, default is 1)
  5121. */
  5122. a: number;
  5123. /**
  5124. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5125. * @param r defines the red component (between 0 and 1, default is 0)
  5126. * @param g defines the green component (between 0 and 1, default is 0)
  5127. * @param b defines the blue component (between 0 and 1, default is 0)
  5128. * @param a defines the alpha component (between 0 and 1, default is 1)
  5129. */
  5130. constructor(
  5131. /**
  5132. * Defines the red component (between 0 and 1, default is 0)
  5133. */
  5134. r?: number,
  5135. /**
  5136. * Defines the green component (between 0 and 1, default is 0)
  5137. */
  5138. g?: number,
  5139. /**
  5140. * Defines the blue component (between 0 and 1, default is 0)
  5141. */
  5142. b?: number,
  5143. /**
  5144. * Defines the alpha component (between 0 and 1, default is 1)
  5145. */
  5146. a?: number);
  5147. /**
  5148. * Adds in place the given Color4 values to the current Color4 object
  5149. * @param right defines the second operand
  5150. * @returns the current updated Color4 object
  5151. */
  5152. addInPlace(right: DeepImmutable<Color4>): Color4;
  5153. /**
  5154. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5155. * @returns the new array
  5156. */
  5157. asArray(): number[];
  5158. /**
  5159. * Stores from the starting index in the given array the Color4 successive values
  5160. * @param array defines the array where to store the r,g,b components
  5161. * @param index defines an optional index in the target array to define where to start storing values
  5162. * @returns the current Color4 object
  5163. */
  5164. toArray(array: number[], index?: number): Color4;
  5165. /**
  5166. * Determines equality between Color4 objects
  5167. * @param otherColor defines the second operand
  5168. * @returns true if the rgba values are equal to the given ones
  5169. */
  5170. equals(otherColor: DeepImmutable<Color4>): boolean;
  5171. /**
  5172. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5173. * @param right defines the second operand
  5174. * @returns a new Color4 object
  5175. */
  5176. add(right: DeepImmutable<Color4>): Color4;
  5177. /**
  5178. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5179. * @param right defines the second operand
  5180. * @returns a new Color4 object
  5181. */
  5182. subtract(right: DeepImmutable<Color4>): Color4;
  5183. /**
  5184. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5185. * @param right defines the second operand
  5186. * @param result defines the Color4 object where to store the result
  5187. * @returns the current Color4 object
  5188. */
  5189. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5190. /**
  5191. * Creates a new Color4 with the current Color4 values multiplied by scale
  5192. * @param scale defines the scaling factor to apply
  5193. * @returns a new Color4 object
  5194. */
  5195. scale(scale: number): Color4;
  5196. /**
  5197. * Multiplies the current Color4 values by scale and stores the result in "result"
  5198. * @param scale defines the scaling factor to apply
  5199. * @param result defines the Color4 object where to store the result
  5200. * @returns the current unmodified Color4
  5201. */
  5202. scaleToRef(scale: number, result: Color4): Color4;
  5203. /**
  5204. * Scale the current Color4 values by a factor and add the result to a given Color4
  5205. * @param scale defines the scale factor
  5206. * @param result defines the Color4 object where to store the result
  5207. * @returns the unmodified current Color4
  5208. */
  5209. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5210. /**
  5211. * Clamps the rgb values by the min and max values and stores the result into "result"
  5212. * @param min defines minimum clamping value (default is 0)
  5213. * @param max defines maximum clamping value (default is 1)
  5214. * @param result defines color to store the result into.
  5215. * @returns the cuurent Color4
  5216. */
  5217. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5218. /**
  5219. * Multipy an Color4 value by another and return a new Color4 object
  5220. * @param color defines the Color4 value to multiply by
  5221. * @returns a new Color4 object
  5222. */
  5223. multiply(color: Color4): Color4;
  5224. /**
  5225. * Multipy a Color4 value by another and push the result in a reference value
  5226. * @param color defines the Color4 value to multiply by
  5227. * @param result defines the Color4 to fill the result in
  5228. * @returns the result Color4
  5229. */
  5230. multiplyToRef(color: Color4, result: Color4): Color4;
  5231. /**
  5232. * Creates a string with the Color4 current values
  5233. * @returns the string representation of the Color4 object
  5234. */
  5235. toString(): string;
  5236. /**
  5237. * Returns the string "Color4"
  5238. * @returns "Color4"
  5239. */
  5240. getClassName(): string;
  5241. /**
  5242. * Compute the Color4 hash code
  5243. * @returns an unique number that can be used to hash Color4 objects
  5244. */
  5245. getHashCode(): number;
  5246. /**
  5247. * Creates a new Color4 copied from the current one
  5248. * @returns a new Color4 object
  5249. */
  5250. clone(): Color4;
  5251. /**
  5252. * Copies the given Color4 values into the current one
  5253. * @param source defines the source Color4 object
  5254. * @returns the current updated Color4 object
  5255. */
  5256. copyFrom(source: Color4): Color4;
  5257. /**
  5258. * Copies the given float values into the current one
  5259. * @param r defines the red component to read from
  5260. * @param g defines the green component to read from
  5261. * @param b defines the blue component to read from
  5262. * @param a defines the alpha component to read from
  5263. * @returns the current updated Color4 object
  5264. */
  5265. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5266. /**
  5267. * Copies the given float values into the current one
  5268. * @param r defines the red component to read from
  5269. * @param g defines the green component to read from
  5270. * @param b defines the blue component to read from
  5271. * @param a defines the alpha component to read from
  5272. * @returns the current updated Color4 object
  5273. */
  5274. set(r: number, g: number, b: number, a: number): Color4;
  5275. /**
  5276. * Compute the Color4 hexadecimal code as a string
  5277. * @returns a string containing the hexadecimal representation of the Color4 object
  5278. */
  5279. toHexString(): string;
  5280. /**
  5281. * Computes a new Color4 converted from the current one to linear space
  5282. * @returns a new Color4 object
  5283. */
  5284. toLinearSpace(): Color4;
  5285. /**
  5286. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5287. * @param convertedColor defines the Color4 object where to store the linear space version
  5288. * @returns the unmodified Color4
  5289. */
  5290. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5291. /**
  5292. * Computes a new Color4 converted from the current one to gamma space
  5293. * @returns a new Color4 object
  5294. */
  5295. toGammaSpace(): Color4;
  5296. /**
  5297. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5298. * @param convertedColor defines the Color4 object where to store the gamma space version
  5299. * @returns the unmodified Color4
  5300. */
  5301. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5302. /**
  5303. * Creates a new Color4 from the string containing valid hexadecimal values
  5304. * @param hex defines a string containing valid hexadecimal values
  5305. * @returns a new Color4 object
  5306. */
  5307. static FromHexString(hex: string): Color4;
  5308. /**
  5309. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5310. * @param left defines the start value
  5311. * @param right defines the end value
  5312. * @param amount defines the gradient factor
  5313. * @returns a new Color4 object
  5314. */
  5315. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5316. /**
  5317. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5318. * @param left defines the start value
  5319. * @param right defines the end value
  5320. * @param amount defines the gradient factor
  5321. * @param result defines the Color4 object where to store data
  5322. */
  5323. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5324. /**
  5325. * Creates a new Color4 from a Color3 and an alpha value
  5326. * @param color3 defines the source Color3 to read from
  5327. * @param alpha defines the alpha component (1.0 by default)
  5328. * @returns a new Color4 object
  5329. */
  5330. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5331. /**
  5332. * Creates a new Color4 from the starting index element of the given array
  5333. * @param array defines the source array to read from
  5334. * @param offset defines the offset in the source array
  5335. * @returns a new Color4 object
  5336. */
  5337. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5338. /**
  5339. * Creates a new Color3 from integer values (< 256)
  5340. * @param r defines the red component to read from (value between 0 and 255)
  5341. * @param g defines the green component to read from (value between 0 and 255)
  5342. * @param b defines the blue component to read from (value between 0 and 255)
  5343. * @param a defines the alpha component to read from (value between 0 and 255)
  5344. * @returns a new Color3 object
  5345. */
  5346. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5347. /**
  5348. * Check the content of a given array and convert it to an array containing RGBA data
  5349. * If the original array was already containing count * 4 values then it is returned directly
  5350. * @param colors defines the array to check
  5351. * @param count defines the number of RGBA data to expect
  5352. * @returns an array containing count * 4 values (RGBA)
  5353. */
  5354. static CheckColors4(colors: number[], count: number): number[];
  5355. }
  5356. /**
  5357. * @hidden
  5358. */
  5359. export class TmpColors {
  5360. static Color3: Color3[];
  5361. static Color4: Color4[];
  5362. }
  5363. }
  5364. declare module BABYLON {
  5365. /**
  5366. * Class representing spherical harmonics coefficients to the 3rd degree
  5367. */
  5368. export class SphericalHarmonics {
  5369. /**
  5370. * Defines whether or not the harmonics have been prescaled for rendering.
  5371. */
  5372. preScaled: boolean;
  5373. /**
  5374. * The l0,0 coefficients of the spherical harmonics
  5375. */
  5376. l00: Vector3;
  5377. /**
  5378. * The l1,-1 coefficients of the spherical harmonics
  5379. */
  5380. l1_1: Vector3;
  5381. /**
  5382. * The l1,0 coefficients of the spherical harmonics
  5383. */
  5384. l10: Vector3;
  5385. /**
  5386. * The l1,1 coefficients of the spherical harmonics
  5387. */
  5388. l11: Vector3;
  5389. /**
  5390. * The l2,-2 coefficients of the spherical harmonics
  5391. */
  5392. l2_2: Vector3;
  5393. /**
  5394. * The l2,-1 coefficients of the spherical harmonics
  5395. */
  5396. l2_1: Vector3;
  5397. /**
  5398. * The l2,0 coefficients of the spherical harmonics
  5399. */
  5400. l20: Vector3;
  5401. /**
  5402. * The l2,1 coefficients of the spherical harmonics
  5403. */
  5404. l21: Vector3;
  5405. /**
  5406. * The l2,2 coefficients of the spherical harmonics
  5407. */
  5408. l22: Vector3;
  5409. /**
  5410. * Adds a light to the spherical harmonics
  5411. * @param direction the direction of the light
  5412. * @param color the color of the light
  5413. * @param deltaSolidAngle the delta solid angle of the light
  5414. */
  5415. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5416. /**
  5417. * Scales the spherical harmonics by the given amount
  5418. * @param scale the amount to scale
  5419. */
  5420. scaleInPlace(scale: number): void;
  5421. /**
  5422. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5423. *
  5424. * ```
  5425. * E_lm = A_l * L_lm
  5426. * ```
  5427. *
  5428. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5429. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5430. * the scaling factors are given in equation 9.
  5431. */
  5432. convertIncidentRadianceToIrradiance(): void;
  5433. /**
  5434. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5435. *
  5436. * ```
  5437. * L = (1/pi) * E * rho
  5438. * ```
  5439. *
  5440. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5441. */
  5442. convertIrradianceToLambertianRadiance(): void;
  5443. /**
  5444. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5445. * required operations at run time.
  5446. *
  5447. * This is simply done by scaling back the SH with Ylm constants parameter.
  5448. * The trigonometric part being applied by the shader at run time.
  5449. */
  5450. preScaleForRendering(): void;
  5451. /**
  5452. * Constructs a spherical harmonics from an array.
  5453. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5454. * @returns the spherical harmonics
  5455. */
  5456. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5457. /**
  5458. * Gets the spherical harmonics from polynomial
  5459. * @param polynomial the spherical polynomial
  5460. * @returns the spherical harmonics
  5461. */
  5462. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5463. }
  5464. /**
  5465. * Class representing spherical polynomial coefficients to the 3rd degree
  5466. */
  5467. export class SphericalPolynomial {
  5468. private _harmonics;
  5469. /**
  5470. * The spherical harmonics used to create the polynomials.
  5471. */
  5472. readonly preScaledHarmonics: SphericalHarmonics;
  5473. /**
  5474. * The x coefficients of the spherical polynomial
  5475. */
  5476. x: Vector3;
  5477. /**
  5478. * The y coefficients of the spherical polynomial
  5479. */
  5480. y: Vector3;
  5481. /**
  5482. * The z coefficients of the spherical polynomial
  5483. */
  5484. z: Vector3;
  5485. /**
  5486. * The xx coefficients of the spherical polynomial
  5487. */
  5488. xx: Vector3;
  5489. /**
  5490. * The yy coefficients of the spherical polynomial
  5491. */
  5492. yy: Vector3;
  5493. /**
  5494. * The zz coefficients of the spherical polynomial
  5495. */
  5496. zz: Vector3;
  5497. /**
  5498. * The xy coefficients of the spherical polynomial
  5499. */
  5500. xy: Vector3;
  5501. /**
  5502. * The yz coefficients of the spherical polynomial
  5503. */
  5504. yz: Vector3;
  5505. /**
  5506. * The zx coefficients of the spherical polynomial
  5507. */
  5508. zx: Vector3;
  5509. /**
  5510. * Adds an ambient color to the spherical polynomial
  5511. * @param color the color to add
  5512. */
  5513. addAmbient(color: Color3): void;
  5514. /**
  5515. * Scales the spherical polynomial by the given amount
  5516. * @param scale the amount to scale
  5517. */
  5518. scaleInPlace(scale: number): void;
  5519. /**
  5520. * Gets the spherical polynomial from harmonics
  5521. * @param harmonics the spherical harmonics
  5522. * @returns the spherical polynomial
  5523. */
  5524. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5525. /**
  5526. * Constructs a spherical polynomial from an array.
  5527. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5528. * @returns the spherical polynomial
  5529. */
  5530. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5531. }
  5532. }
  5533. declare module BABYLON {
  5534. /**
  5535. * Define options used to create a render target texture
  5536. */
  5537. export class RenderTargetCreationOptions {
  5538. /**
  5539. * Specifies is mipmaps must be generated
  5540. */
  5541. generateMipMaps?: boolean;
  5542. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5543. generateDepthBuffer?: boolean;
  5544. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5545. generateStencilBuffer?: boolean;
  5546. /** Defines texture type (int by default) */
  5547. type?: number;
  5548. /** Defines sampling mode (trilinear by default) */
  5549. samplingMode?: number;
  5550. /** Defines format (RGBA by default) */
  5551. format?: number;
  5552. }
  5553. }
  5554. declare module BABYLON {
  5555. /**
  5556. * @hidden
  5557. **/
  5558. export class _AlphaState {
  5559. private _isAlphaBlendDirty;
  5560. private _isBlendFunctionParametersDirty;
  5561. private _isBlendEquationParametersDirty;
  5562. private _isBlendConstantsDirty;
  5563. private _alphaBlend;
  5564. private _blendFunctionParameters;
  5565. private _blendEquationParameters;
  5566. private _blendConstants;
  5567. /**
  5568. * Initializes the state.
  5569. */
  5570. constructor();
  5571. readonly isDirty: boolean;
  5572. alphaBlend: boolean;
  5573. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5574. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5575. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5576. reset(): void;
  5577. apply(gl: WebGLRenderingContext): void;
  5578. }
  5579. }
  5580. declare module BABYLON {
  5581. /**
  5582. * @hidden
  5583. **/
  5584. export class _DepthCullingState {
  5585. private _isDepthTestDirty;
  5586. private _isDepthMaskDirty;
  5587. private _isDepthFuncDirty;
  5588. private _isCullFaceDirty;
  5589. private _isCullDirty;
  5590. private _isZOffsetDirty;
  5591. private _isFrontFaceDirty;
  5592. private _depthTest;
  5593. private _depthMask;
  5594. private _depthFunc;
  5595. private _cull;
  5596. private _cullFace;
  5597. private _zOffset;
  5598. private _frontFace;
  5599. /**
  5600. * Initializes the state.
  5601. */
  5602. constructor();
  5603. readonly isDirty: boolean;
  5604. zOffset: number;
  5605. cullFace: Nullable<number>;
  5606. cull: Nullable<boolean>;
  5607. depthFunc: Nullable<number>;
  5608. depthMask: boolean;
  5609. depthTest: boolean;
  5610. frontFace: Nullable<number>;
  5611. reset(): void;
  5612. apply(gl: WebGLRenderingContext): void;
  5613. }
  5614. }
  5615. declare module BABYLON {
  5616. /**
  5617. * @hidden
  5618. **/
  5619. export class _StencilState {
  5620. /** 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 */
  5621. static readonly ALWAYS: number;
  5622. /** Passed to stencilOperation to specify that stencil value must be kept */
  5623. static readonly KEEP: number;
  5624. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5625. static readonly REPLACE: number;
  5626. private _isStencilTestDirty;
  5627. private _isStencilMaskDirty;
  5628. private _isStencilFuncDirty;
  5629. private _isStencilOpDirty;
  5630. private _stencilTest;
  5631. private _stencilMask;
  5632. private _stencilFunc;
  5633. private _stencilFuncRef;
  5634. private _stencilFuncMask;
  5635. private _stencilOpStencilFail;
  5636. private _stencilOpDepthFail;
  5637. private _stencilOpStencilDepthPass;
  5638. readonly isDirty: boolean;
  5639. stencilFunc: number;
  5640. stencilFuncRef: number;
  5641. stencilFuncMask: number;
  5642. stencilOpStencilFail: number;
  5643. stencilOpDepthFail: number;
  5644. stencilOpStencilDepthPass: number;
  5645. stencilMask: number;
  5646. stencilTest: boolean;
  5647. constructor();
  5648. reset(): void;
  5649. apply(gl: WebGLRenderingContext): void;
  5650. }
  5651. }
  5652. declare module BABYLON {
  5653. /**
  5654. * @hidden
  5655. **/
  5656. export class _TimeToken { private _startTimeQuery: Nullable<WebGLQuery>; private _endTimeQuery: Nullable<WebGLQuery>; private _timeElapsedQuery: Nullable<WebGLQuery>; private _timeElapsedQueryEnded: boolean;
  5657. }
  5658. }
  5659. declare module BABYLON {
  5660. /**
  5661. * Class used to evalaute queries containing `and` and `or` operators
  5662. */
  5663. export class AndOrNotEvaluator {
  5664. /**
  5665. * Evaluate a query
  5666. * @param query defines the query to evaluate
  5667. * @param evaluateCallback defines the callback used to filter result
  5668. * @returns true if the query matches
  5669. */
  5670. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5671. private static _HandleParenthesisContent;
  5672. private static _SimplifyNegation;
  5673. }
  5674. }
  5675. declare module BABYLON {
  5676. /**
  5677. * Class used to store custom tags
  5678. */
  5679. export class Tags {
  5680. /**
  5681. * Adds support for tags on the given object
  5682. * @param obj defines the object to use
  5683. */
  5684. static EnableFor(obj: any): void;
  5685. /**
  5686. * Removes tags support
  5687. * @param obj defines the object to use
  5688. */
  5689. static DisableFor(obj: any): void;
  5690. /**
  5691. * Gets a boolean indicating if the given object has tags
  5692. * @param obj defines the object to use
  5693. * @returns a boolean
  5694. */
  5695. static HasTags(obj: any): boolean;
  5696. /**
  5697. * Gets the tags available on a given object
  5698. * @param obj defines the object to use
  5699. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5700. * @returns the tags
  5701. */
  5702. static GetTags(obj: any, asString?: boolean): any;
  5703. /**
  5704. * Adds tags to an object
  5705. * @param obj defines the object to use
  5706. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5707. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5708. */
  5709. static AddTagsTo(obj: any, tagsString: string): void;
  5710. /**
  5711. * @hidden
  5712. */ private static _AddTagTo(obj: any, tag: string): void;
  5713. /**
  5714. * Removes specific tags from a specific object
  5715. * @param obj defines the object to use
  5716. * @param tagsString defines the tags to remove
  5717. */
  5718. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5719. /**
  5720. * @hidden
  5721. */ private static _RemoveTagFrom(obj: any, tag: string): void;
  5722. /**
  5723. * Defines if tags hosted on an object match a given query
  5724. * @param obj defines the object to use
  5725. * @param tagsQuery defines the tag query
  5726. * @returns a boolean
  5727. */
  5728. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5729. }
  5730. }
  5731. declare module BABYLON {
  5732. /**
  5733. * Defines potential orientation for back face culling
  5734. */
  5735. export enum Orientation {
  5736. /**
  5737. * Clockwise
  5738. */
  5739. CW = 0,
  5740. /** Counter clockwise */
  5741. CCW = 1
  5742. }
  5743. /** Class used to represent a Bezier curve */
  5744. export class BezierCurve {
  5745. /**
  5746. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5747. * @param t defines the time
  5748. * @param x1 defines the left coordinate on X axis
  5749. * @param y1 defines the left coordinate on Y axis
  5750. * @param x2 defines the right coordinate on X axis
  5751. * @param y2 defines the right coordinate on Y axis
  5752. * @returns the interpolated value
  5753. */
  5754. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5755. }
  5756. /**
  5757. * Defines angle representation
  5758. */
  5759. export class Angle {
  5760. private _radians;
  5761. /**
  5762. * Creates an Angle object of "radians" radians (float).
  5763. * @param radians the angle in radians
  5764. */
  5765. constructor(radians: number);
  5766. /**
  5767. * Get value in degrees
  5768. * @returns the Angle value in degrees (float)
  5769. */
  5770. degrees(): number;
  5771. /**
  5772. * Get value in radians
  5773. * @returns the Angle value in radians (float)
  5774. */
  5775. radians(): number;
  5776. /**
  5777. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5778. * @param a defines first vector
  5779. * @param b defines second vector
  5780. * @returns a new Angle
  5781. */
  5782. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5783. /**
  5784. * Gets a new Angle object from the given float in radians
  5785. * @param radians defines the angle value in radians
  5786. * @returns a new Angle
  5787. */
  5788. static FromRadians(radians: number): Angle;
  5789. /**
  5790. * Gets a new Angle object from the given float in degrees
  5791. * @param degrees defines the angle value in degrees
  5792. * @returns a new Angle
  5793. */
  5794. static FromDegrees(degrees: number): Angle;
  5795. }
  5796. /**
  5797. * This represents an arc in a 2d space.
  5798. */
  5799. export class Arc2 {
  5800. /** Defines the start point of the arc */
  5801. startPoint: Vector2;
  5802. /** Defines the mid point of the arc */
  5803. midPoint: Vector2;
  5804. /** Defines the end point of the arc */
  5805. endPoint: Vector2;
  5806. /**
  5807. * Defines the center point of the arc.
  5808. */
  5809. centerPoint: Vector2;
  5810. /**
  5811. * Defines the radius of the arc.
  5812. */
  5813. radius: number;
  5814. /**
  5815. * Defines the angle of the arc (from mid point to end point).
  5816. */
  5817. angle: Angle;
  5818. /**
  5819. * Defines the start angle of the arc (from start point to middle point).
  5820. */
  5821. startAngle: Angle;
  5822. /**
  5823. * Defines the orientation of the arc (clock wise/counter clock wise).
  5824. */
  5825. orientation: Orientation;
  5826. /**
  5827. * Creates an Arc object from the three given points : start, middle and end.
  5828. * @param startPoint Defines the start point of the arc
  5829. * @param midPoint Defines the midlle point of the arc
  5830. * @param endPoint Defines the end point of the arc
  5831. */
  5832. constructor(
  5833. /** Defines the start point of the arc */
  5834. startPoint: Vector2,
  5835. /** Defines the mid point of the arc */
  5836. midPoint: Vector2,
  5837. /** Defines the end point of the arc */
  5838. endPoint: Vector2);
  5839. }
  5840. /**
  5841. * Represents a 2D path made up of multiple 2D points
  5842. */
  5843. export class Path2 {
  5844. private _points;
  5845. private _length;
  5846. /**
  5847. * If the path start and end point are the same
  5848. */
  5849. closed: boolean;
  5850. /**
  5851. * Creates a Path2 object from the starting 2D coordinates x and y.
  5852. * @param x the starting points x value
  5853. * @param y the starting points y value
  5854. */
  5855. constructor(x: number, y: number);
  5856. /**
  5857. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5858. * @param x the added points x value
  5859. * @param y the added points y value
  5860. * @returns the updated Path2.
  5861. */
  5862. addLineTo(x: number, y: number): Path2;
  5863. /**
  5864. * 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.
  5865. * @param midX middle point x value
  5866. * @param midY middle point y value
  5867. * @param endX end point x value
  5868. * @param endY end point y value
  5869. * @param numberOfSegments (default: 36)
  5870. * @returns the updated Path2.
  5871. */
  5872. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5873. /**
  5874. * Closes the Path2.
  5875. * @returns the Path2.
  5876. */
  5877. close(): Path2;
  5878. /**
  5879. * Gets the sum of the distance between each sequential point in the path
  5880. * @returns the Path2 total length (float).
  5881. */
  5882. length(): number;
  5883. /**
  5884. * Gets the points which construct the path
  5885. * @returns the Path2 internal array of points.
  5886. */
  5887. getPoints(): Vector2[];
  5888. /**
  5889. * Retreives the point at the distance aways from the starting point
  5890. * @param normalizedLengthPosition the length along the path to retreive the point from
  5891. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5892. */
  5893. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5894. /**
  5895. * Creates a new path starting from an x and y position
  5896. * @param x starting x value
  5897. * @param y starting y value
  5898. * @returns a new Path2 starting at the coordinates (x, y).
  5899. */
  5900. static StartingAt(x: number, y: number): Path2;
  5901. }
  5902. /**
  5903. * Represents a 3D path made up of multiple 3D points
  5904. */
  5905. export class Path3D {
  5906. /**
  5907. * an array of Vector3, the curve axis of the Path3D
  5908. */
  5909. path: Vector3[];
  5910. private _curve;
  5911. private _distances;
  5912. private _tangents;
  5913. private _normals;
  5914. private _binormals;
  5915. private _raw;
  5916. /**
  5917. * new Path3D(path, normal, raw)
  5918. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5919. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5920. * @param path an array of Vector3, the curve axis of the Path3D
  5921. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5922. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5923. */
  5924. constructor(
  5925. /**
  5926. * an array of Vector3, the curve axis of the Path3D
  5927. */
  5928. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5929. /**
  5930. * Returns the Path3D array of successive Vector3 designing its curve.
  5931. * @returns the Path3D array of successive Vector3 designing its curve.
  5932. */
  5933. getCurve(): Vector3[];
  5934. /**
  5935. * Returns an array populated with tangent vectors on each Path3D curve point.
  5936. * @returns an array populated with tangent vectors on each Path3D curve point.
  5937. */
  5938. getTangents(): Vector3[];
  5939. /**
  5940. * Returns an array populated with normal vectors on each Path3D curve point.
  5941. * @returns an array populated with normal vectors on each Path3D curve point.
  5942. */
  5943. getNormals(): Vector3[];
  5944. /**
  5945. * Returns an array populated with binormal vectors on each Path3D curve point.
  5946. * @returns an array populated with binormal vectors on each Path3D curve point.
  5947. */
  5948. getBinormals(): Vector3[];
  5949. /**
  5950. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5951. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5952. */
  5953. getDistances(): number[];
  5954. /**
  5955. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5956. * @param path path which all values are copied into the curves points
  5957. * @param firstNormal which should be projected onto the curve
  5958. * @returns the same object updated.
  5959. */
  5960. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5961. private _compute;
  5962. private _getFirstNonNullVector;
  5963. private _getLastNonNullVector;
  5964. private _normalVector;
  5965. }
  5966. /**
  5967. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5968. * A Curve3 is designed from a series of successive Vector3.
  5969. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5970. */
  5971. export class Curve3 {
  5972. private _points;
  5973. private _length;
  5974. /**
  5975. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5976. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5977. * @param v1 (Vector3) the control point
  5978. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5979. * @param nbPoints (integer) the wanted number of points in the curve
  5980. * @returns the created Curve3
  5981. */
  5982. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5983. /**
  5984. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5985. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5986. * @param v1 (Vector3) the first control point
  5987. * @param v2 (Vector3) the second control point
  5988. * @param v3 (Vector3) the end point of the Cubic Bezier
  5989. * @param nbPoints (integer) the wanted number of points in the curve
  5990. * @returns the created Curve3
  5991. */
  5992. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5993. /**
  5994. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5995. * @param p1 (Vector3) the origin point of the Hermite Spline
  5996. * @param t1 (Vector3) the tangent vector at the origin point
  5997. * @param p2 (Vector3) the end point of the Hermite Spline
  5998. * @param t2 (Vector3) the tangent vector at the end point
  5999. * @param nbPoints (integer) the wanted number of points in the curve
  6000. * @returns the created Curve3
  6001. */
  6002. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6003. /**
  6004. * Returns a Curve3 object along a CatmullRom Spline curve :
  6005. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6006. * @param nbPoints (integer) the wanted number of points between each curve control points
  6007. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6008. * @returns the created Curve3
  6009. */
  6010. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6011. /**
  6012. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6013. * A Curve3 is designed from a series of successive Vector3.
  6014. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6015. * @param points points which make up the curve
  6016. */
  6017. constructor(points: Vector3[]);
  6018. /**
  6019. * @returns the Curve3 stored array of successive Vector3
  6020. */
  6021. getPoints(): Vector3[];
  6022. /**
  6023. * @returns the computed length (float) of the curve.
  6024. */
  6025. length(): number;
  6026. /**
  6027. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6028. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6029. * curveA and curveB keep unchanged.
  6030. * @param curve the curve to continue from this curve
  6031. * @returns the newly constructed curve
  6032. */
  6033. continue(curve: DeepImmutable<Curve3>): Curve3;
  6034. private _computeLength;
  6035. }
  6036. }
  6037. declare module BABYLON {
  6038. /**
  6039. * This represents the main contract an easing function should follow.
  6040. * Easing functions are used throughout the animation system.
  6041. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6042. */
  6043. export interface IEasingFunction {
  6044. /**
  6045. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6046. * of the easing function.
  6047. * The link below provides some of the most common examples of easing functions.
  6048. * @see https://easings.net/
  6049. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6050. * @returns the corresponding value on the curve defined by the easing function
  6051. */
  6052. ease(gradient: number): number;
  6053. }
  6054. /**
  6055. * Base class used for every default easing function.
  6056. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6057. */
  6058. export class EasingFunction implements IEasingFunction {
  6059. /**
  6060. * Interpolation follows the mathematical formula associated with the easing function.
  6061. */
  6062. static readonly EASINGMODE_EASEIN: number;
  6063. /**
  6064. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6065. */
  6066. static readonly EASINGMODE_EASEOUT: number;
  6067. /**
  6068. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6069. */
  6070. static readonly EASINGMODE_EASEINOUT: number;
  6071. private _easingMode;
  6072. /**
  6073. * Sets the easing mode of the current function.
  6074. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6075. */
  6076. setEasingMode(easingMode: number): void;
  6077. /**
  6078. * Gets the current easing mode.
  6079. * @returns the easing mode
  6080. */
  6081. getEasingMode(): number;
  6082. /**
  6083. * @hidden
  6084. */
  6085. easeInCore(gradient: number): number;
  6086. /**
  6087. * Given an input gradient between 0 and 1, this returns the corresponding value
  6088. * of the easing function.
  6089. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6090. * @returns the corresponding value on the curve defined by the easing function
  6091. */
  6092. ease(gradient: number): number;
  6093. }
  6094. /**
  6095. * Easing function with a circle shape (see link below).
  6096. * @see https://easings.net/#easeInCirc
  6097. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6098. */
  6099. export class CircleEase extends EasingFunction implements IEasingFunction {
  6100. /** @hidden */
  6101. easeInCore(gradient: number): number;
  6102. }
  6103. /**
  6104. * Easing function with a ease back shape (see link below).
  6105. * @see https://easings.net/#easeInBack
  6106. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6107. */
  6108. export class BackEase extends EasingFunction implements IEasingFunction {
  6109. /** Defines the amplitude of the function */
  6110. amplitude: number;
  6111. /**
  6112. * Instantiates a back ease easing
  6113. * @see https://easings.net/#easeInBack
  6114. * @param amplitude Defines the amplitude of the function
  6115. */
  6116. constructor(
  6117. /** Defines the amplitude of the function */
  6118. amplitude?: number);
  6119. /** @hidden */
  6120. easeInCore(gradient: number): number;
  6121. }
  6122. /**
  6123. * Easing function with a bouncing shape (see link below).
  6124. * @see https://easings.net/#easeInBounce
  6125. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6126. */
  6127. export class BounceEase extends EasingFunction implements IEasingFunction {
  6128. /** Defines the number of bounces */
  6129. bounces: number;
  6130. /** Defines the amplitude of the bounce */
  6131. bounciness: number;
  6132. /**
  6133. * Instantiates a bounce easing
  6134. * @see https://easings.net/#easeInBounce
  6135. * @param bounces Defines the number of bounces
  6136. * @param bounciness Defines the amplitude of the bounce
  6137. */
  6138. constructor(
  6139. /** Defines the number of bounces */
  6140. bounces?: number,
  6141. /** Defines the amplitude of the bounce */
  6142. bounciness?: number);
  6143. /** @hidden */
  6144. easeInCore(gradient: number): number;
  6145. }
  6146. /**
  6147. * Easing function with a power of 3 shape (see link below).
  6148. * @see https://easings.net/#easeInCubic
  6149. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6150. */
  6151. export class CubicEase extends EasingFunction implements IEasingFunction {
  6152. /** @hidden */
  6153. easeInCore(gradient: number): number;
  6154. }
  6155. /**
  6156. * Easing function with an elastic shape (see link below).
  6157. * @see https://easings.net/#easeInElastic
  6158. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6159. */
  6160. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6161. /** Defines the number of oscillations*/
  6162. oscillations: number;
  6163. /** Defines the amplitude of the oscillations*/
  6164. springiness: number;
  6165. /**
  6166. * Instantiates an elastic easing function
  6167. * @see https://easings.net/#easeInElastic
  6168. * @param oscillations Defines the number of oscillations
  6169. * @param springiness Defines the amplitude of the oscillations
  6170. */
  6171. constructor(
  6172. /** Defines the number of oscillations*/
  6173. oscillations?: number,
  6174. /** Defines the amplitude of the oscillations*/
  6175. springiness?: number);
  6176. /** @hidden */
  6177. easeInCore(gradient: number): number;
  6178. }
  6179. /**
  6180. * Easing function with an exponential shape (see link below).
  6181. * @see https://easings.net/#easeInExpo
  6182. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6183. */
  6184. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6185. /** Defines the exponent of the function */
  6186. exponent: number;
  6187. /**
  6188. * Instantiates an exponential easing function
  6189. * @see https://easings.net/#easeInExpo
  6190. * @param exponent Defines the exponent of the function
  6191. */
  6192. constructor(
  6193. /** Defines the exponent of the function */
  6194. exponent?: number);
  6195. /** @hidden */
  6196. easeInCore(gradient: number): number;
  6197. }
  6198. /**
  6199. * Easing function with a power shape (see link below).
  6200. * @see https://easings.net/#easeInQuad
  6201. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6202. */
  6203. export class PowerEase extends EasingFunction implements IEasingFunction {
  6204. /** Defines the power of the function */
  6205. power: number;
  6206. /**
  6207. * Instantiates an power base easing function
  6208. * @see https://easings.net/#easeInQuad
  6209. * @param power Defines the power of the function
  6210. */
  6211. constructor(
  6212. /** Defines the power of the function */
  6213. power?: number);
  6214. /** @hidden */
  6215. easeInCore(gradient: number): number;
  6216. }
  6217. /**
  6218. * Easing function with a power of 2 shape (see link below).
  6219. * @see https://easings.net/#easeInQuad
  6220. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6221. */
  6222. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6223. /** @hidden */
  6224. easeInCore(gradient: number): number;
  6225. }
  6226. /**
  6227. * Easing function with a power of 4 shape (see link below).
  6228. * @see https://easings.net/#easeInQuart
  6229. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6230. */
  6231. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6232. /** @hidden */
  6233. easeInCore(gradient: number): number;
  6234. }
  6235. /**
  6236. * Easing function with a power of 5 shape (see link below).
  6237. * @see https://easings.net/#easeInQuint
  6238. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6239. */
  6240. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6241. /** @hidden */
  6242. easeInCore(gradient: number): number;
  6243. }
  6244. /**
  6245. * Easing function with a sin shape (see link below).
  6246. * @see https://easings.net/#easeInSine
  6247. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6248. */
  6249. export class SineEase extends EasingFunction implements IEasingFunction {
  6250. /** @hidden */
  6251. easeInCore(gradient: number): number;
  6252. }
  6253. /**
  6254. * Easing function with a bezier shape (see link below).
  6255. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6256. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6257. */
  6258. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6259. /** Defines the x component of the start tangent in the bezier curve */
  6260. x1: number;
  6261. /** Defines the y component of the start tangent in the bezier curve */
  6262. y1: number;
  6263. /** Defines the x component of the end tangent in the bezier curve */
  6264. x2: number;
  6265. /** Defines the y component of the end tangent in the bezier curve */
  6266. y2: number;
  6267. /**
  6268. * Instantiates a bezier function
  6269. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6270. * @param x1 Defines the x component of the start tangent in the bezier curve
  6271. * @param y1 Defines the y component of the start tangent in the bezier curve
  6272. * @param x2 Defines the x component of the end tangent in the bezier curve
  6273. * @param y2 Defines the y component of the end tangent in the bezier curve
  6274. */
  6275. constructor(
  6276. /** Defines the x component of the start tangent in the bezier curve */
  6277. x1?: number,
  6278. /** Defines the y component of the start tangent in the bezier curve */
  6279. y1?: number,
  6280. /** Defines the x component of the end tangent in the bezier curve */
  6281. x2?: number,
  6282. /** Defines the y component of the end tangent in the bezier curve */
  6283. y2?: number);
  6284. /** @hidden */
  6285. easeInCore(gradient: number): number;
  6286. }
  6287. }
  6288. declare module BABYLON {
  6289. /**
  6290. * Defines an interface which represents an animation key frame
  6291. */
  6292. export interface IAnimationKey {
  6293. /**
  6294. * Frame of the key frame
  6295. */
  6296. frame: number;
  6297. /**
  6298. * Value at the specifies key frame
  6299. */
  6300. value: any;
  6301. /**
  6302. * The input tangent for the cubic hermite spline
  6303. */
  6304. inTangent?: any;
  6305. /**
  6306. * The output tangent for the cubic hermite spline
  6307. */
  6308. outTangent?: any;
  6309. /**
  6310. * The animation interpolation type
  6311. */
  6312. interpolation?: AnimationKeyInterpolation;
  6313. }
  6314. /**
  6315. * Enum for the animation key frame interpolation type
  6316. */
  6317. export enum AnimationKeyInterpolation {
  6318. /**
  6319. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6320. */
  6321. STEP = 1
  6322. }
  6323. }
  6324. declare module BABYLON {
  6325. /**
  6326. * Represents the range of an animation
  6327. */
  6328. export class AnimationRange {
  6329. /**The name of the animation range**/
  6330. name: string;
  6331. /**The starting frame of the animation */
  6332. from: number;
  6333. /**The ending frame of the animation*/
  6334. to: number;
  6335. /**
  6336. * Initializes the range of an animation
  6337. * @param name The name of the animation range
  6338. * @param from The starting frame of the animation
  6339. * @param to The ending frame of the animation
  6340. */
  6341. constructor(
  6342. /**The name of the animation range**/
  6343. name: string,
  6344. /**The starting frame of the animation */
  6345. from: number,
  6346. /**The ending frame of the animation*/
  6347. to: number);
  6348. /**
  6349. * Makes a copy of the animation range
  6350. * @returns A copy of the animation range
  6351. */
  6352. clone(): AnimationRange;
  6353. }
  6354. }
  6355. declare module BABYLON {
  6356. /**
  6357. * Composed of a frame, and an action function
  6358. */
  6359. export class AnimationEvent {
  6360. /** The frame for which the event is triggered **/
  6361. frame: number;
  6362. /** The event to perform when triggered **/
  6363. action: (currentFrame: number) => void;
  6364. /** Specifies if the event should be triggered only once**/
  6365. onlyOnce?: boolean | undefined;
  6366. /**
  6367. * Specifies if the animation event is done
  6368. */
  6369. isDone: boolean;
  6370. /**
  6371. * Initializes the animation event
  6372. * @param frame The frame for which the event is triggered
  6373. * @param action The event to perform when triggered
  6374. * @param onlyOnce Specifies if the event should be triggered only once
  6375. */
  6376. constructor(
  6377. /** The frame for which the event is triggered **/
  6378. frame: number,
  6379. /** The event to perform when triggered **/
  6380. action: (currentFrame: number) => void,
  6381. /** Specifies if the event should be triggered only once**/
  6382. onlyOnce?: boolean | undefined);
  6383. /** @hidden */ private _clone(): AnimationEvent;
  6384. }
  6385. }
  6386. declare module BABYLON {
  6387. /**
  6388. * Interface used to define a behavior
  6389. */
  6390. export interface Behavior<T> {
  6391. /** gets or sets behavior's name */
  6392. name: string;
  6393. /**
  6394. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6395. */
  6396. init(): void;
  6397. /**
  6398. * Called when the behavior is attached to a target
  6399. * @param target defines the target where the behavior is attached to
  6400. */
  6401. attach(target: T): void;
  6402. /**
  6403. * Called when the behavior is detached from its target
  6404. */
  6405. detach(): void;
  6406. }
  6407. /**
  6408. * Interface implemented by classes supporting behaviors
  6409. */
  6410. export interface IBehaviorAware<T> {
  6411. /**
  6412. * Attach a behavior
  6413. * @param behavior defines the behavior to attach
  6414. * @returns the current host
  6415. */
  6416. addBehavior(behavior: Behavior<T>): T;
  6417. /**
  6418. * Remove a behavior from the current object
  6419. * @param behavior defines the behavior to detach
  6420. * @returns the current host
  6421. */
  6422. removeBehavior(behavior: Behavior<T>): T;
  6423. /**
  6424. * Gets a behavior using its name to search
  6425. * @param name defines the name to search
  6426. * @returns the behavior or null if not found
  6427. */
  6428. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6429. }
  6430. }
  6431. declare module BABYLON {
  6432. /**
  6433. * Defines an array and its length.
  6434. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6435. */
  6436. export interface ISmartArrayLike<T> {
  6437. /**
  6438. * The data of the array.
  6439. */
  6440. data: Array<T>;
  6441. /**
  6442. * The active length of the array.
  6443. */
  6444. length: number;
  6445. }
  6446. /**
  6447. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6448. */
  6449. export class SmartArray<T> implements ISmartArrayLike<T> {
  6450. /**
  6451. * The full set of data from the array.
  6452. */
  6453. data: Array<T>;
  6454. /**
  6455. * The active length of the array.
  6456. */
  6457. length: number;
  6458. protected _id: number;
  6459. /**
  6460. * Instantiates a Smart Array.
  6461. * @param capacity defines the default capacity of the array.
  6462. */
  6463. constructor(capacity: number);
  6464. /**
  6465. * Pushes a value at the end of the active data.
  6466. * @param value defines the object to push in the array.
  6467. */
  6468. push(value: T): void;
  6469. /**
  6470. * Iterates over the active data and apply the lambda to them.
  6471. * @param func defines the action to apply on each value.
  6472. */
  6473. forEach(func: (content: T) => void): void;
  6474. /**
  6475. * Sorts the full sets of data.
  6476. * @param compareFn defines the comparison function to apply.
  6477. */
  6478. sort(compareFn: (a: T, b: T) => number): void;
  6479. /**
  6480. * Resets the active data to an empty array.
  6481. */
  6482. reset(): void;
  6483. /**
  6484. * Releases all the data from the array as well as the array.
  6485. */
  6486. dispose(): void;
  6487. /**
  6488. * Concats the active data with a given array.
  6489. * @param array defines the data to concatenate with.
  6490. */
  6491. concat(array: any): void;
  6492. /**
  6493. * Returns the position of a value in the active data.
  6494. * @param value defines the value to find the index for
  6495. * @returns the index if found in the active data otherwise -1
  6496. */
  6497. indexOf(value: T): number;
  6498. /**
  6499. * Returns whether an element is part of the active data.
  6500. * @param value defines the value to look for
  6501. * @returns true if found in the active data otherwise false
  6502. */
  6503. contains(value: T): boolean;
  6504. private static _GlobalId;
  6505. }
  6506. /**
  6507. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6508. * The data in this array can only be present once
  6509. */
  6510. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6511. private _duplicateId;
  6512. /**
  6513. * Pushes a value at the end of the active data.
  6514. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6515. * @param value defines the object to push in the array.
  6516. */
  6517. push(value: T): void;
  6518. /**
  6519. * Pushes a value at the end of the active data.
  6520. * If the data is already present, it won t be added again
  6521. * @param value defines the object to push in the array.
  6522. * @returns true if added false if it was already present
  6523. */
  6524. pushNoDuplicate(value: T): boolean;
  6525. /**
  6526. * Resets the active data to an empty array.
  6527. */
  6528. reset(): void;
  6529. /**
  6530. * Concats the active data with a given array.
  6531. * This ensures no dupplicate will be present in the result.
  6532. * @param array defines the data to concatenate with.
  6533. */
  6534. concatWithNoDuplicate(array: any): void;
  6535. }
  6536. }
  6537. declare module BABYLON {
  6538. /**
  6539. * @ignore
  6540. * This is a list of all the different input types that are available in the application.
  6541. * Fo instance: ArcRotateCameraGamepadInput...
  6542. */
  6543. export var CameraInputTypes: {};
  6544. /**
  6545. * This is the contract to implement in order to create a new input class.
  6546. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6547. */
  6548. export interface ICameraInput<TCamera extends Camera> {
  6549. /**
  6550. * Defines the camera the input is attached to.
  6551. */
  6552. camera: Nullable<TCamera>;
  6553. /**
  6554. * Gets the class name of the current intput.
  6555. * @returns the class name
  6556. */
  6557. getClassName(): string;
  6558. /**
  6559. * Get the friendly name associated with the input class.
  6560. * @returns the input friendly name
  6561. */
  6562. getSimpleName(): string;
  6563. /**
  6564. * Attach the input controls to a specific dom element to get the input from.
  6565. * @param element Defines the element the controls should be listened from
  6566. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6567. */
  6568. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6569. /**
  6570. * Detach the current controls from the specified dom element.
  6571. * @param element Defines the element to stop listening the inputs from
  6572. */
  6573. detachControl(element: Nullable<HTMLElement>): void;
  6574. /**
  6575. * Update the current camera state depending on the inputs that have been used this frame.
  6576. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6577. */
  6578. checkInputs?: () => void;
  6579. }
  6580. /**
  6581. * Represents a map of input types to input instance or input index to input instance.
  6582. */
  6583. export interface CameraInputsMap<TCamera extends Camera> {
  6584. /**
  6585. * Accessor to the input by input type.
  6586. */
  6587. [name: string]: ICameraInput<TCamera>;
  6588. /**
  6589. * Accessor to the input by input index.
  6590. */
  6591. [idx: number]: ICameraInput<TCamera>;
  6592. }
  6593. /**
  6594. * This represents the input manager used within a camera.
  6595. * It helps dealing with all the different kind of input attached to a camera.
  6596. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6597. */
  6598. export class CameraInputsManager<TCamera extends Camera> {
  6599. /**
  6600. * Defines the list of inputs attahed to the camera.
  6601. */
  6602. attached: CameraInputsMap<TCamera>;
  6603. /**
  6604. * Defines the dom element the camera is collecting inputs from.
  6605. * This is null if the controls have not been attached.
  6606. */
  6607. attachedElement: Nullable<HTMLElement>;
  6608. /**
  6609. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6610. */
  6611. noPreventDefault: boolean;
  6612. /**
  6613. * Defined the camera the input manager belongs to.
  6614. */
  6615. camera: TCamera;
  6616. /**
  6617. * Update the current camera state depending on the inputs that have been used this frame.
  6618. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6619. */
  6620. checkInputs: () => void;
  6621. /**
  6622. * Instantiate a new Camera Input Manager.
  6623. * @param camera Defines the camera the input manager blongs to
  6624. */
  6625. constructor(camera: TCamera);
  6626. /**
  6627. * Add an input method to a camera
  6628. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6629. * @param input camera input method
  6630. */
  6631. add(input: ICameraInput<TCamera>): void;
  6632. /**
  6633. * Remove a specific input method from a camera
  6634. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6635. * @param inputToRemove camera input method
  6636. */
  6637. remove(inputToRemove: ICameraInput<TCamera>): void;
  6638. /**
  6639. * Remove a specific input type from a camera
  6640. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6641. * @param inputType the type of the input to remove
  6642. */
  6643. removeByType(inputType: string): void;
  6644. private _addCheckInputs;
  6645. /**
  6646. * Attach the input controls to the currently attached dom element to listen the events from.
  6647. * @param input Defines the input to attach
  6648. */
  6649. attachInput(input: ICameraInput<TCamera>): void;
  6650. /**
  6651. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6652. * @param element Defines the dom element to collect the events from
  6653. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6654. */
  6655. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6656. /**
  6657. * Detach the current manager inputs controls from a specific dom element.
  6658. * @param element Defines the dom element to collect the events from
  6659. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6660. */
  6661. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6662. /**
  6663. * Rebuild the dynamic inputCheck function from the current list of
  6664. * defined inputs in the manager.
  6665. */
  6666. rebuildInputCheck(): void;
  6667. /**
  6668. * Remove all attached input methods from a camera
  6669. */
  6670. clear(): void;
  6671. /**
  6672. * Serialize the current input manager attached to a camera.
  6673. * This ensures than once parsed,
  6674. * the input associated to the camera will be identical to the current ones
  6675. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6676. */
  6677. serialize(serializedCamera: any): void;
  6678. /**
  6679. * Parses an input manager serialized JSON to restore the previous list of inputs
  6680. * and states associated to a camera.
  6681. * @param parsedCamera Defines the JSON to parse
  6682. */
  6683. parse(parsedCamera: any): void;
  6684. }
  6685. }
  6686. declare module BABYLON {
  6687. /**
  6688. * @hidden
  6689. */
  6690. export class IntersectionInfo {
  6691. bu: Nullable<number>;
  6692. bv: Nullable<number>;
  6693. distance: number;
  6694. faceId: number;
  6695. subMeshId: number;
  6696. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6697. }
  6698. }
  6699. declare module BABYLON {
  6700. /**
  6701. * Represens a plane by the equation ax + by + cz + d = 0
  6702. */
  6703. export class Plane {
  6704. private static _TmpMatrix;
  6705. /**
  6706. * Normal of the plane (a,b,c)
  6707. */
  6708. normal: Vector3;
  6709. /**
  6710. * d component of the plane
  6711. */
  6712. d: number;
  6713. /**
  6714. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6715. * @param a a component of the plane
  6716. * @param b b component of the plane
  6717. * @param c c component of the plane
  6718. * @param d d component of the plane
  6719. */
  6720. constructor(a: number, b: number, c: number, d: number);
  6721. /**
  6722. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6723. */
  6724. asArray(): number[];
  6725. /**
  6726. * @returns a new plane copied from the current Plane.
  6727. */
  6728. clone(): Plane;
  6729. /**
  6730. * @returns the string "Plane".
  6731. */
  6732. getClassName(): string;
  6733. /**
  6734. * @returns the Plane hash code.
  6735. */
  6736. getHashCode(): number;
  6737. /**
  6738. * Normalize the current Plane in place.
  6739. * @returns the updated Plane.
  6740. */
  6741. normalize(): Plane;
  6742. /**
  6743. * Applies a transformation the plane and returns the result
  6744. * @param transformation the transformation matrix to be applied to the plane
  6745. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6746. */
  6747. transform(transformation: DeepImmutable<Matrix>): Plane;
  6748. /**
  6749. * Calcualtte the dot product between the point and the plane normal
  6750. * @param point point to calculate the dot product with
  6751. * @returns the dot product (float) of the point coordinates and the plane normal.
  6752. */
  6753. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6754. /**
  6755. * Updates the current Plane from the plane defined by the three given points.
  6756. * @param point1 one of the points used to contruct the plane
  6757. * @param point2 one of the points used to contruct the plane
  6758. * @param point3 one of the points used to contruct the plane
  6759. * @returns the updated Plane.
  6760. */
  6761. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6762. /**
  6763. * Checks if the plane is facing a given direction
  6764. * @param direction the direction to check if the plane is facing
  6765. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6766. * @returns True is the vector "direction" is the same side than the plane normal.
  6767. */
  6768. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6769. /**
  6770. * Calculates the distance to a point
  6771. * @param point point to calculate distance to
  6772. * @returns the signed distance (float) from the given point to the Plane.
  6773. */
  6774. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6775. /**
  6776. * Creates a plane from an array
  6777. * @param array the array to create a plane from
  6778. * @returns a new Plane from the given array.
  6779. */
  6780. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6781. /**
  6782. * Creates a plane from three points
  6783. * @param point1 point used to create the plane
  6784. * @param point2 point used to create the plane
  6785. * @param point3 point used to create the plane
  6786. * @returns a new Plane defined by the three given points.
  6787. */
  6788. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6789. /**
  6790. * Creates a plane from an origin point and a normal
  6791. * @param origin origin of the plane to be constructed
  6792. * @param normal normal of the plane to be constructed
  6793. * @returns a new Plane the normal vector to this plane at the given origin point.
  6794. * Note : the vector "normal" is updated because normalized.
  6795. */
  6796. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6797. /**
  6798. * Calculates the distance from a plane and a point
  6799. * @param origin origin of the plane to be constructed
  6800. * @param normal normal of the plane to be constructed
  6801. * @param point point to calculate distance to
  6802. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6803. */
  6804. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6805. }
  6806. }
  6807. declare module BABYLON {
  6808. /**
  6809. * Class used to store bounding sphere information
  6810. */
  6811. export class BoundingSphere {
  6812. /**
  6813. * Gets the center of the bounding sphere in local space
  6814. */
  6815. readonly center: Vector3;
  6816. /**
  6817. * Radius of the bounding sphere in local space
  6818. */
  6819. radius: number;
  6820. /**
  6821. * Gets the center of the bounding sphere in world space
  6822. */
  6823. readonly centerWorld: Vector3;
  6824. /**
  6825. * Radius of the bounding sphere in world space
  6826. */
  6827. radiusWorld: number;
  6828. /**
  6829. * Gets the minimum vector in local space
  6830. */
  6831. readonly minimum: Vector3;
  6832. /**
  6833. * Gets the maximum vector in local space
  6834. */
  6835. readonly maximum: Vector3;
  6836. private _worldMatrix;
  6837. private static readonly TmpVector3;
  6838. /**
  6839. * Creates a new bounding sphere
  6840. * @param min defines the minimum vector (in local space)
  6841. * @param max defines the maximum vector (in local space)
  6842. * @param worldMatrix defines the new world matrix
  6843. */
  6844. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6845. /**
  6846. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6847. * @param min defines the new minimum vector (in local space)
  6848. * @param max defines the new maximum vector (in local space)
  6849. * @param worldMatrix defines the new world matrix
  6850. */
  6851. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6852. /**
  6853. * Scale the current bounding sphere by applying a scale factor
  6854. * @param factor defines the scale factor to apply
  6855. * @returns the current bounding box
  6856. */
  6857. scale(factor: number): BoundingSphere;
  6858. /**
  6859. * Gets the world matrix of the bounding box
  6860. * @returns a matrix
  6861. */
  6862. getWorldMatrix(): DeepImmutable<Matrix>;
  6863. /** @hidden */ private _update(worldMatrix: DeepImmutable<Matrix>): void;
  6864. /**
  6865. * Tests if the bounding sphere is intersecting the frustum planes
  6866. * @param frustumPlanes defines the frustum planes to test
  6867. * @returns true if there is an intersection
  6868. */
  6869. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6870. /**
  6871. * Tests if the bounding sphere center is in between the frustum planes.
  6872. * Used for optimistic fast inclusion.
  6873. * @param frustumPlanes defines the frustum planes to test
  6874. * @returns true if the sphere center is in between the frustum planes
  6875. */
  6876. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6877. /**
  6878. * Tests if a point is inside the bounding sphere
  6879. * @param point defines the point to test
  6880. * @returns true if the point is inside the bounding sphere
  6881. */
  6882. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6883. /**
  6884. * Checks if two sphere intersct
  6885. * @param sphere0 sphere 0
  6886. * @param sphere1 sphere 1
  6887. * @returns true if the speres intersect
  6888. */
  6889. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6890. }
  6891. }
  6892. declare module BABYLON {
  6893. /**
  6894. * Class used to store bounding box information
  6895. */
  6896. export class BoundingBox implements ICullable {
  6897. /**
  6898. * Gets the 8 vectors representing the bounding box in local space
  6899. */
  6900. readonly vectors: Vector3[];
  6901. /**
  6902. * Gets the center of the bounding box in local space
  6903. */
  6904. readonly center: Vector3;
  6905. /**
  6906. * Gets the center of the bounding box in world space
  6907. */
  6908. readonly centerWorld: Vector3;
  6909. /**
  6910. * Gets the extend size in local space
  6911. */
  6912. readonly extendSize: Vector3;
  6913. /**
  6914. * Gets the extend size in world space
  6915. */
  6916. readonly extendSizeWorld: Vector3;
  6917. /**
  6918. * Gets the OBB (object bounding box) directions
  6919. */
  6920. readonly directions: Vector3[];
  6921. /**
  6922. * Gets the 8 vectors representing the bounding box in world space
  6923. */
  6924. readonly vectorsWorld: Vector3[];
  6925. /**
  6926. * Gets the minimum vector in world space
  6927. */
  6928. readonly minimumWorld: Vector3;
  6929. /**
  6930. * Gets the maximum vector in world space
  6931. */
  6932. readonly maximumWorld: Vector3;
  6933. /**
  6934. * Gets the minimum vector in local space
  6935. */
  6936. readonly minimum: Vector3;
  6937. /**
  6938. * Gets the maximum vector in local space
  6939. */
  6940. readonly maximum: Vector3;
  6941. private _worldMatrix;
  6942. private static readonly TmpVector3;
  6943. /**
  6944. * @hidden
  6945. */ private _tag: number;
  6946. /**
  6947. * Creates a new bounding box
  6948. * @param min defines the minimum vector (in local space)
  6949. * @param max defines the maximum vector (in local space)
  6950. * @param worldMatrix defines the new world matrix
  6951. */
  6952. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6953. /**
  6954. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6955. * @param min defines the new minimum vector (in local space)
  6956. * @param max defines the new maximum vector (in local space)
  6957. * @param worldMatrix defines the new world matrix
  6958. */
  6959. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6960. /**
  6961. * Scale the current bounding box by applying a scale factor
  6962. * @param factor defines the scale factor to apply
  6963. * @returns the current bounding box
  6964. */
  6965. scale(factor: number): BoundingBox;
  6966. /**
  6967. * Gets the world matrix of the bounding box
  6968. * @returns a matrix
  6969. */
  6970. getWorldMatrix(): DeepImmutable<Matrix>;
  6971. /** @hidden */ private _update(world: DeepImmutable<Matrix>): void;
  6972. /**
  6973. * Tests if the bounding box is intersecting the frustum planes
  6974. * @param frustumPlanes defines the frustum planes to test
  6975. * @returns true if there is an intersection
  6976. */
  6977. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6978. /**
  6979. * Tests if the bounding box is entirely inside the frustum planes
  6980. * @param frustumPlanes defines the frustum planes to test
  6981. * @returns true if there is an inclusion
  6982. */
  6983. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6984. /**
  6985. * Tests if a point is inside the bounding box
  6986. * @param point defines the point to test
  6987. * @returns true if the point is inside the bounding box
  6988. */
  6989. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6990. /**
  6991. * Tests if the bounding box intersects with a bounding sphere
  6992. * @param sphere defines the sphere to test
  6993. * @returns true if there is an intersection
  6994. */
  6995. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6996. /**
  6997. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6998. * @param min defines the min vector to use
  6999. * @param max defines the max vector to use
  7000. * @returns true if there is an intersection
  7001. */
  7002. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7003. /**
  7004. * Tests if two bounding boxes are intersections
  7005. * @param box0 defines the first box to test
  7006. * @param box1 defines the second box to test
  7007. * @returns true if there is an intersection
  7008. */
  7009. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7010. /**
  7011. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7012. * @param minPoint defines the minimum vector of the bounding box
  7013. * @param maxPoint defines the maximum vector of the bounding box
  7014. * @param sphereCenter defines the sphere center
  7015. * @param sphereRadius defines the sphere radius
  7016. * @returns true if there is an intersection
  7017. */
  7018. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7019. /**
  7020. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7021. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7022. * @param frustumPlanes defines the frustum planes to test
  7023. * @return true if there is an inclusion
  7024. */
  7025. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7026. /**
  7027. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7028. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7029. * @param frustumPlanes defines the frustum planes to test
  7030. * @return true if there is an intersection
  7031. */
  7032. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7033. }
  7034. }
  7035. declare module BABYLON {
  7036. /** @hidden */
  7037. export class Collider {
  7038. /** Define if a collision was found */
  7039. collisionFound: boolean;
  7040. /**
  7041. * Define last intersection point in local space
  7042. */
  7043. intersectionPoint: Vector3;
  7044. /**
  7045. * Define last collided mesh
  7046. */
  7047. collidedMesh: Nullable<AbstractMesh>;
  7048. private _collisionPoint;
  7049. private _planeIntersectionPoint;
  7050. private _tempVector;
  7051. private _tempVector2;
  7052. private _tempVector3;
  7053. private _tempVector4;
  7054. private _edge;
  7055. private _baseToVertex;
  7056. private _destinationPoint;
  7057. private _slidePlaneNormal;
  7058. private _displacementVector;
  7059. /** @hidden */ private _radius: Vector3;
  7060. /** @hidden */ private _retry: number;
  7061. private _velocity;
  7062. private _basePoint;
  7063. private _epsilon;
  7064. /** @hidden */ private _velocityWorldLength: number;
  7065. /** @hidden */ private _basePointWorld: Vector3;
  7066. private _velocityWorld;
  7067. private _normalizedVelocity;
  7068. /** @hidden */ private _initialVelocity: Vector3;
  7069. /** @hidden */ private _initialPosition: Vector3;
  7070. private _nearestDistance;
  7071. private _collisionMask;
  7072. collisionMask: number;
  7073. /**
  7074. * Gets the plane normal used to compute the sliding response (in local space)
  7075. */
  7076. readonly slidePlaneNormal: Vector3;
  7077. /** @hidden */ private _initialize(source: Vector3, dir: Vector3, e: number): void;
  7078. /** @hidden */ private _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7079. /** @hidden */ private _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7080. /** @hidden */ private _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7081. /** @hidden */ private _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7082. /** @hidden */ private _getResponse(pos: Vector3, vel: Vector3): void;
  7083. }
  7084. }
  7085. declare module BABYLON {
  7086. /**
  7087. * Interface for cullable objects
  7088. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7089. */
  7090. export interface ICullable {
  7091. /**
  7092. * Checks if the object or part of the object is in the frustum
  7093. * @param frustumPlanes Camera near/planes
  7094. * @returns true if the object is in frustum otherwise false
  7095. */
  7096. isInFrustum(frustumPlanes: Plane[]): boolean;
  7097. /**
  7098. * Checks if a cullable object (mesh...) is in the camera frustum
  7099. * Unlike isInFrustum this cheks the full bounding box
  7100. * @param frustumPlanes Camera near/planes
  7101. * @returns true if the object is in frustum otherwise false
  7102. */
  7103. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7104. }
  7105. /**
  7106. * Info for a bounding data of a mesh
  7107. */
  7108. export class BoundingInfo implements ICullable {
  7109. /**
  7110. * Bounding box for the mesh
  7111. */
  7112. readonly boundingBox: BoundingBox;
  7113. /**
  7114. * Bounding sphere for the mesh
  7115. */
  7116. readonly boundingSphere: BoundingSphere;
  7117. private _isLocked;
  7118. private static readonly TmpVector3;
  7119. /**
  7120. * Constructs bounding info
  7121. * @param minimum min vector of the bounding box/sphere
  7122. * @param maximum max vector of the bounding box/sphere
  7123. * @param worldMatrix defines the new world matrix
  7124. */
  7125. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7126. /**
  7127. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7128. * @param min defines the new minimum vector (in local space)
  7129. * @param max defines the new maximum vector (in local space)
  7130. * @param worldMatrix defines the new world matrix
  7131. */
  7132. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7133. /**
  7134. * min vector of the bounding box/sphere
  7135. */
  7136. readonly minimum: Vector3;
  7137. /**
  7138. * max vector of the bounding box/sphere
  7139. */
  7140. readonly maximum: Vector3;
  7141. /**
  7142. * If the info is locked and won't be updated to avoid perf overhead
  7143. */
  7144. isLocked: boolean;
  7145. /**
  7146. * Updates the bounding sphere and box
  7147. * @param world world matrix to be used to update
  7148. */
  7149. update(world: DeepImmutable<Matrix>): void;
  7150. /**
  7151. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7152. * @param center New center of the bounding info
  7153. * @param extend New extend of the bounding info
  7154. * @returns the current bounding info
  7155. */
  7156. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7157. /**
  7158. * Scale the current bounding info by applying a scale factor
  7159. * @param factor defines the scale factor to apply
  7160. * @returns the current bounding info
  7161. */
  7162. scale(factor: number): BoundingInfo;
  7163. /**
  7164. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7165. * @param frustumPlanes defines the frustum to test
  7166. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7167. * @returns true if the bounding info is in the frustum planes
  7168. */
  7169. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7170. /**
  7171. * Gets the world distance between the min and max points of the bounding box
  7172. */
  7173. readonly diagonalLength: number;
  7174. /**
  7175. * Checks if a cullable object (mesh...) is in the camera frustum
  7176. * Unlike isInFrustum this cheks the full bounding box
  7177. * @param frustumPlanes Camera near/planes
  7178. * @returns true if the object is in frustum otherwise false
  7179. */
  7180. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7181. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  7182. /**
  7183. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7184. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7185. * @param point the point to check intersection with
  7186. * @returns if the point intersects
  7187. */
  7188. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7189. /**
  7190. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7191. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7192. * @param boundingInfo the bounding info to check intersection with
  7193. * @param precise if the intersection should be done using OBB
  7194. * @returns if the bounding info intersects
  7195. */
  7196. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7197. }
  7198. }
  7199. declare module BABYLON {
  7200. /**
  7201. * Extracts minimum and maximum values from a list of indexed positions
  7202. * @param positions defines the positions to use
  7203. * @param indices defines the indices to the positions
  7204. * @param indexStart defines the start index
  7205. * @param indexCount defines the end index
  7206. * @param bias defines bias value to add to the result
  7207. * @return minimum and maximum values
  7208. */
  7209. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7210. minimum: Vector3;
  7211. maximum: Vector3;
  7212. };
  7213. /**
  7214. * Extracts minimum and maximum values from a list of positions
  7215. * @param positions defines the positions to use
  7216. * @param start defines the start index in the positions array
  7217. * @param count defines the number of positions to handle
  7218. * @param bias defines bias value to add to the result
  7219. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7220. * @return minimum and maximum values
  7221. */
  7222. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7223. minimum: Vector3;
  7224. maximum: Vector3;
  7225. };
  7226. }
  7227. declare module BABYLON {
  7228. /**
  7229. * Enum that determines the text-wrapping mode to use.
  7230. */
  7231. export enum InspectableType {
  7232. /**
  7233. * Checkbox for booleans
  7234. */
  7235. Checkbox = 0,
  7236. /**
  7237. * Sliders for numbers
  7238. */
  7239. Slider = 1,
  7240. /**
  7241. * Vector3
  7242. */
  7243. Vector3 = 2,
  7244. /**
  7245. * Quaternions
  7246. */
  7247. Quaternion = 3,
  7248. /**
  7249. * Color3
  7250. */
  7251. Color3 = 4,
  7252. /**
  7253. * String
  7254. */
  7255. String = 5
  7256. }
  7257. /**
  7258. * Interface used to define custom inspectable properties.
  7259. * This interface is used by the inspector to display custom property grids
  7260. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7261. */
  7262. export interface IInspectable {
  7263. /**
  7264. * Gets the label to display
  7265. */
  7266. label: string;
  7267. /**
  7268. * Gets the name of the property to edit
  7269. */
  7270. propertyName: string;
  7271. /**
  7272. * Gets the type of the editor to use
  7273. */
  7274. type: InspectableType;
  7275. /**
  7276. * Gets the minimum value of the property when using in "slider" mode
  7277. */
  7278. min?: number;
  7279. /**
  7280. * Gets the maximum value of the property when using in "slider" mode
  7281. */
  7282. max?: number;
  7283. /**
  7284. * Gets the setp to use when using in "slider" mode
  7285. */
  7286. step?: number;
  7287. }
  7288. }
  7289. declare module BABYLON {
  7290. /**
  7291. * Class used to provide helper for timing
  7292. */
  7293. export class TimingTools {
  7294. /**
  7295. * Polyfill for setImmediate
  7296. * @param action defines the action to execute after the current execution block
  7297. */
  7298. static SetImmediate(action: () => void): void;
  7299. }
  7300. }
  7301. declare module BABYLON {
  7302. /**
  7303. * Class used to enable instatition of objects by class name
  7304. */
  7305. export class InstantiationTools {
  7306. /**
  7307. * Use this object to register external classes like custom textures or material
  7308. * to allow the laoders to instantiate them
  7309. */
  7310. static RegisteredExternalClasses: {
  7311. [key: string]: Object;
  7312. };
  7313. /**
  7314. * Tries to instantiate a new object from a given class name
  7315. * @param className defines the class name to instantiate
  7316. * @returns the new object or null if the system was not able to do the instantiation
  7317. */
  7318. static Instantiate(className: string): any;
  7319. }
  7320. }
  7321. declare module BABYLON {
  7322. /**
  7323. * This represents the required contract to create a new type of texture loader.
  7324. */
  7325. export interface IInternalTextureLoader {
  7326. /**
  7327. * Defines wether the loader supports cascade loading the different faces.
  7328. */
  7329. supportCascades: boolean;
  7330. /**
  7331. * This returns if the loader support the current file information.
  7332. * @param extension defines the file extension of the file being loaded
  7333. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7334. * @param fallback defines the fallback internal texture if any
  7335. * @param isBase64 defines whether the texture is encoded as a base64
  7336. * @param isBuffer defines whether the texture data are stored as a buffer
  7337. * @returns true if the loader can load the specified file
  7338. */
  7339. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7340. /**
  7341. * Transform the url before loading if required.
  7342. * @param rootUrl the url of the texture
  7343. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7344. * @returns the transformed texture
  7345. */
  7346. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7347. /**
  7348. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7349. * @param rootUrl the url of the texture
  7350. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7351. * @returns the fallback texture
  7352. */
  7353. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7354. /**
  7355. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7356. * @param data contains the texture data
  7357. * @param texture defines the BabylonJS internal texture
  7358. * @param createPolynomials will be true if polynomials have been requested
  7359. * @param onLoad defines the callback to trigger once the texture is ready
  7360. * @param onError defines the callback to trigger in case of error
  7361. */
  7362. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7363. /**
  7364. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7365. * @param data contains the texture data
  7366. * @param texture defines the BabylonJS internal texture
  7367. * @param callback defines the method to call once ready to upload
  7368. */
  7369. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7370. }
  7371. }
  7372. declare module BABYLON {
  7373. interface Engine {
  7374. /**
  7375. * Creates a depth stencil cube texture.
  7376. * This is only available in WebGL 2.
  7377. * @param size The size of face edge in the cube texture.
  7378. * @param options The options defining the cube texture.
  7379. * @returns The cube texture
  7380. */ private _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7381. /**
  7382. * Creates a cube texture
  7383. * @param rootUrl defines the url where the files to load is located
  7384. * @param scene defines the current scene
  7385. * @param files defines the list of files to load (1 per face)
  7386. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7387. * @param onLoad defines an optional callback raised when the texture is loaded
  7388. * @param onError defines an optional callback raised if there is an issue to load the texture
  7389. * @param format defines the format of the data
  7390. * @param forcedExtension defines the extension to use to pick the right loader
  7391. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7392. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7393. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7394. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7395. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7396. * @returns the cube texture as an InternalTexture
  7397. */
  7398. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7399. /**
  7400. * Creates a cube texture
  7401. * @param rootUrl defines the url where the files to load is located
  7402. * @param scene defines the current scene
  7403. * @param files defines the list of files to load (1 per face)
  7404. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7405. * @param onLoad defines an optional callback raised when the texture is loaded
  7406. * @param onError defines an optional callback raised if there is an issue to load the texture
  7407. * @param format defines the format of the data
  7408. * @param forcedExtension defines the extension to use to pick the right loader
  7409. * @returns the cube texture as an InternalTexture
  7410. */
  7411. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7412. /**
  7413. * Creates a cube texture
  7414. * @param rootUrl defines the url where the files to load is located
  7415. * @param scene defines the current scene
  7416. * @param files defines the list of files to load (1 per face)
  7417. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7418. * @param onLoad defines an optional callback raised when the texture is loaded
  7419. * @param onError defines an optional callback raised if there is an issue to load the texture
  7420. * @param format defines the format of the data
  7421. * @param forcedExtension defines the extension to use to pick the right loader
  7422. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7423. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7424. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7425. * @returns the cube texture as an InternalTexture
  7426. */
  7427. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7428. /** @hidden */ private _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7429. /** @hidden */ private _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7430. /** @hidden */ private _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7431. /** @hidden */ private _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7432. }
  7433. }
  7434. declare module BABYLON {
  7435. /**
  7436. * Class for creating a cube texture
  7437. */
  7438. export class CubeTexture extends BaseTexture {
  7439. private _delayedOnLoad;
  7440. /**
  7441. * The url of the texture
  7442. */
  7443. url: string;
  7444. /**
  7445. * Gets or sets the center of the bounding box associated with the cube texture.
  7446. * It must define where the camera used to render the texture was set
  7447. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7448. */
  7449. boundingBoxPosition: Vector3;
  7450. private _boundingBoxSize;
  7451. /**
  7452. * Gets or sets the size of the bounding box associated with the cube texture
  7453. * When defined, the cubemap will switch to local mode
  7454. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7455. * @example https://www.babylonjs-playground.com/#RNASML
  7456. */
  7457. /**
  7458. * Returns the bounding box size
  7459. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7460. */
  7461. boundingBoxSize: Vector3;
  7462. protected _rotationY: number;
  7463. /**
  7464. * Sets texture matrix rotation angle around Y axis in radians.
  7465. */
  7466. /**
  7467. * Gets texture matrix rotation angle around Y axis radians.
  7468. */
  7469. rotationY: number;
  7470. /**
  7471. * Are mip maps generated for this texture or not.
  7472. */
  7473. readonly noMipmap: boolean;
  7474. private _noMipmap;
  7475. private _files;
  7476. private _extensions;
  7477. private _textureMatrix;
  7478. private _format;
  7479. private _createPolynomials;
  7480. /** @hidden */ private _prefiltered: boolean;
  7481. /**
  7482. * Creates a cube texture from an array of image urls
  7483. * @param files defines an array of image urls
  7484. * @param scene defines the hosting scene
  7485. * @param noMipmap specifies if mip maps are not used
  7486. * @returns a cube texture
  7487. */
  7488. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7489. /**
  7490. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7491. * @param url defines the url of the prefiltered texture
  7492. * @param scene defines the scene the texture is attached to
  7493. * @param forcedExtension defines the extension of the file if different from the url
  7494. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7495. * @return the prefiltered texture
  7496. */
  7497. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7498. /**
  7499. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7500. * as prefiltered data.
  7501. * @param rootUrl defines the url of the texture or the root name of the six images
  7502. * @param scene defines the scene the texture is attached to
  7503. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7504. * @param noMipmap defines if mipmaps should be created or not
  7505. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7506. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7507. * @param onError defines a callback triggered in case of error during load
  7508. * @param format defines the internal format to use for the texture once loaded
  7509. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7510. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7511. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7512. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7513. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7514. * @return the cube texture
  7515. */
  7516. 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);
  7517. /**
  7518. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7519. */
  7520. readonly isPrefiltered: boolean;
  7521. /**
  7522. * Get the current class name of the texture useful for serialization or dynamic coding.
  7523. * @returns "CubeTexture"
  7524. */
  7525. getClassName(): string;
  7526. /**
  7527. * Update the url (and optional buffer) of this texture if url was null during construction.
  7528. * @param url the url of the texture
  7529. * @param forcedExtension defines the extension to use
  7530. * @param onLoad callback called when the texture is loaded (defaults to null)
  7531. */
  7532. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7533. /**
  7534. * Delays loading of the cube texture
  7535. * @param forcedExtension defines the extension to use
  7536. */
  7537. delayLoad(forcedExtension?: string): void;
  7538. /**
  7539. * Returns the reflection texture matrix
  7540. * @returns the reflection texture matrix
  7541. */
  7542. getReflectionTextureMatrix(): Matrix;
  7543. /**
  7544. * Sets the reflection texture matrix
  7545. * @param value Reflection texture matrix
  7546. */
  7547. setReflectionTextureMatrix(value: Matrix): void;
  7548. /**
  7549. * Parses text to create a cube texture
  7550. * @param parsedTexture define the serialized text to read from
  7551. * @param scene defines the hosting scene
  7552. * @param rootUrl defines the root url of the cube texture
  7553. * @returns a cube texture
  7554. */
  7555. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7556. /**
  7557. * Makes a clone, or deep copy, of the cube texture
  7558. * @returns a new cube texture
  7559. */
  7560. clone(): CubeTexture;
  7561. }
  7562. }
  7563. declare module BABYLON {
  7564. /**
  7565. * Manages the defines for the Material
  7566. */
  7567. export class MaterialDefines {
  7568. /** @hidden */
  7569. protected _keys: string[];
  7570. private _isDirty;
  7571. /** @hidden */ private _renderId: number;
  7572. /** @hidden */ private _areLightsDirty: boolean;
  7573. /** @hidden */ private _areAttributesDirty: boolean;
  7574. /** @hidden */ private _areTexturesDirty: boolean;
  7575. /** @hidden */ private _areFresnelDirty: boolean;
  7576. /** @hidden */ private _areMiscDirty: boolean;
  7577. /** @hidden */ private _areImageProcessingDirty: boolean;
  7578. /** @hidden */ private _normals: boolean;
  7579. /** @hidden */ private _uvs: boolean;
  7580. /** @hidden */ private _needNormals: boolean;
  7581. /** @hidden */ private _needUVs: boolean;
  7582. [id: string]: any;
  7583. /**
  7584. * Specifies if the material needs to be re-calculated
  7585. */
  7586. readonly isDirty: boolean;
  7587. /**
  7588. * Marks the material to indicate that it has been re-calculated
  7589. */
  7590. markAsProcessed(): void;
  7591. /**
  7592. * Marks the material to indicate that it needs to be re-calculated
  7593. */
  7594. markAsUnprocessed(): void;
  7595. /**
  7596. * Marks the material to indicate all of its defines need to be re-calculated
  7597. */
  7598. markAllAsDirty(): void;
  7599. /**
  7600. * Marks the material to indicate that image processing needs to be re-calculated
  7601. */
  7602. markAsImageProcessingDirty(): void;
  7603. /**
  7604. * Marks the material to indicate the lights need to be re-calculated
  7605. */
  7606. markAsLightDirty(): void;
  7607. /**
  7608. * Marks the attribute state as changed
  7609. */
  7610. markAsAttributesDirty(): void;
  7611. /**
  7612. * Marks the texture state as changed
  7613. */
  7614. markAsTexturesDirty(): void;
  7615. /**
  7616. * Marks the fresnel state as changed
  7617. */
  7618. markAsFresnelDirty(): void;
  7619. /**
  7620. * Marks the misc state as changed
  7621. */
  7622. markAsMiscDirty(): void;
  7623. /**
  7624. * Rebuilds the material defines
  7625. */
  7626. rebuild(): void;
  7627. /**
  7628. * Specifies if two material defines are equal
  7629. * @param other - A material define instance to compare to
  7630. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7631. */
  7632. isEqual(other: MaterialDefines): boolean;
  7633. /**
  7634. * Clones this instance's defines to another instance
  7635. * @param other - material defines to clone values to
  7636. */
  7637. cloneTo(other: MaterialDefines): void;
  7638. /**
  7639. * Resets the material define values
  7640. */
  7641. reset(): void;
  7642. /**
  7643. * Converts the material define values to a string
  7644. * @returns - String of material define information
  7645. */
  7646. toString(): string;
  7647. }
  7648. }
  7649. declare module BABYLON {
  7650. /**
  7651. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7652. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7653. * 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;
  7654. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7655. */
  7656. export class ColorCurves {
  7657. private _dirty;
  7658. private _tempColor;
  7659. private _globalCurve;
  7660. private _highlightsCurve;
  7661. private _midtonesCurve;
  7662. private _shadowsCurve;
  7663. private _positiveCurve;
  7664. private _negativeCurve;
  7665. private _globalHue;
  7666. private _globalDensity;
  7667. private _globalSaturation;
  7668. private _globalExposure;
  7669. /**
  7670. * Gets the global Hue value.
  7671. * 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).
  7672. */
  7673. /**
  7674. * Sets the global Hue value.
  7675. * 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).
  7676. */
  7677. globalHue: number;
  7678. /**
  7679. * Gets the global Density value.
  7680. * 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.
  7681. * Values less than zero provide a filter of opposite hue.
  7682. */
  7683. /**
  7684. * Sets the global Density value.
  7685. * 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.
  7686. * Values less than zero provide a filter of opposite hue.
  7687. */
  7688. globalDensity: number;
  7689. /**
  7690. * Gets the global Saturation value.
  7691. * 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.
  7692. */
  7693. /**
  7694. * Sets the global Saturation value.
  7695. * 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.
  7696. */
  7697. globalSaturation: number;
  7698. /**
  7699. * Gets the global Exposure value.
  7700. * 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.
  7701. */
  7702. /**
  7703. * Sets the global Exposure value.
  7704. * 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.
  7705. */
  7706. globalExposure: number;
  7707. private _highlightsHue;
  7708. private _highlightsDensity;
  7709. private _highlightsSaturation;
  7710. private _highlightsExposure;
  7711. /**
  7712. * Gets the highlights Hue value.
  7713. * 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).
  7714. */
  7715. /**
  7716. * Sets the highlights Hue value.
  7717. * 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).
  7718. */
  7719. highlightsHue: number;
  7720. /**
  7721. * Gets the highlights Density value.
  7722. * 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.
  7723. * Values less than zero provide a filter of opposite hue.
  7724. */
  7725. /**
  7726. * Sets the highlights Density value.
  7727. * 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.
  7728. * Values less than zero provide a filter of opposite hue.
  7729. */
  7730. highlightsDensity: number;
  7731. /**
  7732. * Gets the highlights Saturation value.
  7733. * 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.
  7734. */
  7735. /**
  7736. * Sets the highlights Saturation value.
  7737. * 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.
  7738. */
  7739. highlightsSaturation: number;
  7740. /**
  7741. * Gets the highlights Exposure value.
  7742. * 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.
  7743. */
  7744. /**
  7745. * Sets the highlights Exposure value.
  7746. * 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.
  7747. */
  7748. highlightsExposure: number;
  7749. private _midtonesHue;
  7750. private _midtonesDensity;
  7751. private _midtonesSaturation;
  7752. private _midtonesExposure;
  7753. /**
  7754. * Gets the midtones Hue value.
  7755. * 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).
  7756. */
  7757. /**
  7758. * Sets the midtones Hue value.
  7759. * 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).
  7760. */
  7761. midtonesHue: number;
  7762. /**
  7763. * Gets the midtones Density value.
  7764. * 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.
  7765. * Values less than zero provide a filter of opposite hue.
  7766. */
  7767. /**
  7768. * Sets the midtones Density value.
  7769. * 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.
  7770. * Values less than zero provide a filter of opposite hue.
  7771. */
  7772. midtonesDensity: number;
  7773. /**
  7774. * Gets the midtones Saturation value.
  7775. * 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.
  7776. */
  7777. /**
  7778. * Sets the midtones Saturation value.
  7779. * 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.
  7780. */
  7781. midtonesSaturation: number;
  7782. /**
  7783. * Gets the midtones Exposure value.
  7784. * 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.
  7785. */
  7786. /**
  7787. * Sets the midtones Exposure value.
  7788. * 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.
  7789. */
  7790. midtonesExposure: number;
  7791. private _shadowsHue;
  7792. private _shadowsDensity;
  7793. private _shadowsSaturation;
  7794. private _shadowsExposure;
  7795. /**
  7796. * Gets the shadows Hue value.
  7797. * 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).
  7798. */
  7799. /**
  7800. * Sets the shadows Hue value.
  7801. * 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).
  7802. */
  7803. shadowsHue: number;
  7804. /**
  7805. * Gets the shadows Density value.
  7806. * 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.
  7807. * Values less than zero provide a filter of opposite hue.
  7808. */
  7809. /**
  7810. * Sets the shadows Density value.
  7811. * 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.
  7812. * Values less than zero provide a filter of opposite hue.
  7813. */
  7814. shadowsDensity: number;
  7815. /**
  7816. * Gets the shadows Saturation value.
  7817. * 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.
  7818. */
  7819. /**
  7820. * Sets the shadows Saturation value.
  7821. * 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.
  7822. */
  7823. shadowsSaturation: number;
  7824. /**
  7825. * Gets the shadows Exposure value.
  7826. * 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.
  7827. */
  7828. /**
  7829. * Sets the shadows Exposure value.
  7830. * 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.
  7831. */
  7832. shadowsExposure: number;
  7833. /**
  7834. * Returns the class name
  7835. * @returns The class name
  7836. */
  7837. getClassName(): string;
  7838. /**
  7839. * Binds the color curves to the shader.
  7840. * @param colorCurves The color curve to bind
  7841. * @param effect The effect to bind to
  7842. * @param positiveUniform The positive uniform shader parameter
  7843. * @param neutralUniform The neutral uniform shader parameter
  7844. * @param negativeUniform The negative uniform shader parameter
  7845. */
  7846. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7847. /**
  7848. * Prepare the list of uniforms associated with the ColorCurves effects.
  7849. * @param uniformsList The list of uniforms used in the effect
  7850. */
  7851. static PrepareUniforms(uniformsList: string[]): void;
  7852. /**
  7853. * Returns color grading data based on a hue, density, saturation and exposure value.
  7854. * @param filterHue The hue of the color filter.
  7855. * @param filterDensity The density of the color filter.
  7856. * @param saturation The saturation.
  7857. * @param exposure The exposure.
  7858. * @param result The result data container.
  7859. */
  7860. private getColorGradingDataToRef;
  7861. /**
  7862. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7863. * @param value The input slider value in range [-100,100].
  7864. * @returns Adjusted value.
  7865. */
  7866. private static applyColorGradingSliderNonlinear;
  7867. /**
  7868. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7869. * @param hue The hue (H) input.
  7870. * @param saturation The saturation (S) input.
  7871. * @param brightness The brightness (B) input.
  7872. * @result An RGBA color represented as Vector4.
  7873. */
  7874. private static fromHSBToRef;
  7875. /**
  7876. * Returns a value clamped between min and max
  7877. * @param value The value to clamp
  7878. * @param min The minimum of value
  7879. * @param max The maximum of value
  7880. * @returns The clamped value.
  7881. */
  7882. private static clamp;
  7883. /**
  7884. * Clones the current color curve instance.
  7885. * @return The cloned curves
  7886. */
  7887. clone(): ColorCurves;
  7888. /**
  7889. * Serializes the current color curve instance to a json representation.
  7890. * @return a JSON representation
  7891. */
  7892. serialize(): any;
  7893. /**
  7894. * Parses the color curve from a json representation.
  7895. * @param source the JSON source to parse
  7896. * @return The parsed curves
  7897. */
  7898. static Parse(source: any): ColorCurves;
  7899. }
  7900. }
  7901. declare module BABYLON {
  7902. /**
  7903. * Interface to follow in your material defines to integrate easily the
  7904. * Image proccessing functions.
  7905. * @hidden
  7906. */
  7907. export interface IImageProcessingConfigurationDefines {
  7908. IMAGEPROCESSING: boolean;
  7909. VIGNETTE: boolean;
  7910. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7911. VIGNETTEBLENDMODEOPAQUE: boolean;
  7912. TONEMAPPING: boolean;
  7913. TONEMAPPING_ACES: boolean;
  7914. CONTRAST: boolean;
  7915. EXPOSURE: boolean;
  7916. COLORCURVES: boolean;
  7917. COLORGRADING: boolean;
  7918. COLORGRADING3D: boolean;
  7919. SAMPLER3DGREENDEPTH: boolean;
  7920. SAMPLER3DBGRMAP: boolean;
  7921. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7922. }
  7923. /**
  7924. * @hidden
  7925. */
  7926. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  7927. IMAGEPROCESSING: boolean;
  7928. VIGNETTE: boolean;
  7929. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7930. VIGNETTEBLENDMODEOPAQUE: boolean;
  7931. TONEMAPPING: boolean;
  7932. TONEMAPPING_ACES: boolean;
  7933. CONTRAST: boolean;
  7934. COLORCURVES: boolean;
  7935. COLORGRADING: boolean;
  7936. COLORGRADING3D: boolean;
  7937. SAMPLER3DGREENDEPTH: boolean;
  7938. SAMPLER3DBGRMAP: boolean;
  7939. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7940. EXPOSURE: boolean;
  7941. constructor();
  7942. }
  7943. /**
  7944. * This groups together the common properties used for image processing either in direct forward pass
  7945. * or through post processing effect depending on the use of the image processing pipeline in your scene
  7946. * or not.
  7947. */
  7948. export class ImageProcessingConfiguration {
  7949. /**
  7950. * Default tone mapping applied in BabylonJS.
  7951. */
  7952. static readonly TONEMAPPING_STANDARD: number;
  7953. /**
  7954. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  7955. * to other engines rendering to increase portability.
  7956. */
  7957. static readonly TONEMAPPING_ACES: number;
  7958. /**
  7959. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  7960. */
  7961. colorCurves: Nullable<ColorCurves>;
  7962. private _colorCurvesEnabled;
  7963. /**
  7964. * Gets wether the color curves effect is enabled.
  7965. */
  7966. /**
  7967. * Sets wether the color curves effect is enabled.
  7968. */
  7969. colorCurvesEnabled: boolean;
  7970. private _colorGradingTexture;
  7971. /**
  7972. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  7973. */
  7974. /**
  7975. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  7976. */
  7977. colorGradingTexture: Nullable<BaseTexture>;
  7978. private _colorGradingEnabled;
  7979. /**
  7980. * Gets wether the color grading effect is enabled.
  7981. */
  7982. /**
  7983. * Sets wether the color grading effect is enabled.
  7984. */
  7985. colorGradingEnabled: boolean;
  7986. private _colorGradingWithGreenDepth;
  7987. /**
  7988. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  7989. */
  7990. /**
  7991. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  7992. */
  7993. colorGradingWithGreenDepth: boolean;
  7994. private _colorGradingBGR;
  7995. /**
  7996. * Gets wether the color grading texture contains BGR values.
  7997. */
  7998. /**
  7999. * Sets wether the color grading texture contains BGR values.
  8000. */
  8001. colorGradingBGR: boolean;
  8002. /** @hidden */ private _exposure: number;
  8003. /**
  8004. * Gets the Exposure used in the effect.
  8005. */
  8006. /**
  8007. * Sets the Exposure used in the effect.
  8008. */
  8009. exposure: number;
  8010. private _toneMappingEnabled;
  8011. /**
  8012. * Gets wether the tone mapping effect is enabled.
  8013. */
  8014. /**
  8015. * Sets wether the tone mapping effect is enabled.
  8016. */
  8017. toneMappingEnabled: boolean;
  8018. private _toneMappingType;
  8019. /**
  8020. * Gets the type of tone mapping effect.
  8021. */
  8022. /**
  8023. * Sets the type of tone mapping effect used in BabylonJS.
  8024. */
  8025. toneMappingType: number;
  8026. protected _contrast: number;
  8027. /**
  8028. * Gets the contrast used in the effect.
  8029. */
  8030. /**
  8031. * Sets the contrast used in the effect.
  8032. */
  8033. contrast: number;
  8034. /**
  8035. * Vignette stretch size.
  8036. */
  8037. vignetteStretch: number;
  8038. /**
  8039. * Vignette centre X Offset.
  8040. */
  8041. vignetteCentreX: number;
  8042. /**
  8043. * Vignette centre Y Offset.
  8044. */
  8045. vignetteCentreY: number;
  8046. /**
  8047. * Vignette weight or intensity of the vignette effect.
  8048. */
  8049. vignetteWeight: number;
  8050. /**
  8051. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8052. * if vignetteEnabled is set to true.
  8053. */
  8054. vignetteColor: Color4;
  8055. /**
  8056. * Camera field of view used by the Vignette effect.
  8057. */
  8058. vignetteCameraFov: number;
  8059. private _vignetteBlendMode;
  8060. /**
  8061. * Gets the vignette blend mode allowing different kind of effect.
  8062. */
  8063. /**
  8064. * Sets the vignette blend mode allowing different kind of effect.
  8065. */
  8066. vignetteBlendMode: number;
  8067. private _vignetteEnabled;
  8068. /**
  8069. * Gets wether the vignette effect is enabled.
  8070. */
  8071. /**
  8072. * Sets wether the vignette effect is enabled.
  8073. */
  8074. vignetteEnabled: boolean;
  8075. private _applyByPostProcess;
  8076. /**
  8077. * Gets wether the image processing is applied through a post process or not.
  8078. */
  8079. /**
  8080. * Sets wether the image processing is applied through a post process or not.
  8081. */
  8082. applyByPostProcess: boolean;
  8083. private _isEnabled;
  8084. /**
  8085. * Gets wether the image processing is enabled or not.
  8086. */
  8087. /**
  8088. * Sets wether the image processing is enabled or not.
  8089. */
  8090. isEnabled: boolean;
  8091. /**
  8092. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8093. */
  8094. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8095. /**
  8096. * Method called each time the image processing information changes requires to recompile the effect.
  8097. */
  8098. protected _updateParameters(): void;
  8099. /**
  8100. * Gets the current class name.
  8101. * @return "ImageProcessingConfiguration"
  8102. */
  8103. getClassName(): string;
  8104. /**
  8105. * Prepare the list of uniforms associated with the Image Processing effects.
  8106. * @param uniforms The list of uniforms used in the effect
  8107. * @param defines the list of defines currently in use
  8108. */
  8109. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8110. /**
  8111. * Prepare the list of samplers associated with the Image Processing effects.
  8112. * @param samplersList The list of uniforms used in the effect
  8113. * @param defines the list of defines currently in use
  8114. */
  8115. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8116. /**
  8117. * Prepare the list of defines associated to the shader.
  8118. * @param defines the list of defines to complete
  8119. * @param forPostProcess Define if we are currently in post process mode or not
  8120. */
  8121. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8122. /**
  8123. * Returns true if all the image processing information are ready.
  8124. * @returns True if ready, otherwise, false
  8125. */
  8126. isReady(): boolean;
  8127. /**
  8128. * Binds the image processing to the shader.
  8129. * @param effect The effect to bind to
  8130. * @param aspectRatio Define the current aspect ratio of the effect
  8131. */
  8132. bind(effect: Effect, aspectRatio?: number): void;
  8133. /**
  8134. * Clones the current image processing instance.
  8135. * @return The cloned image processing
  8136. */
  8137. clone(): ImageProcessingConfiguration;
  8138. /**
  8139. * Serializes the current image processing instance to a json representation.
  8140. * @return a JSON representation
  8141. */
  8142. serialize(): any;
  8143. /**
  8144. * Parses the image processing from a json representation.
  8145. * @param source the JSON source to parse
  8146. * @return The parsed image processing
  8147. */
  8148. static Parse(source: any): ImageProcessingConfiguration;
  8149. private static _VIGNETTEMODE_MULTIPLY;
  8150. private static _VIGNETTEMODE_OPAQUE;
  8151. /**
  8152. * Used to apply the vignette as a mix with the pixel color.
  8153. */
  8154. static readonly VIGNETTEMODE_MULTIPLY: number;
  8155. /**
  8156. * Used to apply the vignette as a replacement of the pixel color.
  8157. */
  8158. static readonly VIGNETTEMODE_OPAQUE: number;
  8159. }
  8160. }
  8161. declare module BABYLON {
  8162. /** @hidden */
  8163. export var postprocessVertexShader: {
  8164. name: string;
  8165. shader: string;
  8166. };
  8167. }
  8168. declare module BABYLON {
  8169. /** Defines supported spaces */
  8170. export enum Space {
  8171. /** Local (object) space */
  8172. LOCAL = 0,
  8173. /** World space */
  8174. WORLD = 1,
  8175. /** Bone space */
  8176. BONE = 2
  8177. }
  8178. /** Defines the 3 main axes */
  8179. export class Axis {
  8180. /** X axis */
  8181. static X: Vector3;
  8182. /** Y axis */
  8183. static Y: Vector3;
  8184. /** Z axis */
  8185. static Z: Vector3;
  8186. }
  8187. }
  8188. declare module BABYLON {
  8189. /**
  8190. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8191. * This is the base of the follow, arc rotate cameras and Free camera
  8192. * @see http://doc.babylonjs.com/features/cameras
  8193. */
  8194. export class TargetCamera extends Camera {
  8195. private static _RigCamTransformMatrix;
  8196. private static _TargetTransformMatrix;
  8197. private static _TargetFocalPoint;
  8198. /**
  8199. * Define the current direction the camera is moving to
  8200. */
  8201. cameraDirection: Vector3;
  8202. /**
  8203. * Define the current rotation the camera is rotating to
  8204. */
  8205. cameraRotation: Vector2;
  8206. /**
  8207. * When set, the up vector of the camera will be updated by the rotation of the camera
  8208. */
  8209. updateUpVectorFromRotation: boolean;
  8210. private _tmpQuaternion;
  8211. /**
  8212. * Define the current rotation of the camera
  8213. */
  8214. rotation: Vector3;
  8215. /**
  8216. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8217. */
  8218. rotationQuaternion: Quaternion;
  8219. /**
  8220. * Define the current speed of the camera
  8221. */
  8222. speed: number;
  8223. /**
  8224. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8225. * around all axis.
  8226. */
  8227. noRotationConstraint: boolean;
  8228. /**
  8229. * Define the current target of the camera as an object or a position.
  8230. */
  8231. lockedTarget: any;
  8232. /** @hidden */ private _currentTarget: Vector3;
  8233. /** @hidden */ private _initialFocalDistance: number;
  8234. /** @hidden */ private _viewMatrix: Matrix;
  8235. /** @hidden */ private _camMatrix: Matrix;
  8236. /** @hidden */ private _cameraTransformMatrix: Matrix;
  8237. /** @hidden */ private _cameraRotationMatrix: Matrix;
  8238. /** @hidden */ private _referencePoint: Vector3;
  8239. /** @hidden */ private _transformedReferencePoint: Vector3;
  8240. protected _globalCurrentTarget: Vector3;
  8241. protected _globalCurrentUpVector: Vector3;
  8242. /** @hidden */ private _reset: () => void;
  8243. private _defaultUp;
  8244. /**
  8245. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8246. * This is the base of the follow, arc rotate cameras and Free camera
  8247. * @see http://doc.babylonjs.com/features/cameras
  8248. * @param name Defines the name of the camera in the scene
  8249. * @param position Defines the start position of the camera in the scene
  8250. * @param scene Defines the scene the camera belongs to
  8251. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8252. */
  8253. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8254. /**
  8255. * Gets the position in front of the camera at a given distance.
  8256. * @param distance The distance from the camera we want the position to be
  8257. * @returns the position
  8258. */
  8259. getFrontPosition(distance: number): Vector3;
  8260. /** @hidden */ private _getLockedTargetPosition(): Nullable<Vector3>;
  8261. private _storedPosition;
  8262. private _storedRotation;
  8263. private _storedRotationQuaternion;
  8264. /**
  8265. * Store current camera state of the camera (fov, position, rotation, etc..)
  8266. * @returns the camera
  8267. */
  8268. storeState(): Camera;
  8269. /**
  8270. * Restored camera state. You must call storeState() first
  8271. * @returns whether it was successful or not
  8272. * @hidden
  8273. */ private _restoreStateValues(): boolean;
  8274. /** @hidden */ private _initCache(): void;
  8275. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  8276. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  8277. /** @hidden */ private _computeLocalCameraSpeed(): number;
  8278. /**
  8279. * Defines the target the camera should look at.
  8280. * @param target Defines the new target as a Vector or a mesh
  8281. */
  8282. setTarget(target: Vector3): void;
  8283. /**
  8284. * Return the current target position of the camera. This value is expressed in local space.
  8285. * @returns the target position
  8286. */
  8287. getTarget(): Vector3;
  8288. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  8289. /** @hidden */ private _updatePosition(): void;
  8290. /** @hidden */ private _checkInputs(): void;
  8291. protected _updateCameraRotationMatrix(): void;
  8292. /**
  8293. * 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)
  8294. * @returns the current camera
  8295. */
  8296. private _rotateUpVectorWithCameraRotationMatrix;
  8297. private _cachedRotationZ;
  8298. private _cachedQuaternionRotationZ;
  8299. /** @hidden */ private _getViewMatrix(): Matrix;
  8300. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8301. /**
  8302. * @hidden
  8303. */
  8304. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8305. /**
  8306. * @hidden
  8307. */ private _updateRigCameras(): void;
  8308. private _getRigCamPositionAndTarget;
  8309. /**
  8310. * Gets the current object class name.
  8311. * @return the class name
  8312. */
  8313. getClassName(): string;
  8314. }
  8315. }
  8316. declare module BABYLON {
  8317. /**
  8318. * Gather the list of keyboard event types as constants.
  8319. */
  8320. export class KeyboardEventTypes {
  8321. /**
  8322. * The keydown event is fired when a key becomes active (pressed).
  8323. */
  8324. static readonly KEYDOWN: number;
  8325. /**
  8326. * The keyup event is fired when a key has been released.
  8327. */
  8328. static readonly KEYUP: number;
  8329. }
  8330. /**
  8331. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8332. */
  8333. export class KeyboardInfo {
  8334. /**
  8335. * Defines the type of event (KeyboardEventTypes)
  8336. */
  8337. type: number;
  8338. /**
  8339. * Defines the related dom event
  8340. */
  8341. event: KeyboardEvent;
  8342. /**
  8343. * Instantiates a new keyboard info.
  8344. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8345. * @param type Defines the type of event (KeyboardEventTypes)
  8346. * @param event Defines the related dom event
  8347. */
  8348. constructor(
  8349. /**
  8350. * Defines the type of event (KeyboardEventTypes)
  8351. */
  8352. type: number,
  8353. /**
  8354. * Defines the related dom event
  8355. */
  8356. event: KeyboardEvent);
  8357. }
  8358. /**
  8359. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8360. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8361. */
  8362. export class KeyboardInfoPre extends KeyboardInfo {
  8363. /**
  8364. * Defines the type of event (KeyboardEventTypes)
  8365. */
  8366. type: number;
  8367. /**
  8368. * Defines the related dom event
  8369. */
  8370. event: KeyboardEvent;
  8371. /**
  8372. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8373. */
  8374. skipOnPointerObservable: boolean;
  8375. /**
  8376. * Instantiates a new keyboard pre info.
  8377. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8378. * @param type Defines the type of event (KeyboardEventTypes)
  8379. * @param event Defines the related dom event
  8380. */
  8381. constructor(
  8382. /**
  8383. * Defines the type of event (KeyboardEventTypes)
  8384. */
  8385. type: number,
  8386. /**
  8387. * Defines the related dom event
  8388. */
  8389. event: KeyboardEvent);
  8390. }
  8391. }
  8392. declare module BABYLON {
  8393. /**
  8394. * Manage the keyboard inputs to control the movement of a free camera.
  8395. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8396. */
  8397. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8398. /**
  8399. * Defines the camera the input is attached to.
  8400. */
  8401. camera: FreeCamera;
  8402. /**
  8403. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8404. */
  8405. keysUp: number[];
  8406. /**
  8407. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8408. */
  8409. keysDown: number[];
  8410. /**
  8411. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8412. */
  8413. keysLeft: number[];
  8414. /**
  8415. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8416. */
  8417. keysRight: number[];
  8418. private _keys;
  8419. private _onCanvasBlurObserver;
  8420. private _onKeyboardObserver;
  8421. private _engine;
  8422. private _scene;
  8423. /**
  8424. * Attach the input controls to a specific dom element to get the input from.
  8425. * @param element Defines the element the controls should be listened from
  8426. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8427. */
  8428. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8429. /**
  8430. * Detach the current controls from the specified dom element.
  8431. * @param element Defines the element to stop listening the inputs from
  8432. */
  8433. detachControl(element: Nullable<HTMLElement>): void;
  8434. /**
  8435. * Update the current camera state depending on the inputs that have been used this frame.
  8436. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8437. */
  8438. checkInputs(): void;
  8439. /**
  8440. * Gets the class name of the current intput.
  8441. * @returns the class name
  8442. */
  8443. getClassName(): string;
  8444. /** @hidden */ private _onLostFocus(): void;
  8445. /**
  8446. * Get the friendly name associated with the input class.
  8447. * @returns the input friendly name
  8448. */
  8449. getSimpleName(): string;
  8450. }
  8451. }
  8452. declare module BABYLON {
  8453. /**
  8454. * Interface describing all the common properties and methods a shadow light needs to implement.
  8455. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8456. * as well as binding the different shadow properties to the effects.
  8457. */
  8458. export interface IShadowLight extends Light {
  8459. /**
  8460. * The light id in the scene (used in scene.findLighById for instance)
  8461. */
  8462. id: string;
  8463. /**
  8464. * The position the shdow will be casted from.
  8465. */
  8466. position: Vector3;
  8467. /**
  8468. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8469. */
  8470. direction: Vector3;
  8471. /**
  8472. * The transformed position. Position of the light in world space taking parenting in account.
  8473. */
  8474. transformedPosition: Vector3;
  8475. /**
  8476. * The transformed direction. Direction of the light in world space taking parenting in account.
  8477. */
  8478. transformedDirection: Vector3;
  8479. /**
  8480. * The friendly name of the light in the scene.
  8481. */
  8482. name: string;
  8483. /**
  8484. * Defines the shadow projection clipping minimum z value.
  8485. */
  8486. shadowMinZ: number;
  8487. /**
  8488. * Defines the shadow projection clipping maximum z value.
  8489. */
  8490. shadowMaxZ: number;
  8491. /**
  8492. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8493. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8494. */
  8495. computeTransformedInformation(): boolean;
  8496. /**
  8497. * Gets the scene the light belongs to.
  8498. * @returns The scene
  8499. */
  8500. getScene(): Scene;
  8501. /**
  8502. * Callback defining a custom Projection Matrix Builder.
  8503. * This can be used to override the default projection matrix computation.
  8504. */
  8505. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8506. /**
  8507. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8508. * @param matrix The materix to updated with the projection information
  8509. * @param viewMatrix The transform matrix of the light
  8510. * @param renderList The list of mesh to render in the map
  8511. * @returns The current light
  8512. */
  8513. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8514. /**
  8515. * Gets the current depth scale used in ESM.
  8516. * @returns The scale
  8517. */
  8518. getDepthScale(): number;
  8519. /**
  8520. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8521. * @returns true if a cube texture needs to be use
  8522. */
  8523. needCube(): boolean;
  8524. /**
  8525. * Detects if the projection matrix requires to be recomputed this frame.
  8526. * @returns true if it requires to be recomputed otherwise, false.
  8527. */
  8528. needProjectionMatrixCompute(): boolean;
  8529. /**
  8530. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8531. */
  8532. forceProjectionMatrixCompute(): void;
  8533. /**
  8534. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8535. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8536. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8537. */
  8538. getShadowDirection(faceIndex?: number): Vector3;
  8539. /**
  8540. * Gets the minZ used for shadow according to both the scene and the light.
  8541. * @param activeCamera The camera we are returning the min for
  8542. * @returns the depth min z
  8543. */
  8544. getDepthMinZ(activeCamera: Camera): number;
  8545. /**
  8546. * Gets the maxZ used for shadow according to both the scene and the light.
  8547. * @param activeCamera The camera we are returning the max for
  8548. * @returns the depth max z
  8549. */
  8550. getDepthMaxZ(activeCamera: Camera): number;
  8551. }
  8552. /**
  8553. * Base implementation IShadowLight
  8554. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8555. */
  8556. export abstract class ShadowLight extends Light implements IShadowLight {
  8557. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8558. protected _position: Vector3;
  8559. protected _setPosition(value: Vector3): void;
  8560. /**
  8561. * Sets the position the shadow will be casted from. Also use as the light position for both
  8562. * point and spot lights.
  8563. */
  8564. /**
  8565. * Sets the position the shadow will be casted from. Also use as the light position for both
  8566. * point and spot lights.
  8567. */
  8568. position: Vector3;
  8569. protected _direction: Vector3;
  8570. protected _setDirection(value: Vector3): void;
  8571. /**
  8572. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8573. * Also use as the light direction on spot and directional lights.
  8574. */
  8575. /**
  8576. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8577. * Also use as the light direction on spot and directional lights.
  8578. */
  8579. direction: Vector3;
  8580. private _shadowMinZ;
  8581. /**
  8582. * Gets the shadow projection clipping minimum z value.
  8583. */
  8584. /**
  8585. * Sets the shadow projection clipping minimum z value.
  8586. */
  8587. shadowMinZ: number;
  8588. private _shadowMaxZ;
  8589. /**
  8590. * Sets the shadow projection clipping maximum z value.
  8591. */
  8592. /**
  8593. * Gets the shadow projection clipping maximum z value.
  8594. */
  8595. shadowMaxZ: number;
  8596. /**
  8597. * Callback defining a custom Projection Matrix Builder.
  8598. * This can be used to override the default projection matrix computation.
  8599. */
  8600. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8601. /**
  8602. * The transformed position. Position of the light in world space taking parenting in account.
  8603. */
  8604. transformedPosition: Vector3;
  8605. /**
  8606. * The transformed direction. Direction of the light in world space taking parenting in account.
  8607. */
  8608. transformedDirection: Vector3;
  8609. private _needProjectionMatrixCompute;
  8610. /**
  8611. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8612. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8613. */
  8614. computeTransformedInformation(): boolean;
  8615. /**
  8616. * Return the depth scale used for the shadow map.
  8617. * @returns the depth scale.
  8618. */
  8619. getDepthScale(): number;
  8620. /**
  8621. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8622. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8623. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8624. */
  8625. getShadowDirection(faceIndex?: number): Vector3;
  8626. /**
  8627. * Returns the ShadowLight absolute position in the World.
  8628. * @returns the position vector in world space
  8629. */
  8630. getAbsolutePosition(): Vector3;
  8631. /**
  8632. * Sets the ShadowLight direction toward the passed target.
  8633. * @param target The point to target in local space
  8634. * @returns the updated ShadowLight direction
  8635. */
  8636. setDirectionToTarget(target: Vector3): Vector3;
  8637. /**
  8638. * Returns the light rotation in euler definition.
  8639. * @returns the x y z rotation in local space.
  8640. */
  8641. getRotation(): Vector3;
  8642. /**
  8643. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8644. * @returns true if a cube texture needs to be use
  8645. */
  8646. needCube(): boolean;
  8647. /**
  8648. * Detects if the projection matrix requires to be recomputed this frame.
  8649. * @returns true if it requires to be recomputed otherwise, false.
  8650. */
  8651. needProjectionMatrixCompute(): boolean;
  8652. /**
  8653. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8654. */
  8655. forceProjectionMatrixCompute(): void;
  8656. /** @hidden */ private _initCache(): void;
  8657. /** @hidden */ private _isSynchronized(): boolean;
  8658. /**
  8659. * Computes the world matrix of the node
  8660. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8661. * @returns the world matrix
  8662. */
  8663. computeWorldMatrix(force?: boolean): Matrix;
  8664. /**
  8665. * Gets the minZ used for shadow according to both the scene and the light.
  8666. * @param activeCamera The camera we are returning the min for
  8667. * @returns the depth min z
  8668. */
  8669. getDepthMinZ(activeCamera: Camera): number;
  8670. /**
  8671. * Gets the maxZ used for shadow according to both the scene and the light.
  8672. * @param activeCamera The camera we are returning the max for
  8673. * @returns the depth max z
  8674. */
  8675. getDepthMaxZ(activeCamera: Camera): number;
  8676. /**
  8677. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8678. * @param matrix The materix to updated with the projection information
  8679. * @param viewMatrix The transform matrix of the light
  8680. * @param renderList The list of mesh to render in the map
  8681. * @returns The current light
  8682. */
  8683. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8684. }
  8685. }
  8686. declare module BABYLON {
  8687. /**
  8688. * "Static Class" containing the most commonly used helper while dealing with material for
  8689. * rendering purpose.
  8690. *
  8691. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8692. *
  8693. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8694. */
  8695. export class MaterialHelper {
  8696. /**
  8697. * Bind the current view position to an effect.
  8698. * @param effect The effect to be bound
  8699. * @param scene The scene the eyes position is used from
  8700. */
  8701. static BindEyePosition(effect: Effect, scene: Scene): void;
  8702. /**
  8703. * Helps preparing the defines values about the UVs in used in the effect.
  8704. * UVs are shared as much as we can accross channels in the shaders.
  8705. * @param texture The texture we are preparing the UVs for
  8706. * @param defines The defines to update
  8707. * @param key The channel key "diffuse", "specular"... used in the shader
  8708. */
  8709. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8710. /**
  8711. * Binds a texture matrix value to its corrsponding uniform
  8712. * @param texture The texture to bind the matrix for
  8713. * @param uniformBuffer The uniform buffer receivin the data
  8714. * @param key The channel key "diffuse", "specular"... used in the shader
  8715. */
  8716. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8717. /**
  8718. * Gets the current status of the fog (should it be enabled?)
  8719. * @param mesh defines the mesh to evaluate for fog support
  8720. * @param scene defines the hosting scene
  8721. * @returns true if fog must be enabled
  8722. */
  8723. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8724. /**
  8725. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8726. * @param mesh defines the current mesh
  8727. * @param scene defines the current scene
  8728. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8729. * @param pointsCloud defines if point cloud rendering has to be turned on
  8730. * @param fogEnabled defines if fog has to be turned on
  8731. * @param alphaTest defines if alpha testing has to be turned on
  8732. * @param defines defines the current list of defines
  8733. */
  8734. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8735. /**
  8736. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8737. * @param scene defines the current scene
  8738. * @param engine defines the current engine
  8739. * @param defines specifies the list of active defines
  8740. * @param useInstances defines if instances have to be turned on
  8741. * @param useClipPlane defines if clip plane have to be turned on
  8742. */
  8743. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8744. /**
  8745. * Prepares the defines for bones
  8746. * @param mesh The mesh containing the geometry data we will draw
  8747. * @param defines The defines to update
  8748. */
  8749. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8750. /**
  8751. * Prepares the defines for morph targets
  8752. * @param mesh The mesh containing the geometry data we will draw
  8753. * @param defines The defines to update
  8754. */
  8755. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8756. /**
  8757. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8758. * @param mesh The mesh containing the geometry data we will draw
  8759. * @param defines The defines to update
  8760. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8761. * @param useBones Precise whether bones should be used or not (override mesh info)
  8762. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8763. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8764. * @returns false if defines are considered not dirty and have not been checked
  8765. */
  8766. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8767. /**
  8768. * Prepares the defines related to multiview
  8769. * @param scene The scene we are intending to draw
  8770. * @param defines The defines to update
  8771. */
  8772. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8773. /**
  8774. * Prepares the defines related to the light information passed in parameter
  8775. * @param scene The scene we are intending to draw
  8776. * @param mesh The mesh the effect is compiling for
  8777. * @param light The light the effect is compiling for
  8778. * @param lightIndex The index of the light
  8779. * @param defines The defines to update
  8780. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8781. * @param state Defines the current state regarding what is needed (normals, etc...)
  8782. */
  8783. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8784. needNormals: boolean;
  8785. needRebuild: boolean;
  8786. shadowEnabled: boolean;
  8787. specularEnabled: boolean;
  8788. lightmapMode: boolean;
  8789. }): void;
  8790. /**
  8791. * Prepares the defines related to the light information passed in parameter
  8792. * @param scene The scene we are intending to draw
  8793. * @param mesh The mesh the effect is compiling for
  8794. * @param defines The defines to update
  8795. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8796. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8797. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8798. * @returns true if normals will be required for the rest of the effect
  8799. */
  8800. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8801. /**
  8802. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8803. * @param lightIndex defines the light index
  8804. * @param uniformsList The uniform list
  8805. * @param samplersList The sampler list
  8806. * @param projectedLightTexture defines if projected texture must be used
  8807. * @param uniformBuffersList defines an optional list of uniform buffers
  8808. */
  8809. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8810. /**
  8811. * Prepares the uniforms and samplers list to be used in the effect
  8812. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8813. * @param samplersList The sampler list
  8814. * @param defines The defines helping in the list generation
  8815. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8816. */
  8817. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8818. /**
  8819. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8820. * @param defines The defines to update while falling back
  8821. * @param fallbacks The authorized effect fallbacks
  8822. * @param maxSimultaneousLights The maximum number of lights allowed
  8823. * @param rank the current rank of the Effect
  8824. * @returns The newly affected rank
  8825. */
  8826. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8827. private static _TmpMorphInfluencers;
  8828. /**
  8829. * Prepares the list of attributes required for morph targets according to the effect defines.
  8830. * @param attribs The current list of supported attribs
  8831. * @param mesh The mesh to prepare the morph targets attributes for
  8832. * @param influencers The number of influencers
  8833. */
  8834. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  8835. /**
  8836. * Prepares the list of attributes required for morph targets according to the effect defines.
  8837. * @param attribs The current list of supported attribs
  8838. * @param mesh The mesh to prepare the morph targets attributes for
  8839. * @param defines The current Defines of the effect
  8840. */
  8841. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8842. /**
  8843. * Prepares the list of attributes required for bones according to the effect defines.
  8844. * @param attribs The current list of supported attribs
  8845. * @param mesh The mesh to prepare the bones attributes for
  8846. * @param defines The current Defines of the effect
  8847. * @param fallbacks The current efffect fallback strategy
  8848. */
  8849. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  8850. /**
  8851. * Check and prepare the list of attributes required for instances according to the effect defines.
  8852. * @param attribs The current list of supported attribs
  8853. * @param defines The current MaterialDefines of the effect
  8854. */
  8855. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  8856. /**
  8857. * Add the list of attributes required for instances to the attribs array.
  8858. * @param attribs The current list of supported attribs
  8859. */
  8860. static PushAttributesForInstances(attribs: string[]): void;
  8861. /**
  8862. * Binds the light shadow information to the effect for the given mesh.
  8863. * @param light The light containing the generator
  8864. * @param scene The scene the lights belongs to
  8865. * @param mesh The mesh we are binding the information to render
  8866. * @param lightIndex The light index in the effect used to render the mesh
  8867. * @param effect The effect we are binding the data to
  8868. */
  8869. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  8870. /**
  8871. * Binds the light information to the effect.
  8872. * @param light The light containing the generator
  8873. * @param effect The effect we are binding the data to
  8874. * @param lightIndex The light index in the effect used to render
  8875. */
  8876. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  8877. /**
  8878. * Binds the lights information from the scene to the effect for the given mesh.
  8879. * @param light Light to bind
  8880. * @param lightIndex Light index
  8881. * @param scene The scene where the light belongs to
  8882. * @param mesh The mesh we are binding the information to render
  8883. * @param effect The effect we are binding the data to
  8884. * @param useSpecular Defines if specular is supported
  8885. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8886. */
  8887. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  8888. /**
  8889. * Binds the lights information from the scene to the effect for the given mesh.
  8890. * @param scene The scene the lights belongs to
  8891. * @param mesh The mesh we are binding the information to render
  8892. * @param effect The effect we are binding the data to
  8893. * @param defines The generated defines for the effect
  8894. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  8895. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8896. */
  8897. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  8898. private static _tempFogColor;
  8899. /**
  8900. * Binds the fog information from the scene to the effect for the given mesh.
  8901. * @param scene The scene the lights belongs to
  8902. * @param mesh The mesh we are binding the information to render
  8903. * @param effect The effect we are binding the data to
  8904. * @param linearSpace Defines if the fog effect is applied in linear space
  8905. */
  8906. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  8907. /**
  8908. * Binds the bones information from the mesh to the effect.
  8909. * @param mesh The mesh we are binding the information to render
  8910. * @param effect The effect we are binding the data to
  8911. */
  8912. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  8913. /**
  8914. * Binds the morph targets information from the mesh to the effect.
  8915. * @param abstractMesh The mesh we are binding the information to render
  8916. * @param effect The effect we are binding the data to
  8917. */
  8918. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  8919. /**
  8920. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  8921. * @param defines The generated defines used in the effect
  8922. * @param effect The effect we are binding the data to
  8923. * @param scene The scene we are willing to render with logarithmic scale for
  8924. */
  8925. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  8926. /**
  8927. * Binds the clip plane information from the scene to the effect.
  8928. * @param scene The scene the clip plane information are extracted from
  8929. * @param effect The effect we are binding the data to
  8930. */
  8931. static BindClipPlane(effect: Effect, scene: Scene): void;
  8932. }
  8933. }
  8934. declare module BABYLON {
  8935. /** @hidden */
  8936. export var packingFunctions: {
  8937. name: string;
  8938. shader: string;
  8939. };
  8940. }
  8941. declare module BABYLON {
  8942. /** @hidden */
  8943. export var shadowMapPixelShader: {
  8944. name: string;
  8945. shader: string;
  8946. };
  8947. }
  8948. declare module BABYLON {
  8949. /** @hidden */
  8950. export var bonesDeclaration: {
  8951. name: string;
  8952. shader: string;
  8953. };
  8954. }
  8955. declare module BABYLON {
  8956. /** @hidden */
  8957. export var morphTargetsVertexGlobalDeclaration: {
  8958. name: string;
  8959. shader: string;
  8960. };
  8961. }
  8962. declare module BABYLON {
  8963. /** @hidden */
  8964. export var morphTargetsVertexDeclaration: {
  8965. name: string;
  8966. shader: string;
  8967. };
  8968. }
  8969. declare module BABYLON {
  8970. /** @hidden */
  8971. export var instancesDeclaration: {
  8972. name: string;
  8973. shader: string;
  8974. };
  8975. }
  8976. declare module BABYLON {
  8977. /** @hidden */
  8978. export var helperFunctions: {
  8979. name: string;
  8980. shader: string;
  8981. };
  8982. }
  8983. declare module BABYLON {
  8984. /** @hidden */
  8985. export var morphTargetsVertex: {
  8986. name: string;
  8987. shader: string;
  8988. };
  8989. }
  8990. declare module BABYLON {
  8991. /** @hidden */
  8992. export var instancesVertex: {
  8993. name: string;
  8994. shader: string;
  8995. };
  8996. }
  8997. declare module BABYLON {
  8998. /** @hidden */
  8999. export var bonesVertex: {
  9000. name: string;
  9001. shader: string;
  9002. };
  9003. }
  9004. declare module BABYLON {
  9005. /** @hidden */
  9006. export var shadowMapVertexShader: {
  9007. name: string;
  9008. shader: string;
  9009. };
  9010. }
  9011. declare module BABYLON {
  9012. /** @hidden */
  9013. export var depthBoxBlurPixelShader: {
  9014. name: string;
  9015. shader: string;
  9016. };
  9017. }
  9018. declare module BABYLON {
  9019. /**
  9020. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9021. */
  9022. export interface ICustomShaderOptions {
  9023. /**
  9024. * Gets or sets the custom shader name to use
  9025. */
  9026. shaderName: string;
  9027. /**
  9028. * The list of attribute names used in the shader
  9029. */
  9030. attributes?: string[];
  9031. /**
  9032. * The list of unifrom names used in the shader
  9033. */
  9034. uniforms?: string[];
  9035. /**
  9036. * The list of sampler names used in the shader
  9037. */
  9038. samplers?: string[];
  9039. /**
  9040. * The list of defines used in the shader
  9041. */
  9042. defines?: string[];
  9043. }
  9044. /**
  9045. * Interface to implement to create a shadow generator compatible with BJS.
  9046. */
  9047. export interface IShadowGenerator {
  9048. /**
  9049. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9050. * @returns The render target texture if present otherwise, null
  9051. */
  9052. getShadowMap(): Nullable<RenderTargetTexture>;
  9053. /**
  9054. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9055. * @returns The render target texture if the shadow map is present otherwise, null
  9056. */
  9057. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9058. /**
  9059. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9060. * @param subMesh The submesh we want to render in the shadow map
  9061. * @param useInstances Defines wether will draw in the map using instances
  9062. * @returns true if ready otherwise, false
  9063. */
  9064. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9065. /**
  9066. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9067. * @param defines Defines of the material we want to update
  9068. * @param lightIndex Index of the light in the enabled light list of the material
  9069. */
  9070. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9071. /**
  9072. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9073. * defined in the generator but impacting the effect).
  9074. * It implies the unifroms available on the materials are the standard BJS ones.
  9075. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9076. * @param effect The effect we are binfing the information for
  9077. */
  9078. bindShadowLight(lightIndex: string, effect: Effect): void;
  9079. /**
  9080. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9081. * (eq to shadow prjection matrix * light transform matrix)
  9082. * @returns The transform matrix used to create the shadow map
  9083. */
  9084. getTransformMatrix(): Matrix;
  9085. /**
  9086. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9087. * Cube and 2D textures for instance.
  9088. */
  9089. recreateShadowMap(): void;
  9090. /**
  9091. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9092. * @param onCompiled Callback triggered at the and of the effects compilation
  9093. * @param options Sets of optional options forcing the compilation with different modes
  9094. */
  9095. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9096. useInstances: boolean;
  9097. }>): void;
  9098. /**
  9099. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9100. * @param options Sets of optional options forcing the compilation with different modes
  9101. * @returns A promise that resolves when the compilation completes
  9102. */
  9103. forceCompilationAsync(options?: Partial<{
  9104. useInstances: boolean;
  9105. }>): Promise<void>;
  9106. /**
  9107. * Serializes the shadow generator setup to a json object.
  9108. * @returns The serialized JSON object
  9109. */
  9110. serialize(): any;
  9111. /**
  9112. * Disposes the Shadow map and related Textures and effects.
  9113. */
  9114. dispose(): void;
  9115. }
  9116. /**
  9117. * Default implementation IShadowGenerator.
  9118. * This is the main object responsible of generating shadows in the framework.
  9119. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9120. */
  9121. export class ShadowGenerator implements IShadowGenerator {
  9122. /**
  9123. * Shadow generator mode None: no filtering applied.
  9124. */
  9125. static readonly FILTER_NONE: number;
  9126. /**
  9127. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9128. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9129. */
  9130. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9131. /**
  9132. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9133. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9134. */
  9135. static readonly FILTER_POISSONSAMPLING: number;
  9136. /**
  9137. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9138. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9139. */
  9140. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9141. /**
  9142. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9143. * edge artifacts on steep falloff.
  9144. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9145. */
  9146. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9147. /**
  9148. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9149. * edge artifacts on steep falloff.
  9150. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9151. */
  9152. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9153. /**
  9154. * Shadow generator mode PCF: Percentage Closer Filtering
  9155. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9156. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9157. */
  9158. static readonly FILTER_PCF: number;
  9159. /**
  9160. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9161. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9162. * Contact Hardening
  9163. */
  9164. static readonly FILTER_PCSS: number;
  9165. /**
  9166. * Reserved for PCF and PCSS
  9167. * Highest Quality.
  9168. *
  9169. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9170. *
  9171. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9172. */
  9173. static readonly QUALITY_HIGH: number;
  9174. /**
  9175. * Reserved for PCF and PCSS
  9176. * Good tradeoff for quality/perf cross devices
  9177. *
  9178. * Execute PCF on a 3*3 kernel.
  9179. *
  9180. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9181. */
  9182. static readonly QUALITY_MEDIUM: number;
  9183. /**
  9184. * Reserved for PCF and PCSS
  9185. * The lowest quality but the fastest.
  9186. *
  9187. * Execute PCF on a 1*1 kernel.
  9188. *
  9189. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9190. */
  9191. static readonly QUALITY_LOW: number;
  9192. /** Gets or sets the custom shader name to use */
  9193. customShaderOptions: ICustomShaderOptions;
  9194. /**
  9195. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9196. */
  9197. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9198. /**
  9199. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9200. */
  9201. onAfterShadowMapRenderObservable: Observable<Effect>;
  9202. /**
  9203. * Observable triggered before a mesh is rendered in the shadow map.
  9204. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9205. */
  9206. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9207. /**
  9208. * Observable triggered after a mesh is rendered in the shadow map.
  9209. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9210. */
  9211. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9212. private _bias;
  9213. /**
  9214. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9215. */
  9216. /**
  9217. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9218. */
  9219. bias: number;
  9220. private _normalBias;
  9221. /**
  9222. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9223. */
  9224. /**
  9225. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9226. */
  9227. normalBias: number;
  9228. private _blurBoxOffset;
  9229. /**
  9230. * Gets the blur box offset: offset applied during the blur pass.
  9231. * Only useful if useKernelBlur = false
  9232. */
  9233. /**
  9234. * Sets the blur box offset: offset applied during the blur pass.
  9235. * Only useful if useKernelBlur = false
  9236. */
  9237. blurBoxOffset: number;
  9238. private _blurScale;
  9239. /**
  9240. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9241. * 2 means half of the size.
  9242. */
  9243. /**
  9244. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9245. * 2 means half of the size.
  9246. */
  9247. blurScale: number;
  9248. private _blurKernel;
  9249. /**
  9250. * Gets the blur kernel: kernel size of the blur pass.
  9251. * Only useful if useKernelBlur = true
  9252. */
  9253. /**
  9254. * Sets the blur kernel: kernel size of the blur pass.
  9255. * Only useful if useKernelBlur = true
  9256. */
  9257. blurKernel: number;
  9258. private _useKernelBlur;
  9259. /**
  9260. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9261. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9262. */
  9263. /**
  9264. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9265. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9266. */
  9267. useKernelBlur: boolean;
  9268. private _depthScale;
  9269. /**
  9270. * Gets the depth scale used in ESM mode.
  9271. */
  9272. /**
  9273. * Sets the depth scale used in ESM mode.
  9274. * This can override the scale stored on the light.
  9275. */
  9276. depthScale: number;
  9277. private _filter;
  9278. /**
  9279. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9280. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9281. */
  9282. /**
  9283. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9284. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9285. */
  9286. filter: number;
  9287. /**
  9288. * Gets if the current filter is set to Poisson Sampling.
  9289. */
  9290. /**
  9291. * Sets the current filter to Poisson Sampling.
  9292. */
  9293. usePoissonSampling: boolean;
  9294. /**
  9295. * Gets if the current filter is set to ESM.
  9296. */
  9297. /**
  9298. * Sets the current filter is to ESM.
  9299. */
  9300. useExponentialShadowMap: boolean;
  9301. /**
  9302. * Gets if the current filter is set to filtered ESM.
  9303. */
  9304. /**
  9305. * Gets if the current filter is set to filtered ESM.
  9306. */
  9307. useBlurExponentialShadowMap: boolean;
  9308. /**
  9309. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9310. * exponential to prevent steep falloff artifacts).
  9311. */
  9312. /**
  9313. * Sets the current filter to "close ESM" (using the inverse of the
  9314. * exponential to prevent steep falloff artifacts).
  9315. */
  9316. useCloseExponentialShadowMap: boolean;
  9317. /**
  9318. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9319. * exponential to prevent steep falloff artifacts).
  9320. */
  9321. /**
  9322. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9323. * exponential to prevent steep falloff artifacts).
  9324. */
  9325. useBlurCloseExponentialShadowMap: boolean;
  9326. /**
  9327. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9328. */
  9329. /**
  9330. * Sets the current filter to "PCF" (percentage closer filtering).
  9331. */
  9332. usePercentageCloserFiltering: boolean;
  9333. private _filteringQuality;
  9334. /**
  9335. * Gets the PCF or PCSS Quality.
  9336. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9337. */
  9338. /**
  9339. * Sets the PCF or PCSS Quality.
  9340. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9341. */
  9342. filteringQuality: number;
  9343. /**
  9344. * Gets if the current filter is set to "PCSS" (contact hardening).
  9345. */
  9346. /**
  9347. * Sets the current filter to "PCSS" (contact hardening).
  9348. */
  9349. useContactHardeningShadow: boolean;
  9350. private _contactHardeningLightSizeUVRatio;
  9351. /**
  9352. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9353. * Using a ratio helps keeping shape stability independently of the map size.
  9354. *
  9355. * It does not account for the light projection as it was having too much
  9356. * instability during the light setup or during light position changes.
  9357. *
  9358. * Only valid if useContactHardeningShadow is true.
  9359. */
  9360. /**
  9361. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9362. * Using a ratio helps keeping shape stability independently of the map size.
  9363. *
  9364. * It does not account for the light projection as it was having too much
  9365. * instability during the light setup or during light position changes.
  9366. *
  9367. * Only valid if useContactHardeningShadow is true.
  9368. */
  9369. contactHardeningLightSizeUVRatio: number;
  9370. private _darkness;
  9371. /** Gets or sets the actual darkness of a shadow */
  9372. darkness: number;
  9373. /**
  9374. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9375. * 0 means strongest and 1 would means no shadow.
  9376. * @returns the darkness.
  9377. */
  9378. getDarkness(): number;
  9379. /**
  9380. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9381. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9382. * @returns the shadow generator allowing fluent coding.
  9383. */
  9384. setDarkness(darkness: number): ShadowGenerator;
  9385. private _transparencyShadow;
  9386. /** Gets or sets the ability to have transparent shadow */
  9387. transparencyShadow: boolean;
  9388. /**
  9389. * Sets the ability to have transparent shadow (boolean).
  9390. * @param transparent True if transparent else False
  9391. * @returns the shadow generator allowing fluent coding
  9392. */
  9393. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9394. private _shadowMap;
  9395. private _shadowMap2;
  9396. /**
  9397. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9398. * @returns The render target texture if present otherwise, null
  9399. */
  9400. getShadowMap(): Nullable<RenderTargetTexture>;
  9401. /**
  9402. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9403. * @returns The render target texture if the shadow map is present otherwise, null
  9404. */
  9405. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9406. /**
  9407. * Gets the class name of that object
  9408. * @returns "ShadowGenerator"
  9409. */
  9410. getClassName(): string;
  9411. /**
  9412. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9413. * @param mesh Mesh to add
  9414. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9415. * @returns the Shadow Generator itself
  9416. */
  9417. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9418. /**
  9419. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9420. * @param mesh Mesh to remove
  9421. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9422. * @returns the Shadow Generator itself
  9423. */
  9424. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9425. /**
  9426. * Controls the extent to which the shadows fade out at the edge of the frustum
  9427. * Used only by directionals and spots
  9428. */
  9429. frustumEdgeFalloff: number;
  9430. private _light;
  9431. /**
  9432. * Returns the associated light object.
  9433. * @returns the light generating the shadow
  9434. */
  9435. getLight(): IShadowLight;
  9436. /**
  9437. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9438. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9439. * It might on the other hand introduce peter panning.
  9440. */
  9441. forceBackFacesOnly: boolean;
  9442. private _scene;
  9443. private _lightDirection;
  9444. private _effect;
  9445. private _viewMatrix;
  9446. private _projectionMatrix;
  9447. private _transformMatrix;
  9448. private _cachedPosition;
  9449. private _cachedDirection;
  9450. private _cachedDefines;
  9451. private _currentRenderID;
  9452. private _boxBlurPostprocess;
  9453. private _kernelBlurXPostprocess;
  9454. private _kernelBlurYPostprocess;
  9455. private _blurPostProcesses;
  9456. private _mapSize;
  9457. private _currentFaceIndex;
  9458. private _currentFaceIndexCache;
  9459. private _textureType;
  9460. private _defaultTextureMatrix;
  9461. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  9462. /**
  9463. * Creates a ShadowGenerator object.
  9464. * A ShadowGenerator is the required tool to use the shadows.
  9465. * Each light casting shadows needs to use its own ShadowGenerator.
  9466. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9467. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9468. * @param light The light object generating the shadows.
  9469. * @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.
  9470. */
  9471. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9472. private _initializeGenerator;
  9473. private _initializeShadowMap;
  9474. private _initializeBlurRTTAndPostProcesses;
  9475. private _renderForShadowMap;
  9476. private _renderSubMeshForShadowMap;
  9477. private _applyFilterValues;
  9478. /**
  9479. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9480. * @param onCompiled Callback triggered at the and of the effects compilation
  9481. * @param options Sets of optional options forcing the compilation with different modes
  9482. */
  9483. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9484. useInstances: boolean;
  9485. }>): void;
  9486. /**
  9487. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9488. * @param options Sets of optional options forcing the compilation with different modes
  9489. * @returns A promise that resolves when the compilation completes
  9490. */
  9491. forceCompilationAsync(options?: Partial<{
  9492. useInstances: boolean;
  9493. }>): Promise<void>;
  9494. /**
  9495. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9496. * @param subMesh The submesh we want to render in the shadow map
  9497. * @param useInstances Defines wether will draw in the map using instances
  9498. * @returns true if ready otherwise, false
  9499. */
  9500. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9501. /**
  9502. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9503. * @param defines Defines of the material we want to update
  9504. * @param lightIndex Index of the light in the enabled light list of the material
  9505. */
  9506. prepareDefines(defines: any, lightIndex: number): void;
  9507. /**
  9508. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9509. * defined in the generator but impacting the effect).
  9510. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9511. * @param effect The effect we are binfing the information for
  9512. */
  9513. bindShadowLight(lightIndex: string, effect: Effect): void;
  9514. /**
  9515. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9516. * (eq to shadow prjection matrix * light transform matrix)
  9517. * @returns The transform matrix used to create the shadow map
  9518. */
  9519. getTransformMatrix(): Matrix;
  9520. /**
  9521. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9522. * Cube and 2D textures for instance.
  9523. */
  9524. recreateShadowMap(): void;
  9525. private _disposeBlurPostProcesses;
  9526. private _disposeRTTandPostProcesses;
  9527. /**
  9528. * Disposes the ShadowGenerator.
  9529. * Returns nothing.
  9530. */
  9531. dispose(): void;
  9532. /**
  9533. * Serializes the shadow generator setup to a json object.
  9534. * @returns The serialized JSON object
  9535. */
  9536. serialize(): any;
  9537. /**
  9538. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9539. * @param parsedShadowGenerator The JSON object to parse
  9540. * @param scene The scene to create the shadow map for
  9541. * @returns The parsed shadow generator
  9542. */
  9543. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9544. }
  9545. }
  9546. declare module BABYLON {
  9547. /**
  9548. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9549. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9550. * 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.
  9551. */
  9552. export abstract class Light extends Node {
  9553. /**
  9554. * Falloff Default: light is falling off following the material specification:
  9555. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9556. */
  9557. static readonly FALLOFF_DEFAULT: number;
  9558. /**
  9559. * Falloff Physical: light is falling off following the inverse squared distance law.
  9560. */
  9561. static readonly FALLOFF_PHYSICAL: number;
  9562. /**
  9563. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9564. * to enhance interoperability with other engines.
  9565. */
  9566. static readonly FALLOFF_GLTF: number;
  9567. /**
  9568. * Falloff Standard: light is falling off like in the standard material
  9569. * to enhance interoperability with other materials.
  9570. */
  9571. static readonly FALLOFF_STANDARD: number;
  9572. /**
  9573. * If every light affecting the material is in this lightmapMode,
  9574. * material.lightmapTexture adds or multiplies
  9575. * (depends on material.useLightmapAsShadowmap)
  9576. * after every other light calculations.
  9577. */
  9578. static readonly LIGHTMAP_DEFAULT: number;
  9579. /**
  9580. * material.lightmapTexture as only diffuse lighting from this light
  9581. * adds only specular lighting from this light
  9582. * adds dynamic shadows
  9583. */
  9584. static readonly LIGHTMAP_SPECULAR: number;
  9585. /**
  9586. * material.lightmapTexture as only lighting
  9587. * no light calculation from this light
  9588. * only adds dynamic shadows from this light
  9589. */
  9590. static readonly LIGHTMAP_SHADOWSONLY: number;
  9591. /**
  9592. * Each light type uses the default quantity according to its type:
  9593. * point/spot lights use luminous intensity
  9594. * directional lights use illuminance
  9595. */
  9596. static readonly INTENSITYMODE_AUTOMATIC: number;
  9597. /**
  9598. * lumen (lm)
  9599. */
  9600. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9601. /**
  9602. * candela (lm/sr)
  9603. */
  9604. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9605. /**
  9606. * lux (lm/m^2)
  9607. */
  9608. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9609. /**
  9610. * nit (cd/m^2)
  9611. */
  9612. static readonly INTENSITYMODE_LUMINANCE: number;
  9613. /**
  9614. * Light type const id of the point light.
  9615. */
  9616. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9617. /**
  9618. * Light type const id of the directional light.
  9619. */
  9620. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9621. /**
  9622. * Light type const id of the spot light.
  9623. */
  9624. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9625. /**
  9626. * Light type const id of the hemispheric light.
  9627. */
  9628. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9629. /**
  9630. * Diffuse gives the basic color to an object.
  9631. */
  9632. diffuse: Color3;
  9633. /**
  9634. * Specular produces a highlight color on an object.
  9635. * Note: This is note affecting PBR materials.
  9636. */
  9637. specular: Color3;
  9638. /**
  9639. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9640. * falling off base on range or angle.
  9641. * This can be set to any values in Light.FALLOFF_x.
  9642. *
  9643. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9644. * other types of materials.
  9645. */
  9646. falloffType: number;
  9647. /**
  9648. * Strength of the light.
  9649. * Note: By default it is define in the framework own unit.
  9650. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9651. */
  9652. intensity: number;
  9653. private _range;
  9654. protected _inverseSquaredRange: number;
  9655. /**
  9656. * Defines how far from the source the light is impacting in scene units.
  9657. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9658. */
  9659. /**
  9660. * Defines how far from the source the light is impacting in scene units.
  9661. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9662. */
  9663. range: number;
  9664. /**
  9665. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9666. * of light.
  9667. */
  9668. private _photometricScale;
  9669. private _intensityMode;
  9670. /**
  9671. * Gets the photometric scale used to interpret the intensity.
  9672. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9673. */
  9674. /**
  9675. * Sets the photometric scale used to interpret the intensity.
  9676. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9677. */
  9678. intensityMode: number;
  9679. private _radius;
  9680. /**
  9681. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9682. */
  9683. /**
  9684. * sets the light radius used by PBR Materials to simulate soft area lights.
  9685. */
  9686. radius: number;
  9687. private _renderPriority;
  9688. /**
  9689. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9690. * exceeding the number allowed of the materials.
  9691. */
  9692. renderPriority: number;
  9693. private _shadowEnabled;
  9694. /**
  9695. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9696. * the current shadow generator.
  9697. */
  9698. /**
  9699. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9700. * the current shadow generator.
  9701. */
  9702. shadowEnabled: boolean;
  9703. private _includedOnlyMeshes;
  9704. /**
  9705. * Gets the only meshes impacted by this light.
  9706. */
  9707. /**
  9708. * Sets the only meshes impacted by this light.
  9709. */
  9710. includedOnlyMeshes: AbstractMesh[];
  9711. private _excludedMeshes;
  9712. /**
  9713. * Gets the meshes not impacted by this light.
  9714. */
  9715. /**
  9716. * Sets the meshes not impacted by this light.
  9717. */
  9718. excludedMeshes: AbstractMesh[];
  9719. private _excludeWithLayerMask;
  9720. /**
  9721. * Gets the layer id use to find what meshes are not impacted by the light.
  9722. * Inactive if 0
  9723. */
  9724. /**
  9725. * Sets the layer id use to find what meshes are not impacted by the light.
  9726. * Inactive if 0
  9727. */
  9728. excludeWithLayerMask: number;
  9729. private _includeOnlyWithLayerMask;
  9730. /**
  9731. * Gets the layer id use to find what meshes are impacted by the light.
  9732. * Inactive if 0
  9733. */
  9734. /**
  9735. * Sets the layer id use to find what meshes are impacted by the light.
  9736. * Inactive if 0
  9737. */
  9738. includeOnlyWithLayerMask: number;
  9739. private _lightmapMode;
  9740. /**
  9741. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9742. */
  9743. /**
  9744. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9745. */
  9746. lightmapMode: number;
  9747. /**
  9748. * Shadow generator associted to the light.
  9749. * @hidden Internal use only.
  9750. */ private _shadowGenerator: Nullable<IShadowGenerator>;
  9751. /**
  9752. * @hidden Internal use only.
  9753. */ private _excludedMeshesIds: string[];
  9754. /**
  9755. * @hidden Internal use only.
  9756. */ private _includedOnlyMeshesIds: string[];
  9757. /**
  9758. * The current light unifom buffer.
  9759. * @hidden Internal use only.
  9760. */ private _uniformBuffer: UniformBuffer;
  9761. /**
  9762. * Creates a Light object in the scene.
  9763. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9764. * @param name The firendly name of the light
  9765. * @param scene The scene the light belongs too
  9766. */
  9767. constructor(name: string, scene: Scene);
  9768. protected abstract _buildUniformLayout(): void;
  9769. /**
  9770. * Sets the passed Effect "effect" with the Light information.
  9771. * @param effect The effect to update
  9772. * @param lightIndex The index of the light in the effect to update
  9773. * @returns The light
  9774. */
  9775. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9776. /**
  9777. * Returns the string "Light".
  9778. * @returns the class name
  9779. */
  9780. getClassName(): string;
  9781. /** @hidden */ protected readonly _isLight: boolean;
  9782. /**
  9783. * Converts the light information to a readable string for debug purpose.
  9784. * @param fullDetails Supports for multiple levels of logging within scene loading
  9785. * @returns the human readable light info
  9786. */
  9787. toString(fullDetails?: boolean): string;
  9788. /** @hidden */
  9789. protected _syncParentEnabledState(): void;
  9790. /**
  9791. * Set the enabled state of this node.
  9792. * @param value - the new enabled state
  9793. */
  9794. setEnabled(value: boolean): void;
  9795. /**
  9796. * Returns the Light associated shadow generator if any.
  9797. * @return the associated shadow generator.
  9798. */
  9799. getShadowGenerator(): Nullable<IShadowGenerator>;
  9800. /**
  9801. * Returns a Vector3, the absolute light position in the World.
  9802. * @returns the world space position of the light
  9803. */
  9804. getAbsolutePosition(): Vector3;
  9805. /**
  9806. * Specifies if the light will affect the passed mesh.
  9807. * @param mesh The mesh to test against the light
  9808. * @return true the mesh is affected otherwise, false.
  9809. */
  9810. canAffectMesh(mesh: AbstractMesh): boolean;
  9811. /**
  9812. * Sort function to order lights for rendering.
  9813. * @param a First Light object to compare to second.
  9814. * @param b Second Light object to compare first.
  9815. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9816. */
  9817. static CompareLightsPriority(a: Light, b: Light): number;
  9818. /**
  9819. * Releases resources associated with this node.
  9820. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9821. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9822. */
  9823. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9824. /**
  9825. * Returns the light type ID (integer).
  9826. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9827. */
  9828. getTypeID(): number;
  9829. /**
  9830. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9831. * @returns the scaled intensity in intensity mode unit
  9832. */
  9833. getScaledIntensity(): number;
  9834. /**
  9835. * Returns a new Light object, named "name", from the current one.
  9836. * @param name The name of the cloned light
  9837. * @returns the new created light
  9838. */
  9839. clone(name: string): Nullable<Light>;
  9840. /**
  9841. * Serializes the current light into a Serialization object.
  9842. * @returns the serialized object.
  9843. */
  9844. serialize(): any;
  9845. /**
  9846. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9847. * This new light is named "name" and added to the passed scene.
  9848. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9849. * @param name The friendly name of the light
  9850. * @param scene The scene the new light will belong to
  9851. * @returns the constructor function
  9852. */
  9853. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9854. /**
  9855. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9856. * @param parsedLight The JSON representation of the light
  9857. * @param scene The scene to create the parsed light in
  9858. * @returns the created light after parsing
  9859. */
  9860. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9861. private _hookArrayForExcluded;
  9862. private _hookArrayForIncludedOnly;
  9863. private _resyncMeshes;
  9864. /**
  9865. * Forces the meshes to update their light related information in their rendering used effects
  9866. * @hidden Internal Use Only
  9867. */ private _markMeshesAsLightDirty(): void;
  9868. /**
  9869. * Recomputes the cached photometric scale if needed.
  9870. */
  9871. private _computePhotometricScale;
  9872. /**
  9873. * Returns the Photometric Scale according to the light type and intensity mode.
  9874. */
  9875. private _getPhotometricScale;
  9876. /**
  9877. * Reorder the light in the scene according to their defined priority.
  9878. * @hidden Internal Use Only
  9879. */ private _reorderLightsInScene(): void;
  9880. /**
  9881. * Prepares the list of defines specific to the light type.
  9882. * @param defines the list of defines
  9883. * @param lightIndex defines the index of the light for the effect
  9884. */
  9885. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9886. }
  9887. }
  9888. declare module BABYLON {
  9889. /**
  9890. * Interface used to define Action
  9891. */
  9892. export interface IAction {
  9893. /**
  9894. * Trigger for the action
  9895. */
  9896. trigger: number;
  9897. /** Options of the trigger */
  9898. triggerOptions: any;
  9899. /**
  9900. * Gets the trigger parameters
  9901. * @returns the trigger parameters
  9902. */
  9903. getTriggerParameter(): any;
  9904. /**
  9905. * Internal only - executes current action event
  9906. * @hidden
  9907. */ private _executeCurrent(evt?: ActionEvent): void;
  9908. /**
  9909. * Serialize placeholder for child classes
  9910. * @param parent of child
  9911. * @returns the serialized object
  9912. */
  9913. serialize(parent: any): any;
  9914. /**
  9915. * Internal only
  9916. * @hidden
  9917. */ private _prepare(): void;
  9918. /**
  9919. * Internal only - manager for action
  9920. * @hidden
  9921. */ private _actionManager: AbstractActionManager;
  9922. /**
  9923. * Adds action to chain of actions, may be a DoNothingAction
  9924. * @param action defines the next action to execute
  9925. * @returns The action passed in
  9926. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9927. */
  9928. then(action: IAction): IAction;
  9929. }
  9930. /**
  9931. * The action to be carried out following a trigger
  9932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9933. */
  9934. export class Action implements IAction {
  9935. /** the trigger, with or without parameters, for the action */
  9936. triggerOptions: any;
  9937. /**
  9938. * Trigger for the action
  9939. */
  9940. trigger: number;
  9941. /**
  9942. * Internal only - manager for action
  9943. * @hidden
  9944. */ private _actionManager: ActionManager;
  9945. private _nextActiveAction;
  9946. private _child;
  9947. private _condition?;
  9948. private _triggerParameter;
  9949. /**
  9950. * An event triggered prior to action being executed.
  9951. */
  9952. onBeforeExecuteObservable: Observable<Action>;
  9953. /**
  9954. * Creates a new Action
  9955. * @param triggerOptions the trigger, with or without parameters, for the action
  9956. * @param condition an optional determinant of action
  9957. */
  9958. constructor(
  9959. /** the trigger, with or without parameters, for the action */
  9960. triggerOptions: any, condition?: Condition);
  9961. /**
  9962. * Internal only
  9963. * @hidden
  9964. */ private _prepare(): void;
  9965. /**
  9966. * Gets the trigger parameters
  9967. * @returns the trigger parameters
  9968. */
  9969. getTriggerParameter(): any;
  9970. /**
  9971. * Internal only - executes current action event
  9972. * @hidden
  9973. */ private _executeCurrent(evt?: ActionEvent): void;
  9974. /**
  9975. * Execute placeholder for child classes
  9976. * @param evt optional action event
  9977. */
  9978. execute(evt?: ActionEvent): void;
  9979. /**
  9980. * Skips to next active action
  9981. */
  9982. skipToNextActiveAction(): void;
  9983. /**
  9984. * Adds action to chain of actions, may be a DoNothingAction
  9985. * @param action defines the next action to execute
  9986. * @returns The action passed in
  9987. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9988. */
  9989. then(action: Action): Action;
  9990. /**
  9991. * Internal only
  9992. * @hidden
  9993. */ private _getProperty(propertyPath: string): string;
  9994. /**
  9995. * Internal only
  9996. * @hidden
  9997. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  9998. /**
  9999. * Serialize placeholder for child classes
  10000. * @param parent of child
  10001. * @returns the serialized object
  10002. */
  10003. serialize(parent: any): any;
  10004. /**
  10005. * Internal only called by serialize
  10006. * @hidden
  10007. */
  10008. protected _serialize(serializedAction: any, parent?: any): any;
  10009. /**
  10010. * Internal only
  10011. * @hidden
  10012. */ private static _SerializeValueAsString: (value: any) => string;
  10013. /**
  10014. * Internal only
  10015. * @hidden
  10016. */ private static _GetTargetProperty: (target: Node | Scene) => {
  10017. name: string;
  10018. targetType: string;
  10019. value: string;
  10020. };
  10021. }
  10022. }
  10023. declare module BABYLON {
  10024. /**
  10025. * A Condition applied to an Action
  10026. */
  10027. export class Condition {
  10028. /**
  10029. * Internal only - manager for action
  10030. * @hidden
  10031. */ private _actionManager: ActionManager;
  10032. /**
  10033. * Internal only
  10034. * @hidden
  10035. */ private _evaluationId: number;
  10036. /**
  10037. * Internal only
  10038. * @hidden
  10039. */ private _currentResult: boolean;
  10040. /**
  10041. * Creates a new Condition
  10042. * @param actionManager the manager of the action the condition is applied to
  10043. */
  10044. constructor(actionManager: ActionManager);
  10045. /**
  10046. * Check if the current condition is valid
  10047. * @returns a boolean
  10048. */
  10049. isValid(): boolean;
  10050. /**
  10051. * Internal only
  10052. * @hidden
  10053. */ private _getProperty(propertyPath: string): string;
  10054. /**
  10055. * Internal only
  10056. * @hidden
  10057. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10058. /**
  10059. * Serialize placeholder for child classes
  10060. * @returns the serialized object
  10061. */
  10062. serialize(): any;
  10063. /**
  10064. * Internal only
  10065. * @hidden
  10066. */
  10067. protected _serialize(serializedCondition: any): any;
  10068. }
  10069. /**
  10070. * Defines specific conditional operators as extensions of Condition
  10071. */
  10072. export class ValueCondition extends Condition {
  10073. /** path to specify the property of the target the conditional operator uses */
  10074. propertyPath: string;
  10075. /** the value compared by the conditional operator against the current value of the property */
  10076. value: any;
  10077. /** the conditional operator, default ValueCondition.IsEqual */
  10078. operator: number;
  10079. /**
  10080. * Internal only
  10081. * @hidden
  10082. */
  10083. private static _IsEqual;
  10084. /**
  10085. * Internal only
  10086. * @hidden
  10087. */
  10088. private static _IsDifferent;
  10089. /**
  10090. * Internal only
  10091. * @hidden
  10092. */
  10093. private static _IsGreater;
  10094. /**
  10095. * Internal only
  10096. * @hidden
  10097. */
  10098. private static _IsLesser;
  10099. /**
  10100. * returns the number for IsEqual
  10101. */
  10102. static readonly IsEqual: number;
  10103. /**
  10104. * Returns the number for IsDifferent
  10105. */
  10106. static readonly IsDifferent: number;
  10107. /**
  10108. * Returns the number for IsGreater
  10109. */
  10110. static readonly IsGreater: number;
  10111. /**
  10112. * Returns the number for IsLesser
  10113. */
  10114. static readonly IsLesser: number;
  10115. /**
  10116. * Internal only The action manager for the condition
  10117. * @hidden
  10118. */ private _actionManager: ActionManager;
  10119. /**
  10120. * Internal only
  10121. * @hidden
  10122. */
  10123. private _target;
  10124. /**
  10125. * Internal only
  10126. * @hidden
  10127. */
  10128. private _effectiveTarget;
  10129. /**
  10130. * Internal only
  10131. * @hidden
  10132. */
  10133. private _property;
  10134. /**
  10135. * Creates a new ValueCondition
  10136. * @param actionManager manager for the action the condition applies to
  10137. * @param target for the action
  10138. * @param propertyPath path to specify the property of the target the conditional operator uses
  10139. * @param value the value compared by the conditional operator against the current value of the property
  10140. * @param operator the conditional operator, default ValueCondition.IsEqual
  10141. */
  10142. constructor(actionManager: ActionManager, target: any,
  10143. /** path to specify the property of the target the conditional operator uses */
  10144. propertyPath: string,
  10145. /** the value compared by the conditional operator against the current value of the property */
  10146. value: any,
  10147. /** the conditional operator, default ValueCondition.IsEqual */
  10148. operator?: number);
  10149. /**
  10150. * Compares the given value with the property value for the specified conditional operator
  10151. * @returns the result of the comparison
  10152. */
  10153. isValid(): boolean;
  10154. /**
  10155. * Serialize the ValueCondition into a JSON compatible object
  10156. * @returns serialization object
  10157. */
  10158. serialize(): any;
  10159. /**
  10160. * Gets the name of the conditional operator for the ValueCondition
  10161. * @param operator the conditional operator
  10162. * @returns the name
  10163. */
  10164. static GetOperatorName(operator: number): string;
  10165. }
  10166. /**
  10167. * Defines a predicate condition as an extension of Condition
  10168. */
  10169. export class PredicateCondition extends Condition {
  10170. /** defines the predicate function used to validate the condition */
  10171. predicate: () => boolean;
  10172. /**
  10173. * Internal only - manager for action
  10174. * @hidden
  10175. */ private _actionManager: ActionManager;
  10176. /**
  10177. * Creates a new PredicateCondition
  10178. * @param actionManager manager for the action the condition applies to
  10179. * @param predicate defines the predicate function used to validate the condition
  10180. */
  10181. constructor(actionManager: ActionManager,
  10182. /** defines the predicate function used to validate the condition */
  10183. predicate: () => boolean);
  10184. /**
  10185. * @returns the validity of the predicate condition
  10186. */
  10187. isValid(): boolean;
  10188. }
  10189. /**
  10190. * Defines a state condition as an extension of Condition
  10191. */
  10192. export class StateCondition extends Condition {
  10193. /** Value to compare with target state */
  10194. value: string;
  10195. /**
  10196. * Internal only - manager for action
  10197. * @hidden
  10198. */ private _actionManager: ActionManager;
  10199. /**
  10200. * Internal only
  10201. * @hidden
  10202. */
  10203. private _target;
  10204. /**
  10205. * Creates a new StateCondition
  10206. * @param actionManager manager for the action the condition applies to
  10207. * @param target of the condition
  10208. * @param value to compare with target state
  10209. */
  10210. constructor(actionManager: ActionManager, target: any,
  10211. /** Value to compare with target state */
  10212. value: string);
  10213. /**
  10214. * Gets a boolean indicating if the current condition is met
  10215. * @returns the validity of the state
  10216. */
  10217. isValid(): boolean;
  10218. /**
  10219. * Serialize the StateCondition into a JSON compatible object
  10220. * @returns serialization object
  10221. */
  10222. serialize(): any;
  10223. }
  10224. }
  10225. declare module BABYLON {
  10226. /**
  10227. * This defines an action responsible to toggle a boolean once triggered.
  10228. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10229. */
  10230. export class SwitchBooleanAction extends Action {
  10231. /**
  10232. * The path to the boolean property in the target object
  10233. */
  10234. propertyPath: string;
  10235. private _target;
  10236. private _effectiveTarget;
  10237. private _property;
  10238. /**
  10239. * Instantiate the action
  10240. * @param triggerOptions defines the trigger options
  10241. * @param target defines the object containing the boolean
  10242. * @param propertyPath defines the path to the boolean property in the target object
  10243. * @param condition defines the trigger related conditions
  10244. */
  10245. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10246. /** @hidden */ private _prepare(): void;
  10247. /**
  10248. * Execute the action toggle the boolean value.
  10249. */
  10250. execute(): void;
  10251. /**
  10252. * Serializes the actions and its related information.
  10253. * @param parent defines the object to serialize in
  10254. * @returns the serialized object
  10255. */
  10256. serialize(parent: any): any;
  10257. }
  10258. /**
  10259. * This defines an action responsible to set a the state field of the target
  10260. * to a desired value once triggered.
  10261. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10262. */
  10263. export class SetStateAction extends Action {
  10264. /**
  10265. * The value to store in the state field.
  10266. */
  10267. value: string;
  10268. private _target;
  10269. /**
  10270. * Instantiate the action
  10271. * @param triggerOptions defines the trigger options
  10272. * @param target defines the object containing the state property
  10273. * @param value defines the value to store in the state field
  10274. * @param condition defines the trigger related conditions
  10275. */
  10276. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10277. /**
  10278. * Execute the action and store the value on the target state property.
  10279. */
  10280. execute(): void;
  10281. /**
  10282. * Serializes the actions and its related information.
  10283. * @param parent defines the object to serialize in
  10284. * @returns the serialized object
  10285. */
  10286. serialize(parent: any): any;
  10287. }
  10288. /**
  10289. * This defines an action responsible to set a property of the target
  10290. * to a desired value once triggered.
  10291. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10292. */
  10293. export class SetValueAction extends Action {
  10294. /**
  10295. * The path of the property to set in the target.
  10296. */
  10297. propertyPath: string;
  10298. /**
  10299. * The value to set in the property
  10300. */
  10301. value: any;
  10302. private _target;
  10303. private _effectiveTarget;
  10304. private _property;
  10305. /**
  10306. * Instantiate the action
  10307. * @param triggerOptions defines the trigger options
  10308. * @param target defines the object containing the property
  10309. * @param propertyPath defines the path of the property to set in the target
  10310. * @param value defines the value to set in the property
  10311. * @param condition defines the trigger related conditions
  10312. */
  10313. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10314. /** @hidden */ private _prepare(): void;
  10315. /**
  10316. * Execute the action and set the targetted property to the desired value.
  10317. */
  10318. execute(): void;
  10319. /**
  10320. * Serializes the actions and its related information.
  10321. * @param parent defines the object to serialize in
  10322. * @returns the serialized object
  10323. */
  10324. serialize(parent: any): any;
  10325. }
  10326. /**
  10327. * This defines an action responsible to increment the target value
  10328. * to a desired value once triggered.
  10329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10330. */
  10331. export class IncrementValueAction extends Action {
  10332. /**
  10333. * The path of the property to increment in the target.
  10334. */
  10335. propertyPath: string;
  10336. /**
  10337. * The value we should increment the property by.
  10338. */
  10339. value: any;
  10340. private _target;
  10341. private _effectiveTarget;
  10342. private _property;
  10343. /**
  10344. * Instantiate the action
  10345. * @param triggerOptions defines the trigger options
  10346. * @param target defines the object containing the property
  10347. * @param propertyPath defines the path of the property to increment in the target
  10348. * @param value defines the value value we should increment the property by
  10349. * @param condition defines the trigger related conditions
  10350. */
  10351. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10352. /** @hidden */ private _prepare(): void;
  10353. /**
  10354. * Execute the action and increment the target of the value amount.
  10355. */
  10356. execute(): void;
  10357. /**
  10358. * Serializes the actions and its related information.
  10359. * @param parent defines the object to serialize in
  10360. * @returns the serialized object
  10361. */
  10362. serialize(parent: any): any;
  10363. }
  10364. /**
  10365. * This defines an action responsible to start an animation once triggered.
  10366. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10367. */
  10368. export class PlayAnimationAction extends Action {
  10369. /**
  10370. * Where the animation should start (animation frame)
  10371. */
  10372. from: number;
  10373. /**
  10374. * Where the animation should stop (animation frame)
  10375. */
  10376. to: number;
  10377. /**
  10378. * Define if the animation should loop or stop after the first play.
  10379. */
  10380. loop?: boolean;
  10381. private _target;
  10382. /**
  10383. * Instantiate the action
  10384. * @param triggerOptions defines the trigger options
  10385. * @param target defines the target animation or animation name
  10386. * @param from defines from where the animation should start (animation frame)
  10387. * @param end defines where the animation should stop (animation frame)
  10388. * @param loop defines if the animation should loop or stop after the first play
  10389. * @param condition defines the trigger related conditions
  10390. */
  10391. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10392. /** @hidden */ private _prepare(): void;
  10393. /**
  10394. * Execute the action and play the animation.
  10395. */
  10396. execute(): void;
  10397. /**
  10398. * Serializes the actions and its related information.
  10399. * @param parent defines the object to serialize in
  10400. * @returns the serialized object
  10401. */
  10402. serialize(parent: any): any;
  10403. }
  10404. /**
  10405. * This defines an action responsible to stop an animation once triggered.
  10406. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10407. */
  10408. export class StopAnimationAction extends Action {
  10409. private _target;
  10410. /**
  10411. * Instantiate the action
  10412. * @param triggerOptions defines the trigger options
  10413. * @param target defines the target animation or animation name
  10414. * @param condition defines the trigger related conditions
  10415. */
  10416. constructor(triggerOptions: any, target: any, condition?: Condition);
  10417. /** @hidden */ private _prepare(): void;
  10418. /**
  10419. * Execute the action and stop the animation.
  10420. */
  10421. execute(): void;
  10422. /**
  10423. * Serializes the actions and its related information.
  10424. * @param parent defines the object to serialize in
  10425. * @returns the serialized object
  10426. */
  10427. serialize(parent: any): any;
  10428. }
  10429. /**
  10430. * This defines an action responsible that does nothing once triggered.
  10431. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10432. */
  10433. export class DoNothingAction extends Action {
  10434. /**
  10435. * Instantiate the action
  10436. * @param triggerOptions defines the trigger options
  10437. * @param condition defines the trigger related conditions
  10438. */
  10439. constructor(triggerOptions?: any, condition?: Condition);
  10440. /**
  10441. * Execute the action and do nothing.
  10442. */
  10443. execute(): void;
  10444. /**
  10445. * Serializes the actions and its related information.
  10446. * @param parent defines the object to serialize in
  10447. * @returns the serialized object
  10448. */
  10449. serialize(parent: any): any;
  10450. }
  10451. /**
  10452. * This defines an action responsible to trigger several actions once triggered.
  10453. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10454. */
  10455. export class CombineAction extends Action {
  10456. /**
  10457. * The list of aggregated animations to run.
  10458. */
  10459. children: Action[];
  10460. /**
  10461. * Instantiate the action
  10462. * @param triggerOptions defines the trigger options
  10463. * @param children defines the list of aggregated animations to run
  10464. * @param condition defines the trigger related conditions
  10465. */
  10466. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10467. /** @hidden */ private _prepare(): void;
  10468. /**
  10469. * Execute the action and executes all the aggregated actions.
  10470. */
  10471. execute(evt: ActionEvent): void;
  10472. /**
  10473. * Serializes the actions and its related information.
  10474. * @param parent defines the object to serialize in
  10475. * @returns the serialized object
  10476. */
  10477. serialize(parent: any): any;
  10478. }
  10479. /**
  10480. * This defines an action responsible to run code (external event) once triggered.
  10481. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10482. */
  10483. export class ExecuteCodeAction extends Action {
  10484. /**
  10485. * The callback function to run.
  10486. */
  10487. func: (evt: ActionEvent) => void;
  10488. /**
  10489. * Instantiate the action
  10490. * @param triggerOptions defines the trigger options
  10491. * @param func defines the callback function to run
  10492. * @param condition defines the trigger related conditions
  10493. */
  10494. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10495. /**
  10496. * Execute the action and run the attached code.
  10497. */
  10498. execute(evt: ActionEvent): void;
  10499. }
  10500. /**
  10501. * This defines an action responsible to set the parent property of the target once triggered.
  10502. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10503. */
  10504. export class SetParentAction extends Action {
  10505. private _parent;
  10506. private _target;
  10507. /**
  10508. * Instantiate the action
  10509. * @param triggerOptions defines the trigger options
  10510. * @param target defines the target containing the parent property
  10511. * @param parent defines from where the animation should start (animation frame)
  10512. * @param condition defines the trigger related conditions
  10513. */
  10514. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10515. /** @hidden */ private _prepare(): void;
  10516. /**
  10517. * Execute the action and set the parent property.
  10518. */
  10519. execute(): void;
  10520. /**
  10521. * Serializes the actions and its related information.
  10522. * @param parent defines the object to serialize in
  10523. * @returns the serialized object
  10524. */
  10525. serialize(parent: any): any;
  10526. }
  10527. }
  10528. declare module BABYLON {
  10529. /**
  10530. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10531. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10532. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10533. */
  10534. export class ActionManager extends AbstractActionManager {
  10535. /**
  10536. * Nothing
  10537. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10538. */
  10539. static readonly NothingTrigger: number;
  10540. /**
  10541. * On pick
  10542. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10543. */
  10544. static readonly OnPickTrigger: number;
  10545. /**
  10546. * On left pick
  10547. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10548. */
  10549. static readonly OnLeftPickTrigger: number;
  10550. /**
  10551. * On right pick
  10552. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10553. */
  10554. static readonly OnRightPickTrigger: number;
  10555. /**
  10556. * On center pick
  10557. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10558. */
  10559. static readonly OnCenterPickTrigger: number;
  10560. /**
  10561. * On pick down
  10562. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10563. */
  10564. static readonly OnPickDownTrigger: number;
  10565. /**
  10566. * On double pick
  10567. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10568. */
  10569. static readonly OnDoublePickTrigger: number;
  10570. /**
  10571. * On pick up
  10572. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10573. */
  10574. static readonly OnPickUpTrigger: number;
  10575. /**
  10576. * On pick out.
  10577. * This trigger will only be raised if you also declared a OnPickDown
  10578. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10579. */
  10580. static readonly OnPickOutTrigger: number;
  10581. /**
  10582. * On long press
  10583. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10584. */
  10585. static readonly OnLongPressTrigger: number;
  10586. /**
  10587. * On pointer over
  10588. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10589. */
  10590. static readonly OnPointerOverTrigger: number;
  10591. /**
  10592. * On pointer out
  10593. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10594. */
  10595. static readonly OnPointerOutTrigger: number;
  10596. /**
  10597. * On every frame
  10598. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10599. */
  10600. static readonly OnEveryFrameTrigger: number;
  10601. /**
  10602. * On intersection enter
  10603. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10604. */
  10605. static readonly OnIntersectionEnterTrigger: number;
  10606. /**
  10607. * On intersection exit
  10608. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10609. */
  10610. static readonly OnIntersectionExitTrigger: number;
  10611. /**
  10612. * On key down
  10613. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10614. */
  10615. static readonly OnKeyDownTrigger: number;
  10616. /**
  10617. * On key up
  10618. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10619. */
  10620. static readonly OnKeyUpTrigger: number;
  10621. private _scene;
  10622. /**
  10623. * Creates a new action manager
  10624. * @param scene defines the hosting scene
  10625. */
  10626. constructor(scene: Scene);
  10627. /**
  10628. * Releases all associated resources
  10629. */
  10630. dispose(): void;
  10631. /**
  10632. * Gets hosting scene
  10633. * @returns the hosting scene
  10634. */
  10635. getScene(): Scene;
  10636. /**
  10637. * Does this action manager handles actions of any of the given triggers
  10638. * @param triggers defines the triggers to be tested
  10639. * @return a boolean indicating whether one (or more) of the triggers is handled
  10640. */
  10641. hasSpecificTriggers(triggers: number[]): boolean;
  10642. /**
  10643. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10644. * speed.
  10645. * @param triggerA defines the trigger to be tested
  10646. * @param triggerB defines the trigger to be tested
  10647. * @return a boolean indicating whether one (or more) of the triggers is handled
  10648. */
  10649. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10650. /**
  10651. * Does this action manager handles actions of a given trigger
  10652. * @param trigger defines the trigger to be tested
  10653. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10654. * @return whether the trigger is handled
  10655. */
  10656. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10657. /**
  10658. * Does this action manager has pointer triggers
  10659. */
  10660. readonly hasPointerTriggers: boolean;
  10661. /**
  10662. * Does this action manager has pick triggers
  10663. */
  10664. readonly hasPickTriggers: boolean;
  10665. /**
  10666. * Registers an action to this action manager
  10667. * @param action defines the action to be registered
  10668. * @return the action amended (prepared) after registration
  10669. */
  10670. registerAction(action: IAction): Nullable<IAction>;
  10671. /**
  10672. * Unregisters an action to this action manager
  10673. * @param action defines the action to be unregistered
  10674. * @return a boolean indicating whether the action has been unregistered
  10675. */
  10676. unregisterAction(action: IAction): Boolean;
  10677. /**
  10678. * Process a specific trigger
  10679. * @param trigger defines the trigger to process
  10680. * @param evt defines the event details to be processed
  10681. */
  10682. processTrigger(trigger: number, evt?: IActionEvent): void;
  10683. /** @hidden */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10684. /** @hidden */ private _getProperty(propertyPath: string): string;
  10685. /**
  10686. * Serialize this manager to a JSON object
  10687. * @param name defines the property name to store this manager
  10688. * @returns a JSON representation of this manager
  10689. */
  10690. serialize(name: string): any;
  10691. /**
  10692. * Creates a new ActionManager from a JSON data
  10693. * @param parsedActions defines the JSON data to read from
  10694. * @param object defines the hosting mesh
  10695. * @param scene defines the hosting scene
  10696. */
  10697. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10698. /**
  10699. * Get a trigger name by index
  10700. * @param trigger defines the trigger index
  10701. * @returns a trigger name
  10702. */
  10703. static GetTriggerName(trigger: number): string;
  10704. }
  10705. }
  10706. declare module BABYLON {
  10707. /**
  10708. * Class representing a ray with position and direction
  10709. */
  10710. export class Ray {
  10711. /** origin point */
  10712. origin: Vector3;
  10713. /** direction */
  10714. direction: Vector3;
  10715. /** length of the ray */
  10716. length: number;
  10717. private static readonly TmpVector3;
  10718. private _tmpRay;
  10719. /**
  10720. * Creates a new ray
  10721. * @param origin origin point
  10722. * @param direction direction
  10723. * @param length length of the ray
  10724. */
  10725. constructor(
  10726. /** origin point */
  10727. origin: Vector3,
  10728. /** direction */
  10729. direction: Vector3,
  10730. /** length of the ray */
  10731. length?: number);
  10732. /**
  10733. * Checks if the ray intersects a box
  10734. * @param minimum bound of the box
  10735. * @param maximum bound of the box
  10736. * @param intersectionTreshold extra extend to be added to the box in all direction
  10737. * @returns if the box was hit
  10738. */
  10739. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10740. /**
  10741. * Checks if the ray intersects a box
  10742. * @param box the bounding box to check
  10743. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10744. * @returns if the box was hit
  10745. */
  10746. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10747. /**
  10748. * If the ray hits a sphere
  10749. * @param sphere the bounding sphere to check
  10750. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10751. * @returns true if it hits the sphere
  10752. */
  10753. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10754. /**
  10755. * If the ray hits a triange
  10756. * @param vertex0 triangle vertex
  10757. * @param vertex1 triangle vertex
  10758. * @param vertex2 triangle vertex
  10759. * @returns intersection information if hit
  10760. */
  10761. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10762. /**
  10763. * Checks if ray intersects a plane
  10764. * @param plane the plane to check
  10765. * @returns the distance away it was hit
  10766. */
  10767. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10768. /**
  10769. * Calculate the intercept of a ray on a given axis
  10770. * @param axis to check 'x' | 'y' | 'z'
  10771. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10772. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10773. */
  10774. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10775. /**
  10776. * Checks if ray intersects a mesh
  10777. * @param mesh the mesh to check
  10778. * @param fastCheck if only the bounding box should checked
  10779. * @returns picking info of the intersecton
  10780. */
  10781. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10782. /**
  10783. * Checks if ray intersects a mesh
  10784. * @param meshes the meshes to check
  10785. * @param fastCheck if only the bounding box should checked
  10786. * @param results array to store result in
  10787. * @returns Array of picking infos
  10788. */
  10789. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10790. private _comparePickingInfo;
  10791. private static smallnum;
  10792. private static rayl;
  10793. /**
  10794. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10795. * @param sega the first point of the segment to test the intersection against
  10796. * @param segb the second point of the segment to test the intersection against
  10797. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10798. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10799. */
  10800. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10801. /**
  10802. * Update the ray from viewport position
  10803. * @param x position
  10804. * @param y y position
  10805. * @param viewportWidth viewport width
  10806. * @param viewportHeight viewport height
  10807. * @param world world matrix
  10808. * @param view view matrix
  10809. * @param projection projection matrix
  10810. * @returns this ray updated
  10811. */
  10812. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10813. /**
  10814. * Creates a ray with origin and direction of 0,0,0
  10815. * @returns the new ray
  10816. */
  10817. static Zero(): Ray;
  10818. /**
  10819. * Creates a new ray from screen space and viewport
  10820. * @param x position
  10821. * @param y y position
  10822. * @param viewportWidth viewport width
  10823. * @param viewportHeight viewport height
  10824. * @param world world matrix
  10825. * @param view view matrix
  10826. * @param projection projection matrix
  10827. * @returns new ray
  10828. */
  10829. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10830. /**
  10831. * 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
  10832. * transformed to the given world matrix.
  10833. * @param origin The origin point
  10834. * @param end The end point
  10835. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10836. * @returns the new ray
  10837. */
  10838. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10839. /**
  10840. * Transforms a ray by a matrix
  10841. * @param ray ray to transform
  10842. * @param matrix matrix to apply
  10843. * @returns the resulting new ray
  10844. */
  10845. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10846. /**
  10847. * Transforms a ray by a matrix
  10848. * @param ray ray to transform
  10849. * @param matrix matrix to apply
  10850. * @param result ray to store result in
  10851. */
  10852. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10853. /**
  10854. * Unproject a ray from screen space to object space
  10855. * @param sourceX defines the screen space x coordinate to use
  10856. * @param sourceY defines the screen space y coordinate to use
  10857. * @param viewportWidth defines the current width of the viewport
  10858. * @param viewportHeight defines the current height of the viewport
  10859. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10860. * @param view defines the view matrix to use
  10861. * @param projection defines the projection matrix to use
  10862. */
  10863. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10864. }
  10865. /**
  10866. * Type used to define predicate used to select faces when a mesh intersection is detected
  10867. */
  10868. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10869. interface Scene {
  10870. /** @hidden */ private _tempPickingRay: Nullable<Ray>;
  10871. /** @hidden */ private _cachedRayForTransform: Ray;
  10872. /** @hidden */ private _pickWithRayInverseMatrix: Matrix;
  10873. /** @hidden */ private _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10874. /** @hidden */ private _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10875. }
  10876. }
  10877. declare module BABYLON {
  10878. /**
  10879. * Groups all the scene component constants in one place to ease maintenance.
  10880. * @hidden
  10881. */
  10882. export class SceneComponentConstants {
  10883. static readonly NAME_EFFECTLAYER: string;
  10884. static readonly NAME_LAYER: string;
  10885. static readonly NAME_LENSFLARESYSTEM: string;
  10886. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10887. static readonly NAME_PARTICLESYSTEM: string;
  10888. static readonly NAME_GAMEPAD: string;
  10889. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10890. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10891. static readonly NAME_DEPTHRENDERER: string;
  10892. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10893. static readonly NAME_SPRITE: string;
  10894. static readonly NAME_OUTLINERENDERER: string;
  10895. static readonly NAME_PROCEDURALTEXTURE: string;
  10896. static readonly NAME_SHADOWGENERATOR: string;
  10897. static readonly NAME_OCTREE: string;
  10898. static readonly NAME_PHYSICSENGINE: string;
  10899. static readonly NAME_AUDIO: string;
  10900. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10901. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10902. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10903. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10904. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10905. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10906. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10907. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10908. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10909. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10910. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10911. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10912. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10913. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10914. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10915. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10916. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10917. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10918. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10919. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10920. static readonly STEP_AFTERRENDER_AUDIO: number;
  10921. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10922. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10923. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10924. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10925. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10926. static readonly STEP_POINTERMOVE_SPRITE: number;
  10927. static readonly STEP_POINTERDOWN_SPRITE: number;
  10928. static readonly STEP_POINTERUP_SPRITE: number;
  10929. }
  10930. /**
  10931. * This represents a scene component.
  10932. *
  10933. * This is used to decouple the dependency the scene is having on the different workloads like
  10934. * layers, post processes...
  10935. */
  10936. export interface ISceneComponent {
  10937. /**
  10938. * The name of the component. Each component must have a unique name.
  10939. */
  10940. name: string;
  10941. /**
  10942. * The scene the component belongs to.
  10943. */
  10944. scene: Scene;
  10945. /**
  10946. * Register the component to one instance of a scene.
  10947. */
  10948. register(): void;
  10949. /**
  10950. * Rebuilds the elements related to this component in case of
  10951. * context lost for instance.
  10952. */
  10953. rebuild(): void;
  10954. /**
  10955. * Disposes the component and the associated ressources.
  10956. */
  10957. dispose(): void;
  10958. }
  10959. /**
  10960. * This represents a SERIALIZABLE scene component.
  10961. *
  10962. * This extends Scene Component to add Serialization methods on top.
  10963. */
  10964. export interface ISceneSerializableComponent extends ISceneComponent {
  10965. /**
  10966. * Adds all the elements from the container to the scene
  10967. * @param container the container holding the elements
  10968. */
  10969. addFromContainer(container: AbstractScene): void;
  10970. /**
  10971. * Removes all the elements in the container from the scene
  10972. * @param container contains the elements to remove
  10973. * @param dispose if the removed element should be disposed (default: false)
  10974. */
  10975. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10976. /**
  10977. * Serializes the component data to the specified json object
  10978. * @param serializationObject The object to serialize to
  10979. */
  10980. serialize(serializationObject: any): void;
  10981. }
  10982. /**
  10983. * Strong typing of a Mesh related stage step action
  10984. */
  10985. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10986. /**
  10987. * Strong typing of a Evaluate Sub Mesh related stage step action
  10988. */
  10989. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10990. /**
  10991. * Strong typing of a Active Mesh related stage step action
  10992. */
  10993. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10994. /**
  10995. * Strong typing of a Camera related stage step action
  10996. */
  10997. export type CameraStageAction = (camera: Camera) => void;
  10998. /**
  10999. * Strong typing of a Camera Frame buffer related stage step action
  11000. */
  11001. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11002. /**
  11003. * Strong typing of a Render Target related stage step action
  11004. */
  11005. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11006. /**
  11007. * Strong typing of a RenderingGroup related stage step action
  11008. */
  11009. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11010. /**
  11011. * Strong typing of a Mesh Render related stage step action
  11012. */
  11013. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11014. /**
  11015. * Strong typing of a simple stage step action
  11016. */
  11017. export type SimpleStageAction = () => void;
  11018. /**
  11019. * Strong typing of a render target action.
  11020. */
  11021. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11022. /**
  11023. * Strong typing of a pointer move action.
  11024. */
  11025. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11026. /**
  11027. * Strong typing of a pointer up/down action.
  11028. */
  11029. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11030. /**
  11031. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11032. * @hidden
  11033. */
  11034. export class Stage<T extends Function> extends Array<{
  11035. index: number;
  11036. component: ISceneComponent;
  11037. action: T;
  11038. }> {
  11039. /**
  11040. * Hide ctor from the rest of the world.
  11041. * @param items The items to add.
  11042. */
  11043. private constructor();
  11044. /**
  11045. * Creates a new Stage.
  11046. * @returns A new instance of a Stage
  11047. */
  11048. static Create<T extends Function>(): Stage<T>;
  11049. /**
  11050. * Registers a step in an ordered way in the targeted stage.
  11051. * @param index Defines the position to register the step in
  11052. * @param component Defines the component attached to the step
  11053. * @param action Defines the action to launch during the step
  11054. */
  11055. registerStep(index: number, component: ISceneComponent, action: T): void;
  11056. /**
  11057. * Clears all the steps from the stage.
  11058. */
  11059. clear(): void;
  11060. }
  11061. }
  11062. declare module BABYLON {
  11063. interface Scene {
  11064. /** @hidden */ private _pointerOverSprite: Nullable<Sprite>;
  11065. /** @hidden */ private _pickedDownSprite: Nullable<Sprite>;
  11066. /** @hidden */ private _tempSpritePickingRay: Nullable<Ray>;
  11067. /**
  11068. * All of the sprite managers added to this scene
  11069. * @see http://doc.babylonjs.com/babylon101/sprites
  11070. */
  11071. spriteManagers: Array<ISpriteManager>;
  11072. /**
  11073. * An event triggered when sprites rendering is about to start
  11074. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11075. */
  11076. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11077. /**
  11078. * An event triggered when sprites rendering is done
  11079. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11080. */
  11081. onAfterSpritesRenderingObservable: Observable<Scene>;
  11082. /** @hidden */ private _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11083. /** Launch a ray to try to pick a sprite in the scene
  11084. * @param x position on screen
  11085. * @param y position on screen
  11086. * @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
  11087. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11088. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11089. * @returns a PickingInfo
  11090. */
  11091. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11092. /** Use the given ray to pick a sprite in the scene
  11093. * @param ray The ray (in world space) to use to pick meshes
  11094. * @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
  11095. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11096. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11097. * @returns a PickingInfo
  11098. */
  11099. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11100. /**
  11101. * Force the sprite under the pointer
  11102. * @param sprite defines the sprite to use
  11103. */
  11104. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11105. /**
  11106. * Gets the sprite under the pointer
  11107. * @returns a Sprite or null if no sprite is under the pointer
  11108. */
  11109. getPointerOverSprite(): Nullable<Sprite>;
  11110. }
  11111. /**
  11112. * Defines the sprite scene component responsible to manage sprites
  11113. * in a given scene.
  11114. */
  11115. export class SpriteSceneComponent implements ISceneComponent {
  11116. /**
  11117. * The component name helpfull to identify the component in the list of scene components.
  11118. */
  11119. readonly name: string;
  11120. /**
  11121. * The scene the component belongs to.
  11122. */
  11123. scene: Scene;
  11124. /** @hidden */
  11125. private _spritePredicate;
  11126. /**
  11127. * Creates a new instance of the component for the given scene
  11128. * @param scene Defines the scene to register the component in
  11129. */
  11130. constructor(scene: Scene);
  11131. /**
  11132. * Registers the component in a given scene
  11133. */
  11134. register(): void;
  11135. /**
  11136. * Rebuilds the elements related to this component in case of
  11137. * context lost for instance.
  11138. */
  11139. rebuild(): void;
  11140. /**
  11141. * Disposes the component and the associated ressources.
  11142. */
  11143. dispose(): void;
  11144. private _pickSpriteButKeepRay;
  11145. private _pointerMove;
  11146. private _pointerDown;
  11147. private _pointerUp;
  11148. }
  11149. }
  11150. declare module BABYLON {
  11151. /** @hidden */
  11152. export var fogFragmentDeclaration: {
  11153. name: string;
  11154. shader: string;
  11155. };
  11156. }
  11157. declare module BABYLON {
  11158. /** @hidden */
  11159. export var fogFragment: {
  11160. name: string;
  11161. shader: string;
  11162. };
  11163. }
  11164. declare module BABYLON {
  11165. /** @hidden */
  11166. export var spritesPixelShader: {
  11167. name: string;
  11168. shader: string;
  11169. };
  11170. }
  11171. declare module BABYLON {
  11172. /** @hidden */
  11173. export var fogVertexDeclaration: {
  11174. name: string;
  11175. shader: string;
  11176. };
  11177. }
  11178. declare module BABYLON {
  11179. /** @hidden */
  11180. export var spritesVertexShader: {
  11181. name: string;
  11182. shader: string;
  11183. };
  11184. }
  11185. declare module BABYLON {
  11186. /**
  11187. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11188. */
  11189. export interface ISpriteManager extends IDisposable {
  11190. /**
  11191. * Restricts the camera to viewing objects with the same layerMask.
  11192. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11193. */
  11194. layerMask: number;
  11195. /**
  11196. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11197. */
  11198. isPickable: boolean;
  11199. /**
  11200. * Specifies the rendering group id for this mesh (0 by default)
  11201. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11202. */
  11203. renderingGroupId: number;
  11204. /**
  11205. * Defines the list of sprites managed by the manager.
  11206. */
  11207. sprites: Array<Sprite>;
  11208. /**
  11209. * Tests the intersection of a sprite with a specific ray.
  11210. * @param ray The ray we are sending to test the collision
  11211. * @param camera The camera space we are sending rays in
  11212. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11213. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11214. * @returns picking info or null.
  11215. */
  11216. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11217. /**
  11218. * Renders the list of sprites on screen.
  11219. */
  11220. render(): void;
  11221. }
  11222. /**
  11223. * Class used to manage multiple sprites on the same spritesheet
  11224. * @see http://doc.babylonjs.com/babylon101/sprites
  11225. */
  11226. export class SpriteManager implements ISpriteManager {
  11227. /** defines the manager's name */
  11228. name: string;
  11229. /** Gets the list of sprites */
  11230. sprites: Sprite[];
  11231. /** Gets or sets the rendering group id (0 by default) */
  11232. renderingGroupId: number;
  11233. /** Gets or sets camera layer mask */
  11234. layerMask: number;
  11235. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11236. fogEnabled: boolean;
  11237. /** Gets or sets a boolean indicating if the sprites are pickable */
  11238. isPickable: boolean;
  11239. /** Defines the default width of a cell in the spritesheet */
  11240. cellWidth: number;
  11241. /** Defines the default height of a cell in the spritesheet */
  11242. cellHeight: number;
  11243. /** Associative array from JSON sprite data file */
  11244. private _cellData;
  11245. /** Array of sprite names from JSON sprite data file */
  11246. private _spriteMap;
  11247. /** True when packed cell data from JSON file is ready*/
  11248. private _packedAndReady;
  11249. /**
  11250. * An event triggered when the manager is disposed.
  11251. */
  11252. onDisposeObservable: Observable<SpriteManager>;
  11253. private _onDisposeObserver;
  11254. /**
  11255. * Callback called when the manager is disposed
  11256. */
  11257. onDispose: () => void;
  11258. private _capacity;
  11259. private _fromPacked;
  11260. private _spriteTexture;
  11261. private _epsilon;
  11262. private _scene;
  11263. private _vertexData;
  11264. private _buffer;
  11265. private _vertexBuffers;
  11266. private _indexBuffer;
  11267. private _effectBase;
  11268. private _effectFog;
  11269. /**
  11270. * Gets or sets the spritesheet texture
  11271. */
  11272. texture: Texture;
  11273. /**
  11274. * Creates a new sprite manager
  11275. * @param name defines the manager's name
  11276. * @param imgUrl defines the sprite sheet url
  11277. * @param capacity defines the maximum allowed number of sprites
  11278. * @param cellSize defines the size of a sprite cell
  11279. * @param scene defines the hosting scene
  11280. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11281. * @param samplingMode defines the smapling mode to use with spritesheet
  11282. * @param fromPacked set to false; do not alter
  11283. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11284. */
  11285. constructor(
  11286. /** defines the manager's name */
  11287. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11288. private _makePacked;
  11289. private _appendSpriteVertex;
  11290. /**
  11291. * Intersects the sprites with a ray
  11292. * @param ray defines the ray to intersect with
  11293. * @param camera defines the current active camera
  11294. * @param predicate defines a predicate used to select candidate sprites
  11295. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11296. * @returns null if no hit or a PickingInfo
  11297. */
  11298. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11299. /**
  11300. * Render all child sprites
  11301. */
  11302. render(): void;
  11303. /**
  11304. * Release associated resources
  11305. */
  11306. dispose(): void;
  11307. }
  11308. }
  11309. declare module BABYLON {
  11310. /**
  11311. * Class used to represent a sprite
  11312. * @see http://doc.babylonjs.com/babylon101/sprites
  11313. */
  11314. export class Sprite {
  11315. /** defines the name */
  11316. name: string;
  11317. /** Gets or sets the current world position */
  11318. position: Vector3;
  11319. /** Gets or sets the main color */
  11320. color: Color4;
  11321. /** Gets or sets the width */
  11322. width: number;
  11323. /** Gets or sets the height */
  11324. height: number;
  11325. /** Gets or sets rotation angle */
  11326. angle: number;
  11327. /** Gets or sets the cell index in the sprite sheet */
  11328. cellIndex: number;
  11329. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11330. cellRef: string;
  11331. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11332. invertU: number;
  11333. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11334. invertV: number;
  11335. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11336. disposeWhenFinishedAnimating: boolean;
  11337. /** Gets the list of attached animations */
  11338. animations: Animation[];
  11339. /** Gets or sets a boolean indicating if the sprite can be picked */
  11340. isPickable: boolean;
  11341. /**
  11342. * Gets or sets the associated action manager
  11343. */
  11344. actionManager: Nullable<ActionManager>;
  11345. private _animationStarted;
  11346. private _loopAnimation;
  11347. private _fromIndex;
  11348. private _toIndex;
  11349. private _delay;
  11350. private _direction;
  11351. private _manager;
  11352. private _time;
  11353. private _onAnimationEnd;
  11354. /**
  11355. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11356. */
  11357. isVisible: boolean;
  11358. /**
  11359. * Gets or sets the sprite size
  11360. */
  11361. size: number;
  11362. /**
  11363. * Creates a new Sprite
  11364. * @param name defines the name
  11365. * @param manager defines the manager
  11366. */
  11367. constructor(
  11368. /** defines the name */
  11369. name: string, manager: ISpriteManager);
  11370. /**
  11371. * Starts an animation
  11372. * @param from defines the initial key
  11373. * @param to defines the end key
  11374. * @param loop defines if the animation must loop
  11375. * @param delay defines the start delay (in ms)
  11376. * @param onAnimationEnd defines a callback to call when animation ends
  11377. */
  11378. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11379. /** Stops current animation (if any) */
  11380. stopAnimation(): void;
  11381. /** @hidden */ private _animate(deltaTime: number): void;
  11382. /** Release associated resources */
  11383. dispose(): void;
  11384. }
  11385. }
  11386. declare module BABYLON {
  11387. /**
  11388. * Information about the result of picking within a scene
  11389. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11390. */
  11391. export class PickingInfo {
  11392. /** @hidden */ private _pickingUnavailable: boolean;
  11393. /**
  11394. * If the pick collided with an object
  11395. */
  11396. hit: boolean;
  11397. /**
  11398. * Distance away where the pick collided
  11399. */
  11400. distance: number;
  11401. /**
  11402. * The location of pick collision
  11403. */
  11404. pickedPoint: Nullable<Vector3>;
  11405. /**
  11406. * The mesh corresponding the the pick collision
  11407. */
  11408. pickedMesh: Nullable<AbstractMesh>;
  11409. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11410. bu: number;
  11411. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11412. bv: number;
  11413. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11414. faceId: number;
  11415. /** Id of the the submesh that was picked */
  11416. subMeshId: number;
  11417. /** If a sprite was picked, this will be the sprite the pick collided with */
  11418. pickedSprite: Nullable<Sprite>;
  11419. /**
  11420. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11421. */
  11422. originMesh: Nullable<AbstractMesh>;
  11423. /**
  11424. * The ray that was used to perform the picking.
  11425. */
  11426. ray: Nullable<Ray>;
  11427. /**
  11428. * Gets the normal correspodning to the face the pick collided with
  11429. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11430. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11431. * @returns The normal correspodning to the face the pick collided with
  11432. */
  11433. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11434. /**
  11435. * Gets the texture coordinates of where the pick occured
  11436. * @returns the vector containing the coordnates of the texture
  11437. */
  11438. getTextureCoordinates(): Nullable<Vector2>;
  11439. }
  11440. }
  11441. declare module BABYLON {
  11442. /**
  11443. * Gather the list of pointer event types as constants.
  11444. */
  11445. export class PointerEventTypes {
  11446. /**
  11447. * 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.
  11448. */
  11449. static readonly POINTERDOWN: number;
  11450. /**
  11451. * The pointerup event is fired when a pointer is no longer active.
  11452. */
  11453. static readonly POINTERUP: number;
  11454. /**
  11455. * The pointermove event is fired when a pointer changes coordinates.
  11456. */
  11457. static readonly POINTERMOVE: number;
  11458. /**
  11459. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11460. */
  11461. static readonly POINTERWHEEL: number;
  11462. /**
  11463. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11464. */
  11465. static readonly POINTERPICK: number;
  11466. /**
  11467. * The pointertap event is fired when a the object has been touched and released without drag.
  11468. */
  11469. static readonly POINTERTAP: number;
  11470. /**
  11471. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11472. */
  11473. static readonly POINTERDOUBLETAP: number;
  11474. }
  11475. /**
  11476. * Base class of pointer info types.
  11477. */
  11478. export class PointerInfoBase {
  11479. /**
  11480. * Defines the type of event (PointerEventTypes)
  11481. */
  11482. type: number;
  11483. /**
  11484. * Defines the related dom event
  11485. */
  11486. event: PointerEvent | MouseWheelEvent;
  11487. /**
  11488. * Instantiates the base class of pointers info.
  11489. * @param type Defines the type of event (PointerEventTypes)
  11490. * @param event Defines the related dom event
  11491. */
  11492. constructor(
  11493. /**
  11494. * Defines the type of event (PointerEventTypes)
  11495. */
  11496. type: number,
  11497. /**
  11498. * Defines the related dom event
  11499. */
  11500. event: PointerEvent | MouseWheelEvent);
  11501. }
  11502. /**
  11503. * This class is used to store pointer related info for the onPrePointerObservable event.
  11504. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11505. */
  11506. export class PointerInfoPre extends PointerInfoBase {
  11507. /**
  11508. * Ray from a pointer if availible (eg. 6dof controller)
  11509. */
  11510. ray: Nullable<Ray>;
  11511. /**
  11512. * Defines the local position of the pointer on the canvas.
  11513. */
  11514. localPosition: Vector2;
  11515. /**
  11516. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11517. */
  11518. skipOnPointerObservable: boolean;
  11519. /**
  11520. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11521. * @param type Defines the type of event (PointerEventTypes)
  11522. * @param event Defines the related dom event
  11523. * @param localX Defines the local x coordinates of the pointer when the event occured
  11524. * @param localY Defines the local y coordinates of the pointer when the event occured
  11525. */
  11526. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11527. }
  11528. /**
  11529. * This type contains all the data related to a pointer event in Babylon.js.
  11530. * 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.
  11531. */
  11532. export class PointerInfo extends PointerInfoBase {
  11533. /**
  11534. * Defines the picking info associated to the info (if any)\
  11535. */
  11536. pickInfo: Nullable<PickingInfo>;
  11537. /**
  11538. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11539. * @param type Defines the type of event (PointerEventTypes)
  11540. * @param event Defines the related dom event
  11541. * @param pickInfo Defines the picking info associated to the info (if any)\
  11542. */
  11543. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11544. /**
  11545. * Defines the picking info associated to the info (if any)\
  11546. */
  11547. pickInfo: Nullable<PickingInfo>);
  11548. }
  11549. /**
  11550. * Data relating to a touch event on the screen.
  11551. */
  11552. export interface PointerTouch {
  11553. /**
  11554. * X coordinate of touch.
  11555. */
  11556. x: number;
  11557. /**
  11558. * Y coordinate of touch.
  11559. */
  11560. y: number;
  11561. /**
  11562. * Id of touch. Unique for each finger.
  11563. */
  11564. pointerId: number;
  11565. /**
  11566. * Event type passed from DOM.
  11567. */
  11568. type: any;
  11569. }
  11570. }
  11571. declare module BABYLON {
  11572. /**
  11573. * Manage the mouse inputs to control the movement of a free camera.
  11574. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11575. */
  11576. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11577. /**
  11578. * Define if touch is enabled in the mouse input
  11579. */
  11580. touchEnabled: boolean;
  11581. /**
  11582. * Defines the camera the input is attached to.
  11583. */
  11584. camera: FreeCamera;
  11585. /**
  11586. * Defines the buttons associated with the input to handle camera move.
  11587. */
  11588. buttons: number[];
  11589. /**
  11590. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11591. */
  11592. angularSensibility: number;
  11593. private _pointerInput;
  11594. private _onMouseMove;
  11595. private _observer;
  11596. private previousPosition;
  11597. /**
  11598. * Observable for when a pointer move event occurs containing the move offset
  11599. */
  11600. onPointerMovedObservable: Observable<{
  11601. offsetX: number;
  11602. offsetY: number;
  11603. }>;
  11604. /**
  11605. * @hidden
  11606. * If the camera should be rotated automatically based on pointer movement
  11607. */ private _allowCameraRotation: boolean;
  11608. /**
  11609. * Manage the mouse inputs to control the movement of a free camera.
  11610. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11611. * @param touchEnabled Defines if touch is enabled or not
  11612. */
  11613. constructor(
  11614. /**
  11615. * Define if touch is enabled in the mouse input
  11616. */
  11617. touchEnabled?: boolean);
  11618. /**
  11619. * Attach the input controls to a specific dom element to get the input from.
  11620. * @param element Defines the element the controls should be listened from
  11621. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11622. */
  11623. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11624. /**
  11625. * Called on JS contextmenu event.
  11626. * Override this method to provide functionality.
  11627. */
  11628. protected onContextMenu(evt: PointerEvent): void;
  11629. /**
  11630. * Detach the current controls from the specified dom element.
  11631. * @param element Defines the element to stop listening the inputs from
  11632. */
  11633. detachControl(element: Nullable<HTMLElement>): void;
  11634. /**
  11635. * Gets the class name of the current intput.
  11636. * @returns the class name
  11637. */
  11638. getClassName(): string;
  11639. /**
  11640. * Get the friendly name associated with the input class.
  11641. * @returns the input friendly name
  11642. */
  11643. getSimpleName(): string;
  11644. }
  11645. }
  11646. declare module BABYLON {
  11647. /**
  11648. * Manage the touch inputs to control the movement of a free camera.
  11649. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11650. */
  11651. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11652. /**
  11653. * Defines the camera the input is attached to.
  11654. */
  11655. camera: FreeCamera;
  11656. /**
  11657. * Defines the touch sensibility for rotation.
  11658. * The higher the faster.
  11659. */
  11660. touchAngularSensibility: number;
  11661. /**
  11662. * Defines the touch sensibility for move.
  11663. * The higher the faster.
  11664. */
  11665. touchMoveSensibility: number;
  11666. private _offsetX;
  11667. private _offsetY;
  11668. private _pointerPressed;
  11669. private _pointerInput;
  11670. private _observer;
  11671. private _onLostFocus;
  11672. /**
  11673. * Attach the input controls to a specific dom element to get the input from.
  11674. * @param element Defines the element the controls should be listened from
  11675. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11676. */
  11677. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11678. /**
  11679. * Detach the current controls from the specified dom element.
  11680. * @param element Defines the element to stop listening the inputs from
  11681. */
  11682. detachControl(element: Nullable<HTMLElement>): void;
  11683. /**
  11684. * Update the current camera state depending on the inputs that have been used this frame.
  11685. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11686. */
  11687. checkInputs(): void;
  11688. /**
  11689. * Gets the class name of the current intput.
  11690. * @returns the class name
  11691. */
  11692. getClassName(): string;
  11693. /**
  11694. * Get the friendly name associated with the input class.
  11695. * @returns the input friendly name
  11696. */
  11697. getSimpleName(): string;
  11698. }
  11699. }
  11700. declare module BABYLON {
  11701. /**
  11702. * Default Inputs manager for the FreeCamera.
  11703. * It groups all the default supported inputs for ease of use.
  11704. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11705. */
  11706. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11707. /**
  11708. * @hidden
  11709. */ private _mouseInput: Nullable<FreeCameraMouseInput>;
  11710. /**
  11711. * Instantiates a new FreeCameraInputsManager.
  11712. * @param camera Defines the camera the inputs belong to
  11713. */
  11714. constructor(camera: FreeCamera);
  11715. /**
  11716. * Add keyboard input support to the input manager.
  11717. * @returns the current input manager
  11718. */
  11719. addKeyboard(): FreeCameraInputsManager;
  11720. /**
  11721. * Add mouse input support to the input manager.
  11722. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11723. * @returns the current input manager
  11724. */
  11725. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11726. /**
  11727. * Removes the mouse input support from the manager
  11728. * @returns the current input manager
  11729. */
  11730. removeMouse(): FreeCameraInputsManager;
  11731. /**
  11732. * Add touch input support to the input manager.
  11733. * @returns the current input manager
  11734. */
  11735. addTouch(): FreeCameraInputsManager;
  11736. /**
  11737. * Remove all attached input methods from a camera
  11738. */
  11739. clear(): void;
  11740. }
  11741. }
  11742. declare module BABYLON {
  11743. /**
  11744. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11745. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11746. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11747. */
  11748. export class FreeCamera extends TargetCamera {
  11749. /**
  11750. * Define the collision ellipsoid of the camera.
  11751. * This is helpful to simulate a camera body like the player body around the camera
  11752. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11753. */
  11754. ellipsoid: Vector3;
  11755. /**
  11756. * Define an offset for the position of the ellipsoid around the camera.
  11757. * This can be helpful to determine the center of the body near the gravity center of the body
  11758. * instead of its head.
  11759. */
  11760. ellipsoidOffset: Vector3;
  11761. /**
  11762. * Enable or disable collisions of the camera with the rest of the scene objects.
  11763. */
  11764. checkCollisions: boolean;
  11765. /**
  11766. * Enable or disable gravity on the camera.
  11767. */
  11768. applyGravity: boolean;
  11769. /**
  11770. * Define the input manager associated to the camera.
  11771. */
  11772. inputs: FreeCameraInputsManager;
  11773. /**
  11774. * Gets the input sensibility for a mouse input. (default is 2000.0)
  11775. * Higher values reduce sensitivity.
  11776. */
  11777. /**
  11778. * Sets the input sensibility for a mouse input. (default is 2000.0)
  11779. * Higher values reduce sensitivity.
  11780. */
  11781. angularSensibility: number;
  11782. /**
  11783. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  11784. */
  11785. keysUp: number[];
  11786. /**
  11787. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  11788. */
  11789. keysDown: number[];
  11790. /**
  11791. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  11792. */
  11793. keysLeft: number[];
  11794. /**
  11795. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  11796. */
  11797. keysRight: number[];
  11798. /**
  11799. * Event raised when the camera collide with a mesh in the scene.
  11800. */
  11801. onCollide: (collidedMesh: AbstractMesh) => void;
  11802. private _collider;
  11803. private _needMoveForGravity;
  11804. private _oldPosition;
  11805. private _diffPosition;
  11806. private _newPosition;
  11807. /** @hidden */ private _localDirection: Vector3;
  11808. /** @hidden */ private _transformedDirection: Vector3;
  11809. /**
  11810. * Instantiates a Free Camera.
  11811. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11812. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  11813. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11814. * @param name Define the name of the camera in the scene
  11815. * @param position Define the start position of the camera in the scene
  11816. * @param scene Define the scene the camera belongs to
  11817. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  11818. */
  11819. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  11820. /**
  11821. * Attached controls to the current camera.
  11822. * @param element Defines the element the controls should be listened from
  11823. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11824. */
  11825. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11826. /**
  11827. * Detach the current controls from the camera.
  11828. * The camera will stop reacting to inputs.
  11829. * @param element Defines the element to stop listening the inputs from
  11830. */
  11831. detachControl(element: HTMLElement): void;
  11832. private _collisionMask;
  11833. /**
  11834. * Define a collision mask to limit the list of object the camera can collide with
  11835. */
  11836. collisionMask: number;
  11837. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  11838. private _onCollisionPositionChange;
  11839. /** @hidden */ private _checkInputs(): void;
  11840. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  11841. /** @hidden */ private _updatePosition(): void;
  11842. /**
  11843. * Destroy the camera and release the current resources hold by it.
  11844. */
  11845. dispose(): void;
  11846. /**
  11847. * Gets the current object class name.
  11848. * @return the class name
  11849. */
  11850. getClassName(): string;
  11851. }
  11852. }
  11853. declare module BABYLON {
  11854. /**
  11855. * Represents a gamepad control stick position
  11856. */
  11857. export class StickValues {
  11858. /**
  11859. * The x component of the control stick
  11860. */
  11861. x: number;
  11862. /**
  11863. * The y component of the control stick
  11864. */
  11865. y: number;
  11866. /**
  11867. * Initializes the gamepad x and y control stick values
  11868. * @param x The x component of the gamepad control stick value
  11869. * @param y The y component of the gamepad control stick value
  11870. */
  11871. constructor(
  11872. /**
  11873. * The x component of the control stick
  11874. */
  11875. x: number,
  11876. /**
  11877. * The y component of the control stick
  11878. */
  11879. y: number);
  11880. }
  11881. /**
  11882. * An interface which manages callbacks for gamepad button changes
  11883. */
  11884. export interface GamepadButtonChanges {
  11885. /**
  11886. * Called when a gamepad has been changed
  11887. */
  11888. changed: boolean;
  11889. /**
  11890. * Called when a gamepad press event has been triggered
  11891. */
  11892. pressChanged: boolean;
  11893. /**
  11894. * Called when a touch event has been triggered
  11895. */
  11896. touchChanged: boolean;
  11897. /**
  11898. * Called when a value has changed
  11899. */
  11900. valueChanged: boolean;
  11901. }
  11902. /**
  11903. * Represents a gamepad
  11904. */
  11905. export class Gamepad {
  11906. /**
  11907. * The id of the gamepad
  11908. */
  11909. id: string;
  11910. /**
  11911. * The index of the gamepad
  11912. */
  11913. index: number;
  11914. /**
  11915. * The browser gamepad
  11916. */
  11917. browserGamepad: any;
  11918. /**
  11919. * Specifies what type of gamepad this represents
  11920. */
  11921. type: number;
  11922. private _leftStick;
  11923. private _rightStick;
  11924. /** @hidden */ private _isConnected: boolean;
  11925. private _leftStickAxisX;
  11926. private _leftStickAxisY;
  11927. private _rightStickAxisX;
  11928. private _rightStickAxisY;
  11929. /**
  11930. * Triggered when the left control stick has been changed
  11931. */
  11932. private _onleftstickchanged;
  11933. /**
  11934. * Triggered when the right control stick has been changed
  11935. */
  11936. private _onrightstickchanged;
  11937. /**
  11938. * Represents a gamepad controller
  11939. */
  11940. static GAMEPAD: number;
  11941. /**
  11942. * Represents a generic controller
  11943. */
  11944. static GENERIC: number;
  11945. /**
  11946. * Represents an XBox controller
  11947. */
  11948. static XBOX: number;
  11949. /**
  11950. * Represents a pose-enabled controller
  11951. */
  11952. static POSE_ENABLED: number;
  11953. /**
  11954. * Represents an Dual Shock controller
  11955. */
  11956. static DUALSHOCK: number;
  11957. /**
  11958. * Specifies whether the left control stick should be Y-inverted
  11959. */
  11960. protected _invertLeftStickY: boolean;
  11961. /**
  11962. * Specifies if the gamepad has been connected
  11963. */
  11964. readonly isConnected: boolean;
  11965. /**
  11966. * Initializes the gamepad
  11967. * @param id The id of the gamepad
  11968. * @param index The index of the gamepad
  11969. * @param browserGamepad The browser gamepad
  11970. * @param leftStickX The x component of the left joystick
  11971. * @param leftStickY The y component of the left joystick
  11972. * @param rightStickX The x component of the right joystick
  11973. * @param rightStickY The y component of the right joystick
  11974. */
  11975. constructor(
  11976. /**
  11977. * The id of the gamepad
  11978. */
  11979. id: string,
  11980. /**
  11981. * The index of the gamepad
  11982. */
  11983. index: number,
  11984. /**
  11985. * The browser gamepad
  11986. */
  11987. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  11988. /**
  11989. * Callback triggered when the left joystick has changed
  11990. * @param callback
  11991. */
  11992. onleftstickchanged(callback: (values: StickValues) => void): void;
  11993. /**
  11994. * Callback triggered when the right joystick has changed
  11995. * @param callback
  11996. */
  11997. onrightstickchanged(callback: (values: StickValues) => void): void;
  11998. /**
  11999. * Gets the left joystick
  12000. */
  12001. /**
  12002. * Sets the left joystick values
  12003. */
  12004. leftStick: StickValues;
  12005. /**
  12006. * Gets the right joystick
  12007. */
  12008. /**
  12009. * Sets the right joystick value
  12010. */
  12011. rightStick: StickValues;
  12012. /**
  12013. * Updates the gamepad joystick positions
  12014. */
  12015. update(): void;
  12016. /**
  12017. * Disposes the gamepad
  12018. */
  12019. dispose(): void;
  12020. }
  12021. /**
  12022. * Represents a generic gamepad
  12023. */
  12024. export class GenericPad extends Gamepad {
  12025. private _buttons;
  12026. private _onbuttondown;
  12027. private _onbuttonup;
  12028. /**
  12029. * Observable triggered when a button has been pressed
  12030. */
  12031. onButtonDownObservable: Observable<number>;
  12032. /**
  12033. * Observable triggered when a button has been released
  12034. */
  12035. onButtonUpObservable: Observable<number>;
  12036. /**
  12037. * Callback triggered when a button has been pressed
  12038. * @param callback Called when a button has been pressed
  12039. */
  12040. onbuttondown(callback: (buttonPressed: number) => void): void;
  12041. /**
  12042. * Callback triggered when a button has been released
  12043. * @param callback Called when a button has been released
  12044. */
  12045. onbuttonup(callback: (buttonReleased: number) => void): void;
  12046. /**
  12047. * Initializes the generic gamepad
  12048. * @param id The id of the generic gamepad
  12049. * @param index The index of the generic gamepad
  12050. * @param browserGamepad The browser gamepad
  12051. */
  12052. constructor(id: string, index: number, browserGamepad: any);
  12053. private _setButtonValue;
  12054. /**
  12055. * Updates the generic gamepad
  12056. */
  12057. update(): void;
  12058. /**
  12059. * Disposes the generic gamepad
  12060. */
  12061. dispose(): void;
  12062. }
  12063. }
  12064. declare module BABYLON {
  12065. interface Engine {
  12066. /**
  12067. * Creates a raw texture
  12068. * @param data defines the data to store in the texture
  12069. * @param width defines the width of the texture
  12070. * @param height defines the height of the texture
  12071. * @param format defines the format of the data
  12072. * @param generateMipMaps defines if the engine should generate the mip levels
  12073. * @param invertY defines if data must be stored with Y axis inverted
  12074. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12075. * @param compression defines the compression used (null by default)
  12076. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12077. * @returns the raw texture inside an InternalTexture
  12078. */
  12079. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12080. /**
  12081. * Update a raw texture
  12082. * @param texture defines the texture to update
  12083. * @param data defines the data to store in the texture
  12084. * @param format defines the format of the data
  12085. * @param invertY defines if data must be stored with Y axis inverted
  12086. */
  12087. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12088. /**
  12089. * Update a raw texture
  12090. * @param texture defines the texture to update
  12091. * @param data defines the data to store in the texture
  12092. * @param format defines the format of the data
  12093. * @param invertY defines if data must be stored with Y axis inverted
  12094. * @param compression defines the compression used (null by default)
  12095. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12096. */
  12097. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12098. /**
  12099. * Creates a new raw cube texture
  12100. * @param data defines the array of data to use to create each face
  12101. * @param size defines the size of the textures
  12102. * @param format defines the format of the data
  12103. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12104. * @param generateMipMaps defines if the engine should generate the mip levels
  12105. * @param invertY defines if data must be stored with Y axis inverted
  12106. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12107. * @param compression defines the compression used (null by default)
  12108. * @returns the cube texture as an InternalTexture
  12109. */
  12110. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12111. /**
  12112. * Update a raw cube texture
  12113. * @param texture defines the texture to udpdate
  12114. * @param data defines the data to store
  12115. * @param format defines the data format
  12116. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12117. * @param invertY defines if data must be stored with Y axis inverted
  12118. */
  12119. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12120. /**
  12121. * Update a raw cube texture
  12122. * @param texture defines the texture to udpdate
  12123. * @param data defines the data to store
  12124. * @param format defines the data format
  12125. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12126. * @param invertY defines if data must be stored with Y axis inverted
  12127. * @param compression defines the compression used (null by default)
  12128. */
  12129. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12130. /**
  12131. * Update a raw cube texture
  12132. * @param texture defines the texture to udpdate
  12133. * @param data defines the data to store
  12134. * @param format defines the data format
  12135. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12136. * @param invertY defines if data must be stored with Y axis inverted
  12137. * @param compression defines the compression used (null by default)
  12138. * @param level defines which level of the texture to update
  12139. */
  12140. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12141. /**
  12142. * Creates a new raw cube texture from a specified url
  12143. * @param url defines the url where the data is located
  12144. * @param scene defines the current scene
  12145. * @param size defines the size of the textures
  12146. * @param format defines the format of the data
  12147. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12148. * @param noMipmap defines if the engine should avoid generating the mip levels
  12149. * @param callback defines a callback used to extract texture data from loaded data
  12150. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12151. * @param onLoad defines a callback called when texture is loaded
  12152. * @param onError defines a callback called if there is an error
  12153. * @returns the cube texture as an InternalTexture
  12154. */
  12155. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  12156. /**
  12157. * Creates a new raw cube texture from a specified url
  12158. * @param url defines the url where the data is located
  12159. * @param scene defines the current scene
  12160. * @param size defines the size of the textures
  12161. * @param format defines the format of the data
  12162. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12163. * @param noMipmap defines if the engine should avoid generating the mip levels
  12164. * @param callback defines a callback used to extract texture data from loaded data
  12165. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12166. * @param onLoad defines a callback called when texture is loaded
  12167. * @param onError defines a callback called if there is an error
  12168. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12169. * @param invertY defines if data must be stored with Y axis inverted
  12170. * @returns the cube texture as an InternalTexture
  12171. */
  12172. 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;
  12173. /**
  12174. * Creates a new raw 3D texture
  12175. * @param data defines the data used to create the texture
  12176. * @param width defines the width of the texture
  12177. * @param height defines the height of the texture
  12178. * @param depth defines the depth of the texture
  12179. * @param format defines the format of the texture
  12180. * @param generateMipMaps defines if the engine must generate mip levels
  12181. * @param invertY defines if data must be stored with Y axis inverted
  12182. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12183. * @param compression defines the compressed used (can be null)
  12184. * @param textureType defines the compressed used (can be null)
  12185. * @returns a new raw 3D texture (stored in an InternalTexture)
  12186. */
  12187. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12188. /**
  12189. * Update a raw 3D texture
  12190. * @param texture defines the texture to update
  12191. * @param data defines the data to store
  12192. * @param format defines the data format
  12193. * @param invertY defines if data must be stored with Y axis inverted
  12194. */
  12195. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12196. /**
  12197. * Update a raw 3D texture
  12198. * @param texture defines the texture to update
  12199. * @param data defines the data to store
  12200. * @param format defines the data format
  12201. * @param invertY defines if data must be stored with Y axis inverted
  12202. * @param compression defines the used compression (can be null)
  12203. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12204. */
  12205. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12206. }
  12207. }
  12208. declare module BABYLON {
  12209. /**
  12210. * Raw texture can help creating a texture directly from an array of data.
  12211. * This can be super useful if you either get the data from an uncompressed source or
  12212. * if you wish to create your texture pixel by pixel.
  12213. */
  12214. export class RawTexture extends Texture {
  12215. /**
  12216. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12217. */
  12218. format: number;
  12219. private _engine;
  12220. /**
  12221. * Instantiates a new RawTexture.
  12222. * Raw texture can help creating a texture directly from an array of data.
  12223. * This can be super useful if you either get the data from an uncompressed source or
  12224. * if you wish to create your texture pixel by pixel.
  12225. * @param data define the array of data to use to create the texture
  12226. * @param width define the width of the texture
  12227. * @param height define the height of the texture
  12228. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12229. * @param scene define the scene the texture belongs to
  12230. * @param generateMipMaps define whether mip maps should be generated or not
  12231. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12232. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12233. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12234. */
  12235. constructor(data: ArrayBufferView, width: number, height: number,
  12236. /**
  12237. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12238. */
  12239. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12240. /**
  12241. * Updates the texture underlying data.
  12242. * @param data Define the new data of the texture
  12243. */
  12244. update(data: ArrayBufferView): void;
  12245. /**
  12246. * Creates a luminance texture from some data.
  12247. * @param data Define the texture data
  12248. * @param width Define the width of the texture
  12249. * @param height Define the height of the texture
  12250. * @param scene Define the scene the texture belongs to
  12251. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12252. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12253. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12254. * @returns the luminance texture
  12255. */
  12256. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12257. /**
  12258. * Creates a luminance alpha texture from some data.
  12259. * @param data Define the texture data
  12260. * @param width Define the width of the texture
  12261. * @param height Define the height of the texture
  12262. * @param scene Define the scene the texture belongs to
  12263. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12264. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12265. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12266. * @returns the luminance alpha texture
  12267. */
  12268. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12269. /**
  12270. * Creates an alpha texture from some data.
  12271. * @param data Define the texture data
  12272. * @param width Define the width of the texture
  12273. * @param height Define the height of the texture
  12274. * @param scene Define the scene the texture belongs to
  12275. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12276. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12277. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12278. * @returns the alpha texture
  12279. */
  12280. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12281. /**
  12282. * Creates a RGB texture from some data.
  12283. * @param data Define the texture data
  12284. * @param width Define the width of the texture
  12285. * @param height Define the height of the texture
  12286. * @param scene Define the scene the texture belongs to
  12287. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12288. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12289. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12290. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12291. * @returns the RGB alpha texture
  12292. */
  12293. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12294. /**
  12295. * Creates a RGBA texture from some data.
  12296. * @param data Define the texture data
  12297. * @param width Define the width of the texture
  12298. * @param height Define the height of the texture
  12299. * @param scene Define the scene the texture belongs to
  12300. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12301. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12302. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12303. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12304. * @returns the RGBA texture
  12305. */
  12306. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12307. /**
  12308. * Creates a R texture from some data.
  12309. * @param data Define the texture data
  12310. * @param width Define the width of the texture
  12311. * @param height Define the height of the texture
  12312. * @param scene Define the scene the texture belongs to
  12313. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12314. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12315. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12316. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12317. * @returns the R texture
  12318. */
  12319. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12320. }
  12321. }
  12322. declare module BABYLON {
  12323. /**
  12324. * Interface for the size containing width and height
  12325. */
  12326. export interface ISize {
  12327. /**
  12328. * Width
  12329. */
  12330. width: number;
  12331. /**
  12332. * Heighht
  12333. */
  12334. height: number;
  12335. }
  12336. /**
  12337. * Size containing widht and height
  12338. */
  12339. export class Size implements ISize {
  12340. /**
  12341. * Width
  12342. */
  12343. width: number;
  12344. /**
  12345. * Height
  12346. */
  12347. height: number;
  12348. /**
  12349. * Creates a Size object from the given width and height (floats).
  12350. * @param width width of the new size
  12351. * @param height height of the new size
  12352. */
  12353. constructor(width: number, height: number);
  12354. /**
  12355. * Returns a string with the Size width and height
  12356. * @returns a string with the Size width and height
  12357. */
  12358. toString(): string;
  12359. /**
  12360. * "Size"
  12361. * @returns the string "Size"
  12362. */
  12363. getClassName(): string;
  12364. /**
  12365. * Returns the Size hash code.
  12366. * @returns a hash code for a unique width and height
  12367. */
  12368. getHashCode(): number;
  12369. /**
  12370. * Updates the current size from the given one.
  12371. * @param src the given size
  12372. */
  12373. copyFrom(src: Size): void;
  12374. /**
  12375. * Updates in place the current Size from the given floats.
  12376. * @param width width of the new size
  12377. * @param height height of the new size
  12378. * @returns the updated Size.
  12379. */
  12380. copyFromFloats(width: number, height: number): Size;
  12381. /**
  12382. * Updates in place the current Size from the given floats.
  12383. * @param width width to set
  12384. * @param height height to set
  12385. * @returns the updated Size.
  12386. */
  12387. set(width: number, height: number): Size;
  12388. /**
  12389. * Multiplies the width and height by numbers
  12390. * @param w factor to multiple the width by
  12391. * @param h factor to multiple the height by
  12392. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12393. */
  12394. multiplyByFloats(w: number, h: number): Size;
  12395. /**
  12396. * Clones the size
  12397. * @returns a new Size copied from the given one.
  12398. */
  12399. clone(): Size;
  12400. /**
  12401. * True if the current Size and the given one width and height are strictly equal.
  12402. * @param other the other size to compare against
  12403. * @returns True if the current Size and the given one width and height are strictly equal.
  12404. */
  12405. equals(other: Size): boolean;
  12406. /**
  12407. * The surface of the Size : width * height (float).
  12408. */
  12409. readonly surface: number;
  12410. /**
  12411. * Create a new size of zero
  12412. * @returns a new Size set to (0.0, 0.0)
  12413. */
  12414. static Zero(): Size;
  12415. /**
  12416. * Sums the width and height of two sizes
  12417. * @param otherSize size to add to this size
  12418. * @returns a new Size set as the addition result of the current Size and the given one.
  12419. */
  12420. add(otherSize: Size): Size;
  12421. /**
  12422. * Subtracts the width and height of two
  12423. * @param otherSize size to subtract to this size
  12424. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12425. */
  12426. subtract(otherSize: Size): Size;
  12427. /**
  12428. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12429. * @param start starting size to lerp between
  12430. * @param end end size to lerp between
  12431. * @param amount amount to lerp between the start and end values
  12432. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12433. */
  12434. static Lerp(start: Size, end: Size, amount: number): Size;
  12435. }
  12436. }
  12437. declare module BABYLON {
  12438. /**
  12439. * Defines a runtime animation
  12440. */
  12441. export class RuntimeAnimation {
  12442. private _events;
  12443. /**
  12444. * The current frame of the runtime animation
  12445. */
  12446. private _currentFrame;
  12447. /**
  12448. * The animation used by the runtime animation
  12449. */
  12450. private _animation;
  12451. /**
  12452. * The target of the runtime animation
  12453. */
  12454. private _target;
  12455. /**
  12456. * The initiating animatable
  12457. */
  12458. private _host;
  12459. /**
  12460. * The original value of the runtime animation
  12461. */
  12462. private _originalValue;
  12463. /**
  12464. * The original blend value of the runtime animation
  12465. */
  12466. private _originalBlendValue;
  12467. /**
  12468. * The offsets cache of the runtime animation
  12469. */
  12470. private _offsetsCache;
  12471. /**
  12472. * The high limits cache of the runtime animation
  12473. */
  12474. private _highLimitsCache;
  12475. /**
  12476. * Specifies if the runtime animation has been stopped
  12477. */
  12478. private _stopped;
  12479. /**
  12480. * The blending factor of the runtime animation
  12481. */
  12482. private _blendingFactor;
  12483. /**
  12484. * The BabylonJS scene
  12485. */
  12486. private _scene;
  12487. /**
  12488. * The current value of the runtime animation
  12489. */
  12490. private _currentValue;
  12491. /** @hidden */ private _animationState: _IAnimationState;
  12492. /**
  12493. * The active target of the runtime animation
  12494. */
  12495. private _activeTargets;
  12496. private _currentActiveTarget;
  12497. private _directTarget;
  12498. /**
  12499. * The target path of the runtime animation
  12500. */
  12501. private _targetPath;
  12502. /**
  12503. * The weight of the runtime animation
  12504. */
  12505. private _weight;
  12506. /**
  12507. * The ratio offset of the runtime animation
  12508. */
  12509. private _ratioOffset;
  12510. /**
  12511. * The previous delay of the runtime animation
  12512. */
  12513. private _previousDelay;
  12514. /**
  12515. * The previous ratio of the runtime animation
  12516. */
  12517. private _previousRatio;
  12518. private _enableBlending;
  12519. private _keys;
  12520. private _minFrame;
  12521. private _maxFrame;
  12522. private _minValue;
  12523. private _maxValue;
  12524. private _targetIsArray;
  12525. /**
  12526. * Gets the current frame of the runtime animation
  12527. */
  12528. readonly currentFrame: number;
  12529. /**
  12530. * Gets the weight of the runtime animation
  12531. */
  12532. readonly weight: number;
  12533. /**
  12534. * Gets the current value of the runtime animation
  12535. */
  12536. readonly currentValue: any;
  12537. /**
  12538. * Gets the target path of the runtime animation
  12539. */
  12540. readonly targetPath: string;
  12541. /**
  12542. * Gets the actual target of the runtime animation
  12543. */
  12544. readonly target: any;
  12545. /** @hidden */ private _onLoop: () => void;
  12546. /**
  12547. * Create a new RuntimeAnimation object
  12548. * @param target defines the target of the animation
  12549. * @param animation defines the source animation object
  12550. * @param scene defines the hosting scene
  12551. * @param host defines the initiating Animatable
  12552. */
  12553. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12554. private _preparePath;
  12555. /**
  12556. * Gets the animation from the runtime animation
  12557. */
  12558. readonly animation: Animation;
  12559. /**
  12560. * Resets the runtime animation to the beginning
  12561. * @param restoreOriginal defines whether to restore the target property to the original value
  12562. */
  12563. reset(restoreOriginal?: boolean): void;
  12564. /**
  12565. * Specifies if the runtime animation is stopped
  12566. * @returns Boolean specifying if the runtime animation is stopped
  12567. */
  12568. isStopped(): boolean;
  12569. /**
  12570. * Disposes of the runtime animation
  12571. */
  12572. dispose(): void;
  12573. /**
  12574. * Apply the interpolated value to the target
  12575. * @param currentValue defines the value computed by the animation
  12576. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12577. */
  12578. setValue(currentValue: any, weight: number): void;
  12579. private _getOriginalValues;
  12580. private _setValue;
  12581. /**
  12582. * Gets the loop pmode of the runtime animation
  12583. * @returns Loop Mode
  12584. */
  12585. private _getCorrectLoopMode;
  12586. /**
  12587. * Move the current animation to a given frame
  12588. * @param frame defines the frame to move to
  12589. */
  12590. goToFrame(frame: number): void;
  12591. /**
  12592. * @hidden Internal use only
  12593. */ private _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12594. /**
  12595. * Execute the current animation
  12596. * @param delay defines the delay to add to the current frame
  12597. * @param from defines the lower bound of the animation range
  12598. * @param to defines the upper bound of the animation range
  12599. * @param loop defines if the current animation must loop
  12600. * @param speedRatio defines the current speed ratio
  12601. * @param weight defines the weight of the animation (default is -1 so no weight)
  12602. * @param onLoop optional callback called when animation loops
  12603. * @returns a boolean indicating if the animation is running
  12604. */
  12605. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12606. }
  12607. }
  12608. declare module BABYLON {
  12609. /**
  12610. * Class used to store an actual running animation
  12611. */
  12612. export class Animatable {
  12613. /** defines the target object */
  12614. target: any;
  12615. /** defines the starting frame number (default is 0) */
  12616. fromFrame: number;
  12617. /** defines the ending frame number (default is 100) */
  12618. toFrame: number;
  12619. /** defines if the animation must loop (default is false) */
  12620. loopAnimation: boolean;
  12621. /** defines a callback to call when animation ends if it is not looping */
  12622. onAnimationEnd?: (() => void) | null | undefined;
  12623. /** defines a callback to call when animation loops */
  12624. onAnimationLoop?: (() => void) | null | undefined;
  12625. private _localDelayOffset;
  12626. private _pausedDelay;
  12627. private _runtimeAnimations;
  12628. private _paused;
  12629. private _scene;
  12630. private _speedRatio;
  12631. private _weight;
  12632. private _syncRoot;
  12633. /**
  12634. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12635. * This will only apply for non looping animation (default is true)
  12636. */
  12637. disposeOnEnd: boolean;
  12638. /**
  12639. * Gets a boolean indicating if the animation has started
  12640. */
  12641. animationStarted: boolean;
  12642. /**
  12643. * Observer raised when the animation ends
  12644. */
  12645. onAnimationEndObservable: Observable<Animatable>;
  12646. /**
  12647. * Observer raised when the animation loops
  12648. */
  12649. onAnimationLoopObservable: Observable<Animatable>;
  12650. /**
  12651. * Gets the root Animatable used to synchronize and normalize animations
  12652. */
  12653. readonly syncRoot: Nullable<Animatable>;
  12654. /**
  12655. * Gets the current frame of the first RuntimeAnimation
  12656. * Used to synchronize Animatables
  12657. */
  12658. readonly masterFrame: number;
  12659. /**
  12660. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12661. */
  12662. weight: number;
  12663. /**
  12664. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12665. */
  12666. speedRatio: number;
  12667. /**
  12668. * Creates a new Animatable
  12669. * @param scene defines the hosting scene
  12670. * @param target defines the target object
  12671. * @param fromFrame defines the starting frame number (default is 0)
  12672. * @param toFrame defines the ending frame number (default is 100)
  12673. * @param loopAnimation defines if the animation must loop (default is false)
  12674. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12675. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12676. * @param animations defines a group of animation to add to the new Animatable
  12677. * @param onAnimationLoop defines a callback to call when animation loops
  12678. */
  12679. constructor(scene: Scene,
  12680. /** defines the target object */
  12681. target: any,
  12682. /** defines the starting frame number (default is 0) */
  12683. fromFrame?: number,
  12684. /** defines the ending frame number (default is 100) */
  12685. toFrame?: number,
  12686. /** defines if the animation must loop (default is false) */
  12687. loopAnimation?: boolean, speedRatio?: number,
  12688. /** defines a callback to call when animation ends if it is not looping */
  12689. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12690. /** defines a callback to call when animation loops */
  12691. onAnimationLoop?: (() => void) | null | undefined);
  12692. /**
  12693. * Synchronize and normalize current Animatable with a source Animatable
  12694. * This is useful when using animation weights and when animations are not of the same length
  12695. * @param root defines the root Animatable to synchronize with
  12696. * @returns the current Animatable
  12697. */
  12698. syncWith(root: Animatable): Animatable;
  12699. /**
  12700. * Gets the list of runtime animations
  12701. * @returns an array of RuntimeAnimation
  12702. */
  12703. getAnimations(): RuntimeAnimation[];
  12704. /**
  12705. * Adds more animations to the current animatable
  12706. * @param target defines the target of the animations
  12707. * @param animations defines the new animations to add
  12708. */
  12709. appendAnimations(target: any, animations: Animation[]): void;
  12710. /**
  12711. * Gets the source animation for a specific property
  12712. * @param property defines the propertyu to look for
  12713. * @returns null or the source animation for the given property
  12714. */
  12715. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12716. /**
  12717. * Gets the runtime animation for a specific property
  12718. * @param property defines the propertyu to look for
  12719. * @returns null or the runtime animation for the given property
  12720. */
  12721. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12722. /**
  12723. * Resets the animatable to its original state
  12724. */
  12725. reset(): void;
  12726. /**
  12727. * Allows the animatable to blend with current running animations
  12728. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12729. * @param blendingSpeed defines the blending speed to use
  12730. */
  12731. enableBlending(blendingSpeed: number): void;
  12732. /**
  12733. * Disable animation blending
  12734. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12735. */
  12736. disableBlending(): void;
  12737. /**
  12738. * Jump directly to a given frame
  12739. * @param frame defines the frame to jump to
  12740. */
  12741. goToFrame(frame: number): void;
  12742. /**
  12743. * Pause the animation
  12744. */
  12745. pause(): void;
  12746. /**
  12747. * Restart the animation
  12748. */
  12749. restart(): void;
  12750. private _raiseOnAnimationEnd;
  12751. /**
  12752. * Stop and delete the current animation
  12753. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  12754. * @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)
  12755. */
  12756. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  12757. /**
  12758. * Wait asynchronously for the animation to end
  12759. * @returns a promise which will be fullfilled when the animation ends
  12760. */
  12761. waitAsync(): Promise<Animatable>;
  12762. /** @hidden */ private _animate(delay: number): boolean;
  12763. }
  12764. interface Scene {
  12765. /** @hidden */ private _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  12766. /** @hidden */ private _processLateAnimationBindingsForMatrices(holder: {
  12767. totalWeight: number;
  12768. animations: RuntimeAnimation[];
  12769. originalValue: Matrix;
  12770. }): any;
  12771. /** @hidden */ private _processLateAnimationBindingsForQuaternions(holder: {
  12772. totalWeight: number;
  12773. animations: RuntimeAnimation[];
  12774. originalValue: Quaternion;
  12775. }, refQuaternion: Quaternion): Quaternion;
  12776. /** @hidden */ private _processLateAnimationBindings(): void;
  12777. /**
  12778. * Will start the animation sequence of a given target
  12779. * @param target defines the target
  12780. * @param from defines from which frame should animation start
  12781. * @param to defines until which frame should animation run.
  12782. * @param weight defines the weight to apply to the animation (1.0 by default)
  12783. * @param loop defines if the animation loops
  12784. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12785. * @param onAnimationEnd defines the function to be executed when the animation ends
  12786. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12787. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12788. * @param onAnimationLoop defines the callback to call when an animation loops
  12789. * @returns the animatable object created for this animation
  12790. */
  12791. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12792. /**
  12793. * Will start the animation sequence of a given target
  12794. * @param target defines the target
  12795. * @param from defines from which frame should animation start
  12796. * @param to defines until which frame should animation run.
  12797. * @param loop defines if the animation loops
  12798. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12799. * @param onAnimationEnd defines the function to be executed when the animation ends
  12800. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12801. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12802. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  12803. * @param onAnimationLoop defines the callback to call when an animation loops
  12804. * @returns the animatable object created for this animation
  12805. */
  12806. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12807. /**
  12808. * Will start the animation sequence of a given target and its hierarchy
  12809. * @param target defines the target
  12810. * @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.
  12811. * @param from defines from which frame should animation start
  12812. * @param to defines until which frame should animation run.
  12813. * @param loop defines if the animation loops
  12814. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12815. * @param onAnimationEnd defines the function to be executed when the animation ends
  12816. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12817. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12818. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12819. * @param onAnimationLoop defines the callback to call when an animation loops
  12820. * @returns the list of created animatables
  12821. */
  12822. 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[];
  12823. /**
  12824. * Begin a new animation on a given node
  12825. * @param target defines the target where the animation will take place
  12826. * @param animations defines the list of animations to start
  12827. * @param from defines the initial value
  12828. * @param to defines the final value
  12829. * @param loop defines if you want animation to loop (off by default)
  12830. * @param speedRatio defines the speed ratio to apply to all animations
  12831. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  12832. * @param onAnimationLoop defines the callback to call when an animation loops
  12833. * @returns the list of created animatables
  12834. */
  12835. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  12836. /**
  12837. * Begin a new animation on a given node and its hierarchy
  12838. * @param target defines the root node where the animation will take place
  12839. * @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.
  12840. * @param animations defines the list of animations to start
  12841. * @param from defines the initial value
  12842. * @param to defines the final value
  12843. * @param loop defines if you want animation to loop (off by default)
  12844. * @param speedRatio defines the speed ratio to apply to all animations
  12845. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  12846. * @param onAnimationLoop defines the callback to call when an animation loops
  12847. * @returns the list of animatables created for all nodes
  12848. */
  12849. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  12850. /**
  12851. * Gets the animatable associated with a specific target
  12852. * @param target defines the target of the animatable
  12853. * @returns the required animatable if found
  12854. */
  12855. getAnimatableByTarget(target: any): Nullable<Animatable>;
  12856. /**
  12857. * Gets all animatables associated with a given target
  12858. * @param target defines the target to look animatables for
  12859. * @returns an array of Animatables
  12860. */
  12861. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  12862. /**
  12863. * Stops and removes all animations that have been applied to the scene
  12864. */
  12865. stopAllAnimations(): void;
  12866. }
  12867. interface Bone {
  12868. /**
  12869. * Copy an animation range from another bone
  12870. * @param source defines the source bone
  12871. * @param rangeName defines the range name to copy
  12872. * @param frameOffset defines the frame offset
  12873. * @param rescaleAsRequired defines if rescaling must be applied if required
  12874. * @param skelDimensionsRatio defines the scaling ratio
  12875. * @returns true if operation was successful
  12876. */
  12877. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  12878. }
  12879. }
  12880. declare module BABYLON {
  12881. /**
  12882. * Class used to override all child animations of a given target
  12883. */
  12884. export class AnimationPropertiesOverride {
  12885. /**
  12886. * Gets or sets a value indicating if animation blending must be used
  12887. */
  12888. enableBlending: boolean;
  12889. /**
  12890. * Gets or sets the blending speed to use when enableBlending is true
  12891. */
  12892. blendingSpeed: number;
  12893. /**
  12894. * Gets or sets the default loop mode to use
  12895. */
  12896. loopMode: number;
  12897. }
  12898. }
  12899. declare module BABYLON {
  12900. /**
  12901. * Class used to handle skinning animations
  12902. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  12903. */
  12904. export class Skeleton implements IAnimatable {
  12905. /** defines the skeleton name */
  12906. name: string;
  12907. /** defines the skeleton Id */
  12908. id: string;
  12909. /**
  12910. * Defines the list of child bones
  12911. */
  12912. bones: Bone[];
  12913. /**
  12914. * Defines an estimate of the dimension of the skeleton at rest
  12915. */
  12916. dimensionsAtRest: Vector3;
  12917. /**
  12918. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  12919. */
  12920. needInitialSkinMatrix: boolean;
  12921. /**
  12922. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  12923. */
  12924. overrideMesh: Nullable<AbstractMesh>;
  12925. /**
  12926. * Gets the list of animations attached to this skeleton
  12927. */
  12928. animations: Array<Animation>;
  12929. private _scene;
  12930. private _isDirty;
  12931. private _transformMatrices;
  12932. private _transformMatrixTexture;
  12933. private _meshesWithPoseMatrix;
  12934. private _animatables;
  12935. private _identity;
  12936. private _synchronizedWithMesh;
  12937. private _ranges;
  12938. private _lastAbsoluteTransformsUpdateId;
  12939. private _canUseTextureForBones;
  12940. private _uniqueId;
  12941. /** @hidden */ private _numBonesWithLinkedTransformNode: number;
  12942. /** @hidden */ private _hasWaitingData: Nullable<boolean>;
  12943. /**
  12944. * Specifies if the skeleton should be serialized
  12945. */
  12946. doNotSerialize: boolean;
  12947. private _useTextureToStoreBoneMatrices;
  12948. /**
  12949. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  12950. * Please note that this option is not available if the hardware does not support it
  12951. */
  12952. useTextureToStoreBoneMatrices: boolean;
  12953. private _animationPropertiesOverride;
  12954. /**
  12955. * Gets or sets the animation properties override
  12956. */
  12957. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  12958. /**
  12959. * List of inspectable custom properties (used by the Inspector)
  12960. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  12961. */
  12962. inspectableCustomProperties: IInspectable[];
  12963. /**
  12964. * An observable triggered before computing the skeleton's matrices
  12965. */
  12966. onBeforeComputeObservable: Observable<Skeleton>;
  12967. /**
  12968. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  12969. */
  12970. readonly isUsingTextureForMatrices: boolean;
  12971. /**
  12972. * Gets the unique ID of this skeleton
  12973. */
  12974. readonly uniqueId: number;
  12975. /**
  12976. * Creates a new skeleton
  12977. * @param name defines the skeleton name
  12978. * @param id defines the skeleton Id
  12979. * @param scene defines the hosting scene
  12980. */
  12981. constructor(
  12982. /** defines the skeleton name */
  12983. name: string,
  12984. /** defines the skeleton Id */
  12985. id: string, scene: Scene);
  12986. /**
  12987. * Gets the current object class name.
  12988. * @return the class name
  12989. */
  12990. getClassName(): string;
  12991. /**
  12992. * Returns an array containing the root bones
  12993. * @returns an array containing the root bones
  12994. */
  12995. getChildren(): Array<Bone>;
  12996. /**
  12997. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  12998. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  12999. * @returns a Float32Array containing matrices data
  13000. */
  13001. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13002. /**
  13003. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13004. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13005. * @returns a raw texture containing the data
  13006. */
  13007. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13008. /**
  13009. * Gets the current hosting scene
  13010. * @returns a scene object
  13011. */
  13012. getScene(): Scene;
  13013. /**
  13014. * Gets a string representing the current skeleton data
  13015. * @param fullDetails defines a boolean indicating if we want a verbose version
  13016. * @returns a string representing the current skeleton data
  13017. */
  13018. toString(fullDetails?: boolean): string;
  13019. /**
  13020. * Get bone's index searching by name
  13021. * @param name defines bone's name to search for
  13022. * @return the indice of the bone. Returns -1 if not found
  13023. */
  13024. getBoneIndexByName(name: string): number;
  13025. /**
  13026. * Creater a new animation range
  13027. * @param name defines the name of the range
  13028. * @param from defines the start key
  13029. * @param to defines the end key
  13030. */
  13031. createAnimationRange(name: string, from: number, to: number): void;
  13032. /**
  13033. * Delete a specific animation range
  13034. * @param name defines the name of the range
  13035. * @param deleteFrames defines if frames must be removed as well
  13036. */
  13037. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13038. /**
  13039. * Gets a specific animation range
  13040. * @param name defines the name of the range to look for
  13041. * @returns the requested animation range or null if not found
  13042. */
  13043. getAnimationRange(name: string): Nullable<AnimationRange>;
  13044. /**
  13045. * Gets the list of all animation ranges defined on this skeleton
  13046. * @returns an array
  13047. */
  13048. getAnimationRanges(): Nullable<AnimationRange>[];
  13049. /**
  13050. * Copy animation range from a source skeleton.
  13051. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13052. * @param source defines the source skeleton
  13053. * @param name defines the name of the range to copy
  13054. * @param rescaleAsRequired defines if rescaling must be applied if required
  13055. * @returns true if operation was successful
  13056. */
  13057. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13058. /**
  13059. * Forces the skeleton to go to rest pose
  13060. */
  13061. returnToRest(): void;
  13062. private _getHighestAnimationFrame;
  13063. /**
  13064. * Begin a specific animation range
  13065. * @param name defines the name of the range to start
  13066. * @param loop defines if looping must be turned on (false by default)
  13067. * @param speedRatio defines the speed ratio to apply (1 by default)
  13068. * @param onAnimationEnd defines a callback which will be called when animation will end
  13069. * @returns a new animatable
  13070. */
  13071. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13072. /** @hidden */ private _markAsDirty(): void;
  13073. /** @hidden */ private _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13074. /** @hidden */ private _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13075. private _computeTransformMatrices;
  13076. /**
  13077. * Build all resources required to render a skeleton
  13078. */
  13079. prepare(): void;
  13080. /**
  13081. * Gets the list of animatables currently running for this skeleton
  13082. * @returns an array of animatables
  13083. */
  13084. getAnimatables(): IAnimatable[];
  13085. /**
  13086. * Clone the current skeleton
  13087. * @param name defines the name of the new skeleton
  13088. * @param id defines the id of the new skeleton
  13089. * @returns the new skeleton
  13090. */
  13091. clone(name: string, id: string): Skeleton;
  13092. /**
  13093. * Enable animation blending for this skeleton
  13094. * @param blendingSpeed defines the blending speed to apply
  13095. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13096. */
  13097. enableBlending(blendingSpeed?: number): void;
  13098. /**
  13099. * Releases all resources associated with the current skeleton
  13100. */
  13101. dispose(): void;
  13102. /**
  13103. * Serialize the skeleton in a JSON object
  13104. * @returns a JSON object
  13105. */
  13106. serialize(): any;
  13107. /**
  13108. * Creates a new skeleton from serialized data
  13109. * @param parsedSkeleton defines the serialized data
  13110. * @param scene defines the hosting scene
  13111. * @returns a new skeleton
  13112. */
  13113. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13114. /**
  13115. * Compute all node absolute transforms
  13116. * @param forceUpdate defines if computation must be done even if cache is up to date
  13117. */
  13118. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13119. /**
  13120. * Gets the root pose matrix
  13121. * @returns a matrix
  13122. */
  13123. getPoseMatrix(): Nullable<Matrix>;
  13124. /**
  13125. * Sorts bones per internal index
  13126. */
  13127. sortBones(): void;
  13128. private _sortBones;
  13129. }
  13130. }
  13131. declare module BABYLON {
  13132. /**
  13133. * Class used to store bone information
  13134. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13135. */
  13136. export class Bone extends Node {
  13137. /**
  13138. * defines the bone name
  13139. */
  13140. name: string;
  13141. private static _tmpVecs;
  13142. private static _tmpQuat;
  13143. private static _tmpMats;
  13144. /**
  13145. * Gets the list of child bones
  13146. */
  13147. children: Bone[];
  13148. /** Gets the animations associated with this bone */
  13149. animations: Animation[];
  13150. /**
  13151. * Gets or sets bone length
  13152. */
  13153. length: number;
  13154. /**
  13155. * @hidden Internal only
  13156. * Set this value to map this bone to a different index in the transform matrices
  13157. * Set this value to -1 to exclude the bone from the transform matrices
  13158. */ private _index: Nullable<number>;
  13159. private _skeleton;
  13160. private _localMatrix;
  13161. private _restPose;
  13162. private _baseMatrix;
  13163. private _absoluteTransform;
  13164. private _invertedAbsoluteTransform;
  13165. private _parent;
  13166. private _scalingDeterminant;
  13167. private _worldTransform;
  13168. private _localScaling;
  13169. private _localRotation;
  13170. private _localPosition;
  13171. private _needToDecompose;
  13172. private _needToCompose;
  13173. /** @hidden */ private _linkedTransformNode: Nullable<TransformNode>;
  13174. /** @hidden */ private _waitingTransformNodeId: Nullable<string>;
  13175. /** @hidden */
  13176. /** @hidden */ private _matrix: Matrix;
  13177. /**
  13178. * Create a new bone
  13179. * @param name defines the bone name
  13180. * @param skeleton defines the parent skeleton
  13181. * @param parentBone defines the parent (can be null if the bone is the root)
  13182. * @param localMatrix defines the local matrix
  13183. * @param restPose defines the rest pose matrix
  13184. * @param baseMatrix defines the base matrix
  13185. * @param index defines index of the bone in the hiearchy
  13186. */
  13187. constructor(
  13188. /**
  13189. * defines the bone name
  13190. */
  13191. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13192. /**
  13193. * Gets the current object class name.
  13194. * @return the class name
  13195. */
  13196. getClassName(): string;
  13197. /**
  13198. * Gets the parent skeleton
  13199. * @returns a skeleton
  13200. */
  13201. getSkeleton(): Skeleton;
  13202. /**
  13203. * Gets parent bone
  13204. * @returns a bone or null if the bone is the root of the bone hierarchy
  13205. */
  13206. getParent(): Nullable<Bone>;
  13207. /**
  13208. * Returns an array containing the root bones
  13209. * @returns an array containing the root bones
  13210. */
  13211. getChildren(): Array<Bone>;
  13212. /**
  13213. * Sets the parent bone
  13214. * @param parent defines the parent (can be null if the bone is the root)
  13215. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13216. */
  13217. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13218. /**
  13219. * Gets the local matrix
  13220. * @returns a matrix
  13221. */
  13222. getLocalMatrix(): Matrix;
  13223. /**
  13224. * Gets the base matrix (initial matrix which remains unchanged)
  13225. * @returns a matrix
  13226. */
  13227. getBaseMatrix(): Matrix;
  13228. /**
  13229. * Gets the rest pose matrix
  13230. * @returns a matrix
  13231. */
  13232. getRestPose(): Matrix;
  13233. /**
  13234. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13235. */
  13236. getWorldMatrix(): Matrix;
  13237. /**
  13238. * Sets the local matrix to rest pose matrix
  13239. */
  13240. returnToRest(): void;
  13241. /**
  13242. * Gets the inverse of the absolute transform matrix.
  13243. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13244. * @returns a matrix
  13245. */
  13246. getInvertedAbsoluteTransform(): Matrix;
  13247. /**
  13248. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13249. * @returns a matrix
  13250. */
  13251. getAbsoluteTransform(): Matrix;
  13252. /**
  13253. * Links with the given transform node.
  13254. * The local matrix of this bone is copied from the transform node every frame.
  13255. * @param transformNode defines the transform node to link to
  13256. */
  13257. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13258. /**
  13259. * Gets the node used to drive the bone's transformation
  13260. * @returns a transform node or null
  13261. */
  13262. getTransformNode(): Nullable<TransformNode>;
  13263. /** Gets or sets current position (in local space) */
  13264. position: Vector3;
  13265. /** Gets or sets current rotation (in local space) */
  13266. rotation: Vector3;
  13267. /** Gets or sets current rotation quaternion (in local space) */
  13268. rotationQuaternion: Quaternion;
  13269. /** Gets or sets current scaling (in local space) */
  13270. scaling: Vector3;
  13271. /**
  13272. * Gets the animation properties override
  13273. */
  13274. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13275. private _decompose;
  13276. private _compose;
  13277. /**
  13278. * Update the base and local matrices
  13279. * @param matrix defines the new base or local matrix
  13280. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13281. * @param updateLocalMatrix defines if the local matrix should be updated
  13282. */
  13283. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13284. /** @hidden */ private _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13285. /**
  13286. * Flag the bone as dirty (Forcing it to update everything)
  13287. */
  13288. markAsDirty(): void;
  13289. /** @hidden */ private _markAsDirtyAndCompose(): void;
  13290. private _markAsDirtyAndDecompose;
  13291. /**
  13292. * Translate the bone in local or world space
  13293. * @param vec The amount to translate the bone
  13294. * @param space The space that the translation is in
  13295. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13296. */
  13297. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13298. /**
  13299. * Set the postion of the bone in local or world space
  13300. * @param position The position to set the bone
  13301. * @param space The space that the position is in
  13302. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13303. */
  13304. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13305. /**
  13306. * Set the absolute position of the bone (world space)
  13307. * @param position The position to set the bone
  13308. * @param mesh The mesh that this bone is attached to
  13309. */
  13310. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13311. /**
  13312. * Scale the bone on the x, y and z axes (in local space)
  13313. * @param x The amount to scale the bone on the x axis
  13314. * @param y The amount to scale the bone on the y axis
  13315. * @param z The amount to scale the bone on the z axis
  13316. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13317. */
  13318. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13319. /**
  13320. * Set the bone scaling in local space
  13321. * @param scale defines the scaling vector
  13322. */
  13323. setScale(scale: Vector3): void;
  13324. /**
  13325. * Gets the current scaling in local space
  13326. * @returns the current scaling vector
  13327. */
  13328. getScale(): Vector3;
  13329. /**
  13330. * Gets the current scaling in local space and stores it in a target vector
  13331. * @param result defines the target vector
  13332. */
  13333. getScaleToRef(result: Vector3): void;
  13334. /**
  13335. * Set the yaw, pitch, and roll of the bone in local or world space
  13336. * @param yaw The rotation of the bone on the y axis
  13337. * @param pitch The rotation of the bone on the x axis
  13338. * @param roll The rotation of the bone on the z axis
  13339. * @param space The space that the axes of rotation are in
  13340. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13341. */
  13342. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13343. /**
  13344. * Add a rotation to the bone on an axis in local or world space
  13345. * @param axis The axis to rotate the bone on
  13346. * @param amount The amount to rotate the bone
  13347. * @param space The space that the axis is in
  13348. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13349. */
  13350. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13351. /**
  13352. * Set the rotation of the bone to a particular axis angle in local or world space
  13353. * @param axis The axis to rotate the bone on
  13354. * @param angle The angle that the bone should be rotated to
  13355. * @param space The space that the axis is in
  13356. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13357. */
  13358. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13359. /**
  13360. * Set the euler rotation of the bone in local of world space
  13361. * @param rotation The euler rotation that the bone should be set to
  13362. * @param space The space that the rotation is in
  13363. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13364. */
  13365. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13366. /**
  13367. * Set the quaternion rotation of the bone in local of world space
  13368. * @param quat The quaternion rotation that the bone should be set to
  13369. * @param space The space that the rotation is in
  13370. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13371. */
  13372. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13373. /**
  13374. * Set the rotation matrix of the bone in local of world space
  13375. * @param rotMat The rotation matrix that the bone should be set to
  13376. * @param space The space that the rotation is in
  13377. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13378. */
  13379. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13380. private _rotateWithMatrix;
  13381. private _getNegativeRotationToRef;
  13382. /**
  13383. * Get the position of the bone in local or world space
  13384. * @param space The space that the returned position is in
  13385. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13386. * @returns The position of the bone
  13387. */
  13388. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13389. /**
  13390. * Copy the position of the bone to a vector3 in local or world space
  13391. * @param space The space that the returned position is in
  13392. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13393. * @param result The vector3 to copy the position to
  13394. */
  13395. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13396. /**
  13397. * Get the absolute position of the bone (world space)
  13398. * @param mesh The mesh that this bone is attached to
  13399. * @returns The absolute position of the bone
  13400. */
  13401. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13402. /**
  13403. * Copy the absolute position of the bone (world space) to the result param
  13404. * @param mesh The mesh that this bone is attached to
  13405. * @param result The vector3 to copy the absolute position to
  13406. */
  13407. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13408. /**
  13409. * Compute the absolute transforms of this bone and its children
  13410. */
  13411. computeAbsoluteTransforms(): void;
  13412. /**
  13413. * Get the world direction from an axis that is in the local space of the bone
  13414. * @param localAxis The local direction that is used to compute the world direction
  13415. * @param mesh The mesh that this bone is attached to
  13416. * @returns The world direction
  13417. */
  13418. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13419. /**
  13420. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13421. * @param localAxis The local direction that is used to compute the world direction
  13422. * @param mesh The mesh that this bone is attached to
  13423. * @param result The vector3 that the world direction will be copied to
  13424. */
  13425. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13426. /**
  13427. * Get the euler rotation of the bone in local or world space
  13428. * @param space The space that the rotation should be in
  13429. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13430. * @returns The euler rotation
  13431. */
  13432. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13433. /**
  13434. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13435. * @param space The space that the rotation should be in
  13436. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13437. * @param result The vector3 that the rotation should be copied to
  13438. */
  13439. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13440. /**
  13441. * Get the quaternion rotation of the bone in either local or world space
  13442. * @param space The space that the rotation should be in
  13443. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13444. * @returns The quaternion rotation
  13445. */
  13446. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13447. /**
  13448. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13449. * @param space The space that the rotation should be in
  13450. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13451. * @param result The quaternion that the rotation should be copied to
  13452. */
  13453. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13454. /**
  13455. * Get the rotation matrix of the bone in local or world space
  13456. * @param space The space that the rotation should be in
  13457. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13458. * @returns The rotation matrix
  13459. */
  13460. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13461. /**
  13462. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13463. * @param space The space that the rotation should be in
  13464. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13465. * @param result The quaternion that the rotation should be copied to
  13466. */
  13467. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13468. /**
  13469. * Get the world position of a point that is in the local space of the bone
  13470. * @param position The local position
  13471. * @param mesh The mesh that this bone is attached to
  13472. * @returns The world position
  13473. */
  13474. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13475. /**
  13476. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13477. * @param position The local position
  13478. * @param mesh The mesh that this bone is attached to
  13479. * @param result The vector3 that the world position should be copied to
  13480. */
  13481. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13482. /**
  13483. * Get the local position of a point that is in world space
  13484. * @param position The world position
  13485. * @param mesh The mesh that this bone is attached to
  13486. * @returns The local position
  13487. */
  13488. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13489. /**
  13490. * Get the local position of a point that is in world space and copy it to the result param
  13491. * @param position The world position
  13492. * @param mesh The mesh that this bone is attached to
  13493. * @param result The vector3 that the local position should be copied to
  13494. */
  13495. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13496. }
  13497. }
  13498. declare module BABYLON {
  13499. /**
  13500. * 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.
  13501. * @see https://doc.babylonjs.com/how_to/transformnode
  13502. */
  13503. export class TransformNode extends Node {
  13504. /**
  13505. * Object will not rotate to face the camera
  13506. */
  13507. static BILLBOARDMODE_NONE: number;
  13508. /**
  13509. * Object will rotate to face the camera but only on the x axis
  13510. */
  13511. static BILLBOARDMODE_X: number;
  13512. /**
  13513. * Object will rotate to face the camera but only on the y axis
  13514. */
  13515. static BILLBOARDMODE_Y: number;
  13516. /**
  13517. * Object will rotate to face the camera but only on the z axis
  13518. */
  13519. static BILLBOARDMODE_Z: number;
  13520. /**
  13521. * Object will rotate to face the camera
  13522. */
  13523. static BILLBOARDMODE_ALL: number;
  13524. /**
  13525. * Object will rotate to face the camera's position instead of orientation
  13526. */
  13527. static BILLBOARDMODE_USE_POSITION: number;
  13528. private _forward;
  13529. private _forwardInverted;
  13530. private _up;
  13531. private _right;
  13532. private _rightInverted;
  13533. private _position;
  13534. private _rotation;
  13535. private _rotationQuaternion;
  13536. protected _scaling: Vector3;
  13537. protected _isDirty: boolean;
  13538. private _transformToBoneReferal;
  13539. private _isAbsoluteSynced;
  13540. private _billboardMode;
  13541. /**
  13542. * Gets or sets the billboard mode. Default is 0.
  13543. *
  13544. * | Value | Type | Description |
  13545. * | --- | --- | --- |
  13546. * | 0 | BILLBOARDMODE_NONE | |
  13547. * | 1 | BILLBOARDMODE_X | |
  13548. * | 2 | BILLBOARDMODE_Y | |
  13549. * | 4 | BILLBOARDMODE_Z | |
  13550. * | 7 | BILLBOARDMODE_ALL | |
  13551. *
  13552. */
  13553. billboardMode: number;
  13554. private _preserveParentRotationForBillboard;
  13555. /**
  13556. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13557. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13558. */
  13559. preserveParentRotationForBillboard: boolean;
  13560. /**
  13561. * 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
  13562. */
  13563. scalingDeterminant: number;
  13564. private _infiniteDistance;
  13565. /**
  13566. * Gets or sets the distance of the object to max, often used by skybox
  13567. */
  13568. infiniteDistance: boolean;
  13569. /**
  13570. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13571. * By default the system will update normals to compensate
  13572. */
  13573. ignoreNonUniformScaling: boolean;
  13574. /**
  13575. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  13576. */
  13577. reIntegrateRotationIntoRotationQuaternion: boolean;
  13578. /** @hidden */ private _poseMatrix: Nullable<Matrix>;
  13579. /** @hidden */ private _localMatrix: Matrix;
  13580. private _usePivotMatrix;
  13581. private _absolutePosition;
  13582. private _absoluteScaling;
  13583. private _absoluteRotationQuaternion;
  13584. private _pivotMatrix;
  13585. private _pivotMatrixInverse;
  13586. protected _postMultiplyPivotMatrix: boolean;
  13587. protected _isWorldMatrixFrozen: boolean;
  13588. /** @hidden */ private _indexInSceneTransformNodesArray: number;
  13589. /**
  13590. * An event triggered after the world matrix is updated
  13591. */
  13592. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13593. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13594. /**
  13595. * Gets a string identifying the name of the class
  13596. * @returns "TransformNode" string
  13597. */
  13598. getClassName(): string;
  13599. /**
  13600. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13601. */
  13602. position: Vector3;
  13603. /**
  13604. * 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)).
  13605. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13606. */
  13607. rotation: Vector3;
  13608. /**
  13609. * 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)).
  13610. */
  13611. scaling: Vector3;
  13612. /**
  13613. * 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).
  13614. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13615. */
  13616. rotationQuaternion: Nullable<Quaternion>;
  13617. /**
  13618. * The forward direction of that transform in world space.
  13619. */
  13620. readonly forward: Vector3;
  13621. /**
  13622. * The up direction of that transform in world space.
  13623. */
  13624. readonly up: Vector3;
  13625. /**
  13626. * The right direction of that transform in world space.
  13627. */
  13628. readonly right: Vector3;
  13629. /**
  13630. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13631. * @param matrix the matrix to copy the pose from
  13632. * @returns this TransformNode.
  13633. */
  13634. updatePoseMatrix(matrix: Matrix): TransformNode;
  13635. /**
  13636. * Returns the mesh Pose matrix.
  13637. * @returns the pose matrix
  13638. */
  13639. getPoseMatrix(): Matrix;
  13640. /** @hidden */ private _isSynchronized(): boolean;
  13641. /** @hidden */ private _initCache(): void;
  13642. /**
  13643. * Flag the transform node as dirty (Forcing it to update everything)
  13644. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13645. * @returns this transform node
  13646. */
  13647. markAsDirty(property: string): TransformNode;
  13648. /**
  13649. * Returns the current mesh absolute position.
  13650. * Returns a Vector3.
  13651. */
  13652. readonly absolutePosition: Vector3;
  13653. /**
  13654. * Returns the current mesh absolute scaling.
  13655. * Returns a Vector3.
  13656. */
  13657. readonly absoluteScaling: Vector3;
  13658. /**
  13659. * Returns the current mesh absolute rotation.
  13660. * Returns a Quaternion.
  13661. */
  13662. readonly absoluteRotationQuaternion: Quaternion;
  13663. /**
  13664. * Sets a new matrix to apply before all other transformation
  13665. * @param matrix defines the transform matrix
  13666. * @returns the current TransformNode
  13667. */
  13668. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13669. /**
  13670. * Sets a new pivot matrix to the current node
  13671. * @param matrix defines the new pivot matrix to use
  13672. * @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
  13673. * @returns the current TransformNode
  13674. */
  13675. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13676. /**
  13677. * Returns the mesh pivot matrix.
  13678. * Default : Identity.
  13679. * @returns the matrix
  13680. */
  13681. getPivotMatrix(): Matrix;
  13682. /**
  13683. * Instantiate (when possible) or clone that node with its hierarchy
  13684. * @param newParent defines the new parent to use for the instance (or clone)
  13685. * @returns an instance (or a clone) of the current node with its hiearchy
  13686. */
  13687. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  13688. /**
  13689. * Prevents the World matrix to be computed any longer
  13690. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13691. * @returns the TransformNode.
  13692. */
  13693. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13694. /**
  13695. * Allows back the World matrix computation.
  13696. * @returns the TransformNode.
  13697. */
  13698. unfreezeWorldMatrix(): this;
  13699. /**
  13700. * True if the World matrix has been frozen.
  13701. */
  13702. readonly isWorldMatrixFrozen: boolean;
  13703. /**
  13704. * Retuns the mesh absolute position in the World.
  13705. * @returns a Vector3.
  13706. */
  13707. getAbsolutePosition(): Vector3;
  13708. /**
  13709. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13710. * @param absolutePosition the absolute position to set
  13711. * @returns the TransformNode.
  13712. */
  13713. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13714. /**
  13715. * Sets the mesh position in its local space.
  13716. * @param vector3 the position to set in localspace
  13717. * @returns the TransformNode.
  13718. */
  13719. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13720. /**
  13721. * Returns the mesh position in the local space from the current World matrix values.
  13722. * @returns a new Vector3.
  13723. */
  13724. getPositionExpressedInLocalSpace(): Vector3;
  13725. /**
  13726. * Translates the mesh along the passed Vector3 in its local space.
  13727. * @param vector3 the distance to translate in localspace
  13728. * @returns the TransformNode.
  13729. */
  13730. locallyTranslate(vector3: Vector3): TransformNode;
  13731. private static _lookAtVectorCache;
  13732. /**
  13733. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13734. * @param targetPoint the position (must be in same space as current mesh) to look at
  13735. * @param yawCor optional yaw (y-axis) correction in radians
  13736. * @param pitchCor optional pitch (x-axis) correction in radians
  13737. * @param rollCor optional roll (z-axis) correction in radians
  13738. * @param space the choosen space of the target
  13739. * @returns the TransformNode.
  13740. */
  13741. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13742. /**
  13743. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13744. * This Vector3 is expressed in the World space.
  13745. * @param localAxis axis to rotate
  13746. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13747. */
  13748. getDirection(localAxis: Vector3): Vector3;
  13749. /**
  13750. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13751. * localAxis is expressed in the mesh local space.
  13752. * result is computed in the Wordl space from the mesh World matrix.
  13753. * @param localAxis axis to rotate
  13754. * @param result the resulting transformnode
  13755. * @returns this TransformNode.
  13756. */
  13757. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13758. /**
  13759. * Sets this transform node rotation to the given local axis.
  13760. * @param localAxis the axis in local space
  13761. * @param yawCor optional yaw (y-axis) correction in radians
  13762. * @param pitchCor optional pitch (x-axis) correction in radians
  13763. * @param rollCor optional roll (z-axis) correction in radians
  13764. * @returns this TransformNode
  13765. */
  13766. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13767. /**
  13768. * Sets a new pivot point to the current node
  13769. * @param point defines the new pivot point to use
  13770. * @param space defines if the point is in world or local space (local by default)
  13771. * @returns the current TransformNode
  13772. */
  13773. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13774. /**
  13775. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13776. * @returns the pivot point
  13777. */
  13778. getPivotPoint(): Vector3;
  13779. /**
  13780. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13781. * @param result the vector3 to store the result
  13782. * @returns this TransformNode.
  13783. */
  13784. getPivotPointToRef(result: Vector3): TransformNode;
  13785. /**
  13786. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13787. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13788. */
  13789. getAbsolutePivotPoint(): Vector3;
  13790. /**
  13791. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13792. * @param result vector3 to store the result
  13793. * @returns this TransformNode.
  13794. */
  13795. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13796. /**
  13797. * Defines the passed node as the parent of the current node.
  13798. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13799. * @see https://doc.babylonjs.com/how_to/parenting
  13800. * @param node the node ot set as the parent
  13801. * @returns this TransformNode.
  13802. */
  13803. setParent(node: Nullable<Node>): TransformNode;
  13804. private _nonUniformScaling;
  13805. /**
  13806. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13807. */
  13808. readonly nonUniformScaling: boolean;
  13809. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  13810. /**
  13811. * Attach the current TransformNode to another TransformNode associated with a bone
  13812. * @param bone Bone affecting the TransformNode
  13813. * @param affectedTransformNode TransformNode associated with the bone
  13814. * @returns this object
  13815. */
  13816. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13817. /**
  13818. * Detach the transform node if its associated with a bone
  13819. * @returns this object
  13820. */
  13821. detachFromBone(): TransformNode;
  13822. private static _rotationAxisCache;
  13823. /**
  13824. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13825. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13826. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13827. * The passed axis is also normalized.
  13828. * @param axis the axis to rotate around
  13829. * @param amount the amount to rotate in radians
  13830. * @param space Space to rotate in (Default: local)
  13831. * @returns the TransformNode.
  13832. */
  13833. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13834. /**
  13835. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13836. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13837. * The passed axis is also normalized. .
  13838. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13839. * @param point the point to rotate around
  13840. * @param axis the axis to rotate around
  13841. * @param amount the amount to rotate in radians
  13842. * @returns the TransformNode
  13843. */
  13844. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13845. /**
  13846. * Translates the mesh along the axis vector for the passed distance in the given space.
  13847. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13848. * @param axis the axis to translate in
  13849. * @param distance the distance to translate
  13850. * @param space Space to rotate in (Default: local)
  13851. * @returns the TransformNode.
  13852. */
  13853. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13854. /**
  13855. * Adds a rotation step to the mesh current rotation.
  13856. * x, y, z are Euler angles expressed in radians.
  13857. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13858. * This means this rotation is made in the mesh local space only.
  13859. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13860. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13861. * ```javascript
  13862. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13863. * ```
  13864. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13865. * 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.
  13866. * @param x Rotation to add
  13867. * @param y Rotation to add
  13868. * @param z Rotation to add
  13869. * @returns the TransformNode.
  13870. */
  13871. addRotation(x: number, y: number, z: number): TransformNode;
  13872. /**
  13873. * @hidden
  13874. */
  13875. protected _getEffectiveParent(): Nullable<Node>;
  13876. /**
  13877. * Computes the world matrix of the node
  13878. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13879. * @returns the world matrix
  13880. */
  13881. computeWorldMatrix(force?: boolean): Matrix;
  13882. protected _afterComputeWorldMatrix(): void;
  13883. /**
  13884. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  13885. * @param func callback function to add
  13886. *
  13887. * @returns the TransformNode.
  13888. */
  13889. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13890. /**
  13891. * Removes a registered callback function.
  13892. * @param func callback function to remove
  13893. * @returns the TransformNode.
  13894. */
  13895. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13896. /**
  13897. * Gets the position of the current mesh in camera space
  13898. * @param camera defines the camera to use
  13899. * @returns a position
  13900. */
  13901. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  13902. /**
  13903. * Returns the distance from the mesh to the active camera
  13904. * @param camera defines the camera to use
  13905. * @returns the distance
  13906. */
  13907. getDistanceToCamera(camera?: Nullable<Camera>): number;
  13908. /**
  13909. * Clone the current transform node
  13910. * @param name Name of the new clone
  13911. * @param newParent New parent for the clone
  13912. * @param doNotCloneChildren Do not clone children hierarchy
  13913. * @returns the new transform node
  13914. */
  13915. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  13916. /**
  13917. * Serializes the objects information.
  13918. * @param currentSerializationObject defines the object to serialize in
  13919. * @returns the serialized object
  13920. */
  13921. serialize(currentSerializationObject?: any): any;
  13922. /**
  13923. * Returns a new TransformNode object parsed from the source provided.
  13924. * @param parsedTransformNode is the source.
  13925. * @param scene the scne the object belongs to
  13926. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  13927. * @returns a new TransformNode object parsed from the source provided.
  13928. */
  13929. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  13930. /**
  13931. * Get all child-transformNodes of this node
  13932. * @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
  13933. * @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
  13934. * @returns an array of TransformNode
  13935. */
  13936. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  13937. /**
  13938. * Releases resources associated with this transform node.
  13939. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13940. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13941. */
  13942. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13943. /**
  13944. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  13945. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  13946. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  13947. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  13948. * @returns the current mesh
  13949. */
  13950. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  13951. private _syncAbsoluteScalingAndRotation;
  13952. }
  13953. }
  13954. declare module BABYLON {
  13955. /**
  13956. * Defines the types of pose enabled controllers that are supported
  13957. */
  13958. export enum PoseEnabledControllerType {
  13959. /**
  13960. * HTC Vive
  13961. */
  13962. VIVE = 0,
  13963. /**
  13964. * Oculus Rift
  13965. */
  13966. OCULUS = 1,
  13967. /**
  13968. * Windows mixed reality
  13969. */
  13970. WINDOWS = 2,
  13971. /**
  13972. * Samsung gear VR
  13973. */
  13974. GEAR_VR = 3,
  13975. /**
  13976. * Google Daydream
  13977. */
  13978. DAYDREAM = 4,
  13979. /**
  13980. * Generic
  13981. */
  13982. GENERIC = 5
  13983. }
  13984. /**
  13985. * Defines the MutableGamepadButton interface for the state of a gamepad button
  13986. */
  13987. export interface MutableGamepadButton {
  13988. /**
  13989. * Value of the button/trigger
  13990. */
  13991. value: number;
  13992. /**
  13993. * If the button/trigger is currently touched
  13994. */
  13995. touched: boolean;
  13996. /**
  13997. * If the button/trigger is currently pressed
  13998. */
  13999. pressed: boolean;
  14000. }
  14001. /**
  14002. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14003. * @hidden
  14004. */
  14005. export interface ExtendedGamepadButton extends GamepadButton {
  14006. /**
  14007. * If the button/trigger is currently pressed
  14008. */
  14009. readonly pressed: boolean;
  14010. /**
  14011. * If the button/trigger is currently touched
  14012. */
  14013. readonly touched: boolean;
  14014. /**
  14015. * Value of the button/trigger
  14016. */
  14017. readonly value: number;
  14018. }
  14019. /** @hidden */
  14020. export interface _GamePadFactory {
  14021. /**
  14022. * Returns wether or not the current gamepad can be created for this type of controller.
  14023. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14024. * @returns true if it can be created, otherwise false
  14025. */
  14026. canCreate(gamepadInfo: any): boolean;
  14027. /**
  14028. * Creates a new instance of the Gamepad.
  14029. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14030. * @returns the new gamepad instance
  14031. */
  14032. create(gamepadInfo: any): Gamepad;
  14033. }
  14034. /**
  14035. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14036. */
  14037. export class PoseEnabledControllerHelper {
  14038. /** @hidden */ private static _ControllerFactories: _GamePadFactory[];
  14039. /** @hidden */ private static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14040. /**
  14041. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14042. * @param vrGamepad the gamepad to initialized
  14043. * @returns a vr controller of the type the gamepad identified as
  14044. */
  14045. static InitiateController(vrGamepad: any): Gamepad;
  14046. }
  14047. /**
  14048. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14049. */
  14050. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14051. /**
  14052. * If the controller is used in a webXR session
  14053. */
  14054. isXR: boolean;
  14055. private _deviceRoomPosition;
  14056. private _deviceRoomRotationQuaternion;
  14057. /**
  14058. * The device position in babylon space
  14059. */
  14060. devicePosition: Vector3;
  14061. /**
  14062. * The device rotation in babylon space
  14063. */
  14064. deviceRotationQuaternion: Quaternion;
  14065. /**
  14066. * The scale factor of the device in babylon space
  14067. */
  14068. deviceScaleFactor: number;
  14069. /**
  14070. * (Likely devicePosition should be used instead) The device position in its room space
  14071. */
  14072. position: Vector3;
  14073. /**
  14074. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14075. */
  14076. rotationQuaternion: Quaternion;
  14077. /**
  14078. * The type of controller (Eg. Windows mixed reality)
  14079. */
  14080. controllerType: PoseEnabledControllerType;
  14081. protected _calculatedPosition: Vector3;
  14082. private _calculatedRotation;
  14083. /**
  14084. * The raw pose from the device
  14085. */
  14086. rawPose: DevicePose;
  14087. private _trackPosition;
  14088. private _maxRotationDistFromHeadset;
  14089. private _draggedRoomRotation;
  14090. /**
  14091. * @hidden
  14092. */ private _disableTrackPosition(fixedPosition: Vector3): void;
  14093. /**
  14094. * Internal, the mesh attached to the controller
  14095. * @hidden
  14096. */ private _mesh: Nullable<AbstractMesh>;
  14097. private _poseControlledCamera;
  14098. private _leftHandSystemQuaternion;
  14099. /**
  14100. * Internal, matrix used to convert room space to babylon space
  14101. * @hidden
  14102. */ private _deviceToWorld: Matrix;
  14103. /**
  14104. * Node to be used when casting a ray from the controller
  14105. * @hidden
  14106. */ private _pointingPoseNode: Nullable<TransformNode>;
  14107. /**
  14108. * Name of the child mesh that can be used to cast a ray from the controller
  14109. */
  14110. static readonly POINTING_POSE: string;
  14111. /**
  14112. * Creates a new PoseEnabledController from a gamepad
  14113. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14114. */
  14115. constructor(browserGamepad: any);
  14116. private _workingMatrix;
  14117. /**
  14118. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14119. */
  14120. update(): void;
  14121. /**
  14122. * Updates only the pose device and mesh without doing any button event checking
  14123. */
  14124. protected _updatePoseAndMesh(): void;
  14125. /**
  14126. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14127. * @param poseData raw pose fromthe device
  14128. */
  14129. updateFromDevice(poseData: DevicePose): void;
  14130. /**
  14131. * @hidden
  14132. */ private _meshAttachedObservable: Observable<AbstractMesh>;
  14133. /**
  14134. * Attaches a mesh to the controller
  14135. * @param mesh the mesh to be attached
  14136. */
  14137. attachToMesh(mesh: AbstractMesh): void;
  14138. /**
  14139. * Attaches the controllers mesh to a camera
  14140. * @param camera the camera the mesh should be attached to
  14141. */
  14142. attachToPoseControlledCamera(camera: TargetCamera): void;
  14143. /**
  14144. * Disposes of the controller
  14145. */
  14146. dispose(): void;
  14147. /**
  14148. * The mesh that is attached to the controller
  14149. */
  14150. readonly mesh: Nullable<AbstractMesh>;
  14151. /**
  14152. * Gets the ray of the controller in the direction the controller is pointing
  14153. * @param length the length the resulting ray should be
  14154. * @returns a ray in the direction the controller is pointing
  14155. */
  14156. getForwardRay(length?: number): Ray;
  14157. }
  14158. }
  14159. declare module BABYLON {
  14160. /**
  14161. * Defines the WebVRController object that represents controllers tracked in 3D space
  14162. */
  14163. export abstract class WebVRController extends PoseEnabledController {
  14164. /**
  14165. * Internal, the default controller model for the controller
  14166. */
  14167. protected _defaultModel: AbstractMesh;
  14168. /**
  14169. * Fired when the trigger state has changed
  14170. */
  14171. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14172. /**
  14173. * Fired when the main button state has changed
  14174. */
  14175. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14176. /**
  14177. * Fired when the secondary button state has changed
  14178. */
  14179. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14180. /**
  14181. * Fired when the pad state has changed
  14182. */
  14183. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14184. /**
  14185. * Fired when controllers stick values have changed
  14186. */
  14187. onPadValuesChangedObservable: Observable<StickValues>;
  14188. /**
  14189. * Array of button availible on the controller
  14190. */
  14191. protected _buttons: Array<MutableGamepadButton>;
  14192. private _onButtonStateChange;
  14193. /**
  14194. * Fired when a controller button's state has changed
  14195. * @param callback the callback containing the button that was modified
  14196. */
  14197. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14198. /**
  14199. * X and Y axis corresponding to the controllers joystick
  14200. */
  14201. pad: StickValues;
  14202. /**
  14203. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14204. */
  14205. hand: string;
  14206. /**
  14207. * The default controller model for the controller
  14208. */
  14209. readonly defaultModel: AbstractMesh;
  14210. /**
  14211. * Creates a new WebVRController from a gamepad
  14212. * @param vrGamepad the gamepad that the WebVRController should be created from
  14213. */
  14214. constructor(vrGamepad: any);
  14215. /**
  14216. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14217. */
  14218. update(): void;
  14219. /**
  14220. * Function to be called when a button is modified
  14221. */
  14222. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14223. /**
  14224. * Loads a mesh and attaches it to the controller
  14225. * @param scene the scene the mesh should be added to
  14226. * @param meshLoaded callback for when the mesh has been loaded
  14227. */
  14228. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14229. private _setButtonValue;
  14230. private _changes;
  14231. private _checkChanges;
  14232. /**
  14233. * Disposes of th webVRCOntroller
  14234. */
  14235. dispose(): void;
  14236. }
  14237. }
  14238. declare module BABYLON {
  14239. /**
  14240. * The HemisphericLight simulates the ambient environment light,
  14241. * so the passed direction is the light reflection direction, not the incoming direction.
  14242. */
  14243. export class HemisphericLight extends Light {
  14244. /**
  14245. * The groundColor is the light in the opposite direction to the one specified during creation.
  14246. * 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.
  14247. */
  14248. groundColor: Color3;
  14249. /**
  14250. * The light reflection direction, not the incoming direction.
  14251. */
  14252. direction: Vector3;
  14253. /**
  14254. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14255. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14256. * The HemisphericLight can't cast shadows.
  14257. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14258. * @param name The friendly name of the light
  14259. * @param direction The direction of the light reflection
  14260. * @param scene The scene the light belongs to
  14261. */
  14262. constructor(name: string, direction: Vector3, scene: Scene);
  14263. protected _buildUniformLayout(): void;
  14264. /**
  14265. * Returns the string "HemisphericLight".
  14266. * @return The class name
  14267. */
  14268. getClassName(): string;
  14269. /**
  14270. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14271. * Returns the updated direction.
  14272. * @param target The target the direction should point to
  14273. * @return The computed direction
  14274. */
  14275. setDirectionToTarget(target: Vector3): Vector3;
  14276. /**
  14277. * Returns the shadow generator associated to the light.
  14278. * @returns Always null for hemispheric lights because it does not support shadows.
  14279. */
  14280. getShadowGenerator(): Nullable<IShadowGenerator>;
  14281. /**
  14282. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14283. * @param effect The effect to update
  14284. * @param lightIndex The index of the light in the effect to update
  14285. * @returns The hemispheric light
  14286. */
  14287. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14288. /**
  14289. * Computes the world matrix of the node
  14290. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14291. * @param useWasUpdatedFlag defines a reserved property
  14292. * @returns the world matrix
  14293. */
  14294. computeWorldMatrix(): Matrix;
  14295. /**
  14296. * Returns the integer 3.
  14297. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14298. */
  14299. getTypeID(): number;
  14300. /**
  14301. * Prepares the list of defines specific to the light type.
  14302. * @param defines the list of defines
  14303. * @param lightIndex defines the index of the light for the effect
  14304. */
  14305. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14306. }
  14307. }
  14308. declare module BABYLON {
  14309. /** @hidden */
  14310. export var vrMultiviewToSingleviewPixelShader: {
  14311. name: string;
  14312. shader: string;
  14313. };
  14314. }
  14315. declare module BABYLON {
  14316. /**
  14317. * Renders to multiple views with a single draw call
  14318. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14319. */
  14320. export class MultiviewRenderTarget extends RenderTargetTexture {
  14321. /**
  14322. * Creates a multiview render target
  14323. * @param scene scene used with the render target
  14324. * @param size the size of the render target (used for each view)
  14325. */
  14326. constructor(scene: Scene, size?: number | {
  14327. width: number;
  14328. height: number;
  14329. } | {
  14330. ratio: number;
  14331. });
  14332. /**
  14333. * @hidden
  14334. * @param faceIndex the face index, if its a cube texture
  14335. */ private _bindFrameBuffer(faceIndex?: number): void;
  14336. /**
  14337. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14338. * @returns the view count
  14339. */
  14340. getViewCount(): number;
  14341. }
  14342. }
  14343. declare module BABYLON {
  14344. /**
  14345. * Reprasents a camera frustum
  14346. */
  14347. export class Frustum {
  14348. /**
  14349. * Gets the planes representing the frustum
  14350. * @param transform matrix to be applied to the returned planes
  14351. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14352. */
  14353. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14354. /**
  14355. * Gets the near frustum plane transformed by the transform matrix
  14356. * @param transform transformation matrix to be applied to the resulting frustum plane
  14357. * @param frustumPlane the resuling frustum plane
  14358. */
  14359. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14360. /**
  14361. * Gets the far frustum plane transformed by the transform matrix
  14362. * @param transform transformation matrix to be applied to the resulting frustum plane
  14363. * @param frustumPlane the resuling frustum plane
  14364. */
  14365. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14366. /**
  14367. * Gets the left frustum plane transformed by the transform matrix
  14368. * @param transform transformation matrix to be applied to the resulting frustum plane
  14369. * @param frustumPlane the resuling frustum plane
  14370. */
  14371. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14372. /**
  14373. * Gets the right frustum plane transformed by the transform matrix
  14374. * @param transform transformation matrix to be applied to the resulting frustum plane
  14375. * @param frustumPlane the resuling frustum plane
  14376. */
  14377. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14378. /**
  14379. * Gets the top frustum plane transformed by the transform matrix
  14380. * @param transform transformation matrix to be applied to the resulting frustum plane
  14381. * @param frustumPlane the resuling frustum plane
  14382. */
  14383. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14384. /**
  14385. * Gets the bottom frustum plane transformed by the transform matrix
  14386. * @param transform transformation matrix to be applied to the resulting frustum plane
  14387. * @param frustumPlane the resuling frustum plane
  14388. */
  14389. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14390. /**
  14391. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14392. * @param transform transformation matrix to be applied to the resulting frustum planes
  14393. * @param frustumPlanes the resuling frustum planes
  14394. */
  14395. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14396. }
  14397. }
  14398. declare module BABYLON {
  14399. interface Engine {
  14400. /**
  14401. * Creates a new multiview render target
  14402. * @param width defines the width of the texture
  14403. * @param height defines the height of the texture
  14404. * @returns the created multiview texture
  14405. */
  14406. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14407. /**
  14408. * Binds a multiview framebuffer to be drawn to
  14409. * @param multiviewTexture texture to bind
  14410. */
  14411. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14412. }
  14413. interface Camera {
  14414. /**
  14415. * @hidden
  14416. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  14417. */ private _useMultiviewToSingleView: boolean;
  14418. /**
  14419. * @hidden
  14420. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  14421. */ private _multiviewTexture: Nullable<RenderTargetTexture>;
  14422. /**
  14423. * @hidden
  14424. * ensures the multiview texture of the camera exists and has the specified width/height
  14425. * @param width height to set on the multiview texture
  14426. * @param height width to set on the multiview texture
  14427. */ private _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14428. }
  14429. interface Scene {
  14430. /** @hidden */ private _transformMatrixR: Matrix;
  14431. /** @hidden */ private _multiviewSceneUbo: Nullable<UniformBuffer>;
  14432. /** @hidden */ private _createMultiviewUbo(): void;
  14433. /** @hidden */ private _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14434. /** @hidden */ private _renderMultiviewToSingleView(camera: Camera): void;
  14435. }
  14436. }
  14437. declare module BABYLON {
  14438. /**
  14439. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14440. * This will not be used for webXR as it supports displaying texture arrays directly
  14441. */
  14442. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14443. /**
  14444. * Initializes a VRMultiviewToSingleview
  14445. * @param name name of the post process
  14446. * @param camera camera to be applied to
  14447. * @param scaleFactor scaling factor to the size of the output texture
  14448. */
  14449. constructor(name: string, camera: Camera, scaleFactor: number);
  14450. }
  14451. }
  14452. declare module BABYLON {
  14453. interface Engine {
  14454. /** @hidden */ private _vrDisplay: any;
  14455. /** @hidden */ private _vrSupported: boolean;
  14456. /** @hidden */ private _oldSize: Size;
  14457. /** @hidden */ private _oldHardwareScaleFactor: number;
  14458. /** @hidden */ private _vrExclusivePointerMode: boolean;
  14459. /** @hidden */ private _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14460. /** @hidden */ private _onVRDisplayPointerRestricted: () => void;
  14461. /** @hidden */ private _onVRDisplayPointerUnrestricted: () => void;
  14462. /** @hidden */ private _onVrDisplayConnect: Nullable<(display: any) => void>;
  14463. /** @hidden */ private _onVrDisplayDisconnect: Nullable<() => void>;
  14464. /** @hidden */ private _onVrDisplayPresentChange: Nullable<() => void>;
  14465. /**
  14466. * Observable signaled when VR display mode changes
  14467. */
  14468. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14469. /**
  14470. * Observable signaled when VR request present is complete
  14471. */
  14472. onVRRequestPresentComplete: Observable<boolean>;
  14473. /**
  14474. * Observable signaled when VR request present starts
  14475. */
  14476. onVRRequestPresentStart: Observable<Engine>;
  14477. /**
  14478. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14479. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14480. */
  14481. isInVRExclusivePointerMode: boolean;
  14482. /**
  14483. * Gets a boolean indicating if a webVR device was detected
  14484. * @returns true if a webVR device was detected
  14485. */
  14486. isVRDevicePresent(): boolean;
  14487. /**
  14488. * Gets the current webVR device
  14489. * @returns the current webVR device (or null)
  14490. */
  14491. getVRDevice(): any;
  14492. /**
  14493. * Initializes a webVR display and starts listening to display change events
  14494. * The onVRDisplayChangedObservable will be notified upon these changes
  14495. * @returns A promise containing a VRDisplay and if vr is supported
  14496. */
  14497. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14498. /** @hidden */ private _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14499. /**
  14500. * Call this function to switch to webVR mode
  14501. * Will do nothing if webVR is not supported or if there is no webVR device
  14502. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14503. */
  14504. enableVR(): void;
  14505. /** @hidden */ private _onVRFullScreenTriggered(): void;
  14506. }
  14507. }
  14508. declare module BABYLON {
  14509. /**
  14510. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14511. * IMPORTANT!! The data is right-hand data.
  14512. * @export
  14513. * @interface DevicePose
  14514. */
  14515. export interface DevicePose {
  14516. /**
  14517. * The position of the device, values in array are [x,y,z].
  14518. */
  14519. readonly position: Nullable<Float32Array>;
  14520. /**
  14521. * The linearVelocity of the device, values in array are [x,y,z].
  14522. */
  14523. readonly linearVelocity: Nullable<Float32Array>;
  14524. /**
  14525. * The linearAcceleration of the device, values in array are [x,y,z].
  14526. */
  14527. readonly linearAcceleration: Nullable<Float32Array>;
  14528. /**
  14529. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14530. */
  14531. readonly orientation: Nullable<Float32Array>;
  14532. /**
  14533. * The angularVelocity of the device, values in array are [x,y,z].
  14534. */
  14535. readonly angularVelocity: Nullable<Float32Array>;
  14536. /**
  14537. * The angularAcceleration of the device, values in array are [x,y,z].
  14538. */
  14539. readonly angularAcceleration: Nullable<Float32Array>;
  14540. }
  14541. /**
  14542. * Interface representing a pose controlled object in Babylon.
  14543. * A pose controlled object has both regular pose values as well as pose values
  14544. * from an external device such as a VR head mounted display
  14545. */
  14546. export interface PoseControlled {
  14547. /**
  14548. * The position of the object in babylon space.
  14549. */
  14550. position: Vector3;
  14551. /**
  14552. * The rotation quaternion of the object in babylon space.
  14553. */
  14554. rotationQuaternion: Quaternion;
  14555. /**
  14556. * The position of the device in babylon space.
  14557. */
  14558. devicePosition?: Vector3;
  14559. /**
  14560. * The rotation quaternion of the device in babylon space.
  14561. */
  14562. deviceRotationQuaternion: Quaternion;
  14563. /**
  14564. * The raw pose coming from the device.
  14565. */
  14566. rawPose: Nullable<DevicePose>;
  14567. /**
  14568. * The scale of the device to be used when translating from device space to babylon space.
  14569. */
  14570. deviceScaleFactor: number;
  14571. /**
  14572. * Updates the poseControlled values based on the input device pose.
  14573. * @param poseData the pose data to update the object with
  14574. */
  14575. updateFromDevice(poseData: DevicePose): void;
  14576. }
  14577. /**
  14578. * Set of options to customize the webVRCamera
  14579. */
  14580. export interface WebVROptions {
  14581. /**
  14582. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14583. */
  14584. trackPosition?: boolean;
  14585. /**
  14586. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14587. */
  14588. positionScale?: number;
  14589. /**
  14590. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14591. */
  14592. displayName?: string;
  14593. /**
  14594. * Should the native controller meshes be initialized. (default: true)
  14595. */
  14596. controllerMeshes?: boolean;
  14597. /**
  14598. * Creating a default HemiLight only on controllers. (default: true)
  14599. */
  14600. defaultLightingOnControllers?: boolean;
  14601. /**
  14602. * If you don't want to use the default VR button of the helper. (default: false)
  14603. */
  14604. useCustomVRButton?: boolean;
  14605. /**
  14606. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14607. */
  14608. customVRButton?: HTMLButtonElement;
  14609. /**
  14610. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14611. */
  14612. rayLength?: number;
  14613. /**
  14614. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14615. */
  14616. defaultHeight?: number;
  14617. /**
  14618. * If multiview should be used if availible (default: false)
  14619. */
  14620. useMultiview?: boolean;
  14621. }
  14622. /**
  14623. * This represents a WebVR camera.
  14624. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14625. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14626. */
  14627. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14628. private webVROptions;
  14629. /**
  14630. * @hidden
  14631. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14632. */ private _vrDevice: any;
  14633. /**
  14634. * The rawPose of the vrDevice.
  14635. */
  14636. rawPose: Nullable<DevicePose>;
  14637. private _onVREnabled;
  14638. private _specsVersion;
  14639. private _attached;
  14640. private _frameData;
  14641. protected _descendants: Array<Node>;
  14642. private _deviceRoomPosition;
  14643. /** @hidden */ private _deviceRoomRotationQuaternion: Quaternion;
  14644. private _standingMatrix;
  14645. /**
  14646. * Represents device position in babylon space.
  14647. */
  14648. devicePosition: Vector3;
  14649. /**
  14650. * Represents device rotation in babylon space.
  14651. */
  14652. deviceRotationQuaternion: Quaternion;
  14653. /**
  14654. * The scale of the device to be used when translating from device space to babylon space.
  14655. */
  14656. deviceScaleFactor: number;
  14657. private _deviceToWorld;
  14658. private _worldToDevice;
  14659. /**
  14660. * References to the webVR controllers for the vrDevice.
  14661. */
  14662. controllers: Array<WebVRController>;
  14663. /**
  14664. * Emits an event when a controller is attached.
  14665. */
  14666. onControllersAttachedObservable: Observable<WebVRController[]>;
  14667. /**
  14668. * Emits an event when a controller's mesh has been loaded;
  14669. */
  14670. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14671. /**
  14672. * Emits an event when the HMD's pose has been updated.
  14673. */
  14674. onPoseUpdatedFromDeviceObservable: Observable<any>;
  14675. private _poseSet;
  14676. /**
  14677. * If the rig cameras be used as parent instead of this camera.
  14678. */
  14679. rigParenting: boolean;
  14680. private _lightOnControllers;
  14681. private _defaultHeight?;
  14682. /**
  14683. * Instantiates a WebVRFreeCamera.
  14684. * @param name The name of the WebVRFreeCamera
  14685. * @param position The starting anchor position for the camera
  14686. * @param scene The scene the camera belongs to
  14687. * @param webVROptions a set of customizable options for the webVRCamera
  14688. */
  14689. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  14690. /**
  14691. * Gets the device distance from the ground in meters.
  14692. * @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.
  14693. */
  14694. deviceDistanceToRoomGround(): number;
  14695. /**
  14696. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14697. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  14698. */
  14699. useStandingMatrix(callback?: (bool: boolean) => void): void;
  14700. /**
  14701. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14702. * @returns A promise with a boolean set to if the standing matrix is supported.
  14703. */
  14704. useStandingMatrixAsync(): Promise<boolean>;
  14705. /**
  14706. * Disposes the camera
  14707. */
  14708. dispose(): void;
  14709. /**
  14710. * Gets a vrController by name.
  14711. * @param name The name of the controller to retreive
  14712. * @returns the controller matching the name specified or null if not found
  14713. */
  14714. getControllerByName(name: string): Nullable<WebVRController>;
  14715. private _leftController;
  14716. /**
  14717. * The controller corresponding to the users left hand.
  14718. */
  14719. readonly leftController: Nullable<WebVRController>;
  14720. private _rightController;
  14721. /**
  14722. * The controller corresponding to the users right hand.
  14723. */
  14724. readonly rightController: Nullable<WebVRController>;
  14725. /**
  14726. * Casts a ray forward from the vrCamera's gaze.
  14727. * @param length Length of the ray (default: 100)
  14728. * @returns the ray corresponding to the gaze
  14729. */
  14730. getForwardRay(length?: number): Ray;
  14731. /**
  14732. * @hidden
  14733. * Updates the camera based on device's frame data
  14734. */ private _checkInputs(): void;
  14735. /**
  14736. * Updates the poseControlled values based on the input device pose.
  14737. * @param poseData Pose coming from the device
  14738. */
  14739. updateFromDevice(poseData: DevicePose): void;
  14740. private _htmlElementAttached;
  14741. private _detachIfAttached;
  14742. /**
  14743. * WebVR's attach control will start broadcasting frames to the device.
  14744. * Note that in certain browsers (chrome for example) this function must be called
  14745. * within a user-interaction callback. Example:
  14746. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  14747. *
  14748. * @param element html element to attach the vrDevice to
  14749. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  14750. */
  14751. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  14752. /**
  14753. * Detaches the camera from the html element and disables VR
  14754. *
  14755. * @param element html element to detach from
  14756. */
  14757. detachControl(element: HTMLElement): void;
  14758. /**
  14759. * @returns the name of this class
  14760. */
  14761. getClassName(): string;
  14762. /**
  14763. * Calls resetPose on the vrDisplay
  14764. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  14765. */
  14766. resetToCurrentRotation(): void;
  14767. /**
  14768. * @hidden
  14769. * Updates the rig cameras (left and right eye)
  14770. */ private _updateRigCameras(): void;
  14771. private _workingVector;
  14772. private _oneVector;
  14773. private _workingMatrix;
  14774. private updateCacheCalled;
  14775. private _correctPositionIfNotTrackPosition;
  14776. /**
  14777. * @hidden
  14778. * Updates the cached values of the camera
  14779. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  14780. */ private _updateCache(ignoreParentClass?: boolean): void;
  14781. /**
  14782. * @hidden
  14783. * Get current device position in babylon world
  14784. */ private _computeDevicePosition(): void;
  14785. /**
  14786. * Updates the current device position and rotation in the babylon world
  14787. */
  14788. update(): void;
  14789. /**
  14790. * @hidden
  14791. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  14792. * @returns an identity matrix
  14793. */ private _getViewMatrix(): Matrix;
  14794. private _tmpMatrix;
  14795. /**
  14796. * This function is called by the two RIG cameras.
  14797. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  14798. * @hidden
  14799. */ private _getWebVRViewMatrix(): Matrix;
  14800. /** @hidden */ private _getWebVRProjectionMatrix(): Matrix;
  14801. private _onGamepadConnectedObserver;
  14802. private _onGamepadDisconnectedObserver;
  14803. private _updateCacheWhenTrackingDisabledObserver;
  14804. /**
  14805. * Initializes the controllers and their meshes
  14806. */
  14807. initControllers(): void;
  14808. }
  14809. }
  14810. declare module BABYLON {
  14811. /**
  14812. * Size options for a post process
  14813. */
  14814. export type PostProcessOptions = {
  14815. width: number;
  14816. height: number;
  14817. };
  14818. /**
  14819. * PostProcess can be used to apply a shader to a texture after it has been rendered
  14820. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14821. */
  14822. export class PostProcess {
  14823. /** Name of the PostProcess. */
  14824. name: string;
  14825. /**
  14826. * Gets or sets the unique id of the post process
  14827. */
  14828. uniqueId: number;
  14829. /**
  14830. * Width of the texture to apply the post process on
  14831. */
  14832. width: number;
  14833. /**
  14834. * Height of the texture to apply the post process on
  14835. */
  14836. height: number;
  14837. /**
  14838. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  14839. * @hidden
  14840. */ private _outputTexture: Nullable<InternalTexture>;
  14841. /**
  14842. * Sampling mode used by the shader
  14843. * See https://doc.babylonjs.com/classes/3.1/texture
  14844. */
  14845. renderTargetSamplingMode: number;
  14846. /**
  14847. * Clear color to use when screen clearing
  14848. */
  14849. clearColor: Color4;
  14850. /**
  14851. * If the buffer needs to be cleared before applying the post process. (default: true)
  14852. * Should be set to false if shader will overwrite all previous pixels.
  14853. */
  14854. autoClear: boolean;
  14855. /**
  14856. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  14857. */
  14858. alphaMode: number;
  14859. /**
  14860. * Sets the setAlphaBlendConstants of the babylon engine
  14861. */
  14862. alphaConstants: Color4;
  14863. /**
  14864. * Animations to be used for the post processing
  14865. */
  14866. animations: Animation[];
  14867. /**
  14868. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  14869. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  14870. */
  14871. enablePixelPerfectMode: boolean;
  14872. /**
  14873. * Force the postprocess to be applied without taking in account viewport
  14874. */
  14875. forceFullscreenViewport: boolean;
  14876. /**
  14877. * List of inspectable custom properties (used by the Inspector)
  14878. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  14879. */
  14880. inspectableCustomProperties: IInspectable[];
  14881. /**
  14882. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  14883. *
  14884. * | Value | Type | Description |
  14885. * | ----- | ----------------------------------- | ----------- |
  14886. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  14887. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  14888. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  14889. *
  14890. */
  14891. scaleMode: number;
  14892. /**
  14893. * Force textures to be a power of two (default: false)
  14894. */
  14895. alwaysForcePOT: boolean;
  14896. private _samples;
  14897. /**
  14898. * Number of sample textures (default: 1)
  14899. */
  14900. samples: number;
  14901. /**
  14902. * Modify the scale of the post process to be the same as the viewport (default: false)
  14903. */
  14904. adaptScaleToCurrentViewport: boolean;
  14905. private _camera;
  14906. private _scene;
  14907. private _engine;
  14908. private _options;
  14909. private _reusable;
  14910. private _textureType;
  14911. /**
  14912. * Smart array of input and output textures for the post process.
  14913. * @hidden
  14914. */ private _textures: SmartArray<InternalTexture>;
  14915. /**
  14916. * The index in _textures that corresponds to the output texture.
  14917. * @hidden
  14918. */ private _currentRenderTextureInd: number;
  14919. private _effect;
  14920. private _samplers;
  14921. private _fragmentUrl;
  14922. private _vertexUrl;
  14923. private _parameters;
  14924. private _scaleRatio;
  14925. protected _indexParameters: any;
  14926. private _shareOutputWithPostProcess;
  14927. private _texelSize;
  14928. private _forcedOutputTexture;
  14929. /**
  14930. * Returns the fragment url or shader name used in the post process.
  14931. * @returns the fragment url or name in the shader store.
  14932. */
  14933. getEffectName(): string;
  14934. /**
  14935. * An event triggered when the postprocess is activated.
  14936. */
  14937. onActivateObservable: Observable<Camera>;
  14938. private _onActivateObserver;
  14939. /**
  14940. * A function that is added to the onActivateObservable
  14941. */
  14942. onActivate: Nullable<(camera: Camera) => void>;
  14943. /**
  14944. * An event triggered when the postprocess changes its size.
  14945. */
  14946. onSizeChangedObservable: Observable<PostProcess>;
  14947. private _onSizeChangedObserver;
  14948. /**
  14949. * A function that is added to the onSizeChangedObservable
  14950. */
  14951. onSizeChanged: (postProcess: PostProcess) => void;
  14952. /**
  14953. * An event triggered when the postprocess applies its effect.
  14954. */
  14955. onApplyObservable: Observable<Effect>;
  14956. private _onApplyObserver;
  14957. /**
  14958. * A function that is added to the onApplyObservable
  14959. */
  14960. onApply: (effect: Effect) => void;
  14961. /**
  14962. * An event triggered before rendering the postprocess
  14963. */
  14964. onBeforeRenderObservable: Observable<Effect>;
  14965. private _onBeforeRenderObserver;
  14966. /**
  14967. * A function that is added to the onBeforeRenderObservable
  14968. */
  14969. onBeforeRender: (effect: Effect) => void;
  14970. /**
  14971. * An event triggered after rendering the postprocess
  14972. */
  14973. onAfterRenderObservable: Observable<Effect>;
  14974. private _onAfterRenderObserver;
  14975. /**
  14976. * A function that is added to the onAfterRenderObservable
  14977. */
  14978. onAfterRender: (efect: Effect) => void;
  14979. /**
  14980. * 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
  14981. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  14982. */
  14983. inputTexture: InternalTexture;
  14984. /**
  14985. * Gets the camera which post process is applied to.
  14986. * @returns The camera the post process is applied to.
  14987. */
  14988. getCamera(): Camera;
  14989. /**
  14990. * Gets the texel size of the postprocess.
  14991. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  14992. */
  14993. readonly texelSize: Vector2;
  14994. /**
  14995. * Creates a new instance PostProcess
  14996. * @param name The name of the PostProcess.
  14997. * @param fragmentUrl The url of the fragment shader to be used.
  14998. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  14999. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15000. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15001. * @param camera The camera to apply the render pass to.
  15002. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15003. * @param engine The engine which the post process will be applied. (default: current engine)
  15004. * @param reusable If the post process can be reused on the same frame. (default: false)
  15005. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15006. * @param textureType Type of textures used when performing the post process. (default: 0)
  15007. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15008. * @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
  15009. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15010. */
  15011. constructor(
  15012. /** Name of the PostProcess. */
  15013. 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);
  15014. /**
  15015. * Gets a string idenfifying the name of the class
  15016. * @returns "PostProcess" string
  15017. */
  15018. getClassName(): string;
  15019. /**
  15020. * Gets the engine which this post process belongs to.
  15021. * @returns The engine the post process was enabled with.
  15022. */
  15023. getEngine(): Engine;
  15024. /**
  15025. * The effect that is created when initializing the post process.
  15026. * @returns The created effect corresponding the the postprocess.
  15027. */
  15028. getEffect(): Effect;
  15029. /**
  15030. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15031. * @param postProcess The post process to share the output with.
  15032. * @returns This post process.
  15033. */
  15034. shareOutputWith(postProcess: PostProcess): PostProcess;
  15035. /**
  15036. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15037. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15038. */
  15039. useOwnOutput(): void;
  15040. /**
  15041. * Updates the effect with the current post process compile time values and recompiles the shader.
  15042. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15043. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15044. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15045. * @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
  15046. * @param onCompiled Called when the shader has been compiled.
  15047. * @param onError Called if there is an error when compiling a shader.
  15048. */
  15049. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15050. /**
  15051. * The post process is reusable if it can be used multiple times within one frame.
  15052. * @returns If the post process is reusable
  15053. */
  15054. isReusable(): boolean;
  15055. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15056. markTextureDirty(): void;
  15057. /**
  15058. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15059. * 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.
  15060. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15061. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15062. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15063. * @returns The target texture that was bound to be written to.
  15064. */
  15065. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15066. /**
  15067. * If the post process is supported.
  15068. */
  15069. readonly isSupported: boolean;
  15070. /**
  15071. * The aspect ratio of the output texture.
  15072. */
  15073. readonly aspectRatio: number;
  15074. /**
  15075. * Get a value indicating if the post-process is ready to be used
  15076. * @returns true if the post-process is ready (shader is compiled)
  15077. */
  15078. isReady(): boolean;
  15079. /**
  15080. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15081. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15082. */
  15083. apply(): Nullable<Effect>;
  15084. private _disposeTextures;
  15085. /**
  15086. * Disposes the post process.
  15087. * @param camera The camera to dispose the post process on.
  15088. */
  15089. dispose(camera?: Camera): void;
  15090. }
  15091. }
  15092. declare module BABYLON {
  15093. /** @hidden */
  15094. export var kernelBlurVaryingDeclaration: {
  15095. name: string;
  15096. shader: string;
  15097. };
  15098. }
  15099. declare module BABYLON {
  15100. /** @hidden */
  15101. export var kernelBlurFragment: {
  15102. name: string;
  15103. shader: string;
  15104. };
  15105. }
  15106. declare module BABYLON {
  15107. /** @hidden */
  15108. export var kernelBlurFragment2: {
  15109. name: string;
  15110. shader: string;
  15111. };
  15112. }
  15113. declare module BABYLON {
  15114. /** @hidden */
  15115. export var kernelBlurPixelShader: {
  15116. name: string;
  15117. shader: string;
  15118. };
  15119. }
  15120. declare module BABYLON {
  15121. /** @hidden */
  15122. export var kernelBlurVertex: {
  15123. name: string;
  15124. shader: string;
  15125. };
  15126. }
  15127. declare module BABYLON {
  15128. /** @hidden */
  15129. export var kernelBlurVertexShader: {
  15130. name: string;
  15131. shader: string;
  15132. };
  15133. }
  15134. declare module BABYLON {
  15135. /**
  15136. * The Blur Post Process which blurs an image based on a kernel and direction.
  15137. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15138. */
  15139. export class BlurPostProcess extends PostProcess {
  15140. /** The direction in which to blur the image. */
  15141. direction: Vector2;
  15142. private blockCompilation;
  15143. protected _kernel: number;
  15144. protected _idealKernel: number;
  15145. protected _packedFloat: boolean;
  15146. private _staticDefines;
  15147. /**
  15148. * Sets the length in pixels of the blur sample region
  15149. */
  15150. /**
  15151. * Gets the length in pixels of the blur sample region
  15152. */
  15153. kernel: number;
  15154. /**
  15155. * Sets wether or not the blur needs to unpack/repack floats
  15156. */
  15157. /**
  15158. * Gets wether or not the blur is unpacking/repacking floats
  15159. */
  15160. packedFloat: boolean;
  15161. /**
  15162. * Creates a new instance BlurPostProcess
  15163. * @param name The name of the effect.
  15164. * @param direction The direction in which to blur the image.
  15165. * @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.
  15166. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15167. * @param camera The camera to apply the render pass to.
  15168. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15169. * @param engine The engine which the post process will be applied. (default: current engine)
  15170. * @param reusable If the post process can be reused on the same frame. (default: false)
  15171. * @param textureType Type of textures used when performing the post process. (default: 0)
  15172. * @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)
  15173. */
  15174. constructor(name: string,
  15175. /** The direction in which to blur the image. */
  15176. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15177. /**
  15178. * Updates the effect with the current post process compile time values and recompiles the shader.
  15179. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15180. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15181. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15182. * @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
  15183. * @param onCompiled Called when the shader has been compiled.
  15184. * @param onError Called if there is an error when compiling a shader.
  15185. */
  15186. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15187. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15188. /**
  15189. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15190. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15191. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15192. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15193. * The gaps between physical kernels are compensated for in the weighting of the samples
  15194. * @param idealKernel Ideal blur kernel.
  15195. * @return Nearest best kernel.
  15196. */
  15197. protected _nearestBestKernel(idealKernel: number): number;
  15198. /**
  15199. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15200. * @param x The point on the Gaussian distribution to sample.
  15201. * @return the value of the Gaussian function at x.
  15202. */
  15203. protected _gaussianWeight(x: number): number;
  15204. /**
  15205. * Generates a string that can be used as a floating point number in GLSL.
  15206. * @param x Value to print.
  15207. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15208. * @return GLSL float string.
  15209. */
  15210. protected _glslFloat(x: number, decimalFigures?: number): string;
  15211. }
  15212. }
  15213. declare module BABYLON {
  15214. /**
  15215. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15216. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15217. * You can then easily use it as a reflectionTexture on a flat surface.
  15218. * In case the surface is not a plane, please consider relying on reflection probes.
  15219. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15220. */
  15221. export class MirrorTexture extends RenderTargetTexture {
  15222. private scene;
  15223. /**
  15224. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15225. * 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.
  15226. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15227. */
  15228. mirrorPlane: Plane;
  15229. /**
  15230. * Define the blur ratio used to blur the reflection if needed.
  15231. */
  15232. blurRatio: number;
  15233. /**
  15234. * Define the adaptive blur kernel used to blur the reflection if needed.
  15235. * This will autocompute the closest best match for the `blurKernel`
  15236. */
  15237. adaptiveBlurKernel: number;
  15238. /**
  15239. * Define the blur kernel used to blur the reflection if needed.
  15240. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15241. */
  15242. blurKernel: number;
  15243. /**
  15244. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15245. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15246. */
  15247. blurKernelX: number;
  15248. /**
  15249. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15250. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15251. */
  15252. blurKernelY: number;
  15253. private _autoComputeBlurKernel;
  15254. protected _onRatioRescale(): void;
  15255. private _updateGammaSpace;
  15256. private _imageProcessingConfigChangeObserver;
  15257. private _transformMatrix;
  15258. private _mirrorMatrix;
  15259. private _savedViewMatrix;
  15260. private _blurX;
  15261. private _blurY;
  15262. private _adaptiveBlurKernel;
  15263. private _blurKernelX;
  15264. private _blurKernelY;
  15265. private _blurRatio;
  15266. /**
  15267. * Instantiates a Mirror Texture.
  15268. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15269. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15270. * You can then easily use it as a reflectionTexture on a flat surface.
  15271. * In case the surface is not a plane, please consider relying on reflection probes.
  15272. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15273. * @param name
  15274. * @param size
  15275. * @param scene
  15276. * @param generateMipMaps
  15277. * @param type
  15278. * @param samplingMode
  15279. * @param generateDepthBuffer
  15280. */
  15281. constructor(name: string, size: number | {
  15282. width: number;
  15283. height: number;
  15284. } | {
  15285. ratio: number;
  15286. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15287. private _preparePostProcesses;
  15288. /**
  15289. * Clone the mirror texture.
  15290. * @returns the cloned texture
  15291. */
  15292. clone(): MirrorTexture;
  15293. /**
  15294. * Serialize the texture to a JSON representation you could use in Parse later on
  15295. * @returns the serialized JSON representation
  15296. */
  15297. serialize(): any;
  15298. /**
  15299. * Dispose the texture and release its associated resources.
  15300. */
  15301. dispose(): void;
  15302. }
  15303. }
  15304. declare module BABYLON {
  15305. /**
  15306. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15307. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15308. */
  15309. export class Texture extends BaseTexture {
  15310. /** @hidden */ private static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15311. /** @hidden */ private static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15312. /** @hidden */ private static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15313. /** nearest is mag = nearest and min = nearest and mip = linear */
  15314. static readonly NEAREST_SAMPLINGMODE: number;
  15315. /** nearest is mag = nearest and min = nearest and mip = linear */
  15316. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15317. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15318. static readonly BILINEAR_SAMPLINGMODE: number;
  15319. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15320. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15321. /** Trilinear is mag = linear and min = linear and mip = linear */
  15322. static readonly TRILINEAR_SAMPLINGMODE: number;
  15323. /** Trilinear is mag = linear and min = linear and mip = linear */
  15324. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15325. /** mag = nearest and min = nearest and mip = nearest */
  15326. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15327. /** mag = nearest and min = linear and mip = nearest */
  15328. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15329. /** mag = nearest and min = linear and mip = linear */
  15330. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15331. /** mag = nearest and min = linear and mip = none */
  15332. static readonly NEAREST_LINEAR: number;
  15333. /** mag = nearest and min = nearest and mip = none */
  15334. static readonly NEAREST_NEAREST: number;
  15335. /** mag = linear and min = nearest and mip = nearest */
  15336. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15337. /** mag = linear and min = nearest and mip = linear */
  15338. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15339. /** mag = linear and min = linear and mip = none */
  15340. static readonly LINEAR_LINEAR: number;
  15341. /** mag = linear and min = nearest and mip = none */
  15342. static readonly LINEAR_NEAREST: number;
  15343. /** Explicit coordinates mode */
  15344. static readonly EXPLICIT_MODE: number;
  15345. /** Spherical coordinates mode */
  15346. static readonly SPHERICAL_MODE: number;
  15347. /** Planar coordinates mode */
  15348. static readonly PLANAR_MODE: number;
  15349. /** Cubic coordinates mode */
  15350. static readonly CUBIC_MODE: number;
  15351. /** Projection coordinates mode */
  15352. static readonly PROJECTION_MODE: number;
  15353. /** Inverse Cubic coordinates mode */
  15354. static readonly SKYBOX_MODE: number;
  15355. /** Inverse Cubic coordinates mode */
  15356. static readonly INVCUBIC_MODE: number;
  15357. /** Equirectangular coordinates mode */
  15358. static readonly EQUIRECTANGULAR_MODE: number;
  15359. /** Equirectangular Fixed coordinates mode */
  15360. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15361. /** Equirectangular Fixed Mirrored coordinates mode */
  15362. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15363. /** Texture is not repeating outside of 0..1 UVs */
  15364. static readonly CLAMP_ADDRESSMODE: number;
  15365. /** Texture is repeating outside of 0..1 UVs */
  15366. static readonly WRAP_ADDRESSMODE: number;
  15367. /** Texture is repeating and mirrored */
  15368. static readonly MIRROR_ADDRESSMODE: number;
  15369. /**
  15370. * 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
  15371. */
  15372. static UseSerializedUrlIfAny: boolean;
  15373. /**
  15374. * Define the url of the texture.
  15375. */
  15376. url: Nullable<string>;
  15377. /**
  15378. * Define an offset on the texture to offset the u coordinates of the UVs
  15379. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15380. */
  15381. uOffset: number;
  15382. /**
  15383. * Define an offset on the texture to offset the v coordinates of the UVs
  15384. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15385. */
  15386. vOffset: number;
  15387. /**
  15388. * Define an offset on the texture to scale the u coordinates of the UVs
  15389. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15390. */
  15391. uScale: number;
  15392. /**
  15393. * Define an offset on the texture to scale the v coordinates of the UVs
  15394. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15395. */
  15396. vScale: number;
  15397. /**
  15398. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15399. * @see http://doc.babylonjs.com/how_to/more_materials
  15400. */
  15401. uAng: number;
  15402. /**
  15403. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15404. * @see http://doc.babylonjs.com/how_to/more_materials
  15405. */
  15406. vAng: number;
  15407. /**
  15408. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15409. * @see http://doc.babylonjs.com/how_to/more_materials
  15410. */
  15411. wAng: number;
  15412. /**
  15413. * Defines the center of rotation (U)
  15414. */
  15415. uRotationCenter: number;
  15416. /**
  15417. * Defines the center of rotation (V)
  15418. */
  15419. vRotationCenter: number;
  15420. /**
  15421. * Defines the center of rotation (W)
  15422. */
  15423. wRotationCenter: number;
  15424. /**
  15425. * Are mip maps generated for this texture or not.
  15426. */
  15427. readonly noMipmap: boolean;
  15428. /**
  15429. * List of inspectable custom properties (used by the Inspector)
  15430. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15431. */
  15432. inspectableCustomProperties: Nullable<IInspectable[]>;
  15433. private _noMipmap;
  15434. /** @hidden */ private _invertY: boolean;
  15435. private _rowGenerationMatrix;
  15436. private _cachedTextureMatrix;
  15437. private _projectionModeMatrix;
  15438. private _t0;
  15439. private _t1;
  15440. private _t2;
  15441. private _cachedUOffset;
  15442. private _cachedVOffset;
  15443. private _cachedUScale;
  15444. private _cachedVScale;
  15445. private _cachedUAng;
  15446. private _cachedVAng;
  15447. private _cachedWAng;
  15448. private _cachedProjectionMatrixId;
  15449. private _cachedCoordinatesMode;
  15450. /** @hidden */
  15451. protected _initialSamplingMode: number;
  15452. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  15453. private _deleteBuffer;
  15454. protected _format: Nullable<number>;
  15455. private _delayedOnLoad;
  15456. private _delayedOnError;
  15457. /**
  15458. * Observable triggered once the texture has been loaded.
  15459. */
  15460. onLoadObservable: Observable<Texture>;
  15461. protected _isBlocking: boolean;
  15462. /**
  15463. * Is the texture preventing material to render while loading.
  15464. * If false, a default texture will be used instead of the loading one during the preparation step.
  15465. */
  15466. isBlocking: boolean;
  15467. /**
  15468. * Get the current sampling mode associated with the texture.
  15469. */
  15470. readonly samplingMode: number;
  15471. /**
  15472. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15473. */
  15474. readonly invertY: boolean;
  15475. /**
  15476. * Instantiates a new texture.
  15477. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15478. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15479. * @param url define the url of the picture to load as a texture
  15480. * @param scene define the scene or engine the texture will belong to
  15481. * @param noMipmap define if the texture will require mip maps or not
  15482. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15483. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15484. * @param onLoad define a callback triggered when the texture has been loaded
  15485. * @param onError define a callback triggered when an error occurred during the loading session
  15486. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15487. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15488. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15489. */
  15490. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  15491. /**
  15492. * Update the url (and optional buffer) of this texture if url was null during construction.
  15493. * @param url the url of the texture
  15494. * @param buffer the buffer of the texture (defaults to null)
  15495. * @param onLoad callback called when the texture is loaded (defaults to null)
  15496. */
  15497. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15498. /**
  15499. * Finish the loading sequence of a texture flagged as delayed load.
  15500. * @hidden
  15501. */
  15502. delayLoad(): void;
  15503. private _prepareRowForTextureGeneration;
  15504. /**
  15505. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15506. * @returns the transform matrix of the texture.
  15507. */
  15508. getTextureMatrix(): Matrix;
  15509. /**
  15510. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15511. * @returns The reflection texture transform
  15512. */
  15513. getReflectionTextureMatrix(): Matrix;
  15514. /**
  15515. * Clones the texture.
  15516. * @returns the cloned texture
  15517. */
  15518. clone(): Texture;
  15519. /**
  15520. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15521. * @returns The JSON representation of the texture
  15522. */
  15523. serialize(): any;
  15524. /**
  15525. * Get the current class name of the texture useful for serialization or dynamic coding.
  15526. * @returns "Texture"
  15527. */
  15528. getClassName(): string;
  15529. /**
  15530. * Dispose the texture and release its associated resources.
  15531. */
  15532. dispose(): void;
  15533. /**
  15534. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15535. * @param parsedTexture Define the JSON representation of the texture
  15536. * @param scene Define the scene the parsed texture should be instantiated in
  15537. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15538. * @returns The parsed texture if successful
  15539. */
  15540. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15541. /**
  15542. * Creates a texture from its base 64 representation.
  15543. * @param data Define the base64 payload without the data: prefix
  15544. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15545. * @param scene Define the scene the texture should belong to
  15546. * @param noMipmap Forces the texture to not create mip map information if true
  15547. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15548. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15549. * @param onLoad define a callback triggered when the texture has been loaded
  15550. * @param onError define a callback triggered when an error occurred during the loading session
  15551. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15552. * @returns the created texture
  15553. */
  15554. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15555. /**
  15556. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15557. * @param data Define the base64 payload without the data: prefix
  15558. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15559. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15560. * @param scene Define the scene the texture should belong to
  15561. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15562. * @param noMipmap Forces the texture to not create mip map information if true
  15563. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15564. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15565. * @param onLoad define a callback triggered when the texture has been loaded
  15566. * @param onError define a callback triggered when an error occurred during the loading session
  15567. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15568. * @returns the created texture
  15569. */
  15570. 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;
  15571. }
  15572. }
  15573. declare module BABYLON {
  15574. /**
  15575. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15576. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15577. */
  15578. export class PostProcessManager {
  15579. private _scene;
  15580. private _indexBuffer;
  15581. private _vertexBuffers;
  15582. /**
  15583. * Creates a new instance PostProcess
  15584. * @param scene The scene that the post process is associated with.
  15585. */
  15586. constructor(scene: Scene);
  15587. private _prepareBuffers;
  15588. private _buildIndexBuffer;
  15589. /**
  15590. * Rebuilds the vertex buffers of the manager.
  15591. * @hidden
  15592. */ private _rebuild(): void;
  15593. /**
  15594. * Prepares a frame to be run through a post process.
  15595. * @param sourceTexture The input texture to the post procesess. (default: null)
  15596. * @param postProcesses An array of post processes to be run. (default: null)
  15597. * @returns True if the post processes were able to be run.
  15598. * @hidden
  15599. */ private _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15600. /**
  15601. * Manually render a set of post processes to a texture.
  15602. * @param postProcesses An array of post processes to be run.
  15603. * @param targetTexture The target texture to render to.
  15604. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15605. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15606. * @param lodLevel defines which lod of the texture to render to
  15607. */
  15608. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15609. /**
  15610. * Finalize the result of the output of the postprocesses.
  15611. * @param doNotPresent If true the result will not be displayed to the screen.
  15612. * @param targetTexture The target texture to render to.
  15613. * @param faceIndex The index of the face to bind the target texture to.
  15614. * @param postProcesses The array of post processes to render.
  15615. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15616. * @hidden
  15617. */ private _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15618. /**
  15619. * Disposes of the post process manager.
  15620. */
  15621. dispose(): void;
  15622. }
  15623. }
  15624. declare module BABYLON {
  15625. /** Interface used by value gradients (color, factor, ...) */
  15626. export interface IValueGradient {
  15627. /**
  15628. * Gets or sets the gradient value (between 0 and 1)
  15629. */
  15630. gradient: number;
  15631. }
  15632. /** Class used to store color4 gradient */
  15633. export class ColorGradient implements IValueGradient {
  15634. /**
  15635. * Gets or sets the gradient value (between 0 and 1)
  15636. */
  15637. gradient: number;
  15638. /**
  15639. * Gets or sets first associated color
  15640. */
  15641. color1: Color4;
  15642. /**
  15643. * Gets or sets second associated color
  15644. */
  15645. color2?: Color4;
  15646. /**
  15647. * Will get a color picked randomly between color1 and color2.
  15648. * If color2 is undefined then color1 will be used
  15649. * @param result defines the target Color4 to store the result in
  15650. */
  15651. getColorToRef(result: Color4): void;
  15652. }
  15653. /** Class used to store color 3 gradient */
  15654. export class Color3Gradient implements IValueGradient {
  15655. /**
  15656. * Gets or sets the gradient value (between 0 and 1)
  15657. */
  15658. gradient: number;
  15659. /**
  15660. * Gets or sets the associated color
  15661. */
  15662. color: Color3;
  15663. }
  15664. /** Class used to store factor gradient */
  15665. export class FactorGradient implements IValueGradient {
  15666. /**
  15667. * Gets or sets the gradient value (between 0 and 1)
  15668. */
  15669. gradient: number;
  15670. /**
  15671. * Gets or sets first associated factor
  15672. */
  15673. factor1: number;
  15674. /**
  15675. * Gets or sets second associated factor
  15676. */
  15677. factor2?: number;
  15678. /**
  15679. * Will get a number picked randomly between factor1 and factor2.
  15680. * If factor2 is undefined then factor1 will be used
  15681. * @returns the picked number
  15682. */
  15683. getFactor(): number;
  15684. }
  15685. /**
  15686. * Helper used to simplify some generic gradient tasks
  15687. */
  15688. export class GradientHelper {
  15689. /**
  15690. * Gets the current gradient from an array of IValueGradient
  15691. * @param ratio defines the current ratio to get
  15692. * @param gradients defines the array of IValueGradient
  15693. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  15694. */
  15695. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  15696. }
  15697. }
  15698. declare module BABYLON {
  15699. interface AbstractScene {
  15700. /**
  15701. * The list of procedural textures added to the scene
  15702. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15703. */
  15704. proceduralTextures: Array<ProceduralTexture>;
  15705. }
  15706. /**
  15707. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  15708. * in a given scene.
  15709. */
  15710. export class ProceduralTextureSceneComponent implements ISceneComponent {
  15711. /**
  15712. * The component name helpfull to identify the component in the list of scene components.
  15713. */
  15714. readonly name: string;
  15715. /**
  15716. * The scene the component belongs to.
  15717. */
  15718. scene: Scene;
  15719. /**
  15720. * Creates a new instance of the component for the given scene
  15721. * @param scene Defines the scene to register the component in
  15722. */
  15723. constructor(scene: Scene);
  15724. /**
  15725. * Registers the component in a given scene
  15726. */
  15727. register(): void;
  15728. /**
  15729. * Rebuilds the elements related to this component in case of
  15730. * context lost for instance.
  15731. */
  15732. rebuild(): void;
  15733. /**
  15734. * Disposes the component and the associated ressources.
  15735. */
  15736. dispose(): void;
  15737. private _beforeClear;
  15738. }
  15739. }
  15740. declare module BABYLON {
  15741. interface Engine {
  15742. /**
  15743. * Creates a new render target cube texture
  15744. * @param size defines the size of the texture
  15745. * @param options defines the options used to create the texture
  15746. * @returns a new render target cube texture stored in an InternalTexture
  15747. */
  15748. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  15749. }
  15750. }
  15751. declare module BABYLON {
  15752. /** @hidden */
  15753. export var proceduralVertexShader: {
  15754. name: string;
  15755. shader: string;
  15756. };
  15757. }
  15758. declare module BABYLON {
  15759. /**
  15760. * 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.
  15761. * This is the base class of any Procedural texture and contains most of the shareable code.
  15762. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15763. */
  15764. export class ProceduralTexture extends Texture {
  15765. isCube: boolean;
  15766. /**
  15767. * Define if the texture is enabled or not (disabled texture will not render)
  15768. */
  15769. isEnabled: boolean;
  15770. /**
  15771. * Define if the texture must be cleared before rendering (default is true)
  15772. */
  15773. autoClear: boolean;
  15774. /**
  15775. * Callback called when the texture is generated
  15776. */
  15777. onGenerated: () => void;
  15778. /**
  15779. * Event raised when the texture is generated
  15780. */
  15781. onGeneratedObservable: Observable<ProceduralTexture>;
  15782. /** @hidden */ private _generateMipMaps: boolean;
  15783. /** @hidden **/ private _effect: Effect;
  15784. /** @hidden */ private _textures: {
  15785. [key: string]: Texture;
  15786. };
  15787. private _size;
  15788. private _currentRefreshId;
  15789. private _refreshRate;
  15790. private _vertexBuffers;
  15791. private _indexBuffer;
  15792. private _uniforms;
  15793. private _samplers;
  15794. private _fragment;
  15795. private _floats;
  15796. private _ints;
  15797. private _floatsArrays;
  15798. private _colors3;
  15799. private _colors4;
  15800. private _vectors2;
  15801. private _vectors3;
  15802. private _matrices;
  15803. private _fallbackTexture;
  15804. private _fallbackTextureUsed;
  15805. private _engine;
  15806. private _cachedDefines;
  15807. private _contentUpdateId;
  15808. private _contentData;
  15809. /**
  15810. * Instantiates a new procedural texture.
  15811. * 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.
  15812. * This is the base class of any Procedural texture and contains most of the shareable code.
  15813. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15814. * @param name Define the name of the texture
  15815. * @param size Define the size of the texture to create
  15816. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  15817. * @param scene Define the scene the texture belongs to
  15818. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  15819. * @param generateMipMaps Define if the texture should creates mip maps or not
  15820. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  15821. */
  15822. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  15823. /**
  15824. * The effect that is created when initializing the post process.
  15825. * @returns The created effect corresponding the the postprocess.
  15826. */
  15827. getEffect(): Effect;
  15828. /**
  15829. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  15830. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  15831. */
  15832. getContent(): Nullable<ArrayBufferView>;
  15833. private _createIndexBuffer;
  15834. /** @hidden */ private _rebuild(): void;
  15835. /**
  15836. * Resets the texture in order to recreate its associated resources.
  15837. * This can be called in case of context loss
  15838. */
  15839. reset(): void;
  15840. protected _getDefines(): string;
  15841. /**
  15842. * Is the texture ready to be used ? (rendered at least once)
  15843. * @returns true if ready, otherwise, false.
  15844. */
  15845. isReady(): boolean;
  15846. /**
  15847. * Resets the refresh counter of the texture and start bak from scratch.
  15848. * Could be useful to regenerate the texture if it is setup to render only once.
  15849. */
  15850. resetRefreshCounter(): void;
  15851. /**
  15852. * Set the fragment shader to use in order to render the texture.
  15853. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  15854. */
  15855. setFragment(fragment: any): void;
  15856. /**
  15857. * Define the refresh rate of the texture or the rendering frequency.
  15858. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  15859. */
  15860. refreshRate: number;
  15861. /** @hidden */ private _shouldRender(): boolean;
  15862. /**
  15863. * Get the size the texture is rendering at.
  15864. * @returns the size (texture is always squared)
  15865. */
  15866. getRenderSize(): number;
  15867. /**
  15868. * Resize the texture to new value.
  15869. * @param size Define the new size the texture should have
  15870. * @param generateMipMaps Define whether the new texture should create mip maps
  15871. */
  15872. resize(size: number, generateMipMaps: boolean): void;
  15873. private _checkUniform;
  15874. /**
  15875. * Set a texture in the shader program used to render.
  15876. * @param name Define the name of the uniform samplers as defined in the shader
  15877. * @param texture Define the texture to bind to this sampler
  15878. * @return the texture itself allowing "fluent" like uniform updates
  15879. */
  15880. setTexture(name: string, texture: Texture): ProceduralTexture;
  15881. /**
  15882. * Set a float in the shader.
  15883. * @param name Define the name of the uniform as defined in the shader
  15884. * @param value Define the value to give to the uniform
  15885. * @return the texture itself allowing "fluent" like uniform updates
  15886. */
  15887. setFloat(name: string, value: number): ProceduralTexture;
  15888. /**
  15889. * Set a int in the shader.
  15890. * @param name Define the name of the uniform as defined in the shader
  15891. * @param value Define the value to give to the uniform
  15892. * @return the texture itself allowing "fluent" like uniform updates
  15893. */
  15894. setInt(name: string, value: number): ProceduralTexture;
  15895. /**
  15896. * Set an array of floats in the shader.
  15897. * @param name Define the name of the uniform as defined in the shader
  15898. * @param value Define the value to give to the uniform
  15899. * @return the texture itself allowing "fluent" like uniform updates
  15900. */
  15901. setFloats(name: string, value: number[]): ProceduralTexture;
  15902. /**
  15903. * Set a vec3 in the shader from a Color3.
  15904. * @param name Define the name of the uniform as defined in the shader
  15905. * @param value Define the value to give to the uniform
  15906. * @return the texture itself allowing "fluent" like uniform updates
  15907. */
  15908. setColor3(name: string, value: Color3): ProceduralTexture;
  15909. /**
  15910. * Set a vec4 in the shader from a Color4.
  15911. * @param name Define the name of the uniform as defined in the shader
  15912. * @param value Define the value to give to the uniform
  15913. * @return the texture itself allowing "fluent" like uniform updates
  15914. */
  15915. setColor4(name: string, value: Color4): ProceduralTexture;
  15916. /**
  15917. * Set a vec2 in the shader from a Vector2.
  15918. * @param name Define the name of the uniform as defined in the shader
  15919. * @param value Define the value to give to the uniform
  15920. * @return the texture itself allowing "fluent" like uniform updates
  15921. */
  15922. setVector2(name: string, value: Vector2): ProceduralTexture;
  15923. /**
  15924. * Set a vec3 in the shader from a Vector3.
  15925. * @param name Define the name of the uniform as defined in the shader
  15926. * @param value Define the value to give to the uniform
  15927. * @return the texture itself allowing "fluent" like uniform updates
  15928. */
  15929. setVector3(name: string, value: Vector3): ProceduralTexture;
  15930. /**
  15931. * Set a mat4 in the shader from a MAtrix.
  15932. * @param name Define the name of the uniform as defined in the shader
  15933. * @param value Define the value to give to the uniform
  15934. * @return the texture itself allowing "fluent" like uniform updates
  15935. */
  15936. setMatrix(name: string, value: Matrix): ProceduralTexture;
  15937. /**
  15938. * Render the texture to its associated render target.
  15939. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  15940. */
  15941. render(useCameraPostProcess?: boolean): void;
  15942. /**
  15943. * Clone the texture.
  15944. * @returns the cloned texture
  15945. */
  15946. clone(): ProceduralTexture;
  15947. /**
  15948. * Dispose the texture and release its asoociated resources.
  15949. */
  15950. dispose(): void;
  15951. }
  15952. }
  15953. declare module BABYLON {
  15954. /**
  15955. * This represents the base class for particle system in Babylon.
  15956. * 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.
  15957. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15958. * @example https://doc.babylonjs.com/babylon101/particles
  15959. */
  15960. export class BaseParticleSystem {
  15961. /**
  15962. * Source color is added to the destination color without alpha affecting the result
  15963. */
  15964. static BLENDMODE_ONEONE: number;
  15965. /**
  15966. * Blend current color and particle color using particle’s alpha
  15967. */
  15968. static BLENDMODE_STANDARD: number;
  15969. /**
  15970. * Add current color and particle color multiplied by particle’s alpha
  15971. */
  15972. static BLENDMODE_ADD: number;
  15973. /**
  15974. * Multiply current color with particle color
  15975. */
  15976. static BLENDMODE_MULTIPLY: number;
  15977. /**
  15978. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  15979. */
  15980. static BLENDMODE_MULTIPLYADD: number;
  15981. /**
  15982. * List of animations used by the particle system.
  15983. */
  15984. animations: Animation[];
  15985. /**
  15986. * The id of the Particle system.
  15987. */
  15988. id: string;
  15989. /**
  15990. * The friendly name of the Particle system.
  15991. */
  15992. name: string;
  15993. /**
  15994. * The rendering group used by the Particle system to chose when to render.
  15995. */
  15996. renderingGroupId: number;
  15997. /**
  15998. * The emitter represents the Mesh or position we are attaching the particle system to.
  15999. */
  16000. emitter: Nullable<AbstractMesh | Vector3>;
  16001. /**
  16002. * The maximum number of particles to emit per frame
  16003. */
  16004. emitRate: number;
  16005. /**
  16006. * If you want to launch only a few particles at once, that can be done, as well.
  16007. */
  16008. manualEmitCount: number;
  16009. /**
  16010. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16011. */
  16012. updateSpeed: number;
  16013. /**
  16014. * The amount of time the particle system is running (depends of the overall update speed).
  16015. */
  16016. targetStopDuration: number;
  16017. /**
  16018. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16019. */
  16020. disposeOnStop: boolean;
  16021. /**
  16022. * Minimum power of emitting particles.
  16023. */
  16024. minEmitPower: number;
  16025. /**
  16026. * Maximum power of emitting particles.
  16027. */
  16028. maxEmitPower: number;
  16029. /**
  16030. * Minimum life time of emitting particles.
  16031. */
  16032. minLifeTime: number;
  16033. /**
  16034. * Maximum life time of emitting particles.
  16035. */
  16036. maxLifeTime: number;
  16037. /**
  16038. * Minimum Size of emitting particles.
  16039. */
  16040. minSize: number;
  16041. /**
  16042. * Maximum Size of emitting particles.
  16043. */
  16044. maxSize: number;
  16045. /**
  16046. * Minimum scale of emitting particles on X axis.
  16047. */
  16048. minScaleX: number;
  16049. /**
  16050. * Maximum scale of emitting particles on X axis.
  16051. */
  16052. maxScaleX: number;
  16053. /**
  16054. * Minimum scale of emitting particles on Y axis.
  16055. */
  16056. minScaleY: number;
  16057. /**
  16058. * Maximum scale of emitting particles on Y axis.
  16059. */
  16060. maxScaleY: number;
  16061. /**
  16062. * Gets or sets the minimal initial rotation in radians.
  16063. */
  16064. minInitialRotation: number;
  16065. /**
  16066. * Gets or sets the maximal initial rotation in radians.
  16067. */
  16068. maxInitialRotation: number;
  16069. /**
  16070. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16071. */
  16072. minAngularSpeed: number;
  16073. /**
  16074. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16075. */
  16076. maxAngularSpeed: number;
  16077. /**
  16078. * The texture used to render each particle. (this can be a spritesheet)
  16079. */
  16080. particleTexture: Nullable<Texture>;
  16081. /**
  16082. * The layer mask we are rendering the particles through.
  16083. */
  16084. layerMask: number;
  16085. /**
  16086. * This can help using your own shader to render the particle system.
  16087. * The according effect will be created
  16088. */
  16089. customShader: any;
  16090. /**
  16091. * By default particle system starts as soon as they are created. This prevents the
  16092. * automatic start to happen and let you decide when to start emitting particles.
  16093. */
  16094. preventAutoStart: boolean;
  16095. private _noiseTexture;
  16096. /**
  16097. * Gets or sets a texture used to add random noise to particle positions
  16098. */
  16099. noiseTexture: Nullable<ProceduralTexture>;
  16100. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16101. noiseStrength: Vector3;
  16102. /**
  16103. * Callback triggered when the particle animation is ending.
  16104. */
  16105. onAnimationEnd: Nullable<() => void>;
  16106. /**
  16107. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16108. */
  16109. blendMode: number;
  16110. /**
  16111. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16112. * to override the particles.
  16113. */
  16114. forceDepthWrite: boolean;
  16115. /** 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 */
  16116. preWarmCycles: number;
  16117. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16118. preWarmStepOffset: number;
  16119. /**
  16120. * 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)
  16121. */
  16122. spriteCellChangeSpeed: number;
  16123. /**
  16124. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16125. */
  16126. startSpriteCellID: number;
  16127. /**
  16128. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16129. */
  16130. endSpriteCellID: number;
  16131. /**
  16132. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16133. */
  16134. spriteCellWidth: number;
  16135. /**
  16136. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16137. */
  16138. spriteCellHeight: number;
  16139. /**
  16140. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16141. */
  16142. spriteRandomStartCell: boolean;
  16143. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16144. translationPivot: Vector2;
  16145. /** @hidden */
  16146. protected _isAnimationSheetEnabled: boolean;
  16147. /**
  16148. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16149. */
  16150. beginAnimationOnStart: boolean;
  16151. /**
  16152. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16153. */
  16154. beginAnimationFrom: number;
  16155. /**
  16156. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16157. */
  16158. beginAnimationTo: number;
  16159. /**
  16160. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16161. */
  16162. beginAnimationLoop: boolean;
  16163. /**
  16164. * Gets or sets a world offset applied to all particles
  16165. */
  16166. worldOffset: Vector3;
  16167. /**
  16168. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16169. */
  16170. isAnimationSheetEnabled: boolean;
  16171. /**
  16172. * Get hosting scene
  16173. * @returns the scene
  16174. */
  16175. getScene(): Scene;
  16176. /**
  16177. * You can use gravity if you want to give an orientation to your particles.
  16178. */
  16179. gravity: Vector3;
  16180. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16181. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16182. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16183. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16184. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16185. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16186. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16187. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16188. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16189. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16190. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16191. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16192. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16193. /**
  16194. * Defines the delay in milliseconds before starting the system (0 by default)
  16195. */
  16196. startDelay: number;
  16197. /**
  16198. * Gets the current list of drag gradients.
  16199. * You must use addDragGradient and removeDragGradient to udpate this list
  16200. * @returns the list of drag gradients
  16201. */
  16202. getDragGradients(): Nullable<Array<FactorGradient>>;
  16203. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16204. limitVelocityDamping: number;
  16205. /**
  16206. * Gets the current list of limit velocity gradients.
  16207. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16208. * @returns the list of limit velocity gradients
  16209. */
  16210. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16211. /**
  16212. * Gets the current list of color gradients.
  16213. * You must use addColorGradient and removeColorGradient to udpate this list
  16214. * @returns the list of color gradients
  16215. */
  16216. getColorGradients(): Nullable<Array<ColorGradient>>;
  16217. /**
  16218. * Gets the current list of size gradients.
  16219. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16220. * @returns the list of size gradients
  16221. */
  16222. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16223. /**
  16224. * Gets the current list of color remap gradients.
  16225. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16226. * @returns the list of color remap gradients
  16227. */
  16228. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16229. /**
  16230. * Gets the current list of alpha remap gradients.
  16231. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16232. * @returns the list of alpha remap gradients
  16233. */
  16234. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16235. /**
  16236. * Gets the current list of life time gradients.
  16237. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16238. * @returns the list of life time gradients
  16239. */
  16240. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16241. /**
  16242. * Gets the current list of angular speed gradients.
  16243. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16244. * @returns the list of angular speed gradients
  16245. */
  16246. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16247. /**
  16248. * Gets the current list of velocity gradients.
  16249. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16250. * @returns the list of velocity gradients
  16251. */
  16252. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16253. /**
  16254. * Gets the current list of start size gradients.
  16255. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16256. * @returns the list of start size gradients
  16257. */
  16258. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16259. /**
  16260. * Gets the current list of emit rate gradients.
  16261. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16262. * @returns the list of emit rate gradients
  16263. */
  16264. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16265. /**
  16266. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16267. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16268. */
  16269. direction1: Vector3;
  16270. /**
  16271. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16272. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16273. */
  16274. direction2: Vector3;
  16275. /**
  16276. * 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.
  16277. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16278. */
  16279. minEmitBox: Vector3;
  16280. /**
  16281. * 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.
  16282. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16283. */
  16284. maxEmitBox: Vector3;
  16285. /**
  16286. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16287. */
  16288. color1: Color4;
  16289. /**
  16290. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16291. */
  16292. color2: Color4;
  16293. /**
  16294. * Color the particle will have at the end of its lifetime
  16295. */
  16296. colorDead: Color4;
  16297. /**
  16298. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16299. */
  16300. textureMask: Color4;
  16301. /**
  16302. * The particle emitter type defines the emitter used by the particle system.
  16303. * It can be for example box, sphere, or cone...
  16304. */
  16305. particleEmitterType: IParticleEmitterType;
  16306. /** @hidden */ private _isSubEmitter: boolean;
  16307. /**
  16308. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16309. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16310. */
  16311. billboardMode: number;
  16312. protected _isBillboardBased: boolean;
  16313. /**
  16314. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16315. */
  16316. isBillboardBased: boolean;
  16317. /**
  16318. * The scene the particle system belongs to.
  16319. */
  16320. protected _scene: Scene;
  16321. /**
  16322. * Local cache of defines for image processing.
  16323. */
  16324. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16325. /**
  16326. * Default configuration related to image processing available in the standard Material.
  16327. */
  16328. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16329. /**
  16330. * Gets the image processing configuration used either in this material.
  16331. */
  16332. /**
  16333. * Sets the Default image processing configuration used either in the this material.
  16334. *
  16335. * If sets to null, the scene one is in use.
  16336. */
  16337. imageProcessingConfiguration: ImageProcessingConfiguration;
  16338. /**
  16339. * Attaches a new image processing configuration to the Standard Material.
  16340. * @param configuration
  16341. */
  16342. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16343. /** @hidden */
  16344. protected _reset(): void;
  16345. /** @hidden */
  16346. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16347. /**
  16348. * Instantiates a particle system.
  16349. * 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.
  16350. * @param name The name of the particle system
  16351. */
  16352. constructor(name: string);
  16353. /**
  16354. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16355. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16356. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16357. * @returns the emitter
  16358. */
  16359. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16360. /**
  16361. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16362. * @param radius The radius of the hemisphere to emit from
  16363. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16364. * @returns the emitter
  16365. */
  16366. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16367. /**
  16368. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16369. * @param radius The radius of the sphere to emit from
  16370. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16371. * @returns the emitter
  16372. */
  16373. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16374. /**
  16375. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16376. * @param radius The radius of the sphere to emit from
  16377. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16378. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16379. * @returns the emitter
  16380. */
  16381. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16382. /**
  16383. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16384. * @param radius The radius of the emission cylinder
  16385. * @param height The height of the emission cylinder
  16386. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16387. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16388. * @returns the emitter
  16389. */
  16390. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16391. /**
  16392. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16393. * @param radius The radius of the cylinder to emit from
  16394. * @param height The height of the emission cylinder
  16395. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16396. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16397. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16398. * @returns the emitter
  16399. */
  16400. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16401. /**
  16402. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16403. * @param radius The radius of the cone to emit from
  16404. * @param angle The base angle of the cone
  16405. * @returns the emitter
  16406. */
  16407. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16408. /**
  16409. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16410. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16411. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16412. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16413. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16414. * @returns the emitter
  16415. */
  16416. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16417. }
  16418. }
  16419. declare module BABYLON {
  16420. /**
  16421. * Type of sub emitter
  16422. */
  16423. export enum SubEmitterType {
  16424. /**
  16425. * Attached to the particle over it's lifetime
  16426. */
  16427. ATTACHED = 0,
  16428. /**
  16429. * Created when the particle dies
  16430. */
  16431. END = 1
  16432. }
  16433. /**
  16434. * Sub emitter class used to emit particles from an existing particle
  16435. */
  16436. export class SubEmitter {
  16437. /**
  16438. * the particle system to be used by the sub emitter
  16439. */
  16440. particleSystem: ParticleSystem;
  16441. /**
  16442. * Type of the submitter (Default: END)
  16443. */
  16444. type: SubEmitterType;
  16445. /**
  16446. * 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)
  16447. * Note: This only is supported when using an emitter of type Mesh
  16448. */
  16449. inheritDirection: boolean;
  16450. /**
  16451. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16452. */
  16453. inheritedVelocityAmount: number;
  16454. /**
  16455. * Creates a sub emitter
  16456. * @param particleSystem the particle system to be used by the sub emitter
  16457. */
  16458. constructor(
  16459. /**
  16460. * the particle system to be used by the sub emitter
  16461. */
  16462. particleSystem: ParticleSystem);
  16463. /**
  16464. * Clones the sub emitter
  16465. * @returns the cloned sub emitter
  16466. */
  16467. clone(): SubEmitter;
  16468. /**
  16469. * Serialize current object to a JSON object
  16470. * @returns the serialized object
  16471. */
  16472. serialize(): any;
  16473. /** @hidden */ private static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16474. /**
  16475. * Creates a new SubEmitter from a serialized JSON version
  16476. * @param serializationObject defines the JSON object to read from
  16477. * @param scene defines the hosting scene
  16478. * @param rootUrl defines the rootUrl for data loading
  16479. * @returns a new SubEmitter
  16480. */
  16481. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16482. /** Release associated resources */
  16483. dispose(): void;
  16484. }
  16485. }
  16486. declare module BABYLON {
  16487. /** @hidden */
  16488. export var clipPlaneFragmentDeclaration: {
  16489. name: string;
  16490. shader: string;
  16491. };
  16492. }
  16493. declare module BABYLON {
  16494. /** @hidden */
  16495. export var imageProcessingDeclaration: {
  16496. name: string;
  16497. shader: string;
  16498. };
  16499. }
  16500. declare module BABYLON {
  16501. /** @hidden */
  16502. export var imageProcessingFunctions: {
  16503. name: string;
  16504. shader: string;
  16505. };
  16506. }
  16507. declare module BABYLON {
  16508. /** @hidden */
  16509. export var clipPlaneFragment: {
  16510. name: string;
  16511. shader: string;
  16512. };
  16513. }
  16514. declare module BABYLON {
  16515. /** @hidden */
  16516. export var particlesPixelShader: {
  16517. name: string;
  16518. shader: string;
  16519. };
  16520. }
  16521. declare module BABYLON {
  16522. /** @hidden */
  16523. export var clipPlaneVertexDeclaration: {
  16524. name: string;
  16525. shader: string;
  16526. };
  16527. }
  16528. declare module BABYLON {
  16529. /** @hidden */
  16530. export var clipPlaneVertex: {
  16531. name: string;
  16532. shader: string;
  16533. };
  16534. }
  16535. declare module BABYLON {
  16536. /** @hidden */
  16537. export var particlesVertexShader: {
  16538. name: string;
  16539. shader: string;
  16540. };
  16541. }
  16542. declare module BABYLON {
  16543. /**
  16544. * This represents a particle system in Babylon.
  16545. * 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.
  16546. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16547. * @example https://doc.babylonjs.com/babylon101/particles
  16548. */
  16549. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16550. /**
  16551. * Billboard mode will only apply to Y axis
  16552. */
  16553. static readonly BILLBOARDMODE_Y: number;
  16554. /**
  16555. * Billboard mode will apply to all axes
  16556. */
  16557. static readonly BILLBOARDMODE_ALL: number;
  16558. /**
  16559. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16560. */
  16561. static readonly BILLBOARDMODE_STRETCHED: number;
  16562. /**
  16563. * This function can be defined to provide custom update for active particles.
  16564. * This function will be called instead of regular update (age, position, color, etc.).
  16565. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16566. */
  16567. updateFunction: (particles: Particle[]) => void;
  16568. private _emitterWorldMatrix;
  16569. /**
  16570. * This function can be defined to specify initial direction for every new particle.
  16571. * It by default use the emitterType defined function
  16572. */
  16573. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  16574. /**
  16575. * This function can be defined to specify initial position for every new particle.
  16576. * It by default use the emitterType defined function
  16577. */
  16578. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  16579. /**
  16580. * @hidden
  16581. */ private _inheritedVelocityOffset: Vector3;
  16582. /**
  16583. * An event triggered when the system is disposed
  16584. */
  16585. onDisposeObservable: Observable<ParticleSystem>;
  16586. private _onDisposeObserver;
  16587. /**
  16588. * Sets a callback that will be triggered when the system is disposed
  16589. */
  16590. onDispose: () => void;
  16591. private _particles;
  16592. private _epsilon;
  16593. private _capacity;
  16594. private _stockParticles;
  16595. private _newPartsExcess;
  16596. private _vertexData;
  16597. private _vertexBuffer;
  16598. private _vertexBuffers;
  16599. private _spriteBuffer;
  16600. private _indexBuffer;
  16601. private _effect;
  16602. private _customEffect;
  16603. private _cachedDefines;
  16604. private _scaledColorStep;
  16605. private _colorDiff;
  16606. private _scaledDirection;
  16607. private _scaledGravity;
  16608. private _currentRenderId;
  16609. private _alive;
  16610. private _useInstancing;
  16611. private _started;
  16612. private _stopped;
  16613. private _actualFrame;
  16614. private _scaledUpdateSpeed;
  16615. private _vertexBufferSize;
  16616. /** @hidden */ private _currentEmitRateGradient: Nullable<FactorGradient>;
  16617. /** @hidden */ private _currentEmitRate1: number;
  16618. /** @hidden */ private _currentEmitRate2: number;
  16619. /** @hidden */ private _currentStartSizeGradient: Nullable<FactorGradient>;
  16620. /** @hidden */ private _currentStartSize1: number;
  16621. /** @hidden */ private _currentStartSize2: number;
  16622. private readonly _rawTextureWidth;
  16623. private _rampGradientsTexture;
  16624. private _useRampGradients;
  16625. /** Gets or sets a boolean indicating that ramp gradients must be used
  16626. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16627. */
  16628. useRampGradients: boolean;
  16629. /**
  16630. * 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.
  16631. * 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: [])
  16632. */
  16633. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  16634. private _subEmitters;
  16635. /**
  16636. * @hidden
  16637. * If the particle systems emitter should be disposed when the particle system is disposed
  16638. */ private _disposeEmitterOnDispose: boolean;
  16639. /**
  16640. * The current active Sub-systems, this property is used by the root particle system only.
  16641. */
  16642. activeSubSystems: Array<ParticleSystem>;
  16643. private _rootParticleSystem;
  16644. /**
  16645. * Gets the current list of active particles
  16646. */
  16647. readonly particles: Particle[];
  16648. /**
  16649. * Returns the string "ParticleSystem"
  16650. * @returns a string containing the class name
  16651. */
  16652. getClassName(): string;
  16653. /**
  16654. * Instantiates a particle system.
  16655. * 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.
  16656. * @param name The name of the particle system
  16657. * @param capacity The max number of particles alive at the same time
  16658. * @param scene The scene the particle system belongs to
  16659. * @param customEffect a custom effect used to change the way particles are rendered by default
  16660. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  16661. * @param epsilon Offset used to render the particles
  16662. */
  16663. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  16664. private _addFactorGradient;
  16665. private _removeFactorGradient;
  16666. /**
  16667. * Adds a new life time gradient
  16668. * @param gradient defines the gradient to use (between 0 and 1)
  16669. * @param factor defines the life time factor to affect to the specified gradient
  16670. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16671. * @returns the current particle system
  16672. */
  16673. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16674. /**
  16675. * Remove a specific life time gradient
  16676. * @param gradient defines the gradient to remove
  16677. * @returns the current particle system
  16678. */
  16679. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16680. /**
  16681. * Adds a new size gradient
  16682. * @param gradient defines the gradient to use (between 0 and 1)
  16683. * @param factor defines the size factor to affect to the specified gradient
  16684. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16685. * @returns the current particle system
  16686. */
  16687. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16688. /**
  16689. * Remove a specific size gradient
  16690. * @param gradient defines the gradient to remove
  16691. * @returns the current particle system
  16692. */
  16693. removeSizeGradient(gradient: number): IParticleSystem;
  16694. /**
  16695. * Adds a new color remap gradient
  16696. * @param gradient defines the gradient to use (between 0 and 1)
  16697. * @param min defines the color remap minimal range
  16698. * @param max defines the color remap maximal range
  16699. * @returns the current particle system
  16700. */
  16701. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16702. /**
  16703. * Remove a specific color remap gradient
  16704. * @param gradient defines the gradient to remove
  16705. * @returns the current particle system
  16706. */
  16707. removeColorRemapGradient(gradient: number): IParticleSystem;
  16708. /**
  16709. * Adds a new alpha remap gradient
  16710. * @param gradient defines the gradient to use (between 0 and 1)
  16711. * @param min defines the alpha remap minimal range
  16712. * @param max defines the alpha remap maximal range
  16713. * @returns the current particle system
  16714. */
  16715. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16716. /**
  16717. * Remove a specific alpha remap gradient
  16718. * @param gradient defines the gradient to remove
  16719. * @returns the current particle system
  16720. */
  16721. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  16722. /**
  16723. * Adds a new angular speed gradient
  16724. * @param gradient defines the gradient to use (between 0 and 1)
  16725. * @param factor defines the angular speed to affect to the specified gradient
  16726. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16727. * @returns the current particle system
  16728. */
  16729. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16730. /**
  16731. * Remove a specific angular speed gradient
  16732. * @param gradient defines the gradient to remove
  16733. * @returns the current particle system
  16734. */
  16735. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16736. /**
  16737. * Adds a new velocity gradient
  16738. * @param gradient defines the gradient to use (between 0 and 1)
  16739. * @param factor defines the velocity to affect to the specified gradient
  16740. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16741. * @returns the current particle system
  16742. */
  16743. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16744. /**
  16745. * Remove a specific velocity gradient
  16746. * @param gradient defines the gradient to remove
  16747. * @returns the current particle system
  16748. */
  16749. removeVelocityGradient(gradient: number): IParticleSystem;
  16750. /**
  16751. * Adds a new limit velocity gradient
  16752. * @param gradient defines the gradient to use (between 0 and 1)
  16753. * @param factor defines the limit velocity value to affect to the specified gradient
  16754. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16755. * @returns the current particle system
  16756. */
  16757. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16758. /**
  16759. * Remove a specific limit velocity gradient
  16760. * @param gradient defines the gradient to remove
  16761. * @returns the current particle system
  16762. */
  16763. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16764. /**
  16765. * Adds a new drag gradient
  16766. * @param gradient defines the gradient to use (between 0 and 1)
  16767. * @param factor defines the drag value to affect to the specified gradient
  16768. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16769. * @returns the current particle system
  16770. */
  16771. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16772. /**
  16773. * Remove a specific drag gradient
  16774. * @param gradient defines the gradient to remove
  16775. * @returns the current particle system
  16776. */
  16777. removeDragGradient(gradient: number): IParticleSystem;
  16778. /**
  16779. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16780. * @param gradient defines the gradient to use (between 0 and 1)
  16781. * @param factor defines the emit rate value to affect to the specified gradient
  16782. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16783. * @returns the current particle system
  16784. */
  16785. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16786. /**
  16787. * Remove a specific emit rate gradient
  16788. * @param gradient defines the gradient to remove
  16789. * @returns the current particle system
  16790. */
  16791. removeEmitRateGradient(gradient: number): IParticleSystem;
  16792. /**
  16793. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16794. * @param gradient defines the gradient to use (between 0 and 1)
  16795. * @param factor defines the start size value to affect to the specified gradient
  16796. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16797. * @returns the current particle system
  16798. */
  16799. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16800. /**
  16801. * Remove a specific start size gradient
  16802. * @param gradient defines the gradient to remove
  16803. * @returns the current particle system
  16804. */
  16805. removeStartSizeGradient(gradient: number): IParticleSystem;
  16806. private _createRampGradientTexture;
  16807. /**
  16808. * Gets the current list of ramp gradients.
  16809. * You must use addRampGradient and removeRampGradient to udpate this list
  16810. * @returns the list of ramp gradients
  16811. */
  16812. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16813. /**
  16814. * Adds a new ramp gradient used to remap particle colors
  16815. * @param gradient defines the gradient to use (between 0 and 1)
  16816. * @param color defines the color to affect to the specified gradient
  16817. * @returns the current particle system
  16818. */
  16819. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  16820. /**
  16821. * Remove a specific ramp gradient
  16822. * @param gradient defines the gradient to remove
  16823. * @returns the current particle system
  16824. */
  16825. removeRampGradient(gradient: number): ParticleSystem;
  16826. /**
  16827. * Adds a new color gradient
  16828. * @param gradient defines the gradient to use (between 0 and 1)
  16829. * @param color1 defines the color to affect to the specified gradient
  16830. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16831. * @returns this particle system
  16832. */
  16833. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16834. /**
  16835. * Remove a specific color gradient
  16836. * @param gradient defines the gradient to remove
  16837. * @returns this particle system
  16838. */
  16839. removeColorGradient(gradient: number): IParticleSystem;
  16840. private _fetchR;
  16841. protected _reset(): void;
  16842. private _resetEffect;
  16843. private _createVertexBuffers;
  16844. private _createIndexBuffer;
  16845. /**
  16846. * Gets the maximum number of particles active at the same time.
  16847. * @returns The max number of active particles.
  16848. */
  16849. getCapacity(): number;
  16850. /**
  16851. * Gets whether there are still active particles in the system.
  16852. * @returns True if it is alive, otherwise false.
  16853. */
  16854. isAlive(): boolean;
  16855. /**
  16856. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16857. * @returns True if it has been started, otherwise false.
  16858. */
  16859. isStarted(): boolean;
  16860. private _prepareSubEmitterInternalArray;
  16861. /**
  16862. * Starts the particle system and begins to emit
  16863. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  16864. */
  16865. start(delay?: number): void;
  16866. /**
  16867. * Stops the particle system.
  16868. * @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.
  16869. */
  16870. stop(stopSubEmitters?: boolean): void;
  16871. /**
  16872. * Remove all active particles
  16873. */
  16874. reset(): void;
  16875. /**
  16876. * @hidden (for internal use only)
  16877. */ private _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  16878. /**
  16879. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  16880. * Its lifetime will start back at 0.
  16881. */
  16882. recycleParticle: (particle: Particle) => void;
  16883. private _stopSubEmitters;
  16884. private _createParticle;
  16885. private _removeFromRoot;
  16886. private _emitFromParticle;
  16887. private _update;
  16888. /** @hidden */ private static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  16889. /** @hidden */ private static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  16890. /** @hidden */
  16891. private _getEffect;
  16892. /**
  16893. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  16894. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  16895. */
  16896. animate(preWarmOnly?: boolean): void;
  16897. private _appendParticleVertices;
  16898. /**
  16899. * Rebuilds the particle system.
  16900. */
  16901. rebuild(): void;
  16902. /**
  16903. * Is this system ready to be used/rendered
  16904. * @return true if the system is ready
  16905. */
  16906. isReady(): boolean;
  16907. private _render;
  16908. /**
  16909. * Renders the particle system in its current state.
  16910. * @returns the current number of particles
  16911. */
  16912. render(): number;
  16913. /**
  16914. * Disposes the particle system and free the associated resources
  16915. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16916. */
  16917. dispose(disposeTexture?: boolean): void;
  16918. /**
  16919. * Clones the particle system.
  16920. * @param name The name of the cloned object
  16921. * @param newEmitter The new emitter to use
  16922. * @returns the cloned particle system
  16923. */
  16924. clone(name: string, newEmitter: any): ParticleSystem;
  16925. /**
  16926. * Serializes the particle system to a JSON object.
  16927. * @returns the JSON object
  16928. */
  16929. serialize(): any;
  16930. /** @hidden */ private static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  16931. /** @hidden */ private static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  16932. /**
  16933. * Parses a JSON object to create a particle system.
  16934. * @param parsedParticleSystem The JSON object to parse
  16935. * @param scene The scene to create the particle system in
  16936. * @param rootUrl The root url to use to load external dependencies like texture
  16937. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  16938. * @returns the Parsed particle system
  16939. */
  16940. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  16941. }
  16942. }
  16943. declare module BABYLON {
  16944. /**
  16945. * A particle represents one of the element emitted by a particle system.
  16946. * This is mainly define by its coordinates, direction, velocity and age.
  16947. */
  16948. export class Particle {
  16949. /**
  16950. * The particle system the particle belongs to.
  16951. */
  16952. particleSystem: ParticleSystem;
  16953. private static _Count;
  16954. /**
  16955. * Unique ID of the particle
  16956. */
  16957. id: number;
  16958. /**
  16959. * The world position of the particle in the scene.
  16960. */
  16961. position: Vector3;
  16962. /**
  16963. * The world direction of the particle in the scene.
  16964. */
  16965. direction: Vector3;
  16966. /**
  16967. * The color of the particle.
  16968. */
  16969. color: Color4;
  16970. /**
  16971. * The color change of the particle per step.
  16972. */
  16973. colorStep: Color4;
  16974. /**
  16975. * Defines how long will the life of the particle be.
  16976. */
  16977. lifeTime: number;
  16978. /**
  16979. * The current age of the particle.
  16980. */
  16981. age: number;
  16982. /**
  16983. * The current size of the particle.
  16984. */
  16985. size: number;
  16986. /**
  16987. * The current scale of the particle.
  16988. */
  16989. scale: Vector2;
  16990. /**
  16991. * The current angle of the particle.
  16992. */
  16993. angle: number;
  16994. /**
  16995. * Defines how fast is the angle changing.
  16996. */
  16997. angularSpeed: number;
  16998. /**
  16999. * Defines the cell index used by the particle to be rendered from a sprite.
  17000. */
  17001. cellIndex: number;
  17002. /**
  17003. * The information required to support color remapping
  17004. */
  17005. remapData: Vector4;
  17006. /** @hidden */ private _randomCellOffset?: number;
  17007. /** @hidden */ private _initialDirection: Nullable<Vector3>;
  17008. /** @hidden */ private _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17009. /** @hidden */ private _initialStartSpriteCellID: number;
  17010. /** @hidden */ private _initialEndSpriteCellID: number;
  17011. /** @hidden */ private _currentColorGradient: Nullable<ColorGradient>;
  17012. /** @hidden */ private _currentColor1: Color4;
  17013. /** @hidden */ private _currentColor2: Color4;
  17014. /** @hidden */ private _currentSizeGradient: Nullable<FactorGradient>;
  17015. /** @hidden */ private _currentSize1: number;
  17016. /** @hidden */ private _currentSize2: number;
  17017. /** @hidden */ private _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17018. /** @hidden */ private _currentAngularSpeed1: number;
  17019. /** @hidden */ private _currentAngularSpeed2: number;
  17020. /** @hidden */ private _currentVelocityGradient: Nullable<FactorGradient>;
  17021. /** @hidden */ private _currentVelocity1: number;
  17022. /** @hidden */ private _currentVelocity2: number;
  17023. /** @hidden */ private _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17024. /** @hidden */ private _currentLimitVelocity1: number;
  17025. /** @hidden */ private _currentLimitVelocity2: number;
  17026. /** @hidden */ private _currentDragGradient: Nullable<FactorGradient>;
  17027. /** @hidden */ private _currentDrag1: number;
  17028. /** @hidden */ private _currentDrag2: number;
  17029. /** @hidden */ private _randomNoiseCoordinates1: Vector3;
  17030. /** @hidden */ private _randomNoiseCoordinates2: Vector3;
  17031. /**
  17032. * Creates a new instance Particle
  17033. * @param particleSystem the particle system the particle belongs to
  17034. */
  17035. constructor(
  17036. /**
  17037. * The particle system the particle belongs to.
  17038. */
  17039. particleSystem: ParticleSystem);
  17040. private updateCellInfoFromSystem;
  17041. /**
  17042. * Defines how the sprite cell index is updated for the particle
  17043. */
  17044. updateCellIndex(): void;
  17045. /** @hidden */ private _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17046. /** @hidden */ private _inheritParticleInfoToSubEmitters(): void;
  17047. /** @hidden */ private _reset(): void;
  17048. /**
  17049. * Copy the properties of particle to another one.
  17050. * @param other the particle to copy the information to.
  17051. */
  17052. copyTo(other: Particle): void;
  17053. }
  17054. }
  17055. declare module BABYLON {
  17056. /**
  17057. * Particle emitter represents a volume emitting particles.
  17058. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17059. */
  17060. export interface IParticleEmitterType {
  17061. /**
  17062. * Called by the particle System when the direction is computed for the created particle.
  17063. * @param worldMatrix is the world matrix of the particle system
  17064. * @param directionToUpdate is the direction vector to update with the result
  17065. * @param particle is the particle we are computed the direction for
  17066. */
  17067. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17068. /**
  17069. * Called by the particle System when the position is computed for the created particle.
  17070. * @param worldMatrix is the world matrix of the particle system
  17071. * @param positionToUpdate is the position vector to update with the result
  17072. * @param particle is the particle we are computed the position for
  17073. */
  17074. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17075. /**
  17076. * Clones the current emitter and returns a copy of it
  17077. * @returns the new emitter
  17078. */
  17079. clone(): IParticleEmitterType;
  17080. /**
  17081. * Called by the GPUParticleSystem to setup the update shader
  17082. * @param effect defines the update shader
  17083. */
  17084. applyToShader(effect: Effect): void;
  17085. /**
  17086. * Returns a string to use to update the GPU particles update shader
  17087. * @returns the effect defines string
  17088. */
  17089. getEffectDefines(): string;
  17090. /**
  17091. * Returns a string representing the class name
  17092. * @returns a string containing the class name
  17093. */
  17094. getClassName(): string;
  17095. /**
  17096. * Serializes the particle system to a JSON object.
  17097. * @returns the JSON object
  17098. */
  17099. serialize(): any;
  17100. /**
  17101. * Parse properties from a JSON object
  17102. * @param serializationObject defines the JSON object
  17103. */
  17104. parse(serializationObject: any): void;
  17105. }
  17106. }
  17107. declare module BABYLON {
  17108. /**
  17109. * Particle emitter emitting particles from the inside of a box.
  17110. * It emits the particles randomly between 2 given directions.
  17111. */
  17112. export class BoxParticleEmitter implements IParticleEmitterType {
  17113. /**
  17114. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17115. */
  17116. direction1: Vector3;
  17117. /**
  17118. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17119. */
  17120. direction2: Vector3;
  17121. /**
  17122. * 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.
  17123. */
  17124. minEmitBox: Vector3;
  17125. /**
  17126. * 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.
  17127. */
  17128. maxEmitBox: Vector3;
  17129. /**
  17130. * Creates a new instance BoxParticleEmitter
  17131. */
  17132. constructor();
  17133. /**
  17134. * Called by the particle System when the direction is computed for the created particle.
  17135. * @param worldMatrix is the world matrix of the particle system
  17136. * @param directionToUpdate is the direction vector to update with the result
  17137. * @param particle is the particle we are computed the direction for
  17138. */
  17139. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17140. /**
  17141. * Called by the particle System when the position is computed for the created particle.
  17142. * @param worldMatrix is the world matrix of the particle system
  17143. * @param positionToUpdate is the position vector to update with the result
  17144. * @param particle is the particle we are computed the position for
  17145. */
  17146. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17147. /**
  17148. * Clones the current emitter and returns a copy of it
  17149. * @returns the new emitter
  17150. */
  17151. clone(): BoxParticleEmitter;
  17152. /**
  17153. * Called by the GPUParticleSystem to setup the update shader
  17154. * @param effect defines the update shader
  17155. */
  17156. applyToShader(effect: Effect): void;
  17157. /**
  17158. * Returns a string to use to update the GPU particles update shader
  17159. * @returns a string containng the defines string
  17160. */
  17161. getEffectDefines(): string;
  17162. /**
  17163. * Returns the string "BoxParticleEmitter"
  17164. * @returns a string containing the class name
  17165. */
  17166. getClassName(): string;
  17167. /**
  17168. * Serializes the particle system to a JSON object.
  17169. * @returns the JSON object
  17170. */
  17171. serialize(): any;
  17172. /**
  17173. * Parse properties from a JSON object
  17174. * @param serializationObject defines the JSON object
  17175. */
  17176. parse(serializationObject: any): void;
  17177. }
  17178. }
  17179. declare module BABYLON {
  17180. /**
  17181. * Particle emitter emitting particles from the inside of a cone.
  17182. * It emits the particles alongside the cone volume from the base to the particle.
  17183. * The emission direction might be randomized.
  17184. */
  17185. export class ConeParticleEmitter implements IParticleEmitterType {
  17186. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17187. directionRandomizer: number;
  17188. private _radius;
  17189. private _angle;
  17190. private _height;
  17191. /**
  17192. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17193. */
  17194. radiusRange: number;
  17195. /**
  17196. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17197. */
  17198. heightRange: number;
  17199. /**
  17200. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17201. */
  17202. emitFromSpawnPointOnly: boolean;
  17203. /**
  17204. * Gets or sets the radius of the emission cone
  17205. */
  17206. radius: number;
  17207. /**
  17208. * Gets or sets the angle of the emission cone
  17209. */
  17210. angle: number;
  17211. private _buildHeight;
  17212. /**
  17213. * Creates a new instance ConeParticleEmitter
  17214. * @param radius the radius of the emission cone (1 by default)
  17215. * @param angle the cone base angle (PI by default)
  17216. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17217. */
  17218. constructor(radius?: number, angle?: number,
  17219. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17220. directionRandomizer?: number);
  17221. /**
  17222. * Called by the particle System when the direction is computed for the created particle.
  17223. * @param worldMatrix is the world matrix of the particle system
  17224. * @param directionToUpdate is the direction vector to update with the result
  17225. * @param particle is the particle we are computed the direction for
  17226. */
  17227. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17228. /**
  17229. * Called by the particle System when the position is computed for the created particle.
  17230. * @param worldMatrix is the world matrix of the particle system
  17231. * @param positionToUpdate is the position vector to update with the result
  17232. * @param particle is the particle we are computed the position for
  17233. */
  17234. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17235. /**
  17236. * Clones the current emitter and returns a copy of it
  17237. * @returns the new emitter
  17238. */
  17239. clone(): ConeParticleEmitter;
  17240. /**
  17241. * Called by the GPUParticleSystem to setup the update shader
  17242. * @param effect defines the update shader
  17243. */
  17244. applyToShader(effect: Effect): void;
  17245. /**
  17246. * Returns a string to use to update the GPU particles update shader
  17247. * @returns a string containng the defines string
  17248. */
  17249. getEffectDefines(): string;
  17250. /**
  17251. * Returns the string "ConeParticleEmitter"
  17252. * @returns a string containing the class name
  17253. */
  17254. getClassName(): string;
  17255. /**
  17256. * Serializes the particle system to a JSON object.
  17257. * @returns the JSON object
  17258. */
  17259. serialize(): any;
  17260. /**
  17261. * Parse properties from a JSON object
  17262. * @param serializationObject defines the JSON object
  17263. */
  17264. parse(serializationObject: any): void;
  17265. }
  17266. }
  17267. declare module BABYLON {
  17268. /**
  17269. * Particle emitter emitting particles from the inside of a cylinder.
  17270. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17271. */
  17272. export class CylinderParticleEmitter implements IParticleEmitterType {
  17273. /**
  17274. * The radius of the emission cylinder.
  17275. */
  17276. radius: number;
  17277. /**
  17278. * The height of the emission cylinder.
  17279. */
  17280. height: number;
  17281. /**
  17282. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17283. */
  17284. radiusRange: number;
  17285. /**
  17286. * How much to randomize the particle direction [0-1].
  17287. */
  17288. directionRandomizer: number;
  17289. /**
  17290. * Creates a new instance CylinderParticleEmitter
  17291. * @param radius the radius of the emission cylinder (1 by default)
  17292. * @param height the height of the emission cylinder (1 by default)
  17293. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17294. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17295. */
  17296. constructor(
  17297. /**
  17298. * The radius of the emission cylinder.
  17299. */
  17300. radius?: number,
  17301. /**
  17302. * The height of the emission cylinder.
  17303. */
  17304. height?: number,
  17305. /**
  17306. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17307. */
  17308. radiusRange?: number,
  17309. /**
  17310. * How much to randomize the particle direction [0-1].
  17311. */
  17312. directionRandomizer?: number);
  17313. /**
  17314. * Called by the particle System when the direction is computed for the created particle.
  17315. * @param worldMatrix is the world matrix of the particle system
  17316. * @param directionToUpdate is the direction vector to update with the result
  17317. * @param particle is the particle we are computed the direction for
  17318. */
  17319. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17320. /**
  17321. * Called by the particle System when the position is computed for the created particle.
  17322. * @param worldMatrix is the world matrix of the particle system
  17323. * @param positionToUpdate is the position vector to update with the result
  17324. * @param particle is the particle we are computed the position for
  17325. */
  17326. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17327. /**
  17328. * Clones the current emitter and returns a copy of it
  17329. * @returns the new emitter
  17330. */
  17331. clone(): CylinderParticleEmitter;
  17332. /**
  17333. * Called by the GPUParticleSystem to setup the update shader
  17334. * @param effect defines the update shader
  17335. */
  17336. applyToShader(effect: Effect): void;
  17337. /**
  17338. * Returns a string to use to update the GPU particles update shader
  17339. * @returns a string containng the defines string
  17340. */
  17341. getEffectDefines(): string;
  17342. /**
  17343. * Returns the string "CylinderParticleEmitter"
  17344. * @returns a string containing the class name
  17345. */
  17346. getClassName(): string;
  17347. /**
  17348. * Serializes the particle system to a JSON object.
  17349. * @returns the JSON object
  17350. */
  17351. serialize(): any;
  17352. /**
  17353. * Parse properties from a JSON object
  17354. * @param serializationObject defines the JSON object
  17355. */
  17356. parse(serializationObject: any): void;
  17357. }
  17358. /**
  17359. * Particle emitter emitting particles from the inside of a cylinder.
  17360. * It emits the particles randomly between two vectors.
  17361. */
  17362. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17363. /**
  17364. * The min limit of the emission direction.
  17365. */
  17366. direction1: Vector3;
  17367. /**
  17368. * The max limit of the emission direction.
  17369. */
  17370. direction2: Vector3;
  17371. /**
  17372. * Creates a new instance CylinderDirectedParticleEmitter
  17373. * @param radius the radius of the emission cylinder (1 by default)
  17374. * @param height the height of the emission cylinder (1 by default)
  17375. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17376. * @param direction1 the min limit of the emission direction (up vector by default)
  17377. * @param direction2 the max limit of the emission direction (up vector by default)
  17378. */
  17379. constructor(radius?: number, height?: number, radiusRange?: number,
  17380. /**
  17381. * The min limit of the emission direction.
  17382. */
  17383. direction1?: Vector3,
  17384. /**
  17385. * The max limit of the emission direction.
  17386. */
  17387. direction2?: Vector3);
  17388. /**
  17389. * Called by the particle System when the direction is computed for the created particle.
  17390. * @param worldMatrix is the world matrix of the particle system
  17391. * @param directionToUpdate is the direction vector to update with the result
  17392. * @param particle is the particle we are computed the direction for
  17393. */
  17394. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17395. /**
  17396. * Clones the current emitter and returns a copy of it
  17397. * @returns the new emitter
  17398. */
  17399. clone(): CylinderDirectedParticleEmitter;
  17400. /**
  17401. * Called by the GPUParticleSystem to setup the update shader
  17402. * @param effect defines the update shader
  17403. */
  17404. applyToShader(effect: Effect): void;
  17405. /**
  17406. * Returns a string to use to update the GPU particles update shader
  17407. * @returns a string containng the defines string
  17408. */
  17409. getEffectDefines(): string;
  17410. /**
  17411. * Returns the string "CylinderDirectedParticleEmitter"
  17412. * @returns a string containing the class name
  17413. */
  17414. getClassName(): string;
  17415. /**
  17416. * Serializes the particle system to a JSON object.
  17417. * @returns the JSON object
  17418. */
  17419. serialize(): any;
  17420. /**
  17421. * Parse properties from a JSON object
  17422. * @param serializationObject defines the JSON object
  17423. */
  17424. parse(serializationObject: any): void;
  17425. }
  17426. }
  17427. declare module BABYLON {
  17428. /**
  17429. * Particle emitter emitting particles from the inside of a hemisphere.
  17430. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17431. */
  17432. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17433. /**
  17434. * The radius of the emission hemisphere.
  17435. */
  17436. radius: number;
  17437. /**
  17438. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17439. */
  17440. radiusRange: number;
  17441. /**
  17442. * How much to randomize the particle direction [0-1].
  17443. */
  17444. directionRandomizer: number;
  17445. /**
  17446. * Creates a new instance HemisphericParticleEmitter
  17447. * @param radius the radius of the emission hemisphere (1 by default)
  17448. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17449. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17450. */
  17451. constructor(
  17452. /**
  17453. * The radius of the emission hemisphere.
  17454. */
  17455. radius?: number,
  17456. /**
  17457. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17458. */
  17459. radiusRange?: number,
  17460. /**
  17461. * How much to randomize the particle direction [0-1].
  17462. */
  17463. directionRandomizer?: number);
  17464. /**
  17465. * Called by the particle System when the direction is computed for the created particle.
  17466. * @param worldMatrix is the world matrix of the particle system
  17467. * @param directionToUpdate is the direction vector to update with the result
  17468. * @param particle is the particle we are computed the direction for
  17469. */
  17470. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17471. /**
  17472. * Called by the particle System when the position is computed for the created particle.
  17473. * @param worldMatrix is the world matrix of the particle system
  17474. * @param positionToUpdate is the position vector to update with the result
  17475. * @param particle is the particle we are computed the position for
  17476. */
  17477. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17478. /**
  17479. * Clones the current emitter and returns a copy of it
  17480. * @returns the new emitter
  17481. */
  17482. clone(): HemisphericParticleEmitter;
  17483. /**
  17484. * Called by the GPUParticleSystem to setup the update shader
  17485. * @param effect defines the update shader
  17486. */
  17487. applyToShader(effect: Effect): void;
  17488. /**
  17489. * Returns a string to use to update the GPU particles update shader
  17490. * @returns a string containng the defines string
  17491. */
  17492. getEffectDefines(): string;
  17493. /**
  17494. * Returns the string "HemisphericParticleEmitter"
  17495. * @returns a string containing the class name
  17496. */
  17497. getClassName(): string;
  17498. /**
  17499. * Serializes the particle system to a JSON object.
  17500. * @returns the JSON object
  17501. */
  17502. serialize(): any;
  17503. /**
  17504. * Parse properties from a JSON object
  17505. * @param serializationObject defines the JSON object
  17506. */
  17507. parse(serializationObject: any): void;
  17508. }
  17509. }
  17510. declare module BABYLON {
  17511. /**
  17512. * Particle emitter emitting particles from a point.
  17513. * It emits the particles randomly between 2 given directions.
  17514. */
  17515. export class PointParticleEmitter implements IParticleEmitterType {
  17516. /**
  17517. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17518. */
  17519. direction1: Vector3;
  17520. /**
  17521. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17522. */
  17523. direction2: Vector3;
  17524. /**
  17525. * Creates a new instance PointParticleEmitter
  17526. */
  17527. constructor();
  17528. /**
  17529. * Called by the particle System when the direction is computed for the created particle.
  17530. * @param worldMatrix is the world matrix of the particle system
  17531. * @param directionToUpdate is the direction vector to update with the result
  17532. * @param particle is the particle we are computed the direction for
  17533. */
  17534. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17535. /**
  17536. * Called by the particle System when the position is computed for the created particle.
  17537. * @param worldMatrix is the world matrix of the particle system
  17538. * @param positionToUpdate is the position vector to update with the result
  17539. * @param particle is the particle we are computed the position for
  17540. */
  17541. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17542. /**
  17543. * Clones the current emitter and returns a copy of it
  17544. * @returns the new emitter
  17545. */
  17546. clone(): PointParticleEmitter;
  17547. /**
  17548. * Called by the GPUParticleSystem to setup the update shader
  17549. * @param effect defines the update shader
  17550. */
  17551. applyToShader(effect: Effect): void;
  17552. /**
  17553. * Returns a string to use to update the GPU particles update shader
  17554. * @returns a string containng the defines string
  17555. */
  17556. getEffectDefines(): string;
  17557. /**
  17558. * Returns the string "PointParticleEmitter"
  17559. * @returns a string containing the class name
  17560. */
  17561. getClassName(): string;
  17562. /**
  17563. * Serializes the particle system to a JSON object.
  17564. * @returns the JSON object
  17565. */
  17566. serialize(): any;
  17567. /**
  17568. * Parse properties from a JSON object
  17569. * @param serializationObject defines the JSON object
  17570. */
  17571. parse(serializationObject: any): void;
  17572. }
  17573. }
  17574. declare module BABYLON {
  17575. /**
  17576. * Particle emitter emitting particles from the inside of a sphere.
  17577. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  17578. */
  17579. export class SphereParticleEmitter implements IParticleEmitterType {
  17580. /**
  17581. * The radius of the emission sphere.
  17582. */
  17583. radius: number;
  17584. /**
  17585. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17586. */
  17587. radiusRange: number;
  17588. /**
  17589. * How much to randomize the particle direction [0-1].
  17590. */
  17591. directionRandomizer: number;
  17592. /**
  17593. * Creates a new instance SphereParticleEmitter
  17594. * @param radius the radius of the emission sphere (1 by default)
  17595. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17596. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17597. */
  17598. constructor(
  17599. /**
  17600. * The radius of the emission sphere.
  17601. */
  17602. radius?: number,
  17603. /**
  17604. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17605. */
  17606. radiusRange?: number,
  17607. /**
  17608. * How much to randomize the particle direction [0-1].
  17609. */
  17610. directionRandomizer?: number);
  17611. /**
  17612. * Called by the particle System when the direction is computed for the created particle.
  17613. * @param worldMatrix is the world matrix of the particle system
  17614. * @param directionToUpdate is the direction vector to update with the result
  17615. * @param particle is the particle we are computed the direction for
  17616. */
  17617. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17618. /**
  17619. * Called by the particle System when the position is computed for the created particle.
  17620. * @param worldMatrix is the world matrix of the particle system
  17621. * @param positionToUpdate is the position vector to update with the result
  17622. * @param particle is the particle we are computed the position for
  17623. */
  17624. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17625. /**
  17626. * Clones the current emitter and returns a copy of it
  17627. * @returns the new emitter
  17628. */
  17629. clone(): SphereParticleEmitter;
  17630. /**
  17631. * Called by the GPUParticleSystem to setup the update shader
  17632. * @param effect defines the update shader
  17633. */
  17634. applyToShader(effect: Effect): void;
  17635. /**
  17636. * Returns a string to use to update the GPU particles update shader
  17637. * @returns a string containng the defines string
  17638. */
  17639. getEffectDefines(): string;
  17640. /**
  17641. * Returns the string "SphereParticleEmitter"
  17642. * @returns a string containing the class name
  17643. */
  17644. getClassName(): string;
  17645. /**
  17646. * Serializes the particle system to a JSON object.
  17647. * @returns the JSON object
  17648. */
  17649. serialize(): any;
  17650. /**
  17651. * Parse properties from a JSON object
  17652. * @param serializationObject defines the JSON object
  17653. */
  17654. parse(serializationObject: any): void;
  17655. }
  17656. /**
  17657. * Particle emitter emitting particles from the inside of a sphere.
  17658. * It emits the particles randomly between two vectors.
  17659. */
  17660. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  17661. /**
  17662. * The min limit of the emission direction.
  17663. */
  17664. direction1: Vector3;
  17665. /**
  17666. * The max limit of the emission direction.
  17667. */
  17668. direction2: Vector3;
  17669. /**
  17670. * Creates a new instance SphereDirectedParticleEmitter
  17671. * @param radius the radius of the emission sphere (1 by default)
  17672. * @param direction1 the min limit of the emission direction (up vector by default)
  17673. * @param direction2 the max limit of the emission direction (up vector by default)
  17674. */
  17675. constructor(radius?: number,
  17676. /**
  17677. * The min limit of the emission direction.
  17678. */
  17679. direction1?: Vector3,
  17680. /**
  17681. * The max limit of the emission direction.
  17682. */
  17683. direction2?: Vector3);
  17684. /**
  17685. * Called by the particle System when the direction is computed for the created particle.
  17686. * @param worldMatrix is the world matrix of the particle system
  17687. * @param directionToUpdate is the direction vector to update with the result
  17688. * @param particle is the particle we are computed the direction for
  17689. */
  17690. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17691. /**
  17692. * Clones the current emitter and returns a copy of it
  17693. * @returns the new emitter
  17694. */
  17695. clone(): SphereDirectedParticleEmitter;
  17696. /**
  17697. * Called by the GPUParticleSystem to setup the update shader
  17698. * @param effect defines the update shader
  17699. */
  17700. applyToShader(effect: Effect): void;
  17701. /**
  17702. * Returns a string to use to update the GPU particles update shader
  17703. * @returns a string containng the defines string
  17704. */
  17705. getEffectDefines(): string;
  17706. /**
  17707. * Returns the string "SphereDirectedParticleEmitter"
  17708. * @returns a string containing the class name
  17709. */
  17710. getClassName(): string;
  17711. /**
  17712. * Serializes the particle system to a JSON object.
  17713. * @returns the JSON object
  17714. */
  17715. serialize(): any;
  17716. /**
  17717. * Parse properties from a JSON object
  17718. * @param serializationObject defines the JSON object
  17719. */
  17720. parse(serializationObject: any): void;
  17721. }
  17722. }
  17723. declare module BABYLON {
  17724. /**
  17725. * Interface representing a particle system in Babylon.js.
  17726. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17727. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17728. */
  17729. export interface IParticleSystem {
  17730. /**
  17731. * List of animations used by the particle system.
  17732. */
  17733. animations: Animation[];
  17734. /**
  17735. * The id of the Particle system.
  17736. */
  17737. id: string;
  17738. /**
  17739. * The name of the Particle system.
  17740. */
  17741. name: string;
  17742. /**
  17743. * The emitter represents the Mesh or position we are attaching the particle system to.
  17744. */
  17745. emitter: Nullable<AbstractMesh | Vector3>;
  17746. /**
  17747. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17748. */
  17749. isBillboardBased: boolean;
  17750. /**
  17751. * The rendering group used by the Particle system to chose when to render.
  17752. */
  17753. renderingGroupId: number;
  17754. /**
  17755. * The layer mask we are rendering the particles through.
  17756. */
  17757. layerMask: number;
  17758. /**
  17759. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17760. */
  17761. updateSpeed: number;
  17762. /**
  17763. * The amount of time the particle system is running (depends of the overall update speed).
  17764. */
  17765. targetStopDuration: number;
  17766. /**
  17767. * The texture used to render each particle. (this can be a spritesheet)
  17768. */
  17769. particleTexture: Nullable<Texture>;
  17770. /**
  17771. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  17772. */
  17773. blendMode: number;
  17774. /**
  17775. * Minimum life time of emitting particles.
  17776. */
  17777. minLifeTime: number;
  17778. /**
  17779. * Maximum life time of emitting particles.
  17780. */
  17781. maxLifeTime: number;
  17782. /**
  17783. * Minimum Size of emitting particles.
  17784. */
  17785. minSize: number;
  17786. /**
  17787. * Maximum Size of emitting particles.
  17788. */
  17789. maxSize: number;
  17790. /**
  17791. * Minimum scale of emitting particles on X axis.
  17792. */
  17793. minScaleX: number;
  17794. /**
  17795. * Maximum scale of emitting particles on X axis.
  17796. */
  17797. maxScaleX: number;
  17798. /**
  17799. * Minimum scale of emitting particles on Y axis.
  17800. */
  17801. minScaleY: number;
  17802. /**
  17803. * Maximum scale of emitting particles on Y axis.
  17804. */
  17805. maxScaleY: number;
  17806. /**
  17807. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17808. */
  17809. color1: Color4;
  17810. /**
  17811. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17812. */
  17813. color2: Color4;
  17814. /**
  17815. * Color the particle will have at the end of its lifetime.
  17816. */
  17817. colorDead: Color4;
  17818. /**
  17819. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17820. */
  17821. emitRate: number;
  17822. /**
  17823. * You can use gravity if you want to give an orientation to your particles.
  17824. */
  17825. gravity: Vector3;
  17826. /**
  17827. * Minimum power of emitting particles.
  17828. */
  17829. minEmitPower: number;
  17830. /**
  17831. * Maximum power of emitting particles.
  17832. */
  17833. maxEmitPower: number;
  17834. /**
  17835. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17836. */
  17837. minAngularSpeed: number;
  17838. /**
  17839. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17840. */
  17841. maxAngularSpeed: number;
  17842. /**
  17843. * Gets or sets the minimal initial rotation in radians.
  17844. */
  17845. minInitialRotation: number;
  17846. /**
  17847. * Gets or sets the maximal initial rotation in radians.
  17848. */
  17849. maxInitialRotation: number;
  17850. /**
  17851. * The particle emitter type defines the emitter used by the particle system.
  17852. * It can be for example box, sphere, or cone...
  17853. */
  17854. particleEmitterType: Nullable<IParticleEmitterType>;
  17855. /**
  17856. * Defines the delay in milliseconds before starting the system (0 by default)
  17857. */
  17858. startDelay: number;
  17859. /**
  17860. * 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
  17861. */
  17862. preWarmCycles: number;
  17863. /**
  17864. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  17865. */
  17866. preWarmStepOffset: number;
  17867. /**
  17868. * 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)
  17869. */
  17870. spriteCellChangeSpeed: number;
  17871. /**
  17872. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17873. */
  17874. startSpriteCellID: number;
  17875. /**
  17876. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17877. */
  17878. endSpriteCellID: number;
  17879. /**
  17880. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17881. */
  17882. spriteCellWidth: number;
  17883. /**
  17884. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17885. */
  17886. spriteCellHeight: number;
  17887. /**
  17888. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17889. */
  17890. spriteRandomStartCell: boolean;
  17891. /**
  17892. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  17893. */
  17894. isAnimationSheetEnabled: boolean;
  17895. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17896. translationPivot: Vector2;
  17897. /**
  17898. * Gets or sets a texture used to add random noise to particle positions
  17899. */
  17900. noiseTexture: Nullable<BaseTexture>;
  17901. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17902. noiseStrength: Vector3;
  17903. /**
  17904. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17905. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17906. */
  17907. billboardMode: number;
  17908. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17909. limitVelocityDamping: number;
  17910. /**
  17911. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17912. */
  17913. beginAnimationOnStart: boolean;
  17914. /**
  17915. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17916. */
  17917. beginAnimationFrom: number;
  17918. /**
  17919. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17920. */
  17921. beginAnimationTo: number;
  17922. /**
  17923. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17924. */
  17925. beginAnimationLoop: boolean;
  17926. /**
  17927. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17928. */
  17929. disposeOnStop: boolean;
  17930. /**
  17931. * Gets the maximum number of particles active at the same time.
  17932. * @returns The max number of active particles.
  17933. */
  17934. getCapacity(): number;
  17935. /**
  17936. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17937. * @returns True if it has been started, otherwise false.
  17938. */
  17939. isStarted(): boolean;
  17940. /**
  17941. * Animates the particle system for this frame.
  17942. */
  17943. animate(): void;
  17944. /**
  17945. * Renders the particle system in its current state.
  17946. * @returns the current number of particles
  17947. */
  17948. render(): number;
  17949. /**
  17950. * Dispose the particle system and frees its associated resources.
  17951. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17952. */
  17953. dispose(disposeTexture?: boolean): void;
  17954. /**
  17955. * Clones the particle system.
  17956. * @param name The name of the cloned object
  17957. * @param newEmitter The new emitter to use
  17958. * @returns the cloned particle system
  17959. */
  17960. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  17961. /**
  17962. * Serializes the particle system to a JSON object.
  17963. * @returns the JSON object
  17964. */
  17965. serialize(): any;
  17966. /**
  17967. * Rebuild the particle system
  17968. */
  17969. rebuild(): void;
  17970. /**
  17971. * Starts the particle system and begins to emit
  17972. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  17973. */
  17974. start(delay?: number): void;
  17975. /**
  17976. * Stops the particle system.
  17977. */
  17978. stop(): void;
  17979. /**
  17980. * Remove all active particles
  17981. */
  17982. reset(): void;
  17983. /**
  17984. * Is this system ready to be used/rendered
  17985. * @return true if the system is ready
  17986. */
  17987. isReady(): boolean;
  17988. /**
  17989. * Adds a new color gradient
  17990. * @param gradient defines the gradient to use (between 0 and 1)
  17991. * @param color1 defines the color to affect to the specified gradient
  17992. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17993. * @returns the current particle system
  17994. */
  17995. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17996. /**
  17997. * Remove a specific color gradient
  17998. * @param gradient defines the gradient to remove
  17999. * @returns the current particle system
  18000. */
  18001. removeColorGradient(gradient: number): IParticleSystem;
  18002. /**
  18003. * Adds a new size gradient
  18004. * @param gradient defines the gradient to use (between 0 and 1)
  18005. * @param factor defines the size factor to affect to the specified gradient
  18006. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18007. * @returns the current particle system
  18008. */
  18009. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18010. /**
  18011. * Remove a specific size gradient
  18012. * @param gradient defines the gradient to remove
  18013. * @returns the current particle system
  18014. */
  18015. removeSizeGradient(gradient: number): IParticleSystem;
  18016. /**
  18017. * Gets the current list of color gradients.
  18018. * You must use addColorGradient and removeColorGradient to udpate this list
  18019. * @returns the list of color gradients
  18020. */
  18021. getColorGradients(): Nullable<Array<ColorGradient>>;
  18022. /**
  18023. * Gets the current list of size gradients.
  18024. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18025. * @returns the list of size gradients
  18026. */
  18027. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18028. /**
  18029. * Gets the current list of angular speed gradients.
  18030. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18031. * @returns the list of angular speed gradients
  18032. */
  18033. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18034. /**
  18035. * Adds a new angular speed gradient
  18036. * @param gradient defines the gradient to use (between 0 and 1)
  18037. * @param factor defines the angular speed to affect to the specified gradient
  18038. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18039. * @returns the current particle system
  18040. */
  18041. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18042. /**
  18043. * Remove a specific angular speed gradient
  18044. * @param gradient defines the gradient to remove
  18045. * @returns the current particle system
  18046. */
  18047. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18048. /**
  18049. * Gets the current list of velocity gradients.
  18050. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18051. * @returns the list of velocity gradients
  18052. */
  18053. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18054. /**
  18055. * Adds a new velocity gradient
  18056. * @param gradient defines the gradient to use (between 0 and 1)
  18057. * @param factor defines the velocity to affect to the specified gradient
  18058. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18059. * @returns the current particle system
  18060. */
  18061. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18062. /**
  18063. * Remove a specific velocity gradient
  18064. * @param gradient defines the gradient to remove
  18065. * @returns the current particle system
  18066. */
  18067. removeVelocityGradient(gradient: number): IParticleSystem;
  18068. /**
  18069. * Gets the current list of limit velocity gradients.
  18070. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18071. * @returns the list of limit velocity gradients
  18072. */
  18073. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18074. /**
  18075. * Adds a new limit velocity gradient
  18076. * @param gradient defines the gradient to use (between 0 and 1)
  18077. * @param factor defines the limit velocity to affect to the specified gradient
  18078. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18079. * @returns the current particle system
  18080. */
  18081. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18082. /**
  18083. * Remove a specific limit velocity gradient
  18084. * @param gradient defines the gradient to remove
  18085. * @returns the current particle system
  18086. */
  18087. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18088. /**
  18089. * Adds a new drag gradient
  18090. * @param gradient defines the gradient to use (between 0 and 1)
  18091. * @param factor defines the drag to affect to the specified gradient
  18092. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18093. * @returns the current particle system
  18094. */
  18095. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18096. /**
  18097. * Remove a specific drag gradient
  18098. * @param gradient defines the gradient to remove
  18099. * @returns the current particle system
  18100. */
  18101. removeDragGradient(gradient: number): IParticleSystem;
  18102. /**
  18103. * Gets the current list of drag gradients.
  18104. * You must use addDragGradient and removeDragGradient to udpate this list
  18105. * @returns the list of drag gradients
  18106. */
  18107. getDragGradients(): Nullable<Array<FactorGradient>>;
  18108. /**
  18109. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18110. * @param gradient defines the gradient to use (between 0 and 1)
  18111. * @param factor defines the emit rate to affect to the specified gradient
  18112. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18113. * @returns the current particle system
  18114. */
  18115. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18116. /**
  18117. * Remove a specific emit rate gradient
  18118. * @param gradient defines the gradient to remove
  18119. * @returns the current particle system
  18120. */
  18121. removeEmitRateGradient(gradient: number): IParticleSystem;
  18122. /**
  18123. * Gets the current list of emit rate gradients.
  18124. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18125. * @returns the list of emit rate gradients
  18126. */
  18127. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18128. /**
  18129. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18130. * @param gradient defines the gradient to use (between 0 and 1)
  18131. * @param factor defines the start size to affect to the specified gradient
  18132. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18133. * @returns the current particle system
  18134. */
  18135. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18136. /**
  18137. * Remove a specific start size gradient
  18138. * @param gradient defines the gradient to remove
  18139. * @returns the current particle system
  18140. */
  18141. removeStartSizeGradient(gradient: number): IParticleSystem;
  18142. /**
  18143. * Gets the current list of start size gradients.
  18144. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18145. * @returns the list of start size gradients
  18146. */
  18147. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18148. /**
  18149. * Adds a new life time gradient
  18150. * @param gradient defines the gradient to use (between 0 and 1)
  18151. * @param factor defines the life time factor to affect to the specified gradient
  18152. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18153. * @returns the current particle system
  18154. */
  18155. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18156. /**
  18157. * Remove a specific life time gradient
  18158. * @param gradient defines the gradient to remove
  18159. * @returns the current particle system
  18160. */
  18161. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18162. /**
  18163. * Gets the current list of life time gradients.
  18164. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18165. * @returns the list of life time gradients
  18166. */
  18167. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18168. /**
  18169. * Gets the current list of color gradients.
  18170. * You must use addColorGradient and removeColorGradient to udpate this list
  18171. * @returns the list of color gradients
  18172. */
  18173. getColorGradients(): Nullable<Array<ColorGradient>>;
  18174. /**
  18175. * Adds a new ramp gradient used to remap particle colors
  18176. * @param gradient defines the gradient to use (between 0 and 1)
  18177. * @param color defines the color to affect to the specified gradient
  18178. * @returns the current particle system
  18179. */
  18180. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18181. /**
  18182. * Gets the current list of ramp gradients.
  18183. * You must use addRampGradient and removeRampGradient to udpate this list
  18184. * @returns the list of ramp gradients
  18185. */
  18186. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18187. /** Gets or sets a boolean indicating that ramp gradients must be used
  18188. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18189. */
  18190. useRampGradients: boolean;
  18191. /**
  18192. * Adds a new color remap gradient
  18193. * @param gradient defines the gradient to use (between 0 and 1)
  18194. * @param min defines the color remap minimal range
  18195. * @param max defines the color remap maximal range
  18196. * @returns the current particle system
  18197. */
  18198. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18199. /**
  18200. * Gets the current list of color remap gradients.
  18201. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18202. * @returns the list of color remap gradients
  18203. */
  18204. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18205. /**
  18206. * Adds a new alpha remap gradient
  18207. * @param gradient defines the gradient to use (between 0 and 1)
  18208. * @param min defines the alpha remap minimal range
  18209. * @param max defines the alpha remap maximal range
  18210. * @returns the current particle system
  18211. */
  18212. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18213. /**
  18214. * Gets the current list of alpha remap gradients.
  18215. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18216. * @returns the list of alpha remap gradients
  18217. */
  18218. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18219. /**
  18220. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18221. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18222. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18223. * @returns the emitter
  18224. */
  18225. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18226. /**
  18227. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18228. * @param radius The radius of the hemisphere to emit from
  18229. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18230. * @returns the emitter
  18231. */
  18232. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18233. /**
  18234. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18235. * @param radius The radius of the sphere to emit from
  18236. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18237. * @returns the emitter
  18238. */
  18239. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18240. /**
  18241. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18242. * @param radius The radius of the sphere to emit from
  18243. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18244. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18245. * @returns the emitter
  18246. */
  18247. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18248. /**
  18249. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18250. * @param radius The radius of the emission cylinder
  18251. * @param height The height of the emission cylinder
  18252. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18253. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18254. * @returns the emitter
  18255. */
  18256. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18257. /**
  18258. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18259. * @param radius The radius of the cylinder to emit from
  18260. * @param height The height of the emission cylinder
  18261. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18262. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18263. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18264. * @returns the emitter
  18265. */
  18266. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18267. /**
  18268. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18269. * @param radius The radius of the cone to emit from
  18270. * @param angle The base angle of the cone
  18271. * @returns the emitter
  18272. */
  18273. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18274. /**
  18275. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18276. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18277. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18278. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18279. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18280. * @returns the emitter
  18281. */
  18282. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18283. /**
  18284. * Get hosting scene
  18285. * @returns the scene
  18286. */
  18287. getScene(): Scene;
  18288. }
  18289. }
  18290. declare module BABYLON {
  18291. /**
  18292. * Creates an instance based on a source mesh.
  18293. */
  18294. export class InstancedMesh extends AbstractMesh {
  18295. private _sourceMesh;
  18296. private _currentLOD;
  18297. /** @hidden */ private _indexInSourceMeshInstanceArray: number;
  18298. constructor(name: string, source: Mesh);
  18299. /**
  18300. * Returns the string "InstancedMesh".
  18301. */
  18302. getClassName(): string;
  18303. /** Gets the list of lights affecting that mesh */
  18304. readonly lightSources: Light[]; private _resyncLightSources(): void; private _resyncLighSource(light: Light): void; private _removeLightSource(light: Light): void;
  18305. /**
  18306. * If the source mesh receives shadows
  18307. */
  18308. readonly receiveShadows: boolean;
  18309. /**
  18310. * The material of the source mesh
  18311. */
  18312. readonly material: Nullable<Material>;
  18313. /**
  18314. * Visibility of the source mesh
  18315. */
  18316. readonly visibility: number;
  18317. /**
  18318. * Skeleton of the source mesh
  18319. */
  18320. readonly skeleton: Nullable<Skeleton>;
  18321. /**
  18322. * Rendering ground id of the source mesh
  18323. */
  18324. renderingGroupId: number;
  18325. /**
  18326. * Returns the total number of vertices (integer).
  18327. */
  18328. getTotalVertices(): number;
  18329. /**
  18330. * Returns a positive integer : the total number of indices in this mesh geometry.
  18331. * @returns the numner of indices or zero if the mesh has no geometry.
  18332. */
  18333. getTotalIndices(): number;
  18334. /**
  18335. * The source mesh of the instance
  18336. */
  18337. readonly sourceMesh: Mesh;
  18338. /**
  18339. * Is this node ready to be used/rendered
  18340. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18341. * @return {boolean} is it ready
  18342. */
  18343. isReady(completeCheck?: boolean): boolean;
  18344. /**
  18345. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18346. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18347. * @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.
  18348. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18349. */
  18350. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18351. /**
  18352. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18353. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18354. * The `data` are either a numeric array either a Float32Array.
  18355. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18356. * 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).
  18357. * Note that a new underlying VertexBuffer object is created each call.
  18358. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18359. *
  18360. * Possible `kind` values :
  18361. * - VertexBuffer.PositionKind
  18362. * - VertexBuffer.UVKind
  18363. * - VertexBuffer.UV2Kind
  18364. * - VertexBuffer.UV3Kind
  18365. * - VertexBuffer.UV4Kind
  18366. * - VertexBuffer.UV5Kind
  18367. * - VertexBuffer.UV6Kind
  18368. * - VertexBuffer.ColorKind
  18369. * - VertexBuffer.MatricesIndicesKind
  18370. * - VertexBuffer.MatricesIndicesExtraKind
  18371. * - VertexBuffer.MatricesWeightsKind
  18372. * - VertexBuffer.MatricesWeightsExtraKind
  18373. *
  18374. * Returns the Mesh.
  18375. */
  18376. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18377. /**
  18378. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18379. * If the mesh has no geometry, it is simply returned as it is.
  18380. * The `data` are either a numeric array either a Float32Array.
  18381. * No new underlying VertexBuffer object is created.
  18382. * 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.
  18383. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18384. *
  18385. * Possible `kind` values :
  18386. * - VertexBuffer.PositionKind
  18387. * - VertexBuffer.UVKind
  18388. * - VertexBuffer.UV2Kind
  18389. * - VertexBuffer.UV3Kind
  18390. * - VertexBuffer.UV4Kind
  18391. * - VertexBuffer.UV5Kind
  18392. * - VertexBuffer.UV6Kind
  18393. * - VertexBuffer.ColorKind
  18394. * - VertexBuffer.MatricesIndicesKind
  18395. * - VertexBuffer.MatricesIndicesExtraKind
  18396. * - VertexBuffer.MatricesWeightsKind
  18397. * - VertexBuffer.MatricesWeightsExtraKind
  18398. *
  18399. * Returns the Mesh.
  18400. */
  18401. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18402. /**
  18403. * Sets the mesh indices.
  18404. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18405. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18406. * This method creates a new index buffer each call.
  18407. * Returns the Mesh.
  18408. */
  18409. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18410. /**
  18411. * Boolean : True if the mesh owns the requested kind of data.
  18412. */
  18413. isVerticesDataPresent(kind: string): boolean;
  18414. /**
  18415. * Returns an array of indices (IndicesArray).
  18416. */
  18417. getIndices(): Nullable<IndicesArray>; protected readonly _positions: Nullable<Vector3[]>;
  18418. /**
  18419. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18420. * This means the mesh underlying bounding box and sphere are recomputed.
  18421. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18422. * @returns the current mesh
  18423. */
  18424. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18425. /** @hidden */ private _preActivate(): InstancedMesh;
  18426. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  18427. /** @hidden */ private _postActivate(): void;
  18428. getWorldMatrix(): Matrix;
  18429. readonly isAnInstance: boolean;
  18430. /**
  18431. * Returns the current associated LOD AbstractMesh.
  18432. */
  18433. getLOD(camera: Camera): AbstractMesh;
  18434. /** @hidden */ private _syncSubMeshes(): InstancedMesh;
  18435. /** @hidden */ private _generatePointsArray(): boolean;
  18436. /**
  18437. * Creates a new InstancedMesh from the current mesh.
  18438. * - name (string) : the cloned mesh name
  18439. * - newParent (optional Node) : the optional Node to parent the clone to.
  18440. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18441. *
  18442. * Returns the clone.
  18443. */
  18444. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18445. /**
  18446. * Disposes the InstancedMesh.
  18447. * Returns nothing.
  18448. */
  18449. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18450. }
  18451. }
  18452. declare module BABYLON {
  18453. /**
  18454. * Defines the options associated with the creation of a shader material.
  18455. */
  18456. export interface IShaderMaterialOptions {
  18457. /**
  18458. * Does the material work in alpha blend mode
  18459. */
  18460. needAlphaBlending: boolean;
  18461. /**
  18462. * Does the material work in alpha test mode
  18463. */
  18464. needAlphaTesting: boolean;
  18465. /**
  18466. * The list of attribute names used in the shader
  18467. */
  18468. attributes: string[];
  18469. /**
  18470. * The list of unifrom names used in the shader
  18471. */
  18472. uniforms: string[];
  18473. /**
  18474. * The list of UBO names used in the shader
  18475. */
  18476. uniformBuffers: string[];
  18477. /**
  18478. * The list of sampler names used in the shader
  18479. */
  18480. samplers: string[];
  18481. /**
  18482. * The list of defines used in the shader
  18483. */
  18484. defines: string[];
  18485. }
  18486. /**
  18487. * 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.
  18488. *
  18489. * This returned material effects how the mesh will look based on the code in the shaders.
  18490. *
  18491. * @see http://doc.babylonjs.com/how_to/shader_material
  18492. */
  18493. export class ShaderMaterial extends Material {
  18494. private _shaderPath;
  18495. private _options;
  18496. private _textures;
  18497. private _textureArrays;
  18498. private _floats;
  18499. private _ints;
  18500. private _floatsArrays;
  18501. private _colors3;
  18502. private _colors3Arrays;
  18503. private _colors4;
  18504. private _colors4Arrays;
  18505. private _vectors2;
  18506. private _vectors3;
  18507. private _vectors4;
  18508. private _matrices;
  18509. private _matrices3x3;
  18510. private _matrices2x2;
  18511. private _vectors2Arrays;
  18512. private _vectors3Arrays;
  18513. private _vectors4Arrays;
  18514. private _cachedWorldViewMatrix;
  18515. private _cachedWorldViewProjectionMatrix;
  18516. private _renderId;
  18517. /**
  18518. * Instantiate a new shader material.
  18519. * 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.
  18520. * This returned material effects how the mesh will look based on the code in the shaders.
  18521. * @see http://doc.babylonjs.com/how_to/shader_material
  18522. * @param name Define the name of the material in the scene
  18523. * @param scene Define the scene the material belongs to
  18524. * @param shaderPath Defines the route to the shader code in one of three ways:
  18525. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18526. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  18527. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18528. * @param options Define the options used to create the shader
  18529. */
  18530. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18531. /**
  18532. * Gets the options used to compile the shader.
  18533. * They can be modified to trigger a new compilation
  18534. */
  18535. readonly options: IShaderMaterialOptions;
  18536. /**
  18537. * Gets the current class name of the material e.g. "ShaderMaterial"
  18538. * Mainly use in serialization.
  18539. * @returns the class name
  18540. */
  18541. getClassName(): string;
  18542. /**
  18543. * Specifies if the material will require alpha blending
  18544. * @returns a boolean specifying if alpha blending is needed
  18545. */
  18546. needAlphaBlending(): boolean;
  18547. /**
  18548. * Specifies if this material should be rendered in alpha test mode
  18549. * @returns a boolean specifying if an alpha test is needed.
  18550. */
  18551. needAlphaTesting(): boolean;
  18552. private _checkUniform;
  18553. /**
  18554. * Set a texture in the shader.
  18555. * @param name Define the name of the uniform samplers as defined in the shader
  18556. * @param texture Define the texture to bind to this sampler
  18557. * @return the material itself allowing "fluent" like uniform updates
  18558. */
  18559. setTexture(name: string, texture: Texture): ShaderMaterial;
  18560. /**
  18561. * Set a texture array in the shader.
  18562. * @param name Define the name of the uniform sampler array as defined in the shader
  18563. * @param textures Define the list of textures to bind to this sampler
  18564. * @return the material itself allowing "fluent" like uniform updates
  18565. */
  18566. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18567. /**
  18568. * Set a float in the shader.
  18569. * @param name Define the name of the uniform as defined in the shader
  18570. * @param value Define the value to give to the uniform
  18571. * @return the material itself allowing "fluent" like uniform updates
  18572. */
  18573. setFloat(name: string, value: number): ShaderMaterial;
  18574. /**
  18575. * Set a int in the shader.
  18576. * @param name Define the name of the uniform as defined in the shader
  18577. * @param value Define the value to give to the uniform
  18578. * @return the material itself allowing "fluent" like uniform updates
  18579. */
  18580. setInt(name: string, value: number): ShaderMaterial;
  18581. /**
  18582. * Set an array of floats in the shader.
  18583. * @param name Define the name of the uniform as defined in the shader
  18584. * @param value Define the value to give to the uniform
  18585. * @return the material itself allowing "fluent" like uniform updates
  18586. */
  18587. setFloats(name: string, value: number[]): ShaderMaterial;
  18588. /**
  18589. * Set a vec3 in the shader from a Color3.
  18590. * @param name Define the name of the uniform as defined in the shader
  18591. * @param value Define the value to give to the uniform
  18592. * @return the material itself allowing "fluent" like uniform updates
  18593. */
  18594. setColor3(name: string, value: Color3): ShaderMaterial;
  18595. /**
  18596. * Set a vec3 array in the shader from a Color3 array.
  18597. * @param name Define the name of the uniform as defined in the shader
  18598. * @param value Define the value to give to the uniform
  18599. * @return the material itself allowing "fluent" like uniform updates
  18600. */
  18601. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18602. /**
  18603. * Set a vec4 in the shader from a Color4.
  18604. * @param name Define the name of the uniform as defined in the shader
  18605. * @param value Define the value to give to the uniform
  18606. * @return the material itself allowing "fluent" like uniform updates
  18607. */
  18608. setColor4(name: string, value: Color4): ShaderMaterial;
  18609. /**
  18610. * Set a vec4 array in the shader from a Color4 array.
  18611. * @param name Define the name of the uniform as defined in the shader
  18612. * @param value Define the value to give to the uniform
  18613. * @return the material itself allowing "fluent" like uniform updates
  18614. */
  18615. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  18616. /**
  18617. * Set a vec2 in the shader from a Vector2.
  18618. * @param name Define the name of the uniform as defined in the shader
  18619. * @param value Define the value to give to the uniform
  18620. * @return the material itself allowing "fluent" like uniform updates
  18621. */
  18622. setVector2(name: string, value: Vector2): ShaderMaterial;
  18623. /**
  18624. * Set a vec3 in the shader from a Vector3.
  18625. * @param name Define the name of the uniform as defined in the shader
  18626. * @param value Define the value to give to the uniform
  18627. * @return the material itself allowing "fluent" like uniform updates
  18628. */
  18629. setVector3(name: string, value: Vector3): ShaderMaterial;
  18630. /**
  18631. * Set a vec4 in the shader from a Vector4.
  18632. * @param name Define the name of the uniform as defined in the shader
  18633. * @param value Define the value to give to the uniform
  18634. * @return the material itself allowing "fluent" like uniform updates
  18635. */
  18636. setVector4(name: string, value: Vector4): ShaderMaterial;
  18637. /**
  18638. * Set a mat4 in the shader from a Matrix.
  18639. * @param name Define the name of the uniform as defined in the shader
  18640. * @param value Define the value to give to the uniform
  18641. * @return the material itself allowing "fluent" like uniform updates
  18642. */
  18643. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18644. /**
  18645. * Set a mat3 in the shader from a Float32Array.
  18646. * @param name Define the name of the uniform as defined in the shader
  18647. * @param value Define the value to give to the uniform
  18648. * @return the material itself allowing "fluent" like uniform updates
  18649. */
  18650. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18651. /**
  18652. * Set a mat2 in the shader from a Float32Array.
  18653. * @param name Define the name of the uniform as defined in the shader
  18654. * @param value Define the value to give to the uniform
  18655. * @return the material itself allowing "fluent" like uniform updates
  18656. */
  18657. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18658. /**
  18659. * Set a vec2 array in the shader from a number array.
  18660. * @param name Define the name of the uniform as defined in the shader
  18661. * @param value Define the value to give to the uniform
  18662. * @return the material itself allowing "fluent" like uniform updates
  18663. */
  18664. setArray2(name: string, value: number[]): ShaderMaterial;
  18665. /**
  18666. * Set a vec3 array in the shader from a number array.
  18667. * @param name Define the name of the uniform as defined in the shader
  18668. * @param value Define the value to give to the uniform
  18669. * @return the material itself allowing "fluent" like uniform updates
  18670. */
  18671. setArray3(name: string, value: number[]): ShaderMaterial;
  18672. /**
  18673. * Set a vec4 array in the shader from a number array.
  18674. * @param name Define the name of the uniform as defined in the shader
  18675. * @param value Define the value to give to the uniform
  18676. * @return the material itself allowing "fluent" like uniform updates
  18677. */
  18678. setArray4(name: string, value: number[]): ShaderMaterial;
  18679. private _checkCache;
  18680. /**
  18681. * Specifies that the submesh is ready to be used
  18682. * @param mesh defines the mesh to check
  18683. * @param subMesh defines which submesh to check
  18684. * @param useInstances specifies that instances should be used
  18685. * @returns a boolean indicating that the submesh is ready or not
  18686. */
  18687. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18688. /**
  18689. * Checks if the material is ready to render the requested mesh
  18690. * @param mesh Define the mesh to render
  18691. * @param useInstances Define whether or not the material is used with instances
  18692. * @returns true if ready, otherwise false
  18693. */
  18694. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18695. /**
  18696. * Binds the world matrix to the material
  18697. * @param world defines the world transformation matrix
  18698. */
  18699. bindOnlyWorldMatrix(world: Matrix): void;
  18700. /**
  18701. * Binds the material to the mesh
  18702. * @param world defines the world transformation matrix
  18703. * @param mesh defines the mesh to bind the material to
  18704. */
  18705. bind(world: Matrix, mesh?: Mesh): void;
  18706. /**
  18707. * Gets the active textures from the material
  18708. * @returns an array of textures
  18709. */
  18710. getActiveTextures(): BaseTexture[];
  18711. /**
  18712. * Specifies if the material uses a texture
  18713. * @param texture defines the texture to check against the material
  18714. * @returns a boolean specifying if the material uses the texture
  18715. */
  18716. hasTexture(texture: BaseTexture): boolean;
  18717. /**
  18718. * Makes a duplicate of the material, and gives it a new name
  18719. * @param name defines the new name for the duplicated material
  18720. * @returns the cloned material
  18721. */
  18722. clone(name: string): ShaderMaterial;
  18723. /**
  18724. * Disposes the material
  18725. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18726. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18727. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18728. */
  18729. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18730. /**
  18731. * Serializes this material in a JSON representation
  18732. * @returns the serialized material object
  18733. */
  18734. serialize(): any;
  18735. /**
  18736. * Creates a shader material from parsed shader material data
  18737. * @param source defines the JSON represnetation of the material
  18738. * @param scene defines the hosting scene
  18739. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18740. * @returns a new material
  18741. */
  18742. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  18743. }
  18744. }
  18745. declare module BABYLON {
  18746. /** @hidden */
  18747. export var colorPixelShader: {
  18748. name: string;
  18749. shader: string;
  18750. };
  18751. }
  18752. declare module BABYLON {
  18753. /** @hidden */
  18754. export var colorVertexShader: {
  18755. name: string;
  18756. shader: string;
  18757. };
  18758. }
  18759. declare module BABYLON {
  18760. /**
  18761. * Line mesh
  18762. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  18763. */
  18764. export class LinesMesh extends Mesh {
  18765. /**
  18766. * If vertex color should be applied to the mesh
  18767. */
  18768. readonly useVertexColor?: boolean | undefined;
  18769. /**
  18770. * If vertex alpha should be applied to the mesh
  18771. */
  18772. readonly useVertexAlpha?: boolean | undefined;
  18773. /**
  18774. * Color of the line (Default: White)
  18775. */
  18776. color: Color3;
  18777. /**
  18778. * Alpha of the line (Default: 1)
  18779. */
  18780. alpha: number;
  18781. /**
  18782. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  18783. * This margin is expressed in world space coordinates, so its value may vary.
  18784. * Default value is 0.1
  18785. */
  18786. intersectionThreshold: number;
  18787. private _colorShader;
  18788. private color4;
  18789. /**
  18790. * Creates a new LinesMesh
  18791. * @param name defines the name
  18792. * @param scene defines the hosting scene
  18793. * @param parent defines the parent mesh if any
  18794. * @param source defines the optional source LinesMesh used to clone data from
  18795. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  18796. * When false, achieved by calling a clone(), also passing False.
  18797. * This will make creation of children, recursive.
  18798. * @param useVertexColor defines if this LinesMesh supports vertex color
  18799. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  18800. */
  18801. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  18802. /**
  18803. * If vertex color should be applied to the mesh
  18804. */
  18805. useVertexColor?: boolean | undefined,
  18806. /**
  18807. * If vertex alpha should be applied to the mesh
  18808. */
  18809. useVertexAlpha?: boolean | undefined);
  18810. private _addClipPlaneDefine;
  18811. private _removeClipPlaneDefine;
  18812. isReady(): boolean;
  18813. /**
  18814. * Returns the string "LineMesh"
  18815. */
  18816. getClassName(): string;
  18817. /**
  18818. * @hidden
  18819. */
  18820. /**
  18821. * @hidden
  18822. */
  18823. material: Material;
  18824. /**
  18825. * @hidden
  18826. */
  18827. readonly checkCollisions: boolean;
  18828. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  18829. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  18830. /**
  18831. * Disposes of the line mesh
  18832. * @param doNotRecurse If children should be disposed
  18833. */
  18834. dispose(doNotRecurse?: boolean): void;
  18835. /**
  18836. * Returns a new LineMesh object cloned from the current one.
  18837. */
  18838. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18839. /**
  18840. * Creates a new InstancedLinesMesh object from the mesh model.
  18841. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  18842. * @param name defines the name of the new instance
  18843. * @returns a new InstancedLinesMesh
  18844. */
  18845. createInstance(name: string): InstancedLinesMesh;
  18846. }
  18847. /**
  18848. * Creates an instance based on a source LinesMesh
  18849. */
  18850. export class InstancedLinesMesh extends InstancedMesh {
  18851. /**
  18852. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  18853. * This margin is expressed in world space coordinates, so its value may vary.
  18854. * Initilized with the intersectionThreshold value of the source LinesMesh
  18855. */
  18856. intersectionThreshold: number;
  18857. constructor(name: string, source: LinesMesh);
  18858. /**
  18859. * Returns the string "InstancedLinesMesh".
  18860. */
  18861. getClassName(): string;
  18862. }
  18863. }
  18864. declare module BABYLON {
  18865. /** @hidden */
  18866. export var linePixelShader: {
  18867. name: string;
  18868. shader: string;
  18869. };
  18870. }
  18871. declare module BABYLON {
  18872. /** @hidden */
  18873. export var lineVertexShader: {
  18874. name: string;
  18875. shader: string;
  18876. };
  18877. }
  18878. declare module BABYLON {
  18879. interface AbstractMesh {
  18880. /**
  18881. * Gets the edgesRenderer associated with the mesh
  18882. */
  18883. edgesRenderer: Nullable<EdgesRenderer>;
  18884. }
  18885. interface LinesMesh {
  18886. /**
  18887. * Enables the edge rendering mode on the mesh.
  18888. * This mode makes the mesh edges visible
  18889. * @param epsilon defines the maximal distance between two angles to detect a face
  18890. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  18891. * @returns the currentAbstractMesh
  18892. * @see https://www.babylonjs-playground.com/#19O9TU#0
  18893. */
  18894. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  18895. }
  18896. interface InstancedLinesMesh {
  18897. /**
  18898. * Enables the edge rendering mode on the mesh.
  18899. * This mode makes the mesh edges visible
  18900. * @param epsilon defines the maximal distance between two angles to detect a face
  18901. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  18902. * @returns the current InstancedLinesMesh
  18903. * @see https://www.babylonjs-playground.com/#19O9TU#0
  18904. */
  18905. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  18906. }
  18907. /**
  18908. * Defines the minimum contract an Edges renderer should follow.
  18909. */
  18910. export interface IEdgesRenderer extends IDisposable {
  18911. /**
  18912. * Gets or sets a boolean indicating if the edgesRenderer is active
  18913. */
  18914. isEnabled: boolean;
  18915. /**
  18916. * Renders the edges of the attached mesh,
  18917. */
  18918. render(): void;
  18919. /**
  18920. * Checks wether or not the edges renderer is ready to render.
  18921. * @return true if ready, otherwise false.
  18922. */
  18923. isReady(): boolean;
  18924. }
  18925. /**
  18926. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  18927. */
  18928. export class EdgesRenderer implements IEdgesRenderer {
  18929. /**
  18930. * Define the size of the edges with an orthographic camera
  18931. */
  18932. edgesWidthScalerForOrthographic: number;
  18933. /**
  18934. * Define the size of the edges with a perspective camera
  18935. */
  18936. edgesWidthScalerForPerspective: number;
  18937. protected _source: AbstractMesh;
  18938. protected _linesPositions: number[];
  18939. protected _linesNormals: number[];
  18940. protected _linesIndices: number[];
  18941. protected _epsilon: number;
  18942. protected _indicesCount: number;
  18943. protected _lineShader: ShaderMaterial;
  18944. protected _ib: DataBuffer;
  18945. protected _buffers: {
  18946. [key: string]: Nullable<VertexBuffer>;
  18947. };
  18948. protected _checkVerticesInsteadOfIndices: boolean;
  18949. private _meshRebuildObserver;
  18950. private _meshDisposeObserver;
  18951. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  18952. isEnabled: boolean;
  18953. /**
  18954. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  18955. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  18956. * @param source Mesh used to create edges
  18957. * @param epsilon sum of angles in adjacency to check for edge
  18958. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  18959. * @param generateEdgesLines - should generate Lines or only prepare resources.
  18960. */
  18961. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  18962. protected _prepareRessources(): void;
  18963. /** @hidden */ private _rebuild(): void;
  18964. /**
  18965. * Releases the required resources for the edges renderer
  18966. */
  18967. dispose(): void;
  18968. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  18969. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  18970. /**
  18971. * Checks if the pair of p0 and p1 is en edge
  18972. * @param faceIndex
  18973. * @param edge
  18974. * @param faceNormals
  18975. * @param p0
  18976. * @param p1
  18977. * @private
  18978. */
  18979. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  18980. /**
  18981. * push line into the position, normal and index buffer
  18982. * @protected
  18983. */
  18984. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  18985. /**
  18986. * Generates lines edges from adjacencjes
  18987. * @private
  18988. */ private _generateEdgesLines(): void;
  18989. /**
  18990. * Checks wether or not the edges renderer is ready to render.
  18991. * @return true if ready, otherwise false.
  18992. */
  18993. isReady(): boolean;
  18994. /**
  18995. * Renders the edges of the attached mesh,
  18996. */
  18997. render(): void;
  18998. }
  18999. /**
  19000. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19001. */
  19002. export class LineEdgesRenderer extends EdgesRenderer {
  19003. /**
  19004. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19005. * @param source LineMesh used to generate edges
  19006. * @param epsilon not important (specified angle for edge detection)
  19007. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19008. */
  19009. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19010. /**
  19011. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19012. */ private _generateEdgesLines(): void;
  19013. }
  19014. }
  19015. declare module BABYLON {
  19016. /**
  19017. * This represents the object necessary to create a rendering group.
  19018. * This is exclusively used and created by the rendering manager.
  19019. * To modify the behavior, you use the available helpers in your scene or meshes.
  19020. * @hidden
  19021. */
  19022. export class RenderingGroup {
  19023. index: number;
  19024. private static _zeroVector;
  19025. private _scene;
  19026. private _opaqueSubMeshes;
  19027. private _transparentSubMeshes;
  19028. private _alphaTestSubMeshes;
  19029. private _depthOnlySubMeshes;
  19030. private _particleSystems;
  19031. private _spriteManagers;
  19032. private _opaqueSortCompareFn;
  19033. private _alphaTestSortCompareFn;
  19034. private _transparentSortCompareFn;
  19035. private _renderOpaque;
  19036. private _renderAlphaTest;
  19037. private _renderTransparent;
  19038. /** @hidden */ private _edgesRenderers: SmartArray<IEdgesRenderer>;
  19039. onBeforeTransparentRendering: () => void;
  19040. /**
  19041. * Set the opaque sort comparison function.
  19042. * If null the sub meshes will be render in the order they were created
  19043. */
  19044. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19045. /**
  19046. * Set the alpha test sort comparison function.
  19047. * If null the sub meshes will be render in the order they were created
  19048. */
  19049. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19050. /**
  19051. * Set the transparent sort comparison function.
  19052. * If null the sub meshes will be render in the order they were created
  19053. */
  19054. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19055. /**
  19056. * Creates a new rendering group.
  19057. * @param index The rendering group index
  19058. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19059. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19060. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19061. */
  19062. 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>);
  19063. /**
  19064. * Render all the sub meshes contained in the group.
  19065. * @param customRenderFunction Used to override the default render behaviour of the group.
  19066. * @returns true if rendered some submeshes.
  19067. */
  19068. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19069. /**
  19070. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19071. * @param subMeshes The submeshes to render
  19072. */
  19073. private renderOpaqueSorted;
  19074. /**
  19075. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19076. * @param subMeshes The submeshes to render
  19077. */
  19078. private renderAlphaTestSorted;
  19079. /**
  19080. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19081. * @param subMeshes The submeshes to render
  19082. */
  19083. private renderTransparentSorted;
  19084. /**
  19085. * Renders the submeshes in a specified order.
  19086. * @param subMeshes The submeshes to sort before render
  19087. * @param sortCompareFn The comparison function use to sort
  19088. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19089. * @param transparent Specifies to activate blending if true
  19090. */
  19091. private static renderSorted;
  19092. /**
  19093. * Renders the submeshes in the order they were dispatched (no sort applied).
  19094. * @param subMeshes The submeshes to render
  19095. */
  19096. private static renderUnsorted;
  19097. /**
  19098. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19099. * are rendered back to front if in the same alpha index.
  19100. *
  19101. * @param a The first submesh
  19102. * @param b The second submesh
  19103. * @returns The result of the comparison
  19104. */
  19105. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19106. /**
  19107. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19108. * are rendered back to front.
  19109. *
  19110. * @param a The first submesh
  19111. * @param b The second submesh
  19112. * @returns The result of the comparison
  19113. */
  19114. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19115. /**
  19116. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19117. * are rendered front to back (prevent overdraw).
  19118. *
  19119. * @param a The first submesh
  19120. * @param b The second submesh
  19121. * @returns The result of the comparison
  19122. */
  19123. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19124. /**
  19125. * Resets the different lists of submeshes to prepare a new frame.
  19126. */
  19127. prepare(): void;
  19128. dispose(): void;
  19129. /**
  19130. * Inserts the submesh in its correct queue depending on its material.
  19131. * @param subMesh The submesh to dispatch
  19132. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19133. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19134. */
  19135. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19136. dispatchSprites(spriteManager: ISpriteManager): void;
  19137. dispatchParticles(particleSystem: IParticleSystem): void;
  19138. private _renderParticles;
  19139. private _renderSprites;
  19140. }
  19141. }
  19142. declare module BABYLON {
  19143. /**
  19144. * Interface describing the different options available in the rendering manager
  19145. * regarding Auto Clear between groups.
  19146. */
  19147. export interface IRenderingManagerAutoClearSetup {
  19148. /**
  19149. * Defines whether or not autoclear is enable.
  19150. */
  19151. autoClear: boolean;
  19152. /**
  19153. * Defines whether or not to autoclear the depth buffer.
  19154. */
  19155. depth: boolean;
  19156. /**
  19157. * Defines whether or not to autoclear the stencil buffer.
  19158. */
  19159. stencil: boolean;
  19160. }
  19161. /**
  19162. * This class is used by the onRenderingGroupObservable
  19163. */
  19164. export class RenderingGroupInfo {
  19165. /**
  19166. * The Scene that being rendered
  19167. */
  19168. scene: Scene;
  19169. /**
  19170. * The camera currently used for the rendering pass
  19171. */
  19172. camera: Nullable<Camera>;
  19173. /**
  19174. * The ID of the renderingGroup being processed
  19175. */
  19176. renderingGroupId: number;
  19177. }
  19178. /**
  19179. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19180. * It is enable to manage the different groups as well as the different necessary sort functions.
  19181. * This should not be used directly aside of the few static configurations
  19182. */
  19183. export class RenderingManager {
  19184. /**
  19185. * The max id used for rendering groups (not included)
  19186. */
  19187. static MAX_RENDERINGGROUPS: number;
  19188. /**
  19189. * The min id used for rendering groups (included)
  19190. */
  19191. static MIN_RENDERINGGROUPS: number;
  19192. /**
  19193. * Used to globally prevent autoclearing scenes.
  19194. */
  19195. static AUTOCLEAR: boolean;
  19196. /**
  19197. * @hidden
  19198. */ private _useSceneAutoClearSetup: boolean;
  19199. private _scene;
  19200. private _renderingGroups;
  19201. private _depthStencilBufferAlreadyCleaned;
  19202. private _autoClearDepthStencil;
  19203. private _customOpaqueSortCompareFn;
  19204. private _customAlphaTestSortCompareFn;
  19205. private _customTransparentSortCompareFn;
  19206. private _renderingGroupInfo;
  19207. /**
  19208. * Instantiates a new rendering group for a particular scene
  19209. * @param scene Defines the scene the groups belongs to
  19210. */
  19211. constructor(scene: Scene);
  19212. private _clearDepthStencilBuffer;
  19213. /**
  19214. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19215. * @hidden
  19216. */
  19217. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19218. /**
  19219. * Resets the different information of the group to prepare a new frame
  19220. * @hidden
  19221. */
  19222. reset(): void;
  19223. /**
  19224. * Dispose and release the group and its associated resources.
  19225. * @hidden
  19226. */
  19227. dispose(): void;
  19228. /**
  19229. * Clear the info related to rendering groups preventing retention points during dispose.
  19230. */
  19231. freeRenderingGroups(): void;
  19232. private _prepareRenderingGroup;
  19233. /**
  19234. * Add a sprite manager to the rendering manager in order to render it this frame.
  19235. * @param spriteManager Define the sprite manager to render
  19236. */
  19237. dispatchSprites(spriteManager: ISpriteManager): void;
  19238. /**
  19239. * Add a particle system to the rendering manager in order to render it this frame.
  19240. * @param particleSystem Define the particle system to render
  19241. */
  19242. dispatchParticles(particleSystem: IParticleSystem): void;
  19243. /**
  19244. * Add a submesh to the manager in order to render it this frame
  19245. * @param subMesh The submesh to dispatch
  19246. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19247. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19248. */
  19249. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19250. /**
  19251. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19252. * This allowed control for front to back rendering or reversly depending of the special needs.
  19253. *
  19254. * @param renderingGroupId The rendering group id corresponding to its index
  19255. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19256. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19257. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19258. */
  19259. 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;
  19260. /**
  19261. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19262. *
  19263. * @param renderingGroupId The rendering group id corresponding to its index
  19264. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19265. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19266. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19267. */
  19268. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19269. /**
  19270. * Gets the current auto clear configuration for one rendering group of the rendering
  19271. * manager.
  19272. * @param index the rendering group index to get the information for
  19273. * @returns The auto clear setup for the requested rendering group
  19274. */
  19275. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19276. }
  19277. }
  19278. declare module BABYLON {
  19279. /**
  19280. * This Helps creating a texture that will be created from a camera in your scene.
  19281. * It is basically a dynamic texture that could be used to create special effects for instance.
  19282. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19283. */
  19284. export class RenderTargetTexture extends Texture {
  19285. isCube: boolean;
  19286. /**
  19287. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19288. */
  19289. static readonly REFRESHRATE_RENDER_ONCE: number;
  19290. /**
  19291. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19292. */
  19293. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19294. /**
  19295. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19296. * the central point of your effect and can save a lot of performances.
  19297. */
  19298. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19299. /**
  19300. * Use this predicate to dynamically define the list of mesh you want to render.
  19301. * If set, the renderList property will be overwritten.
  19302. */
  19303. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19304. private _renderList;
  19305. /**
  19306. * Use this list to define the list of mesh you want to render.
  19307. */
  19308. renderList: Nullable<Array<AbstractMesh>>;
  19309. private _hookArray;
  19310. /**
  19311. * Define if particles should be rendered in your texture.
  19312. */
  19313. renderParticles: boolean;
  19314. /**
  19315. * Define if sprites should be rendered in your texture.
  19316. */
  19317. renderSprites: boolean;
  19318. /**
  19319. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19320. */
  19321. coordinatesMode: number;
  19322. /**
  19323. * Define the camera used to render the texture.
  19324. */
  19325. activeCamera: Nullable<Camera>;
  19326. /**
  19327. * Override the render function of the texture with your own one.
  19328. */
  19329. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19330. /**
  19331. * Define if camera post processes should be use while rendering the texture.
  19332. */
  19333. useCameraPostProcesses: boolean;
  19334. /**
  19335. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19336. */
  19337. ignoreCameraViewport: boolean;
  19338. private _postProcessManager;
  19339. private _postProcesses;
  19340. private _resizeObserver;
  19341. /**
  19342. * An event triggered when the texture is unbind.
  19343. */
  19344. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19345. /**
  19346. * An event triggered when the texture is unbind.
  19347. */
  19348. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19349. private _onAfterUnbindObserver;
  19350. /**
  19351. * Set a after unbind callback in the texture.
  19352. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19353. */
  19354. onAfterUnbind: () => void;
  19355. /**
  19356. * An event triggered before rendering the texture
  19357. */
  19358. onBeforeRenderObservable: Observable<number>;
  19359. private _onBeforeRenderObserver;
  19360. /**
  19361. * Set a before render callback in the texture.
  19362. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19363. */
  19364. onBeforeRender: (faceIndex: number) => void;
  19365. /**
  19366. * An event triggered after rendering the texture
  19367. */
  19368. onAfterRenderObservable: Observable<number>;
  19369. private _onAfterRenderObserver;
  19370. /**
  19371. * Set a after render callback in the texture.
  19372. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19373. */
  19374. onAfterRender: (faceIndex: number) => void;
  19375. /**
  19376. * An event triggered after the texture clear
  19377. */
  19378. onClearObservable: Observable<Engine>;
  19379. private _onClearObserver;
  19380. /**
  19381. * Set a clear callback in the texture.
  19382. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19383. */
  19384. onClear: (Engine: Engine) => void;
  19385. /**
  19386. * An event triggered when the texture is resized.
  19387. */
  19388. onResizeObservable: Observable<RenderTargetTexture>;
  19389. /**
  19390. * Define the clear color of the Render Target if it should be different from the scene.
  19391. */
  19392. clearColor: Color4;
  19393. protected _size: number | {
  19394. width: number;
  19395. height: number;
  19396. };
  19397. protected _initialSizeParameter: number | {
  19398. width: number;
  19399. height: number;
  19400. } | {
  19401. ratio: number;
  19402. };
  19403. protected _sizeRatio: Nullable<number>;
  19404. /** @hidden */ private _generateMipMaps: boolean;
  19405. protected _renderingManager: RenderingManager;
  19406. /** @hidden */ private _waitingRenderList: string[];
  19407. protected _doNotChangeAspectRatio: boolean;
  19408. protected _currentRefreshId: number;
  19409. protected _refreshRate: number;
  19410. protected _textureMatrix: Matrix;
  19411. protected _samples: number;
  19412. protected _renderTargetOptions: RenderTargetCreationOptions;
  19413. /**
  19414. * Gets render target creation options that were used.
  19415. */
  19416. readonly renderTargetOptions: RenderTargetCreationOptions;
  19417. protected _engine: Engine;
  19418. protected _onRatioRescale(): void;
  19419. /**
  19420. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19421. * It must define where the camera used to render the texture is set
  19422. */
  19423. boundingBoxPosition: Vector3;
  19424. private _boundingBoxSize;
  19425. /**
  19426. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19427. * When defined, the cubemap will switch to local mode
  19428. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19429. * @example https://www.babylonjs-playground.com/#RNASML
  19430. */
  19431. boundingBoxSize: Vector3;
  19432. /**
  19433. * In case the RTT has been created with a depth texture, get the associated
  19434. * depth texture.
  19435. * Otherwise, return null.
  19436. */
  19437. depthStencilTexture: Nullable<InternalTexture>;
  19438. /**
  19439. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19440. * or used a shadow, depth texture...
  19441. * @param name The friendly name of the texture
  19442. * @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)
  19443. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19444. * @param generateMipMaps True if mip maps need to be generated after render.
  19445. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19446. * @param type The type of the buffer in the RTT (int, half float, float...)
  19447. * @param isCube True if a cube texture needs to be created
  19448. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19449. * @param generateDepthBuffer True to generate a depth buffer
  19450. * @param generateStencilBuffer True to generate a stencil buffer
  19451. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19452. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19453. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19454. */
  19455. constructor(name: string, size: number | {
  19456. width: number;
  19457. height: number;
  19458. } | {
  19459. ratio: number;
  19460. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19461. /**
  19462. * Creates a depth stencil texture.
  19463. * This is only available in WebGL 2 or with the depth texture extension available.
  19464. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19465. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19466. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19467. */
  19468. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19469. private _processSizeParameter;
  19470. /**
  19471. * Define the number of samples to use in case of MSAA.
  19472. * It defaults to one meaning no MSAA has been enabled.
  19473. */
  19474. samples: number;
  19475. /**
  19476. * Resets the refresh counter of the texture and start bak from scratch.
  19477. * Could be useful to regenerate the texture if it is setup to render only once.
  19478. */
  19479. resetRefreshCounter(): void;
  19480. /**
  19481. * Define the refresh rate of the texture or the rendering frequency.
  19482. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19483. */
  19484. refreshRate: number;
  19485. /**
  19486. * Adds a post process to the render target rendering passes.
  19487. * @param postProcess define the post process to add
  19488. */
  19489. addPostProcess(postProcess: PostProcess): void;
  19490. /**
  19491. * Clear all the post processes attached to the render target
  19492. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  19493. */
  19494. clearPostProcesses(dispose?: boolean): void;
  19495. /**
  19496. * Remove one of the post process from the list of attached post processes to the texture
  19497. * @param postProcess define the post process to remove from the list
  19498. */
  19499. removePostProcess(postProcess: PostProcess): void;
  19500. /** @hidden */ private _shouldRender(): boolean;
  19501. /**
  19502. * Gets the actual render size of the texture.
  19503. * @returns the width of the render size
  19504. */
  19505. getRenderSize(): number;
  19506. /**
  19507. * Gets the actual render width of the texture.
  19508. * @returns the width of the render size
  19509. */
  19510. getRenderWidth(): number;
  19511. /**
  19512. * Gets the actual render height of the texture.
  19513. * @returns the height of the render size
  19514. */
  19515. getRenderHeight(): number;
  19516. /**
  19517. * Get if the texture can be rescaled or not.
  19518. */
  19519. readonly canRescale: boolean;
  19520. /**
  19521. * Resize the texture using a ratio.
  19522. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  19523. */
  19524. scale(ratio: number): void;
  19525. /**
  19526. * Get the texture reflection matrix used to rotate/transform the reflection.
  19527. * @returns the reflection matrix
  19528. */
  19529. getReflectionTextureMatrix(): Matrix;
  19530. /**
  19531. * Resize the texture to a new desired size.
  19532. * Be carrefull as it will recreate all the data in the new texture.
  19533. * @param size Define the new size. It can be:
  19534. * - a number for squared texture,
  19535. * - an object containing { width: number, height: number }
  19536. * - or an object containing a ratio { ratio: number }
  19537. */
  19538. resize(size: number | {
  19539. width: number;
  19540. height: number;
  19541. } | {
  19542. ratio: number;
  19543. }): void;
  19544. /**
  19545. * Renders all the objects from the render list into the texture.
  19546. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  19547. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  19548. */
  19549. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  19550. private _bestReflectionRenderTargetDimension;
  19551. /**
  19552. * @hidden
  19553. * @param faceIndex face index to bind to if this is a cubetexture
  19554. */ private _bindFrameBuffer(faceIndex?: number): void;
  19555. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  19556. private renderToTarget;
  19557. /**
  19558. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19559. * This allowed control for front to back rendering or reversly depending of the special needs.
  19560. *
  19561. * @param renderingGroupId The rendering group id corresponding to its index
  19562. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19563. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19564. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19565. */
  19566. 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;
  19567. /**
  19568. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19569. *
  19570. * @param renderingGroupId The rendering group id corresponding to its index
  19571. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19572. */
  19573. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  19574. /**
  19575. * Clones the texture.
  19576. * @returns the cloned texture
  19577. */
  19578. clone(): RenderTargetTexture;
  19579. /**
  19580. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19581. * @returns The JSON representation of the texture
  19582. */
  19583. serialize(): any;
  19584. /**
  19585. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  19586. */
  19587. disposeFramebufferObjects(): void;
  19588. /**
  19589. * Dispose the texture and release its associated resources.
  19590. */
  19591. dispose(): void;
  19592. /** @hidden */ private _rebuild(): void;
  19593. /**
  19594. * Clear the info related to rendering groups preventing retention point in material dispose.
  19595. */
  19596. freeRenderingGroups(): void;
  19597. /**
  19598. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19599. * @returns the view count
  19600. */
  19601. getViewCount(): number;
  19602. }
  19603. }
  19604. declare module BABYLON {
  19605. /**
  19606. * Base class for the main features of a material in Babylon.js
  19607. */
  19608. export class Material implements IAnimatable {
  19609. /**
  19610. * Returns the triangle fill mode
  19611. */
  19612. static readonly TriangleFillMode: number;
  19613. /**
  19614. * Returns the wireframe mode
  19615. */
  19616. static readonly WireFrameFillMode: number;
  19617. /**
  19618. * Returns the point fill mode
  19619. */
  19620. static readonly PointFillMode: number;
  19621. /**
  19622. * Returns the point list draw mode
  19623. */
  19624. static readonly PointListDrawMode: number;
  19625. /**
  19626. * Returns the line list draw mode
  19627. */
  19628. static readonly LineListDrawMode: number;
  19629. /**
  19630. * Returns the line loop draw mode
  19631. */
  19632. static readonly LineLoopDrawMode: number;
  19633. /**
  19634. * Returns the line strip draw mode
  19635. */
  19636. static readonly LineStripDrawMode: number;
  19637. /**
  19638. * Returns the triangle strip draw mode
  19639. */
  19640. static readonly TriangleStripDrawMode: number;
  19641. /**
  19642. * Returns the triangle fan draw mode
  19643. */
  19644. static readonly TriangleFanDrawMode: number;
  19645. /**
  19646. * Stores the clock-wise side orientation
  19647. */
  19648. static readonly ClockWiseSideOrientation: number;
  19649. /**
  19650. * Stores the counter clock-wise side orientation
  19651. */
  19652. static readonly CounterClockWiseSideOrientation: number;
  19653. /**
  19654. * The dirty texture flag value
  19655. */
  19656. static readonly TextureDirtyFlag: number;
  19657. /**
  19658. * The dirty light flag value
  19659. */
  19660. static readonly LightDirtyFlag: number;
  19661. /**
  19662. * The dirty fresnel flag value
  19663. */
  19664. static readonly FresnelDirtyFlag: number;
  19665. /**
  19666. * The dirty attribute flag value
  19667. */
  19668. static readonly AttributesDirtyFlag: number;
  19669. /**
  19670. * The dirty misc flag value
  19671. */
  19672. static readonly MiscDirtyFlag: number;
  19673. /**
  19674. * The all dirty flag value
  19675. */
  19676. static readonly AllDirtyFlag: number;
  19677. /**
  19678. * The ID of the material
  19679. */
  19680. id: string;
  19681. /**
  19682. * Gets or sets the unique id of the material
  19683. */
  19684. uniqueId: number;
  19685. /**
  19686. * The name of the material
  19687. */
  19688. name: string;
  19689. /**
  19690. * Gets or sets user defined metadata
  19691. */
  19692. metadata: any;
  19693. /**
  19694. * For internal use only. Please do not use.
  19695. */
  19696. reservedDataStore: any;
  19697. /**
  19698. * Specifies if the ready state should be checked on each call
  19699. */
  19700. checkReadyOnEveryCall: boolean;
  19701. /**
  19702. * Specifies if the ready state should be checked once
  19703. */
  19704. checkReadyOnlyOnce: boolean;
  19705. /**
  19706. * The state of the material
  19707. */
  19708. state: string;
  19709. /**
  19710. * The alpha value of the material
  19711. */
  19712. protected _alpha: number;
  19713. /**
  19714. * List of inspectable custom properties (used by the Inspector)
  19715. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19716. */
  19717. inspectableCustomProperties: IInspectable[];
  19718. /**
  19719. * Sets the alpha value of the material
  19720. */
  19721. /**
  19722. * Gets the alpha value of the material
  19723. */
  19724. alpha: number;
  19725. /**
  19726. * Specifies if back face culling is enabled
  19727. */
  19728. protected _backFaceCulling: boolean;
  19729. /**
  19730. * Sets the back-face culling state
  19731. */
  19732. /**
  19733. * Gets the back-face culling state
  19734. */
  19735. backFaceCulling: boolean;
  19736. /**
  19737. * Stores the value for side orientation
  19738. */
  19739. sideOrientation: number;
  19740. /**
  19741. * Callback triggered when the material is compiled
  19742. */
  19743. onCompiled: Nullable<(effect: Effect) => void>;
  19744. /**
  19745. * Callback triggered when an error occurs
  19746. */
  19747. onError: Nullable<(effect: Effect, errors: string) => void>;
  19748. /**
  19749. * Callback triggered to get the render target textures
  19750. */
  19751. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  19752. /**
  19753. * Gets a boolean indicating that current material needs to register RTT
  19754. */
  19755. readonly hasRenderTargetTextures: boolean;
  19756. /**
  19757. * Specifies if the material should be serialized
  19758. */
  19759. doNotSerialize: boolean;
  19760. /**
  19761. * @hidden
  19762. */ private _storeEffectOnSubMeshes: boolean;
  19763. /**
  19764. * Stores the animations for the material
  19765. */
  19766. animations: Nullable<Array<Animation>>;
  19767. /**
  19768. * An event triggered when the material is disposed
  19769. */
  19770. onDisposeObservable: Observable<Material>;
  19771. /**
  19772. * An observer which watches for dispose events
  19773. */
  19774. private _onDisposeObserver;
  19775. private _onUnBindObservable;
  19776. /**
  19777. * Called during a dispose event
  19778. */
  19779. onDispose: () => void;
  19780. private _onBindObservable;
  19781. /**
  19782. * An event triggered when the material is bound
  19783. */
  19784. readonly onBindObservable: Observable<AbstractMesh>;
  19785. /**
  19786. * An observer which watches for bind events
  19787. */
  19788. private _onBindObserver;
  19789. /**
  19790. * Called during a bind event
  19791. */
  19792. onBind: (Mesh: AbstractMesh) => void;
  19793. /**
  19794. * An event triggered when the material is unbound
  19795. */
  19796. readonly onUnBindObservable: Observable<Material>;
  19797. /**
  19798. * Stores the value of the alpha mode
  19799. */
  19800. private _alphaMode;
  19801. /**
  19802. * Sets the value of the alpha mode.
  19803. *
  19804. * | Value | Type | Description |
  19805. * | --- | --- | --- |
  19806. * | 0 | ALPHA_DISABLE | |
  19807. * | 1 | ALPHA_ADD | |
  19808. * | 2 | ALPHA_COMBINE | |
  19809. * | 3 | ALPHA_SUBTRACT | |
  19810. * | 4 | ALPHA_MULTIPLY | |
  19811. * | 5 | ALPHA_MAXIMIZED | |
  19812. * | 6 | ALPHA_ONEONE | |
  19813. * | 7 | ALPHA_PREMULTIPLIED | |
  19814. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  19815. * | 9 | ALPHA_INTERPOLATE | |
  19816. * | 10 | ALPHA_SCREENMODE | |
  19817. *
  19818. */
  19819. /**
  19820. * Gets the value of the alpha mode
  19821. */
  19822. alphaMode: number;
  19823. /**
  19824. * Stores the state of the need depth pre-pass value
  19825. */
  19826. private _needDepthPrePass;
  19827. /**
  19828. * Sets the need depth pre-pass value
  19829. */
  19830. /**
  19831. * Gets the depth pre-pass value
  19832. */
  19833. needDepthPrePass: boolean;
  19834. /**
  19835. * Specifies if depth writing should be disabled
  19836. */
  19837. disableDepthWrite: boolean;
  19838. /**
  19839. * Specifies if depth writing should be forced
  19840. */
  19841. forceDepthWrite: boolean;
  19842. /**
  19843. * Specifies if there should be a separate pass for culling
  19844. */
  19845. separateCullingPass: boolean;
  19846. /**
  19847. * Stores the state specifing if fog should be enabled
  19848. */
  19849. private _fogEnabled;
  19850. /**
  19851. * Sets the state for enabling fog
  19852. */
  19853. /**
  19854. * Gets the value of the fog enabled state
  19855. */
  19856. fogEnabled: boolean;
  19857. /**
  19858. * Stores the size of points
  19859. */
  19860. pointSize: number;
  19861. /**
  19862. * Stores the z offset value
  19863. */
  19864. zOffset: number;
  19865. /**
  19866. * Gets a value specifying if wireframe mode is enabled
  19867. */
  19868. /**
  19869. * Sets the state of wireframe mode
  19870. */
  19871. wireframe: boolean;
  19872. /**
  19873. * Gets the value specifying if point clouds are enabled
  19874. */
  19875. /**
  19876. * Sets the state of point cloud mode
  19877. */
  19878. pointsCloud: boolean;
  19879. /**
  19880. * Gets the material fill mode
  19881. */
  19882. /**
  19883. * Sets the material fill mode
  19884. */
  19885. fillMode: number;
  19886. /**
  19887. * @hidden
  19888. * Stores the effects for the material
  19889. */ private _effect: Nullable<Effect>;
  19890. /**
  19891. * @hidden
  19892. * Specifies if the material was previously ready
  19893. */ private _wasPreviouslyReady: boolean;
  19894. /**
  19895. * Specifies if uniform buffers should be used
  19896. */
  19897. private _useUBO;
  19898. /**
  19899. * Stores a reference to the scene
  19900. */
  19901. private _scene;
  19902. /**
  19903. * Stores the fill mode state
  19904. */
  19905. private _fillMode;
  19906. /**
  19907. * Specifies if the depth write state should be cached
  19908. */
  19909. private _cachedDepthWriteState;
  19910. /**
  19911. * Stores the uniform buffer
  19912. */
  19913. protected _uniformBuffer: UniformBuffer;
  19914. /** @hidden */ private _indexInSceneMaterialArray: number;
  19915. /** @hidden */
  19916. meshMap: Nullable<{
  19917. [id: string]: AbstractMesh | undefined;
  19918. }>;
  19919. /**
  19920. * Creates a material instance
  19921. * @param name defines the name of the material
  19922. * @param scene defines the scene to reference
  19923. * @param doNotAdd specifies if the material should be added to the scene
  19924. */
  19925. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  19926. /**
  19927. * Returns a string representation of the current material
  19928. * @param fullDetails defines a boolean indicating which levels of logging is desired
  19929. * @returns a string with material information
  19930. */
  19931. toString(fullDetails?: boolean): string;
  19932. /**
  19933. * Gets the class name of the material
  19934. * @returns a string with the class name of the material
  19935. */
  19936. getClassName(): string;
  19937. /**
  19938. * Specifies if updates for the material been locked
  19939. */
  19940. readonly isFrozen: boolean;
  19941. /**
  19942. * Locks updates for the material
  19943. */
  19944. freeze(): void;
  19945. /**
  19946. * Unlocks updates for the material
  19947. */
  19948. unfreeze(): void;
  19949. /**
  19950. * Specifies if the material is ready to be used
  19951. * @param mesh defines the mesh to check
  19952. * @param useInstances specifies if instances should be used
  19953. * @returns a boolean indicating if the material is ready to be used
  19954. */
  19955. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19956. /**
  19957. * Specifies that the submesh is ready to be used
  19958. * @param mesh defines the mesh to check
  19959. * @param subMesh defines which submesh to check
  19960. * @param useInstances specifies that instances should be used
  19961. * @returns a boolean indicating that the submesh is ready or not
  19962. */
  19963. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19964. /**
  19965. * Returns the material effect
  19966. * @returns the effect associated with the material
  19967. */
  19968. getEffect(): Nullable<Effect>;
  19969. /**
  19970. * Returns the current scene
  19971. * @returns a Scene
  19972. */
  19973. getScene(): Scene;
  19974. /**
  19975. * Specifies if the material will require alpha blending
  19976. * @returns a boolean specifying if alpha blending is needed
  19977. */
  19978. needAlphaBlending(): boolean;
  19979. /**
  19980. * Specifies if the mesh will require alpha blending
  19981. * @param mesh defines the mesh to check
  19982. * @returns a boolean specifying if alpha blending is needed for the mesh
  19983. */
  19984. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  19985. /**
  19986. * Specifies if this material should be rendered in alpha test mode
  19987. * @returns a boolean specifying if an alpha test is needed.
  19988. */
  19989. needAlphaTesting(): boolean;
  19990. /**
  19991. * Gets the texture used for the alpha test
  19992. * @returns the texture to use for alpha testing
  19993. */
  19994. getAlphaTestTexture(): Nullable<BaseTexture>;
  19995. /**
  19996. * Marks the material to indicate that it needs to be re-calculated
  19997. */
  19998. markDirty(): void;
  19999. /** @hidden */ private _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20000. /**
  20001. * Binds the material to the mesh
  20002. * @param world defines the world transformation matrix
  20003. * @param mesh defines the mesh to bind the material to
  20004. */
  20005. bind(world: Matrix, mesh?: Mesh): void;
  20006. /**
  20007. * Binds the submesh to the material
  20008. * @param world defines the world transformation matrix
  20009. * @param mesh defines the mesh containing the submesh
  20010. * @param subMesh defines the submesh to bind the material to
  20011. */
  20012. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20013. /**
  20014. * Binds the world matrix to the material
  20015. * @param world defines the world transformation matrix
  20016. */
  20017. bindOnlyWorldMatrix(world: Matrix): void;
  20018. /**
  20019. * Binds the scene's uniform buffer to the effect.
  20020. * @param effect defines the effect to bind to the scene uniform buffer
  20021. * @param sceneUbo defines the uniform buffer storing scene data
  20022. */
  20023. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20024. /**
  20025. * Binds the view matrix to the effect
  20026. * @param effect defines the effect to bind the view matrix to
  20027. */
  20028. bindView(effect: Effect): void;
  20029. /**
  20030. * Binds the view projection matrix to the effect
  20031. * @param effect defines the effect to bind the view projection matrix to
  20032. */
  20033. bindViewProjection(effect: Effect): void;
  20034. /**
  20035. * Specifies if material alpha testing should be turned on for the mesh
  20036. * @param mesh defines the mesh to check
  20037. */
  20038. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20039. /**
  20040. * Processes to execute after binding the material to a mesh
  20041. * @param mesh defines the rendered mesh
  20042. */
  20043. protected _afterBind(mesh?: Mesh): void;
  20044. /**
  20045. * Unbinds the material from the mesh
  20046. */
  20047. unbind(): void;
  20048. /**
  20049. * Gets the active textures from the material
  20050. * @returns an array of textures
  20051. */
  20052. getActiveTextures(): BaseTexture[];
  20053. /**
  20054. * Specifies if the material uses a texture
  20055. * @param texture defines the texture to check against the material
  20056. * @returns a boolean specifying if the material uses the texture
  20057. */
  20058. hasTexture(texture: BaseTexture): boolean;
  20059. /**
  20060. * Makes a duplicate of the material, and gives it a new name
  20061. * @param name defines the new name for the duplicated material
  20062. * @returns the cloned material
  20063. */
  20064. clone(name: string): Nullable<Material>;
  20065. /**
  20066. * Gets the meshes bound to the material
  20067. * @returns an array of meshes bound to the material
  20068. */
  20069. getBindedMeshes(): AbstractMesh[];
  20070. /**
  20071. * Force shader compilation
  20072. * @param mesh defines the mesh associated with this material
  20073. * @param onCompiled defines a function to execute once the material is compiled
  20074. * @param options defines the options to configure the compilation
  20075. */
  20076. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20077. clipPlane: boolean;
  20078. }>): void;
  20079. /**
  20080. * Force shader compilation
  20081. * @param mesh defines the mesh that will use this material
  20082. * @param options defines additional options for compiling the shaders
  20083. * @returns a promise that resolves when the compilation completes
  20084. */
  20085. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20086. clipPlane: boolean;
  20087. }>): Promise<void>;
  20088. private static readonly _AllDirtyCallBack;
  20089. private static readonly _ImageProcessingDirtyCallBack;
  20090. private static readonly _TextureDirtyCallBack;
  20091. private static readonly _FresnelDirtyCallBack;
  20092. private static readonly _MiscDirtyCallBack;
  20093. private static readonly _LightsDirtyCallBack;
  20094. private static readonly _AttributeDirtyCallBack;
  20095. private static _FresnelAndMiscDirtyCallBack;
  20096. private static _TextureAndMiscDirtyCallBack;
  20097. private static readonly _DirtyCallbackArray;
  20098. private static readonly _RunDirtyCallBacks;
  20099. /**
  20100. * Marks a define in the material to indicate that it needs to be re-computed
  20101. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20102. */
  20103. markAsDirty(flag: number): void;
  20104. /**
  20105. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20106. * @param func defines a function which checks material defines against the submeshes
  20107. */
  20108. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20109. /**
  20110. * Indicates that we need to re-calculated for all submeshes
  20111. */
  20112. protected _markAllSubMeshesAsAllDirty(): void;
  20113. /**
  20114. * Indicates that image processing needs to be re-calculated for all submeshes
  20115. */
  20116. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20117. /**
  20118. * Indicates that textures need to be re-calculated for all submeshes
  20119. */
  20120. protected _markAllSubMeshesAsTexturesDirty(): void;
  20121. /**
  20122. * Indicates that fresnel needs to be re-calculated for all submeshes
  20123. */
  20124. protected _markAllSubMeshesAsFresnelDirty(): void;
  20125. /**
  20126. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20127. */
  20128. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20129. /**
  20130. * Indicates that lights need to be re-calculated for all submeshes
  20131. */
  20132. protected _markAllSubMeshesAsLightsDirty(): void;
  20133. /**
  20134. * Indicates that attributes need to be re-calculated for all submeshes
  20135. */
  20136. protected _markAllSubMeshesAsAttributesDirty(): void;
  20137. /**
  20138. * Indicates that misc needs to be re-calculated for all submeshes
  20139. */
  20140. protected _markAllSubMeshesAsMiscDirty(): void;
  20141. /**
  20142. * Indicates that textures and misc need to be re-calculated for all submeshes
  20143. */
  20144. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20145. /**
  20146. * Disposes the material
  20147. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20148. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20149. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20150. */
  20151. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20152. /** @hidden */
  20153. private releaseVertexArrayObject;
  20154. /**
  20155. * Serializes this material
  20156. * @returns the serialized material object
  20157. */
  20158. serialize(): any;
  20159. /**
  20160. * Creates a material from parsed material data
  20161. * @param parsedMaterial defines parsed material data
  20162. * @param scene defines the hosting scene
  20163. * @param rootUrl defines the root URL to use to load textures
  20164. * @returns a new material
  20165. */
  20166. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20167. }
  20168. }
  20169. declare module BABYLON {
  20170. /**
  20171. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20172. * separate meshes. This can be use to improve performances.
  20173. * @see http://doc.babylonjs.com/how_to/multi_materials
  20174. */
  20175. export class MultiMaterial extends Material {
  20176. private _subMaterials;
  20177. /**
  20178. * Gets or Sets the list of Materials used within the multi material.
  20179. * They need to be ordered according to the submeshes order in the associated mesh
  20180. */
  20181. subMaterials: Nullable<Material>[];
  20182. /**
  20183. * Function used to align with Node.getChildren()
  20184. * @returns the list of Materials used within the multi material
  20185. */
  20186. getChildren(): Nullable<Material>[];
  20187. /**
  20188. * Instantiates a new Multi Material
  20189. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20190. * separate meshes. This can be use to improve performances.
  20191. * @see http://doc.babylonjs.com/how_to/multi_materials
  20192. * @param name Define the name in the scene
  20193. * @param scene Define the scene the material belongs to
  20194. */
  20195. constructor(name: string, scene: Scene);
  20196. private _hookArray;
  20197. /**
  20198. * Get one of the submaterial by its index in the submaterials array
  20199. * @param index The index to look the sub material at
  20200. * @returns The Material if the index has been defined
  20201. */
  20202. getSubMaterial(index: number): Nullable<Material>;
  20203. /**
  20204. * Get the list of active textures for the whole sub materials list.
  20205. * @returns All the textures that will be used during the rendering
  20206. */
  20207. getActiveTextures(): BaseTexture[];
  20208. /**
  20209. * Gets the current class name of the material e.g. "MultiMaterial"
  20210. * Mainly use in serialization.
  20211. * @returns the class name
  20212. */
  20213. getClassName(): string;
  20214. /**
  20215. * Checks if the material is ready to render the requested sub mesh
  20216. * @param mesh Define the mesh the submesh belongs to
  20217. * @param subMesh Define the sub mesh to look readyness for
  20218. * @param useInstances Define whether or not the material is used with instances
  20219. * @returns true if ready, otherwise false
  20220. */
  20221. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20222. /**
  20223. * Clones the current material and its related sub materials
  20224. * @param name Define the name of the newly cloned material
  20225. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20226. * @returns the cloned material
  20227. */
  20228. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20229. /**
  20230. * Serializes the materials into a JSON representation.
  20231. * @returns the JSON representation
  20232. */
  20233. serialize(): any;
  20234. /**
  20235. * Dispose the material and release its associated resources
  20236. * @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)
  20237. * @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)
  20238. * @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)
  20239. */
  20240. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20241. /**
  20242. * Creates a MultiMaterial from parsed MultiMaterial data.
  20243. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20244. * @param scene defines the hosting scene
  20245. * @returns a new MultiMaterial
  20246. */
  20247. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20248. }
  20249. }
  20250. declare module BABYLON {
  20251. /**
  20252. * Base class for submeshes
  20253. */
  20254. export class BaseSubMesh {
  20255. /** @hidden */ private _materialDefines: Nullable<MaterialDefines>;
  20256. /** @hidden */ private _materialEffect: Nullable<Effect>;
  20257. /**
  20258. * Gets associated effect
  20259. */
  20260. readonly effect: Nullable<Effect>;
  20261. /**
  20262. * Sets associated effect (effect used to render this submesh)
  20263. * @param effect defines the effect to associate with
  20264. * @param defines defines the set of defines used to compile this effect
  20265. */
  20266. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20267. }
  20268. /**
  20269. * Defines a subdivision inside a mesh
  20270. */
  20271. export class SubMesh extends BaseSubMesh implements ICullable {
  20272. /** the material index to use */
  20273. materialIndex: number;
  20274. /** vertex index start */
  20275. verticesStart: number;
  20276. /** vertices count */
  20277. verticesCount: number;
  20278. /** index start */
  20279. indexStart: number;
  20280. /** indices count */
  20281. indexCount: number;
  20282. /** @hidden */ private _linesIndexCount: number;
  20283. private _mesh;
  20284. private _renderingMesh;
  20285. private _boundingInfo;
  20286. private _linesIndexBuffer;
  20287. /** @hidden */ private _lastColliderWorldVertices: Nullable<Vector3[]>;
  20288. /** @hidden */ private _trianglePlanes: Plane[];
  20289. /** @hidden */ private _lastColliderTransformMatrix: Nullable<Matrix>;
  20290. /** @hidden */ private _renderId: number;
  20291. /** @hidden */ private _alphaIndex: number;
  20292. /** @hidden */ private _distanceToCamera: number;
  20293. /** @hidden */ private _id: number;
  20294. private _currentMaterial;
  20295. /**
  20296. * Add a new submesh to a mesh
  20297. * @param materialIndex defines the material index to use
  20298. * @param verticesStart defines vertex index start
  20299. * @param verticesCount defines vertices count
  20300. * @param indexStart defines index start
  20301. * @param indexCount defines indices count
  20302. * @param mesh defines the parent mesh
  20303. * @param renderingMesh defines an optional rendering mesh
  20304. * @param createBoundingBox defines if bounding box should be created for this submesh
  20305. * @returns the new submesh
  20306. */
  20307. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20308. /**
  20309. * Creates a new submesh
  20310. * @param materialIndex defines the material index to use
  20311. * @param verticesStart defines vertex index start
  20312. * @param verticesCount defines vertices count
  20313. * @param indexStart defines index start
  20314. * @param indexCount defines indices count
  20315. * @param mesh defines the parent mesh
  20316. * @param renderingMesh defines an optional rendering mesh
  20317. * @param createBoundingBox defines if bounding box should be created for this submesh
  20318. */
  20319. constructor(
  20320. /** the material index to use */
  20321. materialIndex: number,
  20322. /** vertex index start */
  20323. verticesStart: number,
  20324. /** vertices count */
  20325. verticesCount: number,
  20326. /** index start */
  20327. indexStart: number,
  20328. /** indices count */
  20329. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20330. /**
  20331. * Returns true if this submesh covers the entire parent mesh
  20332. * @ignorenaming
  20333. */
  20334. readonly IsGlobal: boolean;
  20335. /**
  20336. * Returns the submesh BoudingInfo object
  20337. * @returns current bounding info (or mesh's one if the submesh is global)
  20338. */
  20339. getBoundingInfo(): BoundingInfo;
  20340. /**
  20341. * Sets the submesh BoundingInfo
  20342. * @param boundingInfo defines the new bounding info to use
  20343. * @returns the SubMesh
  20344. */
  20345. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20346. /**
  20347. * Returns the mesh of the current submesh
  20348. * @return the parent mesh
  20349. */
  20350. getMesh(): AbstractMesh;
  20351. /**
  20352. * Returns the rendering mesh of the submesh
  20353. * @returns the rendering mesh (could be different from parent mesh)
  20354. */
  20355. getRenderingMesh(): Mesh;
  20356. /**
  20357. * Returns the submesh material
  20358. * @returns null or the current material
  20359. */
  20360. getMaterial(): Nullable<Material>;
  20361. /**
  20362. * Sets a new updated BoundingInfo object to the submesh
  20363. * @param data defines an optional position array to use to determine the bounding info
  20364. * @returns the SubMesh
  20365. */
  20366. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20367. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  20368. /**
  20369. * Updates the submesh BoundingInfo
  20370. * @param world defines the world matrix to use to update the bounding info
  20371. * @returns the submesh
  20372. */
  20373. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20374. /**
  20375. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20376. * @param frustumPlanes defines the frustum planes
  20377. * @returns true if the submesh is intersecting with the frustum
  20378. */
  20379. isInFrustum(frustumPlanes: Plane[]): boolean;
  20380. /**
  20381. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20382. * @param frustumPlanes defines the frustum planes
  20383. * @returns true if the submesh is inside the frustum
  20384. */
  20385. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20386. /**
  20387. * Renders the submesh
  20388. * @param enableAlphaMode defines if alpha needs to be used
  20389. * @returns the submesh
  20390. */
  20391. render(enableAlphaMode: boolean): SubMesh;
  20392. /**
  20393. * @hidden
  20394. */ private _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20395. /**
  20396. * Checks if the submesh intersects with a ray
  20397. * @param ray defines the ray to test
  20398. * @returns true is the passed ray intersects the submesh bounding box
  20399. */
  20400. canIntersects(ray: Ray): boolean;
  20401. /**
  20402. * Intersects current submesh with a ray
  20403. * @param ray defines the ray to test
  20404. * @param positions defines mesh's positions array
  20405. * @param indices defines mesh's indices array
  20406. * @param fastCheck defines if only bounding info should be used
  20407. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20408. * @returns intersection info or null if no intersection
  20409. */
  20410. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20411. /** @hidden */
  20412. private _intersectLines;
  20413. /** @hidden */
  20414. private _intersectUnIndexedLines;
  20415. /** @hidden */
  20416. private _intersectTriangles;
  20417. /** @hidden */
  20418. private _intersectUnIndexedTriangles;
  20419. /** @hidden */ private _rebuild(): void;
  20420. /**
  20421. * Creates a new submesh from the passed mesh
  20422. * @param newMesh defines the new hosting mesh
  20423. * @param newRenderingMesh defines an optional rendering mesh
  20424. * @returns the new submesh
  20425. */
  20426. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20427. /**
  20428. * Release associated resources
  20429. */
  20430. dispose(): void;
  20431. /**
  20432. * Gets the class name
  20433. * @returns the string "SubMesh".
  20434. */
  20435. getClassName(): string;
  20436. /**
  20437. * Creates a new submesh from indices data
  20438. * @param materialIndex the index of the main mesh material
  20439. * @param startIndex the index where to start the copy in the mesh indices array
  20440. * @param indexCount the number of indices to copy then from the startIndex
  20441. * @param mesh the main mesh to create the submesh from
  20442. * @param renderingMesh the optional rendering mesh
  20443. * @returns a new submesh
  20444. */
  20445. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20446. }
  20447. }
  20448. declare module BABYLON {
  20449. /**
  20450. * Class used to represent data loading progression
  20451. */
  20452. export class SceneLoaderFlags {
  20453. private static _ForceFullSceneLoadingForIncremental;
  20454. private static _ShowLoadingScreen;
  20455. private static _CleanBoneMatrixWeights;
  20456. private static _loggingLevel;
  20457. /**
  20458. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  20459. */
  20460. static ForceFullSceneLoadingForIncremental: boolean;
  20461. /**
  20462. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  20463. */
  20464. static ShowLoadingScreen: boolean;
  20465. /**
  20466. * Defines the current logging level (while loading the scene)
  20467. * @ignorenaming
  20468. */
  20469. static loggingLevel: number;
  20470. /**
  20471. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  20472. */
  20473. static CleanBoneMatrixWeights: boolean;
  20474. }
  20475. }
  20476. declare module BABYLON {
  20477. /**
  20478. * Class used to store geometry data (vertex buffers + index buffer)
  20479. */
  20480. export class Geometry implements IGetSetVerticesData {
  20481. /**
  20482. * Gets or sets the ID of the geometry
  20483. */
  20484. id: string;
  20485. /**
  20486. * Gets or sets the unique ID of the geometry
  20487. */
  20488. uniqueId: number;
  20489. /**
  20490. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20491. */
  20492. delayLoadState: number;
  20493. /**
  20494. * Gets the file containing the data to load when running in delay load state
  20495. */
  20496. delayLoadingFile: Nullable<string>;
  20497. /**
  20498. * Callback called when the geometry is updated
  20499. */
  20500. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20501. private _scene;
  20502. private _engine;
  20503. private _meshes;
  20504. private _totalVertices;
  20505. /** @hidden */ private _indices: IndicesArray;
  20506. /** @hidden */ private _vertexBuffers: {
  20507. [key: string]: VertexBuffer;
  20508. };
  20509. private _isDisposed;
  20510. private _extend;
  20511. private _boundingBias;
  20512. /** @hidden */ private _delayInfo: Array<string>;
  20513. private _indexBuffer;
  20514. private _indexBufferIsUpdatable;
  20515. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  20516. /** @hidden */ private _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20517. /** @hidden */ private _softwareSkinningFrameId: number;
  20518. private _vertexArrayObjects;
  20519. private _updatable;
  20520. /** @hidden */ private _positions: Nullable<Vector3[]>;
  20521. /**
  20522. * 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
  20523. */
  20524. /**
  20525. * 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
  20526. */
  20527. boundingBias: Vector2;
  20528. /**
  20529. * Static function used to attach a new empty geometry to a mesh
  20530. * @param mesh defines the mesh to attach the geometry to
  20531. * @returns the new Geometry
  20532. */
  20533. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20534. /**
  20535. * Creates a new geometry
  20536. * @param id defines the unique ID
  20537. * @param scene defines the hosting scene
  20538. * @param vertexData defines the VertexData used to get geometry data
  20539. * @param updatable defines if geometry must be updatable (false by default)
  20540. * @param mesh defines the mesh that will be associated with the geometry
  20541. */
  20542. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20543. /**
  20544. * Gets the current extend of the geometry
  20545. */
  20546. readonly extend: {
  20547. minimum: Vector3;
  20548. maximum: Vector3;
  20549. };
  20550. /**
  20551. * Gets the hosting scene
  20552. * @returns the hosting Scene
  20553. */
  20554. getScene(): Scene;
  20555. /**
  20556. * Gets the hosting engine
  20557. * @returns the hosting Engine
  20558. */
  20559. getEngine(): Engine;
  20560. /**
  20561. * Defines if the geometry is ready to use
  20562. * @returns true if the geometry is ready to be used
  20563. */
  20564. isReady(): boolean;
  20565. /**
  20566. * Gets a value indicating that the geometry should not be serialized
  20567. */
  20568. readonly doNotSerialize: boolean;
  20569. /** @hidden */ private _rebuild(): void;
  20570. /**
  20571. * Affects all geometry data in one call
  20572. * @param vertexData defines the geometry data
  20573. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20574. */
  20575. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20576. /**
  20577. * Set specific vertex data
  20578. * @param kind defines the data kind (Position, normal, etc...)
  20579. * @param data defines the vertex data to use
  20580. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20581. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20582. */
  20583. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20584. /**
  20585. * Removes a specific vertex data
  20586. * @param kind defines the data kind (Position, normal, etc...)
  20587. */
  20588. removeVerticesData(kind: string): void;
  20589. /**
  20590. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20591. * @param buffer defines the vertex buffer to use
  20592. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20593. */
  20594. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20595. /**
  20596. * Update a specific vertex buffer
  20597. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  20598. * It will do nothing if the buffer is not updatable
  20599. * @param kind defines the data kind (Position, normal, etc...)
  20600. * @param data defines the data to use
  20601. * @param offset defines the offset in the target buffer where to store the data
  20602. * @param useBytes set to true if the offset is in bytes
  20603. */
  20604. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20605. /**
  20606. * Update a specific vertex buffer
  20607. * This function will create a new buffer if the current one is not updatable
  20608. * @param kind defines the data kind (Position, normal, etc...)
  20609. * @param data defines the data to use
  20610. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20611. */
  20612. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20613. private _updateBoundingInfo;
  20614. /** @hidden */ private _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  20615. /**
  20616. * Gets total number of vertices
  20617. * @returns the total number of vertices
  20618. */
  20619. getTotalVertices(): number;
  20620. /**
  20621. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20622. * @param kind defines the data kind (Position, normal, etc...)
  20623. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20624. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20625. * @returns a float array containing vertex data
  20626. */
  20627. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20628. /**
  20629. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20630. * @param kind defines the data kind (Position, normal, etc...)
  20631. * @returns true if the vertex buffer with the specified kind is updatable
  20632. */
  20633. isVertexBufferUpdatable(kind: string): boolean;
  20634. /**
  20635. * Gets a specific vertex buffer
  20636. * @param kind defines the data kind (Position, normal, etc...)
  20637. * @returns a VertexBuffer
  20638. */
  20639. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20640. /**
  20641. * Returns all vertex buffers
  20642. * @return an object holding all vertex buffers indexed by kind
  20643. */
  20644. getVertexBuffers(): Nullable<{
  20645. [key: string]: VertexBuffer;
  20646. }>;
  20647. /**
  20648. * Gets a boolean indicating if specific vertex buffer is present
  20649. * @param kind defines the data kind (Position, normal, etc...)
  20650. * @returns true if data is present
  20651. */
  20652. isVerticesDataPresent(kind: string): boolean;
  20653. /**
  20654. * Gets a list of all attached data kinds (Position, normal, etc...)
  20655. * @returns a list of string containing all kinds
  20656. */
  20657. getVerticesDataKinds(): string[];
  20658. /**
  20659. * Update index buffer
  20660. * @param indices defines the indices to store in the index buffer
  20661. * @param offset defines the offset in the target buffer where to store the data
  20662. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  20663. */
  20664. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  20665. /**
  20666. * Creates a new index buffer
  20667. * @param indices defines the indices to store in the index buffer
  20668. * @param totalVertices defines the total number of vertices (could be null)
  20669. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20670. */
  20671. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  20672. /**
  20673. * Return the total number of indices
  20674. * @returns the total number of indices
  20675. */
  20676. getTotalIndices(): number;
  20677. /**
  20678. * Gets the index buffer array
  20679. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20680. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20681. * @returns the index buffer array
  20682. */
  20683. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20684. /**
  20685. * Gets the index buffer
  20686. * @return the index buffer
  20687. */
  20688. getIndexBuffer(): Nullable<DataBuffer>;
  20689. /** @hidden */ private _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  20690. /**
  20691. * Release the associated resources for a specific mesh
  20692. * @param mesh defines the source mesh
  20693. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  20694. */
  20695. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  20696. /**
  20697. * Apply current geometry to a given mesh
  20698. * @param mesh defines the mesh to apply geometry to
  20699. */
  20700. applyToMesh(mesh: Mesh): void;
  20701. private _updateExtend;
  20702. private _applyToMesh;
  20703. private notifyUpdate;
  20704. /**
  20705. * Load the geometry if it was flagged as delay loaded
  20706. * @param scene defines the hosting scene
  20707. * @param onLoaded defines a callback called when the geometry is loaded
  20708. */
  20709. load(scene: Scene, onLoaded?: () => void): void;
  20710. private _queueLoad;
  20711. /**
  20712. * Invert the geometry to move from a right handed system to a left handed one.
  20713. */
  20714. toLeftHanded(): void;
  20715. /** @hidden */ private _resetPointsArrayCache(): void;
  20716. /** @hidden */ private _generatePointsArray(): boolean;
  20717. /**
  20718. * Gets a value indicating if the geometry is disposed
  20719. * @returns true if the geometry was disposed
  20720. */
  20721. isDisposed(): boolean;
  20722. private _disposeVertexArrayObjects;
  20723. /**
  20724. * Free all associated resources
  20725. */
  20726. dispose(): void;
  20727. /**
  20728. * Clone the current geometry into a new geometry
  20729. * @param id defines the unique ID of the new geometry
  20730. * @returns a new geometry object
  20731. */
  20732. copy(id: string): Geometry;
  20733. /**
  20734. * Serialize the current geometry info (and not the vertices data) into a JSON object
  20735. * @return a JSON representation of the current geometry data (without the vertices data)
  20736. */
  20737. serialize(): any;
  20738. private toNumberArray;
  20739. /**
  20740. * Serialize all vertices data into a JSON oject
  20741. * @returns a JSON representation of the current geometry data
  20742. */
  20743. serializeVerticeData(): any;
  20744. /**
  20745. * Extracts a clone of a mesh geometry
  20746. * @param mesh defines the source mesh
  20747. * @param id defines the unique ID of the new geometry object
  20748. * @returns the new geometry object
  20749. */
  20750. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  20751. /**
  20752. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  20753. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  20754. * Be aware Math.random() could cause collisions, but:
  20755. * "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"
  20756. * @returns a string containing a new GUID
  20757. */
  20758. static RandomId(): string;
  20759. /** @hidden */ private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  20760. private static _CleanMatricesWeights;
  20761. /**
  20762. * Create a new geometry from persisted data (Using .babylon file format)
  20763. * @param parsedVertexData defines the persisted data
  20764. * @param scene defines the hosting scene
  20765. * @param rootUrl defines the root url to use to load assets (like delayed data)
  20766. * @returns the new geometry object
  20767. */
  20768. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  20769. }
  20770. }
  20771. declare module BABYLON {
  20772. /**
  20773. * Define an interface for all classes that will get and set the data on vertices
  20774. */
  20775. export interface IGetSetVerticesData {
  20776. /**
  20777. * Gets a boolean indicating if specific vertex data is present
  20778. * @param kind defines the vertex data kind to use
  20779. * @returns true is data kind is present
  20780. */
  20781. isVerticesDataPresent(kind: string): boolean;
  20782. /**
  20783. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20784. * @param kind defines the data kind (Position, normal, etc...)
  20785. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20786. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20787. * @returns a float array containing vertex data
  20788. */
  20789. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20790. /**
  20791. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20792. * @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.
  20793. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20794. * @returns the indices array or an empty array if the mesh has no geometry
  20795. */
  20796. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20797. /**
  20798. * Set specific vertex data
  20799. * @param kind defines the data kind (Position, normal, etc...)
  20800. * @param data defines the vertex data to use
  20801. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20802. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20803. */
  20804. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  20805. /**
  20806. * Update a specific associated vertex buffer
  20807. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20808. * - VertexBuffer.PositionKind
  20809. * - VertexBuffer.UVKind
  20810. * - VertexBuffer.UV2Kind
  20811. * - VertexBuffer.UV3Kind
  20812. * - VertexBuffer.UV4Kind
  20813. * - VertexBuffer.UV5Kind
  20814. * - VertexBuffer.UV6Kind
  20815. * - VertexBuffer.ColorKind
  20816. * - VertexBuffer.MatricesIndicesKind
  20817. * - VertexBuffer.MatricesIndicesExtraKind
  20818. * - VertexBuffer.MatricesWeightsKind
  20819. * - VertexBuffer.MatricesWeightsExtraKind
  20820. * @param data defines the data source
  20821. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20822. * @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)
  20823. */
  20824. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  20825. /**
  20826. * Creates a new index buffer
  20827. * @param indices defines the indices to store in the index buffer
  20828. * @param totalVertices defines the total number of vertices (could be null)
  20829. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20830. */
  20831. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  20832. }
  20833. /**
  20834. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  20835. */
  20836. export class VertexData {
  20837. /**
  20838. * Mesh side orientation : usually the external or front surface
  20839. */
  20840. static readonly FRONTSIDE: number;
  20841. /**
  20842. * Mesh side orientation : usually the internal or back surface
  20843. */
  20844. static readonly BACKSIDE: number;
  20845. /**
  20846. * Mesh side orientation : both internal and external or front and back surfaces
  20847. */
  20848. static readonly DOUBLESIDE: number;
  20849. /**
  20850. * Mesh side orientation : by default, `FRONTSIDE`
  20851. */
  20852. static readonly DEFAULTSIDE: number;
  20853. /**
  20854. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  20855. */
  20856. positions: Nullable<FloatArray>;
  20857. /**
  20858. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  20859. */
  20860. normals: Nullable<FloatArray>;
  20861. /**
  20862. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  20863. */
  20864. tangents: Nullable<FloatArray>;
  20865. /**
  20866. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20867. */
  20868. uvs: Nullable<FloatArray>;
  20869. /**
  20870. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20871. */
  20872. uvs2: Nullable<FloatArray>;
  20873. /**
  20874. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20875. */
  20876. uvs3: Nullable<FloatArray>;
  20877. /**
  20878. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20879. */
  20880. uvs4: Nullable<FloatArray>;
  20881. /**
  20882. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20883. */
  20884. uvs5: Nullable<FloatArray>;
  20885. /**
  20886. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20887. */
  20888. uvs6: Nullable<FloatArray>;
  20889. /**
  20890. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  20891. */
  20892. colors: Nullable<FloatArray>;
  20893. /**
  20894. * 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).
  20895. */
  20896. matricesIndices: Nullable<FloatArray>;
  20897. /**
  20898. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  20899. */
  20900. matricesWeights: Nullable<FloatArray>;
  20901. /**
  20902. * An array extending the number of possible indices
  20903. */
  20904. matricesIndicesExtra: Nullable<FloatArray>;
  20905. /**
  20906. * An array extending the number of possible weights when the number of indices is extended
  20907. */
  20908. matricesWeightsExtra: Nullable<FloatArray>;
  20909. /**
  20910. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  20911. */
  20912. indices: Nullable<IndicesArray>;
  20913. /**
  20914. * Uses the passed data array to set the set the values for the specified kind of data
  20915. * @param data a linear array of floating numbers
  20916. * @param kind the type of data that is being set, eg positions, colors etc
  20917. */
  20918. set(data: FloatArray, kind: string): void;
  20919. /**
  20920. * Associates the vertexData to the passed Mesh.
  20921. * Sets it as updatable or not (default `false`)
  20922. * @param mesh the mesh the vertexData is applied to
  20923. * @param updatable when used and having the value true allows new data to update the vertexData
  20924. * @returns the VertexData
  20925. */
  20926. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  20927. /**
  20928. * Associates the vertexData to the passed Geometry.
  20929. * Sets it as updatable or not (default `false`)
  20930. * @param geometry the geometry the vertexData is applied to
  20931. * @param updatable when used and having the value true allows new data to update the vertexData
  20932. * @returns VertexData
  20933. */
  20934. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  20935. /**
  20936. * Updates the associated mesh
  20937. * @param mesh the mesh to be updated
  20938. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  20939. * @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
  20940. * @returns VertexData
  20941. */
  20942. updateMesh(mesh: Mesh): VertexData;
  20943. /**
  20944. * Updates the associated geometry
  20945. * @param geometry the geometry to be updated
  20946. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  20947. * @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
  20948. * @returns VertexData.
  20949. */
  20950. updateGeometry(geometry: Geometry): VertexData;
  20951. private _applyTo;
  20952. private _update;
  20953. /**
  20954. * Transforms each position and each normal of the vertexData according to the passed Matrix
  20955. * @param matrix the transforming matrix
  20956. * @returns the VertexData
  20957. */
  20958. transform(matrix: Matrix): VertexData;
  20959. /**
  20960. * Merges the passed VertexData into the current one
  20961. * @param other the VertexData to be merged into the current one
  20962. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  20963. * @returns the modified VertexData
  20964. */
  20965. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  20966. private _mergeElement;
  20967. private _validate;
  20968. /**
  20969. * Serializes the VertexData
  20970. * @returns a serialized object
  20971. */
  20972. serialize(): any;
  20973. /**
  20974. * Extracts the vertexData from a mesh
  20975. * @param mesh the mesh from which to extract the VertexData
  20976. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  20977. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  20978. * @returns the object VertexData associated to the passed mesh
  20979. */
  20980. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  20981. /**
  20982. * Extracts the vertexData from the geometry
  20983. * @param geometry the geometry from which to extract the VertexData
  20984. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  20985. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  20986. * @returns the object VertexData associated to the passed mesh
  20987. */
  20988. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  20989. private static _ExtractFrom;
  20990. /**
  20991. * Creates the VertexData for a Ribbon
  20992. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  20993. * * pathArray array of paths, each of which an array of successive Vector3
  20994. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  20995. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  20996. * * 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
  20997. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20998. * * 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)
  20999. * * 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)
  21000. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21001. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21002. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21003. * @returns the VertexData of the ribbon
  21004. */
  21005. static CreateRibbon(options: {
  21006. pathArray: Vector3[][];
  21007. closeArray?: boolean;
  21008. closePath?: boolean;
  21009. offset?: number;
  21010. sideOrientation?: number;
  21011. frontUVs?: Vector4;
  21012. backUVs?: Vector4;
  21013. invertUV?: boolean;
  21014. uvs?: Vector2[];
  21015. colors?: Color4[];
  21016. }): VertexData;
  21017. /**
  21018. * Creates the VertexData for a box
  21019. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21020. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21021. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21022. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21023. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21024. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21025. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21026. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21027. * * 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)
  21028. * * 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)
  21029. * @returns the VertexData of the box
  21030. */
  21031. static CreateBox(options: {
  21032. size?: number;
  21033. width?: number;
  21034. height?: number;
  21035. depth?: number;
  21036. faceUV?: Vector4[];
  21037. faceColors?: Color4[];
  21038. sideOrientation?: number;
  21039. frontUVs?: Vector4;
  21040. backUVs?: Vector4;
  21041. }): VertexData;
  21042. /**
  21043. * Creates the VertexData for a tiled box
  21044. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21045. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21046. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21047. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21048. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21049. * @returns the VertexData of the box
  21050. */
  21051. static CreateTiledBox(options: {
  21052. pattern?: number;
  21053. width?: number;
  21054. height?: number;
  21055. depth?: number;
  21056. tileSize?: number;
  21057. tileWidth?: number;
  21058. tileHeight?: number;
  21059. alignHorizontal?: number;
  21060. alignVertical?: number;
  21061. faceUV?: Vector4[];
  21062. faceColors?: Color4[];
  21063. sideOrientation?: number;
  21064. }): VertexData;
  21065. /**
  21066. * Creates the VertexData for a tiled plane
  21067. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21068. * * pattern a limited pattern arrangement depending on the number
  21069. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21070. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21071. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21072. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21073. * * 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)
  21074. * * 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)
  21075. * @returns the VertexData of the tiled plane
  21076. */
  21077. static CreateTiledPlane(options: {
  21078. pattern?: number;
  21079. tileSize?: number;
  21080. tileWidth?: number;
  21081. tileHeight?: number;
  21082. size?: number;
  21083. width?: number;
  21084. height?: number;
  21085. alignHorizontal?: number;
  21086. alignVertical?: number;
  21087. sideOrientation?: number;
  21088. frontUVs?: Vector4;
  21089. backUVs?: Vector4;
  21090. }): VertexData;
  21091. /**
  21092. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21093. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21094. * * segments sets the number of horizontal strips optional, default 32
  21095. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21096. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21097. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21098. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21099. * * 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
  21100. * * 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
  21101. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21102. * * 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)
  21103. * * 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)
  21104. * @returns the VertexData of the ellipsoid
  21105. */
  21106. static CreateSphere(options: {
  21107. segments?: number;
  21108. diameter?: number;
  21109. diameterX?: number;
  21110. diameterY?: number;
  21111. diameterZ?: number;
  21112. arc?: number;
  21113. slice?: number;
  21114. sideOrientation?: number;
  21115. frontUVs?: Vector4;
  21116. backUVs?: Vector4;
  21117. }): VertexData;
  21118. /**
  21119. * Creates the VertexData for a cylinder, cone or prism
  21120. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21121. * * height sets the height (y direction) of the cylinder, optional, default 2
  21122. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21123. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21124. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21125. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21126. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21127. * * 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
  21128. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21129. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21130. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21131. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21132. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21133. * * 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)
  21134. * * 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)
  21135. * @returns the VertexData of the cylinder, cone or prism
  21136. */
  21137. static CreateCylinder(options: {
  21138. height?: number;
  21139. diameterTop?: number;
  21140. diameterBottom?: number;
  21141. diameter?: number;
  21142. tessellation?: number;
  21143. subdivisions?: number;
  21144. arc?: number;
  21145. faceColors?: Color4[];
  21146. faceUV?: Vector4[];
  21147. hasRings?: boolean;
  21148. enclose?: boolean;
  21149. sideOrientation?: number;
  21150. frontUVs?: Vector4;
  21151. backUVs?: Vector4;
  21152. }): VertexData;
  21153. /**
  21154. * Creates the VertexData for a torus
  21155. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21156. * * diameter the diameter of the torus, optional default 1
  21157. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21158. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21159. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21160. * * 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)
  21161. * * 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)
  21162. * @returns the VertexData of the torus
  21163. */
  21164. static CreateTorus(options: {
  21165. diameter?: number;
  21166. thickness?: number;
  21167. tessellation?: number;
  21168. sideOrientation?: number;
  21169. frontUVs?: Vector4;
  21170. backUVs?: Vector4;
  21171. }): VertexData;
  21172. /**
  21173. * Creates the VertexData of the LineSystem
  21174. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21175. * - lines an array of lines, each line being an array of successive Vector3
  21176. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21177. * @returns the VertexData of the LineSystem
  21178. */
  21179. static CreateLineSystem(options: {
  21180. lines: Vector3[][];
  21181. colors?: Nullable<Color4[][]>;
  21182. }): VertexData;
  21183. /**
  21184. * Create the VertexData for a DashedLines
  21185. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21186. * - points an array successive Vector3
  21187. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21188. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21189. * - dashNb the intended total number of dashes, optional, default 200
  21190. * @returns the VertexData for the DashedLines
  21191. */
  21192. static CreateDashedLines(options: {
  21193. points: Vector3[];
  21194. dashSize?: number;
  21195. gapSize?: number;
  21196. dashNb?: number;
  21197. }): VertexData;
  21198. /**
  21199. * Creates the VertexData for a Ground
  21200. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21201. * - width the width (x direction) of the ground, optional, default 1
  21202. * - height the height (z direction) of the ground, optional, default 1
  21203. * - subdivisions the number of subdivisions per side, optional, default 1
  21204. * @returns the VertexData of the Ground
  21205. */
  21206. static CreateGround(options: {
  21207. width?: number;
  21208. height?: number;
  21209. subdivisions?: number;
  21210. subdivisionsX?: number;
  21211. subdivisionsY?: number;
  21212. }): VertexData;
  21213. /**
  21214. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21215. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21216. * * xmin the ground minimum X coordinate, optional, default -1
  21217. * * zmin the ground minimum Z coordinate, optional, default -1
  21218. * * xmax the ground maximum X coordinate, optional, default 1
  21219. * * zmax the ground maximum Z coordinate, optional, default 1
  21220. * * 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}
  21221. * * 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}
  21222. * @returns the VertexData of the TiledGround
  21223. */
  21224. static CreateTiledGround(options: {
  21225. xmin: number;
  21226. zmin: number;
  21227. xmax: number;
  21228. zmax: number;
  21229. subdivisions?: {
  21230. w: number;
  21231. h: number;
  21232. };
  21233. precision?: {
  21234. w: number;
  21235. h: number;
  21236. };
  21237. }): VertexData;
  21238. /**
  21239. * Creates the VertexData of the Ground designed from a heightmap
  21240. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21241. * * width the width (x direction) of the ground
  21242. * * height the height (z direction) of the ground
  21243. * * subdivisions the number of subdivisions per side
  21244. * * minHeight the minimum altitude on the ground, optional, default 0
  21245. * * maxHeight the maximum altitude on the ground, optional default 1
  21246. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21247. * * buffer the array holding the image color data
  21248. * * bufferWidth the width of image
  21249. * * bufferHeight the height of image
  21250. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21251. * @returns the VertexData of the Ground designed from a heightmap
  21252. */
  21253. static CreateGroundFromHeightMap(options: {
  21254. width: number;
  21255. height: number;
  21256. subdivisions: number;
  21257. minHeight: number;
  21258. maxHeight: number;
  21259. colorFilter: Color3;
  21260. buffer: Uint8Array;
  21261. bufferWidth: number;
  21262. bufferHeight: number;
  21263. alphaFilter: number;
  21264. }): VertexData;
  21265. /**
  21266. * Creates the VertexData for a Plane
  21267. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21268. * * size sets the width and height of the plane to the value of size, optional default 1
  21269. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21270. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21271. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21272. * * 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)
  21273. * * 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)
  21274. * @returns the VertexData of the box
  21275. */
  21276. static CreatePlane(options: {
  21277. size?: number;
  21278. width?: number;
  21279. height?: number;
  21280. sideOrientation?: number;
  21281. frontUVs?: Vector4;
  21282. backUVs?: Vector4;
  21283. }): VertexData;
  21284. /**
  21285. * Creates the VertexData of the Disc or regular Polygon
  21286. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21287. * * radius the radius of the disc, optional default 0.5
  21288. * * tessellation the number of polygon sides, optional, default 64
  21289. * * 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
  21290. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21291. * * 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)
  21292. * * 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)
  21293. * @returns the VertexData of the box
  21294. */
  21295. static CreateDisc(options: {
  21296. radius?: number;
  21297. tessellation?: number;
  21298. arc?: number;
  21299. sideOrientation?: number;
  21300. frontUVs?: Vector4;
  21301. backUVs?: Vector4;
  21302. }): VertexData;
  21303. /**
  21304. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21305. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21306. * @param polygon a mesh built from polygonTriangulation.build()
  21307. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21308. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21309. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21310. * @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)
  21311. * @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)
  21312. * @returns the VertexData of the Polygon
  21313. */
  21314. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21315. /**
  21316. * Creates the VertexData of the IcoSphere
  21317. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21318. * * radius the radius of the IcoSphere, optional default 1
  21319. * * radiusX allows stretching in the x direction, optional, default radius
  21320. * * radiusY allows stretching in the y direction, optional, default radius
  21321. * * radiusZ allows stretching in the z direction, optional, default radius
  21322. * * flat when true creates a flat shaded mesh, optional, default true
  21323. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21324. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21325. * * 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)
  21326. * * 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)
  21327. * @returns the VertexData of the IcoSphere
  21328. */
  21329. static CreateIcoSphere(options: {
  21330. radius?: number;
  21331. radiusX?: number;
  21332. radiusY?: number;
  21333. radiusZ?: number;
  21334. flat?: boolean;
  21335. subdivisions?: number;
  21336. sideOrientation?: number;
  21337. frontUVs?: Vector4;
  21338. backUVs?: Vector4;
  21339. }): VertexData;
  21340. /**
  21341. * Creates the VertexData for a Polyhedron
  21342. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21343. * * type provided types are:
  21344. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21345. * * 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)
  21346. * * size the size of the IcoSphere, optional default 1
  21347. * * sizeX allows stretching in the x direction, optional, default size
  21348. * * sizeY allows stretching in the y direction, optional, default size
  21349. * * sizeZ allows stretching in the z direction, optional, default size
  21350. * * 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
  21351. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21352. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21353. * * flat when true creates a flat shaded mesh, optional, default true
  21354. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21355. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21356. * * 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)
  21357. * * 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)
  21358. * @returns the VertexData of the Polyhedron
  21359. */
  21360. static CreatePolyhedron(options: {
  21361. type?: number;
  21362. size?: number;
  21363. sizeX?: number;
  21364. sizeY?: number;
  21365. sizeZ?: number;
  21366. custom?: any;
  21367. faceUV?: Vector4[];
  21368. faceColors?: Color4[];
  21369. flat?: boolean;
  21370. sideOrientation?: number;
  21371. frontUVs?: Vector4;
  21372. backUVs?: Vector4;
  21373. }): VertexData;
  21374. /**
  21375. * Creates the VertexData for a TorusKnot
  21376. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21377. * * radius the radius of the torus knot, optional, default 2
  21378. * * tube the thickness of the tube, optional, default 0.5
  21379. * * radialSegments the number of sides on each tube segments, optional, default 32
  21380. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21381. * * p the number of windings around the z axis, optional, default 2
  21382. * * q the number of windings around the x axis, optional, default 3
  21383. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21384. * * 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)
  21385. * * 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)
  21386. * @returns the VertexData of the Torus Knot
  21387. */
  21388. static CreateTorusKnot(options: {
  21389. radius?: number;
  21390. tube?: number;
  21391. radialSegments?: number;
  21392. tubularSegments?: number;
  21393. p?: number;
  21394. q?: number;
  21395. sideOrientation?: number;
  21396. frontUVs?: Vector4;
  21397. backUVs?: Vector4;
  21398. }): VertexData;
  21399. /**
  21400. * Compute normals for given positions and indices
  21401. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21402. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21403. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21404. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21405. * * facetNormals : optional array of facet normals (vector3)
  21406. * * facetPositions : optional array of facet positions (vector3)
  21407. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21408. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21409. * * bInfo : optional bounding info, required for facetPartitioning computation
  21410. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21411. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21412. * * useRightHandedSystem: optional boolean to for right handed system computation
  21413. * * depthSort : optional boolean to enable the facet depth sort computation
  21414. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21415. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21416. */
  21417. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21418. facetNormals?: any;
  21419. facetPositions?: any;
  21420. facetPartitioning?: any;
  21421. ratio?: number;
  21422. bInfo?: any;
  21423. bbSize?: Vector3;
  21424. subDiv?: any;
  21425. useRightHandedSystem?: boolean;
  21426. depthSort?: boolean;
  21427. distanceTo?: Vector3;
  21428. depthSortedFacets?: any;
  21429. }): void;
  21430. /** @hidden */ private static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21431. /**
  21432. * Applies VertexData created from the imported parameters to the geometry
  21433. * @param parsedVertexData the parsed data from an imported file
  21434. * @param geometry the geometry to apply the VertexData to
  21435. */
  21436. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21437. }
  21438. }
  21439. declare module BABYLON {
  21440. /**
  21441. * Defines a target to use with MorphTargetManager
  21442. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21443. */
  21444. export class MorphTarget implements IAnimatable {
  21445. /** defines the name of the target */
  21446. name: string;
  21447. /**
  21448. * Gets or sets the list of animations
  21449. */
  21450. animations: Animation[];
  21451. private _scene;
  21452. private _positions;
  21453. private _normals;
  21454. private _tangents;
  21455. private _uvs;
  21456. private _influence;
  21457. /**
  21458. * Observable raised when the influence changes
  21459. */
  21460. onInfluenceChanged: Observable<boolean>;
  21461. /** @hidden */ private _onDataLayoutChanged: Observable<void>;
  21462. /**
  21463. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  21464. */
  21465. influence: number;
  21466. /**
  21467. * Gets or sets the id of the morph Target
  21468. */
  21469. id: string;
  21470. private _animationPropertiesOverride;
  21471. /**
  21472. * Gets or sets the animation properties override
  21473. */
  21474. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  21475. /**
  21476. * Creates a new MorphTarget
  21477. * @param name defines the name of the target
  21478. * @param influence defines the influence to use
  21479. * @param scene defines the scene the morphtarget belongs to
  21480. */
  21481. constructor(
  21482. /** defines the name of the target */
  21483. name: string, influence?: number, scene?: Nullable<Scene>);
  21484. /**
  21485. * Gets a boolean defining if the target contains position data
  21486. */
  21487. readonly hasPositions: boolean;
  21488. /**
  21489. * Gets a boolean defining if the target contains normal data
  21490. */
  21491. readonly hasNormals: boolean;
  21492. /**
  21493. * Gets a boolean defining if the target contains tangent data
  21494. */
  21495. readonly hasTangents: boolean;
  21496. /**
  21497. * Gets a boolean defining if the target contains texture coordinates data
  21498. */
  21499. readonly hasUVs: boolean;
  21500. /**
  21501. * Affects position data to this target
  21502. * @param data defines the position data to use
  21503. */
  21504. setPositions(data: Nullable<FloatArray>): void;
  21505. /**
  21506. * Gets the position data stored in this target
  21507. * @returns a FloatArray containing the position data (or null if not present)
  21508. */
  21509. getPositions(): Nullable<FloatArray>;
  21510. /**
  21511. * Affects normal data to this target
  21512. * @param data defines the normal data to use
  21513. */
  21514. setNormals(data: Nullable<FloatArray>): void;
  21515. /**
  21516. * Gets the normal data stored in this target
  21517. * @returns a FloatArray containing the normal data (or null if not present)
  21518. */
  21519. getNormals(): Nullable<FloatArray>;
  21520. /**
  21521. * Affects tangent data to this target
  21522. * @param data defines the tangent data to use
  21523. */
  21524. setTangents(data: Nullable<FloatArray>): void;
  21525. /**
  21526. * Gets the tangent data stored in this target
  21527. * @returns a FloatArray containing the tangent data (or null if not present)
  21528. */
  21529. getTangents(): Nullable<FloatArray>;
  21530. /**
  21531. * Affects texture coordinates data to this target
  21532. * @param data defines the texture coordinates data to use
  21533. */
  21534. setUVs(data: Nullable<FloatArray>): void;
  21535. /**
  21536. * Gets the texture coordinates data stored in this target
  21537. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  21538. */
  21539. getUVs(): Nullable<FloatArray>;
  21540. /**
  21541. * Serializes the current target into a Serialization object
  21542. * @returns the serialized object
  21543. */
  21544. serialize(): any;
  21545. /**
  21546. * Returns the string "MorphTarget"
  21547. * @returns "MorphTarget"
  21548. */
  21549. getClassName(): string;
  21550. /**
  21551. * Creates a new target from serialized data
  21552. * @param serializationObject defines the serialized data to use
  21553. * @returns a new MorphTarget
  21554. */
  21555. static Parse(serializationObject: any): MorphTarget;
  21556. /**
  21557. * Creates a MorphTarget from mesh data
  21558. * @param mesh defines the source mesh
  21559. * @param name defines the name to use for the new target
  21560. * @param influence defines the influence to attach to the target
  21561. * @returns a new MorphTarget
  21562. */
  21563. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  21564. }
  21565. }
  21566. declare module BABYLON {
  21567. /**
  21568. * This class is used to deform meshes using morphing between different targets
  21569. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21570. */
  21571. export class MorphTargetManager {
  21572. private _targets;
  21573. private _targetInfluenceChangedObservers;
  21574. private _targetDataLayoutChangedObservers;
  21575. private _activeTargets;
  21576. private _scene;
  21577. private _influences;
  21578. private _supportsNormals;
  21579. private _supportsTangents;
  21580. private _supportsUVs;
  21581. private _vertexCount;
  21582. private _uniqueId;
  21583. private _tempInfluences;
  21584. /**
  21585. * Gets or sets a boolean indicating if normals must be morphed
  21586. */
  21587. enableNormalMorphing: boolean;
  21588. /**
  21589. * Gets or sets a boolean indicating if tangents must be morphed
  21590. */
  21591. enableTangentMorphing: boolean;
  21592. /**
  21593. * Gets or sets a boolean indicating if UV must be morphed
  21594. */
  21595. enableUVMorphing: boolean;
  21596. /**
  21597. * Creates a new MorphTargetManager
  21598. * @param scene defines the current scene
  21599. */
  21600. constructor(scene?: Nullable<Scene>);
  21601. /**
  21602. * Gets the unique ID of this manager
  21603. */
  21604. readonly uniqueId: number;
  21605. /**
  21606. * Gets the number of vertices handled by this manager
  21607. */
  21608. readonly vertexCount: number;
  21609. /**
  21610. * Gets a boolean indicating if this manager supports morphing of normals
  21611. */
  21612. readonly supportsNormals: boolean;
  21613. /**
  21614. * Gets a boolean indicating if this manager supports morphing of tangents
  21615. */
  21616. readonly supportsTangents: boolean;
  21617. /**
  21618. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  21619. */
  21620. readonly supportsUVs: boolean;
  21621. /**
  21622. * Gets the number of targets stored in this manager
  21623. */
  21624. readonly numTargets: number;
  21625. /**
  21626. * Gets the number of influencers (ie. the number of targets with influences > 0)
  21627. */
  21628. readonly numInfluencers: number;
  21629. /**
  21630. * Gets the list of influences (one per target)
  21631. */
  21632. readonly influences: Float32Array;
  21633. /**
  21634. * Gets the active target at specified index. An active target is a target with an influence > 0
  21635. * @param index defines the index to check
  21636. * @returns the requested target
  21637. */
  21638. getActiveTarget(index: number): MorphTarget;
  21639. /**
  21640. * Gets the target at specified index
  21641. * @param index defines the index to check
  21642. * @returns the requested target
  21643. */
  21644. getTarget(index: number): MorphTarget;
  21645. /**
  21646. * Add a new target to this manager
  21647. * @param target defines the target to add
  21648. */
  21649. addTarget(target: MorphTarget): void;
  21650. /**
  21651. * Removes a target from the manager
  21652. * @param target defines the target to remove
  21653. */
  21654. removeTarget(target: MorphTarget): void;
  21655. /**
  21656. * Serializes the current manager into a Serialization object
  21657. * @returns the serialized object
  21658. */
  21659. serialize(): any;
  21660. private _syncActiveTargets;
  21661. /**
  21662. * Syncrhonize the targets with all the meshes using this morph target manager
  21663. */
  21664. synchronize(): void;
  21665. /**
  21666. * Creates a new MorphTargetManager from serialized data
  21667. * @param serializationObject defines the serialized data
  21668. * @param scene defines the hosting scene
  21669. * @returns the new MorphTargetManager
  21670. */
  21671. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  21672. }
  21673. }
  21674. declare module BABYLON {
  21675. /**
  21676. * Class used to represent a specific level of detail of a mesh
  21677. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21678. */
  21679. export class MeshLODLevel {
  21680. /** Defines the distance where this level should star being displayed */
  21681. distance: number;
  21682. /** Defines the mesh to use to render this level */
  21683. mesh: Nullable<Mesh>;
  21684. /**
  21685. * Creates a new LOD level
  21686. * @param distance defines the distance where this level should star being displayed
  21687. * @param mesh defines the mesh to use to render this level
  21688. */
  21689. constructor(
  21690. /** Defines the distance where this level should star being displayed */
  21691. distance: number,
  21692. /** Defines the mesh to use to render this level */
  21693. mesh: Nullable<Mesh>);
  21694. }
  21695. }
  21696. declare module BABYLON {
  21697. /**
  21698. * Mesh representing the gorund
  21699. */
  21700. export class GroundMesh extends Mesh {
  21701. /** If octree should be generated */
  21702. generateOctree: boolean;
  21703. private _heightQuads;
  21704. /** @hidden */ private _subdivisionsX: number;
  21705. /** @hidden */ private _subdivisionsY: number;
  21706. /** @hidden */ private _width: number;
  21707. /** @hidden */ private _height: number;
  21708. /** @hidden */ private _minX: number;
  21709. /** @hidden */ private _maxX: number;
  21710. /** @hidden */ private _minZ: number;
  21711. /** @hidden */ private _maxZ: number;
  21712. constructor(name: string, scene: Scene);
  21713. /**
  21714. * "GroundMesh"
  21715. * @returns "GroundMesh"
  21716. */
  21717. getClassName(): string;
  21718. /**
  21719. * The minimum of x and y subdivisions
  21720. */
  21721. readonly subdivisions: number;
  21722. /**
  21723. * X subdivisions
  21724. */
  21725. readonly subdivisionsX: number;
  21726. /**
  21727. * Y subdivisions
  21728. */
  21729. readonly subdivisionsY: number;
  21730. /**
  21731. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  21732. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  21733. * @param chunksCount the number of subdivisions for x and y
  21734. * @param octreeBlocksSize (Default: 32)
  21735. */
  21736. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  21737. /**
  21738. * Returns a height (y) value in the Worl system :
  21739. * the ground altitude at the coordinates (x, z) expressed in the World system.
  21740. * @param x x coordinate
  21741. * @param z z coordinate
  21742. * @returns the ground y position if (x, z) are outside the ground surface.
  21743. */
  21744. getHeightAtCoordinates(x: number, z: number): number;
  21745. /**
  21746. * Returns a normalized vector (Vector3) orthogonal to the ground
  21747. * at the ground coordinates (x, z) expressed in the World system.
  21748. * @param x x coordinate
  21749. * @param z z coordinate
  21750. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  21751. */
  21752. getNormalAtCoordinates(x: number, z: number): Vector3;
  21753. /**
  21754. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  21755. * at the ground coordinates (x, z) expressed in the World system.
  21756. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  21757. * @param x x coordinate
  21758. * @param z z coordinate
  21759. * @param ref vector to store the result
  21760. * @returns the GroundMesh.
  21761. */
  21762. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  21763. /**
  21764. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  21765. * if the ground has been updated.
  21766. * This can be used in the render loop.
  21767. * @returns the GroundMesh.
  21768. */
  21769. updateCoordinateHeights(): GroundMesh;
  21770. private _getFacetAt;
  21771. private _initHeightQuads;
  21772. private _computeHeightQuads;
  21773. /**
  21774. * Serializes this ground mesh
  21775. * @param serializationObject object to write serialization to
  21776. */
  21777. serialize(serializationObject: any): void;
  21778. /**
  21779. * Parses a serialized ground mesh
  21780. * @param parsedMesh the serialized mesh
  21781. * @param scene the scene to create the ground mesh in
  21782. * @returns the created ground mesh
  21783. */
  21784. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  21785. }
  21786. }
  21787. declare module BABYLON {
  21788. /**
  21789. * Interface for Physics-Joint data
  21790. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  21791. */
  21792. export interface PhysicsJointData {
  21793. /**
  21794. * The main pivot of the joint
  21795. */
  21796. mainPivot?: Vector3;
  21797. /**
  21798. * The connected pivot of the joint
  21799. */
  21800. connectedPivot?: Vector3;
  21801. /**
  21802. * The main axis of the joint
  21803. */
  21804. mainAxis?: Vector3;
  21805. /**
  21806. * The connected axis of the joint
  21807. */
  21808. connectedAxis?: Vector3;
  21809. /**
  21810. * The collision of the joint
  21811. */
  21812. collision?: boolean;
  21813. /**
  21814. * Native Oimo/Cannon/Energy data
  21815. */
  21816. nativeParams?: any;
  21817. }
  21818. /**
  21819. * This is a holder class for the physics joint created by the physics plugin
  21820. * It holds a set of functions to control the underlying joint
  21821. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  21822. */
  21823. export class PhysicsJoint {
  21824. /**
  21825. * The type of the physics joint
  21826. */
  21827. type: number;
  21828. /**
  21829. * The data for the physics joint
  21830. */
  21831. jointData: PhysicsJointData;
  21832. private _physicsJoint;
  21833. protected _physicsPlugin: IPhysicsEnginePlugin;
  21834. /**
  21835. * Initializes the physics joint
  21836. * @param type The type of the physics joint
  21837. * @param jointData The data for the physics joint
  21838. */
  21839. constructor(
  21840. /**
  21841. * The type of the physics joint
  21842. */
  21843. type: number,
  21844. /**
  21845. * The data for the physics joint
  21846. */
  21847. jointData: PhysicsJointData);
  21848. /**
  21849. * Gets the physics joint
  21850. */
  21851. /**
  21852. * Sets the physics joint
  21853. */
  21854. physicsJoint: any;
  21855. /**
  21856. * Sets the physics plugin
  21857. */
  21858. physicsPlugin: IPhysicsEnginePlugin;
  21859. /**
  21860. * Execute a function that is physics-plugin specific.
  21861. * @param {Function} func the function that will be executed.
  21862. * It accepts two parameters: the physics world and the physics joint
  21863. */
  21864. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  21865. /**
  21866. * Distance-Joint type
  21867. */
  21868. static DistanceJoint: number;
  21869. /**
  21870. * Hinge-Joint type
  21871. */
  21872. static HingeJoint: number;
  21873. /**
  21874. * Ball-and-Socket joint type
  21875. */
  21876. static BallAndSocketJoint: number;
  21877. /**
  21878. * Wheel-Joint type
  21879. */
  21880. static WheelJoint: number;
  21881. /**
  21882. * Slider-Joint type
  21883. */
  21884. static SliderJoint: number;
  21885. /**
  21886. * Prismatic-Joint type
  21887. */
  21888. static PrismaticJoint: number;
  21889. /**
  21890. * Universal-Joint type
  21891. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  21892. */
  21893. static UniversalJoint: number;
  21894. /**
  21895. * Hinge-Joint 2 type
  21896. */
  21897. static Hinge2Joint: number;
  21898. /**
  21899. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  21900. */
  21901. static PointToPointJoint: number;
  21902. /**
  21903. * Spring-Joint type
  21904. */
  21905. static SpringJoint: number;
  21906. /**
  21907. * Lock-Joint type
  21908. */
  21909. static LockJoint: number;
  21910. }
  21911. /**
  21912. * A class representing a physics distance joint
  21913. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  21914. */
  21915. export class DistanceJoint extends PhysicsJoint {
  21916. /**
  21917. *
  21918. * @param jointData The data for the Distance-Joint
  21919. */
  21920. constructor(jointData: DistanceJointData);
  21921. /**
  21922. * Update the predefined distance.
  21923. * @param maxDistance The maximum preferred distance
  21924. * @param minDistance The minimum preferred distance
  21925. */
  21926. updateDistance(maxDistance: number, minDistance?: number): void;
  21927. }
  21928. /**
  21929. * Represents a Motor-Enabled Joint
  21930. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  21931. */
  21932. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  21933. /**
  21934. * Initializes the Motor-Enabled Joint
  21935. * @param type The type of the joint
  21936. * @param jointData The physica joint data for the joint
  21937. */
  21938. constructor(type: number, jointData: PhysicsJointData);
  21939. /**
  21940. * Set the motor values.
  21941. * Attention, this function is plugin specific. Engines won't react 100% the same.
  21942. * @param force the force to apply
  21943. * @param maxForce max force for this motor.
  21944. */
  21945. setMotor(force?: number, maxForce?: number): void;
  21946. /**
  21947. * Set the motor's limits.
  21948. * Attention, this function is plugin specific. Engines won't react 100% the same.
  21949. * @param upperLimit The upper limit of the motor
  21950. * @param lowerLimit The lower limit of the motor
  21951. */
  21952. setLimit(upperLimit: number, lowerLimit?: number): void;
  21953. }
  21954. /**
  21955. * This class represents a single physics Hinge-Joint
  21956. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  21957. */
  21958. export class HingeJoint extends MotorEnabledJoint {
  21959. /**
  21960. * Initializes the Hinge-Joint
  21961. * @param jointData The joint data for the Hinge-Joint
  21962. */
  21963. constructor(jointData: PhysicsJointData);
  21964. /**
  21965. * Set the motor values.
  21966. * Attention, this function is plugin specific. Engines won't react 100% the same.
  21967. * @param {number} force the force to apply
  21968. * @param {number} maxForce max force for this motor.
  21969. */
  21970. setMotor(force?: number, maxForce?: number): void;
  21971. /**
  21972. * Set the motor's limits.
  21973. * Attention, this function is plugin specific. Engines won't react 100% the same.
  21974. * @param upperLimit The upper limit of the motor
  21975. * @param lowerLimit The lower limit of the motor
  21976. */
  21977. setLimit(upperLimit: number, lowerLimit?: number): void;
  21978. }
  21979. /**
  21980. * This class represents a dual hinge physics joint (same as wheel joint)
  21981. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  21982. */
  21983. export class Hinge2Joint extends MotorEnabledJoint {
  21984. /**
  21985. * Initializes the Hinge2-Joint
  21986. * @param jointData The joint data for the Hinge2-Joint
  21987. */
  21988. constructor(jointData: PhysicsJointData);
  21989. /**
  21990. * Set the motor values.
  21991. * Attention, this function is plugin specific. Engines won't react 100% the same.
  21992. * @param {number} targetSpeed the speed the motor is to reach
  21993. * @param {number} maxForce max force for this motor.
  21994. * @param {motorIndex} the motor's index, 0 or 1.
  21995. */
  21996. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  21997. /**
  21998. * Set the motor limits.
  21999. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22000. * @param {number} upperLimit the upper limit
  22001. * @param {number} lowerLimit lower limit
  22002. * @param {motorIndex} the motor's index, 0 or 1.
  22003. */
  22004. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22005. }
  22006. /**
  22007. * Interface for a motor enabled joint
  22008. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22009. */
  22010. export interface IMotorEnabledJoint {
  22011. /**
  22012. * Physics joint
  22013. */
  22014. physicsJoint: any;
  22015. /**
  22016. * Sets the motor of the motor-enabled joint
  22017. * @param force The force of the motor
  22018. * @param maxForce The maximum force of the motor
  22019. * @param motorIndex The index of the motor
  22020. */
  22021. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22022. /**
  22023. * Sets the limit of the motor
  22024. * @param upperLimit The upper limit of the motor
  22025. * @param lowerLimit The lower limit of the motor
  22026. * @param motorIndex The index of the motor
  22027. */
  22028. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22029. }
  22030. /**
  22031. * Joint data for a Distance-Joint
  22032. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22033. */
  22034. export interface DistanceJointData extends PhysicsJointData {
  22035. /**
  22036. * Max distance the 2 joint objects can be apart
  22037. */
  22038. maxDistance: number;
  22039. }
  22040. /**
  22041. * Joint data from a spring joint
  22042. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22043. */
  22044. export interface SpringJointData extends PhysicsJointData {
  22045. /**
  22046. * Length of the spring
  22047. */
  22048. length: number;
  22049. /**
  22050. * Stiffness of the spring
  22051. */
  22052. stiffness: number;
  22053. /**
  22054. * Damping of the spring
  22055. */
  22056. damping: number;
  22057. /** this callback will be called when applying the force to the impostors. */
  22058. forceApplicationCallback: () => void;
  22059. }
  22060. }
  22061. declare module BABYLON {
  22062. /**
  22063. * Holds the data for the raycast result
  22064. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22065. */
  22066. export class PhysicsRaycastResult {
  22067. private _hasHit;
  22068. private _hitDistance;
  22069. private _hitNormalWorld;
  22070. private _hitPointWorld;
  22071. private _rayFromWorld;
  22072. private _rayToWorld;
  22073. /**
  22074. * Gets if there was a hit
  22075. */
  22076. readonly hasHit: boolean;
  22077. /**
  22078. * Gets the distance from the hit
  22079. */
  22080. readonly hitDistance: number;
  22081. /**
  22082. * Gets the hit normal/direction in the world
  22083. */
  22084. readonly hitNormalWorld: Vector3;
  22085. /**
  22086. * Gets the hit point in the world
  22087. */
  22088. readonly hitPointWorld: Vector3;
  22089. /**
  22090. * Gets the ray "start point" of the ray in the world
  22091. */
  22092. readonly rayFromWorld: Vector3;
  22093. /**
  22094. * Gets the ray "end point" of the ray in the world
  22095. */
  22096. readonly rayToWorld: Vector3;
  22097. /**
  22098. * Sets the hit data (normal & point in world space)
  22099. * @param hitNormalWorld defines the normal in world space
  22100. * @param hitPointWorld defines the point in world space
  22101. */
  22102. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22103. /**
  22104. * Sets the distance from the start point to the hit point
  22105. * @param distance
  22106. */
  22107. setHitDistance(distance: number): void;
  22108. /**
  22109. * Calculates the distance manually
  22110. */
  22111. calculateHitDistance(): void;
  22112. /**
  22113. * Resets all the values to default
  22114. * @param from The from point on world space
  22115. * @param to The to point on world space
  22116. */
  22117. reset(from?: Vector3, to?: Vector3): void;
  22118. }
  22119. /**
  22120. * Interface for the size containing width and height
  22121. */
  22122. interface IXYZ {
  22123. /**
  22124. * X
  22125. */
  22126. x: number;
  22127. /**
  22128. * Y
  22129. */
  22130. y: number;
  22131. /**
  22132. * Z
  22133. */
  22134. z: number;
  22135. }
  22136. }
  22137. declare module BABYLON {
  22138. /**
  22139. * Interface used to describe a physics joint
  22140. */
  22141. export interface PhysicsImpostorJoint {
  22142. /** Defines the main impostor to which the joint is linked */
  22143. mainImpostor: PhysicsImpostor;
  22144. /** Defines the impostor that is connected to the main impostor using this joint */
  22145. connectedImpostor: PhysicsImpostor;
  22146. /** Defines the joint itself */
  22147. joint: PhysicsJoint;
  22148. }
  22149. /** @hidden */
  22150. export interface IPhysicsEnginePlugin {
  22151. world: any;
  22152. name: string;
  22153. setGravity(gravity: Vector3): void;
  22154. setTimeStep(timeStep: number): void;
  22155. getTimeStep(): number;
  22156. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22157. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22158. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22159. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22160. removePhysicsBody(impostor: PhysicsImpostor): void;
  22161. generateJoint(joint: PhysicsImpostorJoint): void;
  22162. removeJoint(joint: PhysicsImpostorJoint): void;
  22163. isSupported(): boolean;
  22164. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22165. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22166. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22167. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22168. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22169. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22170. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22171. getBodyMass(impostor: PhysicsImpostor): number;
  22172. getBodyFriction(impostor: PhysicsImpostor): number;
  22173. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22174. getBodyRestitution(impostor: PhysicsImpostor): number;
  22175. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22176. getBodyPressure?(impostor: PhysicsImpostor): number;
  22177. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22178. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22179. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22180. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22181. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22182. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22183. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22184. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22185. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22186. sleepBody(impostor: PhysicsImpostor): void;
  22187. wakeUpBody(impostor: PhysicsImpostor): void;
  22188. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22189. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22190. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22191. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22192. getRadius(impostor: PhysicsImpostor): number;
  22193. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22194. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22195. dispose(): void;
  22196. }
  22197. /**
  22198. * Interface used to define a physics engine
  22199. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22200. */
  22201. export interface IPhysicsEngine {
  22202. /**
  22203. * Gets the gravity vector used by the simulation
  22204. */
  22205. gravity: Vector3;
  22206. /**
  22207. * Sets the gravity vector used by the simulation
  22208. * @param gravity defines the gravity vector to use
  22209. */
  22210. setGravity(gravity: Vector3): void;
  22211. /**
  22212. * Set the time step of the physics engine.
  22213. * Default is 1/60.
  22214. * To slow it down, enter 1/600 for example.
  22215. * To speed it up, 1/30
  22216. * @param newTimeStep the new timestep to apply to this world.
  22217. */
  22218. setTimeStep(newTimeStep: number): void;
  22219. /**
  22220. * Get the time step of the physics engine.
  22221. * @returns the current time step
  22222. */
  22223. getTimeStep(): number;
  22224. /**
  22225. * Release all resources
  22226. */
  22227. dispose(): void;
  22228. /**
  22229. * Gets the name of the current physics plugin
  22230. * @returns the name of the plugin
  22231. */
  22232. getPhysicsPluginName(): string;
  22233. /**
  22234. * Adding a new impostor for the impostor tracking.
  22235. * This will be done by the impostor itself.
  22236. * @param impostor the impostor to add
  22237. */
  22238. addImpostor(impostor: PhysicsImpostor): void;
  22239. /**
  22240. * Remove an impostor from the engine.
  22241. * This impostor and its mesh will not longer be updated by the physics engine.
  22242. * @param impostor the impostor to remove
  22243. */
  22244. removeImpostor(impostor: PhysicsImpostor): void;
  22245. /**
  22246. * Add a joint to the physics engine
  22247. * @param mainImpostor defines the main impostor to which the joint is added.
  22248. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22249. * @param joint defines the joint that will connect both impostors.
  22250. */
  22251. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22252. /**
  22253. * Removes a joint from the simulation
  22254. * @param mainImpostor defines the impostor used with the joint
  22255. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22256. * @param joint defines the joint to remove
  22257. */
  22258. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22259. /**
  22260. * Gets the current plugin used to run the simulation
  22261. * @returns current plugin
  22262. */
  22263. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22264. /**
  22265. * Gets the list of physic impostors
  22266. * @returns an array of PhysicsImpostor
  22267. */
  22268. getImpostors(): Array<PhysicsImpostor>;
  22269. /**
  22270. * Gets the impostor for a physics enabled object
  22271. * @param object defines the object impersonated by the impostor
  22272. * @returns the PhysicsImpostor or null if not found
  22273. */
  22274. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22275. /**
  22276. * Gets the impostor for a physics body object
  22277. * @param body defines physics body used by the impostor
  22278. * @returns the PhysicsImpostor or null if not found
  22279. */
  22280. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22281. /**
  22282. * Does a raycast in the physics world
  22283. * @param from when should the ray start?
  22284. * @param to when should the ray end?
  22285. * @returns PhysicsRaycastResult
  22286. */
  22287. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22288. /**
  22289. * Called by the scene. No need to call it.
  22290. * @param delta defines the timespam between frames
  22291. */ private _step(delta: number): void;
  22292. }
  22293. }
  22294. declare module BABYLON {
  22295. /**
  22296. * The interface for the physics imposter parameters
  22297. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22298. */
  22299. export interface PhysicsImpostorParameters {
  22300. /**
  22301. * The mass of the physics imposter
  22302. */
  22303. mass: number;
  22304. /**
  22305. * The friction of the physics imposter
  22306. */
  22307. friction?: number;
  22308. /**
  22309. * The coefficient of restitution of the physics imposter
  22310. */
  22311. restitution?: number;
  22312. /**
  22313. * The native options of the physics imposter
  22314. */
  22315. nativeOptions?: any;
  22316. /**
  22317. * Specifies if the parent should be ignored
  22318. */
  22319. ignoreParent?: boolean;
  22320. /**
  22321. * Specifies if bi-directional transformations should be disabled
  22322. */
  22323. disableBidirectionalTransformation?: boolean;
  22324. /**
  22325. * The pressure inside the physics imposter, soft object only
  22326. */
  22327. pressure?: number;
  22328. /**
  22329. * The stiffness the physics imposter, soft object only
  22330. */
  22331. stiffness?: number;
  22332. /**
  22333. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22334. */
  22335. velocityIterations?: number;
  22336. /**
  22337. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22338. */
  22339. positionIterations?: number;
  22340. /**
  22341. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22342. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22343. * Add to fix multiple points
  22344. */
  22345. fixedPoints?: number;
  22346. /**
  22347. * The collision margin around a soft object
  22348. */
  22349. margin?: number;
  22350. /**
  22351. * The collision margin around a soft object
  22352. */
  22353. damping?: number;
  22354. /**
  22355. * The path for a rope based on an extrusion
  22356. */
  22357. path?: any;
  22358. /**
  22359. * The shape of an extrusion used for a rope based on an extrusion
  22360. */
  22361. shape?: any;
  22362. }
  22363. /**
  22364. * Interface for a physics-enabled object
  22365. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22366. */
  22367. export interface IPhysicsEnabledObject {
  22368. /**
  22369. * The position of the physics-enabled object
  22370. */
  22371. position: Vector3;
  22372. /**
  22373. * The rotation of the physics-enabled object
  22374. */
  22375. rotationQuaternion: Nullable<Quaternion>;
  22376. /**
  22377. * The scale of the physics-enabled object
  22378. */
  22379. scaling: Vector3;
  22380. /**
  22381. * The rotation of the physics-enabled object
  22382. */
  22383. rotation?: Vector3;
  22384. /**
  22385. * The parent of the physics-enabled object
  22386. */
  22387. parent?: any;
  22388. /**
  22389. * The bounding info of the physics-enabled object
  22390. * @returns The bounding info of the physics-enabled object
  22391. */
  22392. getBoundingInfo(): BoundingInfo;
  22393. /**
  22394. * Computes the world matrix
  22395. * @param force Specifies if the world matrix should be computed by force
  22396. * @returns A world matrix
  22397. */
  22398. computeWorldMatrix(force: boolean): Matrix;
  22399. /**
  22400. * Gets the world matrix
  22401. * @returns A world matrix
  22402. */
  22403. getWorldMatrix?(): Matrix;
  22404. /**
  22405. * Gets the child meshes
  22406. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22407. * @returns An array of abstract meshes
  22408. */
  22409. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22410. /**
  22411. * Gets the vertex data
  22412. * @param kind The type of vertex data
  22413. * @returns A nullable array of numbers, or a float32 array
  22414. */
  22415. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22416. /**
  22417. * Gets the indices from the mesh
  22418. * @returns A nullable array of index arrays
  22419. */
  22420. getIndices?(): Nullable<IndicesArray>;
  22421. /**
  22422. * Gets the scene from the mesh
  22423. * @returns the indices array or null
  22424. */
  22425. getScene?(): Scene;
  22426. /**
  22427. * Gets the absolute position from the mesh
  22428. * @returns the absolute position
  22429. */
  22430. getAbsolutePosition(): Vector3;
  22431. /**
  22432. * Gets the absolute pivot point from the mesh
  22433. * @returns the absolute pivot point
  22434. */
  22435. getAbsolutePivotPoint(): Vector3;
  22436. /**
  22437. * Rotates the mesh
  22438. * @param axis The axis of rotation
  22439. * @param amount The amount of rotation
  22440. * @param space The space of the rotation
  22441. * @returns The rotation transform node
  22442. */
  22443. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22444. /**
  22445. * Translates the mesh
  22446. * @param axis The axis of translation
  22447. * @param distance The distance of translation
  22448. * @param space The space of the translation
  22449. * @returns The transform node
  22450. */
  22451. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22452. /**
  22453. * Sets the absolute position of the mesh
  22454. * @param absolutePosition The absolute position of the mesh
  22455. * @returns The transform node
  22456. */
  22457. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22458. /**
  22459. * Gets the class name of the mesh
  22460. * @returns The class name
  22461. */
  22462. getClassName(): string;
  22463. }
  22464. /**
  22465. * Represents a physics imposter
  22466. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22467. */
  22468. export class PhysicsImpostor {
  22469. /**
  22470. * The physics-enabled object used as the physics imposter
  22471. */
  22472. object: IPhysicsEnabledObject;
  22473. /**
  22474. * The type of the physics imposter
  22475. */
  22476. type: number;
  22477. private _options;
  22478. private _scene?;
  22479. /**
  22480. * The default object size of the imposter
  22481. */
  22482. static DEFAULT_OBJECT_SIZE: Vector3;
  22483. /**
  22484. * The identity quaternion of the imposter
  22485. */
  22486. static IDENTITY_QUATERNION: Quaternion;
  22487. /** @hidden */ private _pluginData: any;
  22488. private _physicsEngine;
  22489. private _physicsBody;
  22490. private _bodyUpdateRequired;
  22491. private _onBeforePhysicsStepCallbacks;
  22492. private _onAfterPhysicsStepCallbacks;
  22493. /** @hidden */ private _onPhysicsCollideCallbacks: Array<{
  22494. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  22495. otherImpostors: Array<PhysicsImpostor>;
  22496. }>;
  22497. private _deltaPosition;
  22498. private _deltaRotation;
  22499. private _deltaRotationConjugated;
  22500. /** @hidden */ private _isFromLine: boolean;
  22501. private _parent;
  22502. private _isDisposed;
  22503. private static _tmpVecs;
  22504. private static _tmpQuat;
  22505. /**
  22506. * Specifies if the physics imposter is disposed
  22507. */
  22508. readonly isDisposed: boolean;
  22509. /**
  22510. * Gets the mass of the physics imposter
  22511. */
  22512. mass: number;
  22513. /**
  22514. * Gets the coefficient of friction
  22515. */
  22516. /**
  22517. * Sets the coefficient of friction
  22518. */
  22519. friction: number;
  22520. /**
  22521. * Gets the coefficient of restitution
  22522. */
  22523. /**
  22524. * Sets the coefficient of restitution
  22525. */
  22526. restitution: number;
  22527. /**
  22528. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  22529. */
  22530. /**
  22531. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  22532. */
  22533. pressure: number;
  22534. /**
  22535. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22536. */
  22537. /**
  22538. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22539. */
  22540. stiffness: number;
  22541. /**
  22542. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22543. */
  22544. /**
  22545. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22546. */
  22547. velocityIterations: number;
  22548. /**
  22549. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22550. */
  22551. /**
  22552. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22553. */
  22554. positionIterations: number;
  22555. /**
  22556. * The unique id of the physics imposter
  22557. * set by the physics engine when adding this impostor to the array
  22558. */
  22559. uniqueId: number;
  22560. /**
  22561. * @hidden
  22562. */
  22563. soft: boolean;
  22564. /**
  22565. * @hidden
  22566. */
  22567. segments: number;
  22568. private _joints;
  22569. /**
  22570. * Initializes the physics imposter
  22571. * @param object The physics-enabled object used as the physics imposter
  22572. * @param type The type of the physics imposter
  22573. * @param _options The options for the physics imposter
  22574. * @param _scene The Babylon scene
  22575. */
  22576. constructor(
  22577. /**
  22578. * The physics-enabled object used as the physics imposter
  22579. */
  22580. object: IPhysicsEnabledObject,
  22581. /**
  22582. * The type of the physics imposter
  22583. */
  22584. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  22585. /**
  22586. * This function will completly initialize this impostor.
  22587. * It will create a new body - but only if this mesh has no parent.
  22588. * If it has, this impostor will not be used other than to define the impostor
  22589. * of the child mesh.
  22590. * @hidden
  22591. */ private _init(): void;
  22592. private _getPhysicsParent;
  22593. /**
  22594. * Should a new body be generated.
  22595. * @returns boolean specifying if body initialization is required
  22596. */
  22597. isBodyInitRequired(): boolean;
  22598. /**
  22599. * Sets the updated scaling
  22600. * @param updated Specifies if the scaling is updated
  22601. */
  22602. setScalingUpdated(): void;
  22603. /**
  22604. * Force a regeneration of this or the parent's impostor's body.
  22605. * Use under cautious - This will remove all joints already implemented.
  22606. */
  22607. forceUpdate(): void;
  22608. /**
  22609. * Gets the body that holds this impostor. Either its own, or its parent.
  22610. */
  22611. /**
  22612. * Set the physics body. Used mainly by the physics engine/plugin
  22613. */
  22614. physicsBody: any;
  22615. /**
  22616. * Get the parent of the physics imposter
  22617. * @returns Physics imposter or null
  22618. */
  22619. /**
  22620. * Sets the parent of the physics imposter
  22621. */
  22622. parent: Nullable<PhysicsImpostor>;
  22623. /**
  22624. * Resets the update flags
  22625. */
  22626. resetUpdateFlags(): void;
  22627. /**
  22628. * Gets the object extend size
  22629. * @returns the object extend size
  22630. */
  22631. getObjectExtendSize(): Vector3;
  22632. /**
  22633. * Gets the object center
  22634. * @returns The object center
  22635. */
  22636. getObjectCenter(): Vector3;
  22637. /**
  22638. * Get a specific parametes from the options parameter
  22639. * @param paramName The object parameter name
  22640. * @returns The object parameter
  22641. */
  22642. getParam(paramName: string): any;
  22643. /**
  22644. * Sets a specific parameter in the options given to the physics plugin
  22645. * @param paramName The parameter name
  22646. * @param value The value of the parameter
  22647. */
  22648. setParam(paramName: string, value: number): void;
  22649. /**
  22650. * Specifically change the body's mass option. Won't recreate the physics body object
  22651. * @param mass The mass of the physics imposter
  22652. */
  22653. setMass(mass: number): void;
  22654. /**
  22655. * Gets the linear velocity
  22656. * @returns linear velocity or null
  22657. */
  22658. getLinearVelocity(): Nullable<Vector3>;
  22659. /**
  22660. * Sets the linear velocity
  22661. * @param velocity linear velocity or null
  22662. */
  22663. setLinearVelocity(velocity: Nullable<Vector3>): void;
  22664. /**
  22665. * Gets the angular velocity
  22666. * @returns angular velocity or null
  22667. */
  22668. getAngularVelocity(): Nullable<Vector3>;
  22669. /**
  22670. * Sets the angular velocity
  22671. * @param velocity The velocity or null
  22672. */
  22673. setAngularVelocity(velocity: Nullable<Vector3>): void;
  22674. /**
  22675. * Execute a function with the physics plugin native code
  22676. * Provide a function the will have two variables - the world object and the physics body object
  22677. * @param func The function to execute with the physics plugin native code
  22678. */
  22679. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  22680. /**
  22681. * Register a function that will be executed before the physics world is stepping forward
  22682. * @param func The function to execute before the physics world is stepped forward
  22683. */
  22684. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22685. /**
  22686. * Unregister a function that will be executed before the physics world is stepping forward
  22687. * @param func The function to execute before the physics world is stepped forward
  22688. */
  22689. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22690. /**
  22691. * Register a function that will be executed after the physics step
  22692. * @param func The function to execute after physics step
  22693. */
  22694. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22695. /**
  22696. * Unregisters a function that will be executed after the physics step
  22697. * @param func The function to execute after physics step
  22698. */
  22699. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22700. /**
  22701. * register a function that will be executed when this impostor collides against a different body
  22702. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  22703. * @param func Callback that is executed on collision
  22704. */
  22705. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  22706. /**
  22707. * Unregisters the physics imposter on contact
  22708. * @param collideAgainst The physics object to collide against
  22709. * @param func Callback to execute on collision
  22710. */
  22711. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  22712. private _tmpQuat;
  22713. private _tmpQuat2;
  22714. /**
  22715. * Get the parent rotation
  22716. * @returns The parent rotation
  22717. */
  22718. getParentsRotation(): Quaternion;
  22719. /**
  22720. * this function is executed by the physics engine.
  22721. */
  22722. beforeStep: () => void;
  22723. /**
  22724. * this function is executed by the physics engine
  22725. */
  22726. afterStep: () => void;
  22727. /**
  22728. * Legacy collision detection event support
  22729. */
  22730. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  22731. /**
  22732. * event and body object due to cannon's event-based architecture.
  22733. */
  22734. onCollide: (e: {
  22735. body: any;
  22736. }) => void;
  22737. /**
  22738. * Apply a force
  22739. * @param force The force to apply
  22740. * @param contactPoint The contact point for the force
  22741. * @returns The physics imposter
  22742. */
  22743. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  22744. /**
  22745. * Apply an impulse
  22746. * @param force The impulse force
  22747. * @param contactPoint The contact point for the impulse force
  22748. * @returns The physics imposter
  22749. */
  22750. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  22751. /**
  22752. * A help function to create a joint
  22753. * @param otherImpostor A physics imposter used to create a joint
  22754. * @param jointType The type of joint
  22755. * @param jointData The data for the joint
  22756. * @returns The physics imposter
  22757. */
  22758. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  22759. /**
  22760. * Add a joint to this impostor with a different impostor
  22761. * @param otherImpostor A physics imposter used to add a joint
  22762. * @param joint The joint to add
  22763. * @returns The physics imposter
  22764. */
  22765. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  22766. /**
  22767. * Add an anchor to a cloth impostor
  22768. * @param otherImpostor rigid impostor to anchor to
  22769. * @param width ratio across width from 0 to 1
  22770. * @param height ratio up height from 0 to 1
  22771. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  22772. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  22773. * @returns impostor the soft imposter
  22774. */
  22775. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  22776. /**
  22777. * Add a hook to a rope impostor
  22778. * @param otherImpostor rigid impostor to anchor to
  22779. * @param length ratio across rope from 0 to 1
  22780. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  22781. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  22782. * @returns impostor the rope imposter
  22783. */
  22784. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  22785. /**
  22786. * Will keep this body still, in a sleep mode.
  22787. * @returns the physics imposter
  22788. */
  22789. sleep(): PhysicsImpostor;
  22790. /**
  22791. * Wake the body up.
  22792. * @returns The physics imposter
  22793. */
  22794. wakeUp(): PhysicsImpostor;
  22795. /**
  22796. * Clones the physics imposter
  22797. * @param newObject The physics imposter clones to this physics-enabled object
  22798. * @returns A nullable physics imposter
  22799. */
  22800. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22801. /**
  22802. * Disposes the physics imposter
  22803. */
  22804. dispose(): void;
  22805. /**
  22806. * Sets the delta position
  22807. * @param position The delta position amount
  22808. */
  22809. setDeltaPosition(position: Vector3): void;
  22810. /**
  22811. * Sets the delta rotation
  22812. * @param rotation The delta rotation amount
  22813. */
  22814. setDeltaRotation(rotation: Quaternion): void;
  22815. /**
  22816. * Gets the box size of the physics imposter and stores the result in the input parameter
  22817. * @param result Stores the box size
  22818. * @returns The physics imposter
  22819. */
  22820. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  22821. /**
  22822. * Gets the radius of the physics imposter
  22823. * @returns Radius of the physics imposter
  22824. */
  22825. getRadius(): number;
  22826. /**
  22827. * Sync a bone with this impostor
  22828. * @param bone The bone to sync to the impostor.
  22829. * @param boneMesh The mesh that the bone is influencing.
  22830. * @param jointPivot The pivot of the joint / bone in local space.
  22831. * @param distToJoint Optional distance from the impostor to the joint.
  22832. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  22833. */
  22834. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  22835. /**
  22836. * Sync impostor to a bone
  22837. * @param bone The bone that the impostor will be synced to.
  22838. * @param boneMesh The mesh that the bone is influencing.
  22839. * @param jointPivot The pivot of the joint / bone in local space.
  22840. * @param distToJoint Optional distance from the impostor to the joint.
  22841. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  22842. * @param boneAxis Optional vector3 axis the bone is aligned with
  22843. */
  22844. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  22845. /**
  22846. * No-Imposter type
  22847. */
  22848. static NoImpostor: number;
  22849. /**
  22850. * Sphere-Imposter type
  22851. */
  22852. static SphereImpostor: number;
  22853. /**
  22854. * Box-Imposter type
  22855. */
  22856. static BoxImpostor: number;
  22857. /**
  22858. * Plane-Imposter type
  22859. */
  22860. static PlaneImpostor: number;
  22861. /**
  22862. * Mesh-imposter type
  22863. */
  22864. static MeshImpostor: number;
  22865. /**
  22866. * Capsule-Impostor type (Ammo.js plugin only)
  22867. */
  22868. static CapsuleImpostor: number;
  22869. /**
  22870. * Cylinder-Imposter type
  22871. */
  22872. static CylinderImpostor: number;
  22873. /**
  22874. * Particle-Imposter type
  22875. */
  22876. static ParticleImpostor: number;
  22877. /**
  22878. * Heightmap-Imposter type
  22879. */
  22880. static HeightmapImpostor: number;
  22881. /**
  22882. * ConvexHull-Impostor type (Ammo.js plugin only)
  22883. */
  22884. static ConvexHullImpostor: number;
  22885. /**
  22886. * Rope-Imposter type
  22887. */
  22888. static RopeImpostor: number;
  22889. /**
  22890. * Cloth-Imposter type
  22891. */
  22892. static ClothImpostor: number;
  22893. /**
  22894. * Softbody-Imposter type
  22895. */
  22896. static SoftbodyImpostor: number;
  22897. }
  22898. }
  22899. declare module BABYLON {
  22900. /**
  22901. * @hidden
  22902. **/
  22903. export class _CreationDataStorage {
  22904. closePath?: boolean;
  22905. closeArray?: boolean;
  22906. idx: number[];
  22907. dashSize: number;
  22908. gapSize: number;
  22909. path3D: Path3D;
  22910. pathArray: Vector3[][];
  22911. arc: number;
  22912. radius: number;
  22913. cap: number;
  22914. tessellation: number;
  22915. }
  22916. /**
  22917. * @hidden
  22918. **/ private class _InstanceDataStorage {
  22919. visibleInstances: any;
  22920. batchCache: _InstancesBatch;
  22921. instancesBufferSize: number;
  22922. instancesBuffer: Nullable<Buffer>;
  22923. instancesData: Float32Array;
  22924. overridenInstanceCount: number;
  22925. isFrozen: boolean;
  22926. previousBatch: Nullable<_InstancesBatch>;
  22927. hardwareInstancedRendering: boolean;
  22928. sideOrientation: number;
  22929. }
  22930. /**
  22931. * @hidden
  22932. **/
  22933. export class _InstancesBatch {
  22934. mustReturn: boolean;
  22935. visibleInstances: Nullable<InstancedMesh[]>[];
  22936. renderSelf: boolean[];
  22937. hardwareInstancedRendering: boolean[];
  22938. }
  22939. /**
  22940. * Class used to represent renderable models
  22941. */
  22942. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  22943. /**
  22944. * Mesh side orientation : usually the external or front surface
  22945. */
  22946. static readonly FRONTSIDE: number;
  22947. /**
  22948. * Mesh side orientation : usually the internal or back surface
  22949. */
  22950. static readonly BACKSIDE: number;
  22951. /**
  22952. * Mesh side orientation : both internal and external or front and back surfaces
  22953. */
  22954. static readonly DOUBLESIDE: number;
  22955. /**
  22956. * Mesh side orientation : by default, `FRONTSIDE`
  22957. */
  22958. static readonly DEFAULTSIDE: number;
  22959. /**
  22960. * Mesh cap setting : no cap
  22961. */
  22962. static readonly NO_CAP: number;
  22963. /**
  22964. * Mesh cap setting : one cap at the beginning of the mesh
  22965. */
  22966. static readonly CAP_START: number;
  22967. /**
  22968. * Mesh cap setting : one cap at the end of the mesh
  22969. */
  22970. static readonly CAP_END: number;
  22971. /**
  22972. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  22973. */
  22974. static readonly CAP_ALL: number;
  22975. /**
  22976. * Mesh pattern setting : no flip or rotate
  22977. */
  22978. static readonly NO_FLIP: number;
  22979. /**
  22980. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  22981. */
  22982. static readonly FLIP_TILE: number;
  22983. /**
  22984. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  22985. */
  22986. static readonly ROTATE_TILE: number;
  22987. /**
  22988. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  22989. */
  22990. static readonly FLIP_ROW: number;
  22991. /**
  22992. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  22993. */
  22994. static readonly ROTATE_ROW: number;
  22995. /**
  22996. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  22997. */
  22998. static readonly FLIP_N_ROTATE_TILE: number;
  22999. /**
  23000. * Mesh pattern setting : rotate pattern and rotate
  23001. */
  23002. static readonly FLIP_N_ROTATE_ROW: number;
  23003. /**
  23004. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23005. */
  23006. static readonly CENTER: number;
  23007. /**
  23008. * Mesh tile positioning : part tiles on left
  23009. */
  23010. static readonly LEFT: number;
  23011. /**
  23012. * Mesh tile positioning : part tiles on right
  23013. */
  23014. static readonly RIGHT: number;
  23015. /**
  23016. * Mesh tile positioning : part tiles on top
  23017. */
  23018. static readonly TOP: number;
  23019. /**
  23020. * Mesh tile positioning : part tiles on bottom
  23021. */
  23022. static readonly BOTTOM: number;
  23023. /**
  23024. * Gets the default side orientation.
  23025. * @param orientation the orientation to value to attempt to get
  23026. * @returns the default orientation
  23027. * @hidden
  23028. */ private static _GetDefaultSideOrientation(orientation?: number): number;
  23029. private _internalMeshDataInfo;
  23030. /**
  23031. * An event triggered before rendering the mesh
  23032. */
  23033. readonly onBeforeRenderObservable: Observable<Mesh>;
  23034. /**
  23035. * An event triggered before binding the mesh
  23036. */
  23037. readonly onBeforeBindObservable: Observable<Mesh>;
  23038. /**
  23039. * An event triggered after rendering the mesh
  23040. */
  23041. readonly onAfterRenderObservable: Observable<Mesh>;
  23042. /**
  23043. * An event triggered before drawing the mesh
  23044. */
  23045. readonly onBeforeDrawObservable: Observable<Mesh>;
  23046. private _onBeforeDrawObserver;
  23047. /**
  23048. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23049. */
  23050. onBeforeDraw: () => void;
  23051. readonly hasInstances: boolean;
  23052. /**
  23053. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23054. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23055. */
  23056. delayLoadState: number;
  23057. /**
  23058. * Gets the list of instances created from this mesh
  23059. * it is not supposed to be modified manually.
  23060. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23061. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23062. */
  23063. instances: InstancedMesh[];
  23064. /**
  23065. * Gets the file containing delay loading data for this mesh
  23066. */
  23067. delayLoadingFile: string;
  23068. /** @hidden */ private _binaryInfo: any;
  23069. /**
  23070. * User defined function used to change how LOD level selection is done
  23071. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23072. */
  23073. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23074. /**
  23075. * Gets or sets the morph target manager
  23076. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23077. */
  23078. morphTargetManager: Nullable<MorphTargetManager>;
  23079. /** @hidden */ private _creationDataStorage: Nullable<_CreationDataStorage>;
  23080. /** @hidden */ private _geometry: Nullable<Geometry>;
  23081. /** @hidden */ private _delayInfo: Array<string>;
  23082. /** @hidden */ private _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23083. /** @hidden */ private _instanceDataStorage: _InstanceDataStorage;
  23084. private _effectiveMaterial;
  23085. /** @hidden */ private _shouldGenerateFlatShading: boolean;
  23086. /** @hidden */ private _originalBuilderSideOrientation: number;
  23087. /**
  23088. * Use this property to change the original side orientation defined at construction time
  23089. */
  23090. overrideMaterialSideOrientation: Nullable<number>;
  23091. /**
  23092. * Gets the source mesh (the one used to clone this one from)
  23093. */
  23094. readonly source: Nullable<Mesh>;
  23095. /**
  23096. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23097. */
  23098. isUnIndexed: boolean;
  23099. /**
  23100. * @constructor
  23101. * @param name The value used by scene.getMeshByName() to do a lookup.
  23102. * @param scene The scene to add this mesh to.
  23103. * @param parent The parent of this mesh, if it has one
  23104. * @param source An optional Mesh from which geometry is shared, cloned.
  23105. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23106. * When false, achieved by calling a clone(), also passing False.
  23107. * This will make creation of children, recursive.
  23108. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23109. */
  23110. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23111. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  23112. /**
  23113. * Gets the class name
  23114. * @returns the string "Mesh".
  23115. */
  23116. getClassName(): string;
  23117. /** @hidden */ protected readonly _isMesh: boolean;
  23118. /**
  23119. * Returns a description of this mesh
  23120. * @param fullDetails define if full details about this mesh must be used
  23121. * @returns a descriptive string representing this mesh
  23122. */
  23123. toString(fullDetails?: boolean): string;
  23124. /** @hidden */ private _unBindEffect(): void;
  23125. /**
  23126. * Gets a boolean indicating if this mesh has LOD
  23127. */
  23128. readonly hasLODLevels: boolean;
  23129. /**
  23130. * Gets the list of MeshLODLevel associated with the current mesh
  23131. * @returns an array of MeshLODLevel
  23132. */
  23133. getLODLevels(): MeshLODLevel[];
  23134. private _sortLODLevels;
  23135. /**
  23136. * Add a mesh as LOD level triggered at the given distance.
  23137. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23138. * @param distance The distance from the center of the object to show this level
  23139. * @param mesh The mesh to be added as LOD level (can be null)
  23140. * @return This mesh (for chaining)
  23141. */
  23142. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23143. /**
  23144. * Returns the LOD level mesh at the passed distance or null if not found.
  23145. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23146. * @param distance The distance from the center of the object to show this level
  23147. * @returns a Mesh or `null`
  23148. */
  23149. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23150. /**
  23151. * Remove a mesh from the LOD array
  23152. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23153. * @param mesh defines the mesh to be removed
  23154. * @return This mesh (for chaining)
  23155. */
  23156. removeLODLevel(mesh: Mesh): Mesh;
  23157. /**
  23158. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23159. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23160. * @param camera defines the camera to use to compute distance
  23161. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23162. * @return This mesh (for chaining)
  23163. */
  23164. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23165. /**
  23166. * Gets the mesh internal Geometry object
  23167. */
  23168. readonly geometry: Nullable<Geometry>;
  23169. /**
  23170. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23171. * @returns the total number of vertices
  23172. */
  23173. getTotalVertices(): number;
  23174. /**
  23175. * Returns the content of an associated vertex buffer
  23176. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23177. * - VertexBuffer.PositionKind
  23178. * - VertexBuffer.UVKind
  23179. * - VertexBuffer.UV2Kind
  23180. * - VertexBuffer.UV3Kind
  23181. * - VertexBuffer.UV4Kind
  23182. * - VertexBuffer.UV5Kind
  23183. * - VertexBuffer.UV6Kind
  23184. * - VertexBuffer.ColorKind
  23185. * - VertexBuffer.MatricesIndicesKind
  23186. * - VertexBuffer.MatricesIndicesExtraKind
  23187. * - VertexBuffer.MatricesWeightsKind
  23188. * - VertexBuffer.MatricesWeightsExtraKind
  23189. * @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
  23190. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23191. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23192. */
  23193. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23194. /**
  23195. * Returns the mesh VertexBuffer object from the requested `kind`
  23196. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23197. * - VertexBuffer.PositionKind
  23198. * - VertexBuffer.NormalKind
  23199. * - VertexBuffer.UVKind
  23200. * - VertexBuffer.UV2Kind
  23201. * - VertexBuffer.UV3Kind
  23202. * - VertexBuffer.UV4Kind
  23203. * - VertexBuffer.UV5Kind
  23204. * - VertexBuffer.UV6Kind
  23205. * - VertexBuffer.ColorKind
  23206. * - VertexBuffer.MatricesIndicesKind
  23207. * - VertexBuffer.MatricesIndicesExtraKind
  23208. * - VertexBuffer.MatricesWeightsKind
  23209. * - VertexBuffer.MatricesWeightsExtraKind
  23210. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23211. */
  23212. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23213. /**
  23214. * Tests if a specific vertex buffer is associated with this mesh
  23215. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23216. * - VertexBuffer.PositionKind
  23217. * - VertexBuffer.NormalKind
  23218. * - VertexBuffer.UVKind
  23219. * - VertexBuffer.UV2Kind
  23220. * - VertexBuffer.UV3Kind
  23221. * - VertexBuffer.UV4Kind
  23222. * - VertexBuffer.UV5Kind
  23223. * - VertexBuffer.UV6Kind
  23224. * - VertexBuffer.ColorKind
  23225. * - VertexBuffer.MatricesIndicesKind
  23226. * - VertexBuffer.MatricesIndicesExtraKind
  23227. * - VertexBuffer.MatricesWeightsKind
  23228. * - VertexBuffer.MatricesWeightsExtraKind
  23229. * @returns a boolean
  23230. */
  23231. isVerticesDataPresent(kind: string): boolean;
  23232. /**
  23233. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23234. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23235. * - VertexBuffer.PositionKind
  23236. * - VertexBuffer.UVKind
  23237. * - VertexBuffer.UV2Kind
  23238. * - VertexBuffer.UV3Kind
  23239. * - VertexBuffer.UV4Kind
  23240. * - VertexBuffer.UV5Kind
  23241. * - VertexBuffer.UV6Kind
  23242. * - VertexBuffer.ColorKind
  23243. * - VertexBuffer.MatricesIndicesKind
  23244. * - VertexBuffer.MatricesIndicesExtraKind
  23245. * - VertexBuffer.MatricesWeightsKind
  23246. * - VertexBuffer.MatricesWeightsExtraKind
  23247. * @returns a boolean
  23248. */
  23249. isVertexBufferUpdatable(kind: string): boolean;
  23250. /**
  23251. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23252. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23253. * - VertexBuffer.PositionKind
  23254. * - VertexBuffer.NormalKind
  23255. * - VertexBuffer.UVKind
  23256. * - VertexBuffer.UV2Kind
  23257. * - VertexBuffer.UV3Kind
  23258. * - VertexBuffer.UV4Kind
  23259. * - VertexBuffer.UV5Kind
  23260. * - VertexBuffer.UV6Kind
  23261. * - VertexBuffer.ColorKind
  23262. * - VertexBuffer.MatricesIndicesKind
  23263. * - VertexBuffer.MatricesIndicesExtraKind
  23264. * - VertexBuffer.MatricesWeightsKind
  23265. * - VertexBuffer.MatricesWeightsExtraKind
  23266. * @returns an array of strings
  23267. */
  23268. getVerticesDataKinds(): string[];
  23269. /**
  23270. * Returns a positive integer : the total number of indices in this mesh geometry.
  23271. * @returns the numner of indices or zero if the mesh has no geometry.
  23272. */
  23273. getTotalIndices(): number;
  23274. /**
  23275. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23276. * @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.
  23277. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23278. * @returns the indices array or an empty array if the mesh has no geometry
  23279. */
  23280. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23281. readonly isBlocked: boolean;
  23282. /**
  23283. * Determine if the current mesh is ready to be rendered
  23284. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23285. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23286. * @returns true if all associated assets are ready (material, textures, shaders)
  23287. */
  23288. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23289. /**
  23290. * 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.
  23291. */
  23292. readonly areNormalsFrozen: boolean;
  23293. /**
  23294. * 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.
  23295. * @returns the current mesh
  23296. */
  23297. freezeNormals(): Mesh;
  23298. /**
  23299. * 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
  23300. * @returns the current mesh
  23301. */
  23302. unfreezeNormals(): Mesh;
  23303. /**
  23304. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23305. */
  23306. overridenInstanceCount: number;
  23307. /** @hidden */ private _preActivate(): Mesh;
  23308. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): Mesh;
  23309. /** @hidden */ private _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23310. /**
  23311. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23312. * This means the mesh underlying bounding box and sphere are recomputed.
  23313. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23314. * @returns the current mesh
  23315. */
  23316. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23317. /** @hidden */ private _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23318. /**
  23319. * This function will subdivide the mesh into multiple submeshes
  23320. * @param count defines the expected number of submeshes
  23321. */
  23322. subdivide(count: number): void;
  23323. /**
  23324. * Copy a FloatArray into a specific associated vertex buffer
  23325. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23326. * - VertexBuffer.PositionKind
  23327. * - VertexBuffer.UVKind
  23328. * - VertexBuffer.UV2Kind
  23329. * - VertexBuffer.UV3Kind
  23330. * - VertexBuffer.UV4Kind
  23331. * - VertexBuffer.UV5Kind
  23332. * - VertexBuffer.UV6Kind
  23333. * - VertexBuffer.ColorKind
  23334. * - VertexBuffer.MatricesIndicesKind
  23335. * - VertexBuffer.MatricesIndicesExtraKind
  23336. * - VertexBuffer.MatricesWeightsKind
  23337. * - VertexBuffer.MatricesWeightsExtraKind
  23338. * @param data defines the data source
  23339. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23340. * @param stride defines the data stride size (can be null)
  23341. * @returns the current mesh
  23342. */
  23343. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23344. /**
  23345. * Flags an associated vertex buffer as updatable
  23346. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23347. * - VertexBuffer.PositionKind
  23348. * - VertexBuffer.UVKind
  23349. * - VertexBuffer.UV2Kind
  23350. * - VertexBuffer.UV3Kind
  23351. * - VertexBuffer.UV4Kind
  23352. * - VertexBuffer.UV5Kind
  23353. * - VertexBuffer.UV6Kind
  23354. * - VertexBuffer.ColorKind
  23355. * - VertexBuffer.MatricesIndicesKind
  23356. * - VertexBuffer.MatricesIndicesExtraKind
  23357. * - VertexBuffer.MatricesWeightsKind
  23358. * - VertexBuffer.MatricesWeightsExtraKind
  23359. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23360. */
  23361. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23362. /**
  23363. * Sets the mesh global Vertex Buffer
  23364. * @param buffer defines the buffer to use
  23365. * @returns the current mesh
  23366. */
  23367. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23368. /**
  23369. * Update a specific associated vertex buffer
  23370. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23371. * - VertexBuffer.PositionKind
  23372. * - VertexBuffer.UVKind
  23373. * - VertexBuffer.UV2Kind
  23374. * - VertexBuffer.UV3Kind
  23375. * - VertexBuffer.UV4Kind
  23376. * - VertexBuffer.UV5Kind
  23377. * - VertexBuffer.UV6Kind
  23378. * - VertexBuffer.ColorKind
  23379. * - VertexBuffer.MatricesIndicesKind
  23380. * - VertexBuffer.MatricesIndicesExtraKind
  23381. * - VertexBuffer.MatricesWeightsKind
  23382. * - VertexBuffer.MatricesWeightsExtraKind
  23383. * @param data defines the data source
  23384. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23385. * @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)
  23386. * @returns the current mesh
  23387. */
  23388. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23389. /**
  23390. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23391. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23392. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23393. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23394. * @returns the current mesh
  23395. */
  23396. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23397. /**
  23398. * Creates a un-shared specific occurence of the geometry for the mesh.
  23399. * @returns the current mesh
  23400. */
  23401. makeGeometryUnique(): Mesh;
  23402. /**
  23403. * Set the index buffer of this mesh
  23404. * @param indices defines the source data
  23405. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23406. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23407. * @returns the current mesh
  23408. */
  23409. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  23410. /**
  23411. * Update the current index buffer
  23412. * @param indices defines the source data
  23413. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  23414. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  23415. * @returns the current mesh
  23416. */
  23417. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  23418. /**
  23419. * Invert the geometry to move from a right handed system to a left handed one.
  23420. * @returns the current mesh
  23421. */
  23422. toLeftHanded(): Mesh;
  23423. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  23424. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  23425. /**
  23426. * Registers for this mesh a javascript function called just before the rendering process
  23427. * @param func defines the function to call before rendering this mesh
  23428. * @returns the current mesh
  23429. */
  23430. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23431. /**
  23432. * Disposes a previously registered javascript function called before the rendering
  23433. * @param func defines the function to remove
  23434. * @returns the current mesh
  23435. */
  23436. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23437. /**
  23438. * Registers for this mesh a javascript function called just after the rendering is complete
  23439. * @param func defines the function to call after rendering this mesh
  23440. * @returns the current mesh
  23441. */
  23442. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23443. /**
  23444. * Disposes a previously registered javascript function called after the rendering.
  23445. * @param func defines the function to remove
  23446. * @returns the current mesh
  23447. */
  23448. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23449. /** @hidden */ private _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  23450. /** @hidden */ private _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  23451. /** @hidden */ private _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  23452. /** @hidden */ private _rebuild(): void;
  23453. /** @hidden */ private _freeze(): void;
  23454. /** @hidden */ private _unFreeze(): void;
  23455. /**
  23456. * 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
  23457. * @param subMesh defines the subMesh to render
  23458. * @param enableAlphaMode defines if alpha mode can be changed
  23459. * @returns the current mesh
  23460. */
  23461. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  23462. private _onBeforeDraw;
  23463. /**
  23464. * Renormalize the mesh and patch it up if there are no weights
  23465. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  23466. * However in the case of zero weights then we set just a single influence to 1.
  23467. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  23468. */
  23469. cleanMatrixWeights(): void;
  23470. private normalizeSkinFourWeights;
  23471. private normalizeSkinWeightsAndExtra;
  23472. /**
  23473. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  23474. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  23475. * the user know there was an issue with importing the mesh
  23476. * @returns a validation object with skinned, valid and report string
  23477. */
  23478. validateSkinning(): {
  23479. skinned: boolean;
  23480. valid: boolean;
  23481. report: string;
  23482. };
  23483. /** @hidden */ private _checkDelayState(): Mesh;
  23484. private _queueLoad;
  23485. /**
  23486. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23487. * A mesh is in the frustum if its bounding box intersects the frustum
  23488. * @param frustumPlanes defines the frustum to test
  23489. * @returns true if the mesh is in the frustum planes
  23490. */
  23491. isInFrustum(frustumPlanes: Plane[]): boolean;
  23492. /**
  23493. * Sets the mesh material by the material or multiMaterial `id` property
  23494. * @param id is a string identifying the material or the multiMaterial
  23495. * @returns the current mesh
  23496. */
  23497. setMaterialByID(id: string): Mesh;
  23498. /**
  23499. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  23500. * @returns an array of IAnimatable
  23501. */
  23502. getAnimatables(): IAnimatable[];
  23503. /**
  23504. * Modifies the mesh geometry according to the passed transformation matrix.
  23505. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  23506. * The mesh normals are modified using the same transformation.
  23507. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23508. * @param transform defines the transform matrix to use
  23509. * @see http://doc.babylonjs.com/resources/baking_transformations
  23510. * @returns the current mesh
  23511. */
  23512. bakeTransformIntoVertices(transform: Matrix): Mesh;
  23513. /**
  23514. * Modifies the mesh geometry according to its own current World Matrix.
  23515. * The mesh World Matrix is then reset.
  23516. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  23517. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23518. * @see http://doc.babylonjs.com/resources/baking_transformations
  23519. * @returns the current mesh
  23520. */
  23521. bakeCurrentTransformIntoVertices(): Mesh;
  23522. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  23523. /** @hidden */ private _resetPointsArrayCache(): Mesh;
  23524. /** @hidden */ private _generatePointsArray(): boolean;
  23525. /**
  23526. * Returns a new Mesh object generated from the current mesh properties.
  23527. * This method must not get confused with createInstance()
  23528. * @param name is a string, the name given to the new mesh
  23529. * @param newParent can be any Node object (default `null`)
  23530. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  23531. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  23532. * @returns a new mesh
  23533. */
  23534. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  23535. /**
  23536. * Releases resources associated with this mesh.
  23537. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23538. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23539. */
  23540. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23541. /**
  23542. * Modifies the mesh geometry according to a displacement map.
  23543. * 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.
  23544. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23545. * @param url is a string, the URL from the image file is to be downloaded.
  23546. * @param minHeight is the lower limit of the displacement.
  23547. * @param maxHeight is the upper limit of the displacement.
  23548. * @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.
  23549. * @param uvOffset is an optional vector2 used to offset UV.
  23550. * @param uvScale is an optional vector2 used to scale UV.
  23551. * @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.
  23552. * @returns the Mesh.
  23553. */
  23554. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23555. /**
  23556. * Modifies the mesh geometry according to a displacementMap buffer.
  23557. * 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.
  23558. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23559. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  23560. * @param heightMapWidth is the width of the buffer image.
  23561. * @param heightMapHeight is the height of the buffer image.
  23562. * @param minHeight is the lower limit of the displacement.
  23563. * @param maxHeight is the upper limit of the displacement.
  23564. * @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.
  23565. * @param uvOffset is an optional vector2 used to offset UV.
  23566. * @param uvScale is an optional vector2 used to scale UV.
  23567. * @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.
  23568. * @returns the Mesh.
  23569. */
  23570. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23571. /**
  23572. * Modify the mesh to get a flat shading rendering.
  23573. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  23574. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  23575. * @returns current mesh
  23576. */
  23577. convertToFlatShadedMesh(): Mesh;
  23578. /**
  23579. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  23580. * In other words, more vertices, no more indices and a single bigger VBO.
  23581. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  23582. * @returns current mesh
  23583. */
  23584. convertToUnIndexedMesh(): Mesh;
  23585. /**
  23586. * Inverses facet orientations.
  23587. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23588. * @param flipNormals will also inverts the normals
  23589. * @returns current mesh
  23590. */
  23591. flipFaces(flipNormals?: boolean): Mesh;
  23592. /**
  23593. * Increase the number of facets and hence vertices in a mesh
  23594. * Vertex normals are interpolated from existing vertex normals
  23595. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23596. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  23597. */
  23598. increaseVertices(numberPerEdge: number): void;
  23599. /**
  23600. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  23601. * This will undo any application of covertToFlatShadedMesh
  23602. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23603. */
  23604. forceSharedVertices(): void;
  23605. /** @hidden */ private static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  23606. /** @hidden */ private static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  23607. /**
  23608. * Creates a new InstancedMesh object from the mesh model.
  23609. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23610. * @param name defines the name of the new instance
  23611. * @returns a new InstancedMesh
  23612. */
  23613. createInstance(name: string): InstancedMesh;
  23614. /**
  23615. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  23616. * After this call, all the mesh instances have the same submeshes than the current mesh.
  23617. * @returns the current mesh
  23618. */
  23619. synchronizeInstances(): Mesh;
  23620. /**
  23621. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  23622. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  23623. * This should be used together with the simplification to avoid disappearing triangles.
  23624. * @param successCallback an optional success callback to be called after the optimization finished.
  23625. * @returns the current mesh
  23626. */
  23627. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  23628. /**
  23629. * Serialize current mesh
  23630. * @param serializationObject defines the object which will receive the serialization data
  23631. */
  23632. serialize(serializationObject: any): void;
  23633. /** @hidden */ private _syncGeometryWithMorphTargetManager(): void;
  23634. /** @hidden */ private static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  23635. /**
  23636. * Returns a new Mesh object parsed from the source provided.
  23637. * @param parsedMesh is the source
  23638. * @param scene defines the hosting scene
  23639. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  23640. * @returns a new Mesh
  23641. */
  23642. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  23643. /**
  23644. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  23645. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  23646. * @param name defines the name of the mesh to create
  23647. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  23648. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  23649. * @param closePath creates a seam between the first and the last points of each path of the path array
  23650. * @param offset is taken in account only if the `pathArray` is containing a single path
  23651. * @param scene defines the hosting scene
  23652. * @param updatable defines if the mesh must be flagged as updatable
  23653. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23654. * @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)
  23655. * @returns a new Mesh
  23656. */
  23657. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  23658. /**
  23659. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  23660. * @param name defines the name of the mesh to create
  23661. * @param radius sets the radius size (float) of the polygon (default 0.5)
  23662. * @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
  23663. * @param scene defines the hosting scene
  23664. * @param updatable defines if the mesh must be flagged as updatable
  23665. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23666. * @returns a new Mesh
  23667. */
  23668. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  23669. /**
  23670. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  23671. * @param name defines the name of the mesh to create
  23672. * @param size sets the size (float) of each box side (default 1)
  23673. * @param scene defines the hosting scene
  23674. * @param updatable defines if the mesh must be flagged as updatable
  23675. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23676. * @returns a new Mesh
  23677. */
  23678. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  23679. /**
  23680. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  23681. * @param name defines the name of the mesh to create
  23682. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  23683. * @param diameter sets the diameter size (float) of the sphere (default 1)
  23684. * @param scene defines the hosting scene
  23685. * @param updatable defines if the mesh must be flagged as updatable
  23686. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23687. * @returns a new Mesh
  23688. */
  23689. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23690. /**
  23691. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  23692. * @param name defines the name of the mesh to create
  23693. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  23694. * @param diameter sets the diameter size (float) of the sphere (default 1)
  23695. * @param scene defines the hosting scene
  23696. * @returns a new Mesh
  23697. */
  23698. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  23699. /**
  23700. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  23701. * @param name defines the name of the mesh to create
  23702. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  23703. * @param diameterTop set the top cap diameter (floats, default 1)
  23704. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  23705. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  23706. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  23707. * @param scene defines the hosting scene
  23708. * @param updatable defines if the mesh must be flagged as updatable
  23709. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23710. * @returns a new Mesh
  23711. */
  23712. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  23713. /**
  23714. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  23715. * @param name defines the name of the mesh to create
  23716. * @param diameter sets the diameter size (float) of the torus (default 1)
  23717. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  23718. * @param tessellation sets the number of torus sides (postive integer, default 16)
  23719. * @param scene defines the hosting scene
  23720. * @param updatable defines if the mesh must be flagged as updatable
  23721. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23722. * @returns a new Mesh
  23723. */
  23724. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23725. /**
  23726. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  23727. * @param name defines the name of the mesh to create
  23728. * @param radius sets the global radius size (float) of the torus knot (default 2)
  23729. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  23730. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  23731. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  23732. * @param p the number of windings on X axis (positive integers, default 2)
  23733. * @param q the number of windings on Y axis (positive integers, default 3)
  23734. * @param scene defines the hosting scene
  23735. * @param updatable defines if the mesh must be flagged as updatable
  23736. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23737. * @returns a new Mesh
  23738. */
  23739. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23740. /**
  23741. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  23742. * @param name defines the name of the mesh to create
  23743. * @param points is an array successive Vector3
  23744. * @param scene defines the hosting scene
  23745. * @param updatable defines if the mesh must be flagged as updatable
  23746. * @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).
  23747. * @returns a new Mesh
  23748. */
  23749. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  23750. /**
  23751. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  23752. * @param name defines the name of the mesh to create
  23753. * @param points is an array successive Vector3
  23754. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  23755. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  23756. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  23757. * @param scene defines the hosting scene
  23758. * @param updatable defines if the mesh must be flagged as updatable
  23759. * @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)
  23760. * @returns a new Mesh
  23761. */
  23762. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  23763. /**
  23764. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  23765. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  23766. * 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.
  23767. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23768. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23769. * Remember you can only change the shape positions, not their number when updating a polygon.
  23770. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  23771. * @param name defines the name of the mesh to create
  23772. * @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
  23773. * @param scene defines the hosting scene
  23774. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  23775. * @param updatable defines if the mesh must be flagged as updatable
  23776. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23777. * @param earcutInjection can be used to inject your own earcut reference
  23778. * @returns a new Mesh
  23779. */
  23780. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  23781. /**
  23782. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  23783. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  23784. * @param name defines the name of the mesh to create
  23785. * @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
  23786. * @param depth defines the height of extrusion
  23787. * @param scene defines the hosting scene
  23788. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  23789. * @param updatable defines if the mesh must be flagged as updatable
  23790. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23791. * @param earcutInjection can be used to inject your own earcut reference
  23792. * @returns a new Mesh
  23793. */
  23794. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  23795. /**
  23796. * Creates an extruded shape mesh.
  23797. * 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
  23798. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  23799. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23800. * @param name defines the name of the mesh to create
  23801. * @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
  23802. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  23803. * @param scale is the value to scale the shape
  23804. * @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
  23805. * @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
  23806. * @param scene defines the hosting scene
  23807. * @param updatable defines if the mesh must be flagged as updatable
  23808. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23809. * @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)
  23810. * @returns a new Mesh
  23811. */
  23812. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  23813. /**
  23814. * Creates an custom extruded shape mesh.
  23815. * The custom extrusion is a parametric shape.
  23816. * It has no predefined shape. Its final shape will depend on the input parameters.
  23817. * Please consider using the same method from the MeshBuilder class instead
  23818. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23819. * @param name defines the name of the mesh to create
  23820. * @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
  23821. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  23822. * @param scaleFunction is a custom Javascript function called on each path point
  23823. * @param rotationFunction is a custom Javascript function called on each path point
  23824. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  23825. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  23826. * @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
  23827. * @param scene defines the hosting scene
  23828. * @param updatable defines if the mesh must be flagged as updatable
  23829. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23830. * @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)
  23831. * @returns a new Mesh
  23832. */
  23833. 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;
  23834. /**
  23835. * Creates lathe mesh.
  23836. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  23837. * Please consider using the same method from the MeshBuilder class instead
  23838. * @param name defines the name of the mesh to create
  23839. * @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
  23840. * @param radius is the radius value of the lathe
  23841. * @param tessellation is the side number of the lathe.
  23842. * @param scene defines the hosting scene
  23843. * @param updatable defines if the mesh must be flagged as updatable
  23844. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23845. * @returns a new Mesh
  23846. */
  23847. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23848. /**
  23849. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  23850. * @param name defines the name of the mesh to create
  23851. * @param size sets the size (float) of both sides of the plane at once (default 1)
  23852. * @param scene defines the hosting scene
  23853. * @param updatable defines if the mesh must be flagged as updatable
  23854. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23855. * @returns a new Mesh
  23856. */
  23857. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23858. /**
  23859. * Creates a ground mesh.
  23860. * Please consider using the same method from the MeshBuilder class instead
  23861. * @param name defines the name of the mesh to create
  23862. * @param width set the width of the ground
  23863. * @param height set the height of the ground
  23864. * @param subdivisions sets the number of subdivisions per side
  23865. * @param scene defines the hosting scene
  23866. * @param updatable defines if the mesh must be flagged as updatable
  23867. * @returns a new Mesh
  23868. */
  23869. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  23870. /**
  23871. * Creates a tiled ground mesh.
  23872. * Please consider using the same method from the MeshBuilder class instead
  23873. * @param name defines the name of the mesh to create
  23874. * @param xmin set the ground minimum X coordinate
  23875. * @param zmin set the ground minimum Y coordinate
  23876. * @param xmax set the ground maximum X coordinate
  23877. * @param zmax set the ground maximum Z coordinate
  23878. * @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
  23879. * @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
  23880. * @param scene defines the hosting scene
  23881. * @param updatable defines if the mesh must be flagged as updatable
  23882. * @returns a new Mesh
  23883. */
  23884. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  23885. w: number;
  23886. h: number;
  23887. }, precision: {
  23888. w: number;
  23889. h: number;
  23890. }, scene: Scene, updatable?: boolean): Mesh;
  23891. /**
  23892. * Creates a ground mesh from a height map.
  23893. * Please consider using the same method from the MeshBuilder class instead
  23894. * @see http://doc.babylonjs.com/babylon101/height_map
  23895. * @param name defines the name of the mesh to create
  23896. * @param url sets the URL of the height map image resource
  23897. * @param width set the ground width size
  23898. * @param height set the ground height size
  23899. * @param subdivisions sets the number of subdivision per side
  23900. * @param minHeight is the minimum altitude on the ground
  23901. * @param maxHeight is the maximum altitude on the ground
  23902. * @param scene defines the hosting scene
  23903. * @param updatable defines if the mesh must be flagged as updatable
  23904. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  23905. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  23906. * @returns a new Mesh
  23907. */
  23908. 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;
  23909. /**
  23910. * Creates a tube mesh.
  23911. * The tube is a parametric shape.
  23912. * It has no predefined shape. Its final shape will depend on the input parameters.
  23913. * Please consider using the same method from the MeshBuilder class instead
  23914. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  23915. * @param name defines the name of the mesh to create
  23916. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  23917. * @param radius sets the tube radius size
  23918. * @param tessellation is the number of sides on the tubular surface
  23919. * @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
  23920. * @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
  23921. * @param scene defines the hosting scene
  23922. * @param updatable defines if the mesh must be flagged as updatable
  23923. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23924. * @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)
  23925. * @returns a new Mesh
  23926. */
  23927. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  23928. (i: number, distance: number): number;
  23929. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  23930. /**
  23931. * Creates a polyhedron mesh.
  23932. * Please consider using the same method from the MeshBuilder class instead.
  23933. * * 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
  23934. * * The parameter `size` (positive float, default 1) sets the polygon size
  23935. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  23936. * * 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`
  23937. * * 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
  23938. * * 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)`)
  23939. * * 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
  23940. * * 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
  23941. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23942. * * 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
  23943. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23944. * @param name defines the name of the mesh to create
  23945. * @param options defines the options used to create the mesh
  23946. * @param scene defines the hosting scene
  23947. * @returns a new Mesh
  23948. */
  23949. static CreatePolyhedron(name: string, options: {
  23950. type?: number;
  23951. size?: number;
  23952. sizeX?: number;
  23953. sizeY?: number;
  23954. sizeZ?: number;
  23955. custom?: any;
  23956. faceUV?: Vector4[];
  23957. faceColors?: Color4[];
  23958. updatable?: boolean;
  23959. sideOrientation?: number;
  23960. }, scene: Scene): Mesh;
  23961. /**
  23962. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  23963. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  23964. * * 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`)
  23965. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  23966. * * 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
  23967. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23968. * * 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
  23969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23970. * @param name defines the name of the mesh
  23971. * @param options defines the options used to create the mesh
  23972. * @param scene defines the hosting scene
  23973. * @returns a new Mesh
  23974. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  23975. */
  23976. static CreateIcoSphere(name: string, options: {
  23977. radius?: number;
  23978. flat?: boolean;
  23979. subdivisions?: number;
  23980. sideOrientation?: number;
  23981. updatable?: boolean;
  23982. }, scene: Scene): Mesh;
  23983. /**
  23984. * Creates a decal mesh.
  23985. * Please consider using the same method from the MeshBuilder class instead.
  23986. * A decal is a mesh usually applied as a model onto the surface of another mesh
  23987. * @param name defines the name of the mesh
  23988. * @param sourceMesh defines the mesh receiving the decal
  23989. * @param position sets the position of the decal in world coordinates
  23990. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  23991. * @param size sets the decal scaling
  23992. * @param angle sets the angle to rotate the decal
  23993. * @returns a new Mesh
  23994. */
  23995. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  23996. /**
  23997. * Prepare internal position array for software CPU skinning
  23998. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  23999. */
  24000. setPositionsForCPUSkinning(): Float32Array;
  24001. /**
  24002. * Prepare internal normal array for software CPU skinning
  24003. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24004. */
  24005. setNormalsForCPUSkinning(): Float32Array;
  24006. /**
  24007. * Updates the vertex buffer by applying transformation from the bones
  24008. * @param skeleton defines the skeleton to apply to current mesh
  24009. * @returns the current mesh
  24010. */
  24011. applySkeleton(skeleton: Skeleton): Mesh;
  24012. /**
  24013. * 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
  24014. * @param meshes defines the list of meshes to scan
  24015. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24016. */
  24017. static MinMax(meshes: AbstractMesh[]): {
  24018. min: Vector3;
  24019. max: Vector3;
  24020. };
  24021. /**
  24022. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24023. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24024. * @returns a vector3
  24025. */
  24026. static Center(meshesOrMinMaxVector: {
  24027. min: Vector3;
  24028. max: Vector3;
  24029. } | AbstractMesh[]): Vector3;
  24030. /**
  24031. * Merge the array of meshes into a single mesh for performance reasons.
  24032. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24033. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24034. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24035. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24036. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24037. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24038. * @returns a new mesh
  24039. */
  24040. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24041. /** @hidden */
  24042. addInstance(instance: InstancedMesh): void;
  24043. /** @hidden */
  24044. removeInstance(instance: InstancedMesh): void;
  24045. }
  24046. }
  24047. declare module BABYLON {
  24048. /**
  24049. * This is the base class of all the camera used in the application.
  24050. * @see http://doc.babylonjs.com/features/cameras
  24051. */
  24052. export class Camera extends Node {
  24053. /** @hidden */ private static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24054. /**
  24055. * This is the default projection mode used by the cameras.
  24056. * It helps recreating a feeling of perspective and better appreciate depth.
  24057. * This is the best way to simulate real life cameras.
  24058. */
  24059. static readonly PERSPECTIVE_CAMERA: number;
  24060. /**
  24061. * This helps creating camera with an orthographic mode.
  24062. * 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.
  24063. */
  24064. static readonly ORTHOGRAPHIC_CAMERA: number;
  24065. /**
  24066. * This is the default FOV mode for perspective cameras.
  24067. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24068. */
  24069. static readonly FOVMODE_VERTICAL_FIXED: number;
  24070. /**
  24071. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24072. */
  24073. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24074. /**
  24075. * This specifies ther is no need for a camera rig.
  24076. * Basically only one eye is rendered corresponding to the camera.
  24077. */
  24078. static readonly RIG_MODE_NONE: number;
  24079. /**
  24080. * Simulates a camera Rig with one blue eye and one red eye.
  24081. * This can be use with 3d blue and red glasses.
  24082. */
  24083. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24084. /**
  24085. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24086. */
  24087. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24088. /**
  24089. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24090. */
  24091. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24092. /**
  24093. * Defines that both eyes of the camera will be rendered over under each other.
  24094. */
  24095. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24096. /**
  24097. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24098. */
  24099. static readonly RIG_MODE_VR: number;
  24100. /**
  24101. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24102. */
  24103. static readonly RIG_MODE_WEBVR: number;
  24104. /**
  24105. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24106. */
  24107. static readonly RIG_MODE_CUSTOM: number;
  24108. /**
  24109. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24110. */
  24111. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24112. /**
  24113. * Define the input manager associated with the camera.
  24114. */
  24115. inputs: CameraInputsManager<Camera>;
  24116. /** @hidden */ private _position: Vector3;
  24117. /**
  24118. * Define the current local position of the camera in the scene
  24119. */
  24120. position: Vector3;
  24121. /**
  24122. * The vector the camera should consider as up.
  24123. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24124. */
  24125. upVector: Vector3;
  24126. /**
  24127. * Define the current limit on the left side for an orthographic camera
  24128. * In scene unit
  24129. */
  24130. orthoLeft: Nullable<number>;
  24131. /**
  24132. * Define the current limit on the right side for an orthographic camera
  24133. * In scene unit
  24134. */
  24135. orthoRight: Nullable<number>;
  24136. /**
  24137. * Define the current limit on the bottom side for an orthographic camera
  24138. * In scene unit
  24139. */
  24140. orthoBottom: Nullable<number>;
  24141. /**
  24142. * Define the current limit on the top side for an orthographic camera
  24143. * In scene unit
  24144. */
  24145. orthoTop: Nullable<number>;
  24146. /**
  24147. * Field Of View is set in Radians. (default is 0.8)
  24148. */
  24149. fov: number;
  24150. /**
  24151. * Define the minimum distance the camera can see from.
  24152. * This is important to note that the depth buffer are not infinite and the closer it starts
  24153. * the more your scene might encounter depth fighting issue.
  24154. */
  24155. minZ: number;
  24156. /**
  24157. * Define the maximum distance the camera can see to.
  24158. * This is important to note that the depth buffer are not infinite and the further it end
  24159. * the more your scene might encounter depth fighting issue.
  24160. */
  24161. maxZ: number;
  24162. /**
  24163. * Define the default inertia of the camera.
  24164. * This helps giving a smooth feeling to the camera movement.
  24165. */
  24166. inertia: number;
  24167. /**
  24168. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24169. */
  24170. mode: number;
  24171. /**
  24172. * Define wether the camera is intermediate.
  24173. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24174. */
  24175. isIntermediate: boolean;
  24176. /**
  24177. * Define the viewport of the camera.
  24178. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24179. */
  24180. viewport: Viewport;
  24181. /**
  24182. * Restricts the camera to viewing objects with the same layerMask.
  24183. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24184. */
  24185. layerMask: number;
  24186. /**
  24187. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24188. */
  24189. fovMode: number;
  24190. /**
  24191. * Rig mode of the camera.
  24192. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24193. * This is normally controlled byt the camera themselves as internal use.
  24194. */
  24195. cameraRigMode: number;
  24196. /**
  24197. * Defines the distance between both "eyes" in case of a RIG
  24198. */
  24199. interaxialDistance: number;
  24200. /**
  24201. * Defines if stereoscopic rendering is done side by side or over under.
  24202. */
  24203. isStereoscopicSideBySide: boolean;
  24204. /**
  24205. * 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
  24206. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24207. * else in the scene. (Eg. security camera)
  24208. *
  24209. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  24210. */
  24211. customRenderTargets: RenderTargetTexture[];
  24212. /**
  24213. * When set, the camera will render to this render target instead of the default canvas
  24214. *
  24215. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24216. */
  24217. outputRenderTarget: Nullable<RenderTargetTexture>;
  24218. /**
  24219. * Observable triggered when the camera view matrix has changed.
  24220. */
  24221. onViewMatrixChangedObservable: Observable<Camera>;
  24222. /**
  24223. * Observable triggered when the camera Projection matrix has changed.
  24224. */
  24225. onProjectionMatrixChangedObservable: Observable<Camera>;
  24226. /**
  24227. * Observable triggered when the inputs have been processed.
  24228. */
  24229. onAfterCheckInputsObservable: Observable<Camera>;
  24230. /**
  24231. * Observable triggered when reset has been called and applied to the camera.
  24232. */
  24233. onRestoreStateObservable: Observable<Camera>;
  24234. /** @hidden */ private _cameraRigParams: any;
  24235. /** @hidden */ private _rigCameras: Camera[];
  24236. /** @hidden */ private _rigPostProcess: Nullable<PostProcess>;
  24237. protected _webvrViewMatrix: Matrix;
  24238. /** @hidden */ private _skipRendering: boolean;
  24239. /** @hidden */ private _projectionMatrix: Matrix;
  24240. /** @hidden */ private _postProcesses: Nullable<PostProcess>[];
  24241. /** @hidden */ private _activeMeshes: SmartArray<AbstractMesh>;
  24242. protected _globalPosition: Vector3;
  24243. /** @hidden */ private _computedViewMatrix: Matrix;
  24244. private _doNotComputeProjectionMatrix;
  24245. private _transformMatrix;
  24246. private _frustumPlanes;
  24247. private _refreshFrustumPlanes;
  24248. private _storedFov;
  24249. private _stateStored;
  24250. /**
  24251. * Instantiates a new camera object.
  24252. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24253. * @see http://doc.babylonjs.com/features/cameras
  24254. * @param name Defines the name of the camera in the scene
  24255. * @param position Defines the position of the camera
  24256. * @param scene Defines the scene the camera belongs too
  24257. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24258. */
  24259. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24260. /**
  24261. * Store current camera state (fov, position, etc..)
  24262. * @returns the camera
  24263. */
  24264. storeState(): Camera;
  24265. /**
  24266. * Restores the camera state values if it has been stored. You must call storeState() first
  24267. */
  24268. protected _restoreStateValues(): boolean;
  24269. /**
  24270. * Restored camera state. You must call storeState() first.
  24271. * @returns true if restored and false otherwise
  24272. */
  24273. restoreState(): boolean;
  24274. /**
  24275. * Gets the class name of the camera.
  24276. * @returns the class name
  24277. */
  24278. getClassName(): string;
  24279. /** @hidden */ protected readonly _isCamera: boolean;
  24280. /**
  24281. * Gets a string representation of the camera useful for debug purpose.
  24282. * @param fullDetails Defines that a more verboe level of logging is required
  24283. * @returns the string representation
  24284. */
  24285. toString(fullDetails?: boolean): string;
  24286. /**
  24287. * Gets the current world space position of the camera.
  24288. */
  24289. readonly globalPosition: Vector3;
  24290. /**
  24291. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24292. * @returns the active meshe list
  24293. */
  24294. getActiveMeshes(): SmartArray<AbstractMesh>;
  24295. /**
  24296. * Check wether a mesh is part of the current active mesh list of the camera
  24297. * @param mesh Defines the mesh to check
  24298. * @returns true if active, false otherwise
  24299. */
  24300. isActiveMesh(mesh: Mesh): boolean;
  24301. /**
  24302. * Is this camera ready to be used/rendered
  24303. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24304. * @return true if the camera is ready
  24305. */
  24306. isReady(completeCheck?: boolean): boolean;
  24307. /** @hidden */ private _initCache(): void;
  24308. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  24309. /** @hidden */ private _isSynchronized(): boolean;
  24310. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  24311. /** @hidden */ private _isSynchronizedProjectionMatrix(): boolean;
  24312. /**
  24313. * Attach the input controls to a specific dom element to get the input from.
  24314. * @param element Defines the element the controls should be listened from
  24315. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24316. */
  24317. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24318. /**
  24319. * Detach the current controls from the specified dom element.
  24320. * @param element Defines the element to stop listening the inputs from
  24321. */
  24322. detachControl(element: HTMLElement): void;
  24323. /**
  24324. * Update the camera state according to the different inputs gathered during the frame.
  24325. */
  24326. update(): void;
  24327. /** @hidden */ private _checkInputs(): void;
  24328. /** @hidden */
  24329. readonly rigCameras: Camera[];
  24330. /**
  24331. * Gets the post process used by the rig cameras
  24332. */
  24333. readonly rigPostProcess: Nullable<PostProcess>;
  24334. /**
  24335. * Internal, gets the first post proces.
  24336. * @returns the first post process to be run on this camera.
  24337. */ private _getFirstPostProcess(): Nullable<PostProcess>;
  24338. private _cascadePostProcessesToRigCams;
  24339. /**
  24340. * Attach a post process to the camera.
  24341. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24342. * @param postProcess The post process to attach to the camera
  24343. * @param insertAt The position of the post process in case several of them are in use in the scene
  24344. * @returns the position the post process has been inserted at
  24345. */
  24346. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24347. /**
  24348. * Detach a post process to the camera.
  24349. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24350. * @param postProcess The post process to detach from the camera
  24351. */
  24352. detachPostProcess(postProcess: PostProcess): void;
  24353. /**
  24354. * Gets the current world matrix of the camera
  24355. */
  24356. getWorldMatrix(): Matrix;
  24357. /** @hidden */ private _getViewMatrix(): Matrix;
  24358. /**
  24359. * Gets the current view matrix of the camera.
  24360. * @param force forces the camera to recompute the matrix without looking at the cached state
  24361. * @returns the view matrix
  24362. */
  24363. getViewMatrix(force?: boolean): Matrix;
  24364. /**
  24365. * Freeze the projection matrix.
  24366. * It will prevent the cache check of the camera projection compute and can speed up perf
  24367. * if no parameter of the camera are meant to change
  24368. * @param projection Defines manually a projection if necessary
  24369. */
  24370. freezeProjectionMatrix(projection?: Matrix): void;
  24371. /**
  24372. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24373. */
  24374. unfreezeProjectionMatrix(): void;
  24375. /**
  24376. * Gets the current projection matrix of the camera.
  24377. * @param force forces the camera to recompute the matrix without looking at the cached state
  24378. * @returns the projection matrix
  24379. */
  24380. getProjectionMatrix(force?: boolean): Matrix;
  24381. /**
  24382. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  24383. * @returns a Matrix
  24384. */
  24385. getTransformationMatrix(): Matrix;
  24386. private _updateFrustumPlanes;
  24387. /**
  24388. * Checks if a cullable object (mesh...) is in the camera frustum
  24389. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  24390. * @param target The object to check
  24391. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  24392. * @returns true if the object is in frustum otherwise false
  24393. */
  24394. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  24395. /**
  24396. * Checks if a cullable object (mesh...) is in the camera frustum
  24397. * Unlike isInFrustum this cheks the full bounding box
  24398. * @param target The object to check
  24399. * @returns true if the object is in frustum otherwise false
  24400. */
  24401. isCompletelyInFrustum(target: ICullable): boolean;
  24402. /**
  24403. * Gets a ray in the forward direction from the camera.
  24404. * @param length Defines the length of the ray to create
  24405. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  24406. * @param origin Defines the start point of the ray which defaults to the camera position
  24407. * @returns the forward ray
  24408. */
  24409. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  24410. /**
  24411. * Releases resources associated with this node.
  24412. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24413. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24414. */
  24415. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24416. /** @hidden */ private _isLeftCamera: boolean;
  24417. /**
  24418. * Gets the left camera of a rig setup in case of Rigged Camera
  24419. */
  24420. readonly isLeftCamera: boolean;
  24421. /** @hidden */ private _isRightCamera: boolean;
  24422. /**
  24423. * Gets the right camera of a rig setup in case of Rigged Camera
  24424. */
  24425. readonly isRightCamera: boolean;
  24426. /**
  24427. * Gets the left camera of a rig setup in case of Rigged Camera
  24428. */
  24429. readonly leftCamera: Nullable<FreeCamera>;
  24430. /**
  24431. * Gets the right camera of a rig setup in case of Rigged Camera
  24432. */
  24433. readonly rightCamera: Nullable<FreeCamera>;
  24434. /**
  24435. * Gets the left camera target of a rig setup in case of Rigged Camera
  24436. * @returns the target position
  24437. */
  24438. getLeftTarget(): Nullable<Vector3>;
  24439. /**
  24440. * Gets the right camera target of a rig setup in case of Rigged Camera
  24441. * @returns the target position
  24442. */
  24443. getRightTarget(): Nullable<Vector3>;
  24444. /**
  24445. * @hidden
  24446. */
  24447. setCameraRigMode(mode: number, rigParams: any): void;
  24448. /** @hidden */ private static _setStereoscopicRigMode(camera: Camera): void;
  24449. /** @hidden */ private static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  24450. /** @hidden */ private static _setVRRigMode(camera: Camera, rigParams: any): void;
  24451. /** @hidden */ private static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  24452. /** @hidden */ private _getVRProjectionMatrix(): Matrix;
  24453. protected _updateCameraRotationMatrix(): void;
  24454. protected _updateWebVRCameraRotationMatrix(): void;
  24455. /**
  24456. * This function MUST be overwritten by the different WebVR cameras available.
  24457. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24458. * @hidden
  24459. */ private _getWebVRProjectionMatrix(): Matrix;
  24460. /**
  24461. * This function MUST be overwritten by the different WebVR cameras available.
  24462. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24463. * @hidden
  24464. */ private _getWebVRViewMatrix(): Matrix;
  24465. /** @hidden */
  24466. setCameraRigParameter(name: string, value: any): void;
  24467. /**
  24468. * needs to be overridden by children so sub has required properties to be copied
  24469. * @hidden
  24470. */
  24471. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  24472. /**
  24473. * May need to be overridden by children
  24474. * @hidden
  24475. */ private _updateRigCameras(): void;
  24476. /** @hidden */ private _setupInputs(): void;
  24477. /**
  24478. * Serialiaze the camera setup to a json represention
  24479. * @returns the JSON representation
  24480. */
  24481. serialize(): any;
  24482. /**
  24483. * Clones the current camera.
  24484. * @param name The cloned camera name
  24485. * @returns the cloned camera
  24486. */
  24487. clone(name: string): Camera;
  24488. /**
  24489. * Gets the direction of the camera relative to a given local axis.
  24490. * @param localAxis Defines the reference axis to provide a relative direction.
  24491. * @return the direction
  24492. */
  24493. getDirection(localAxis: Vector3): Vector3;
  24494. /**
  24495. * Gets the direction of the camera relative to a given local axis into a passed vector.
  24496. * @param localAxis Defines the reference axis to provide a relative direction.
  24497. * @param result Defines the vector to store the result in
  24498. */
  24499. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  24500. /**
  24501. * Gets a camera constructor for a given camera type
  24502. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  24503. * @param name The name of the camera the result will be able to instantiate
  24504. * @param scene The scene the result will construct the camera in
  24505. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  24506. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  24507. * @returns a factory method to construc the camera
  24508. */
  24509. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  24510. /**
  24511. * Compute the world matrix of the camera.
  24512. * @returns the camera workd matrix
  24513. */
  24514. computeWorldMatrix(): Matrix;
  24515. /**
  24516. * Parse a JSON and creates the camera from the parsed information
  24517. * @param parsedCamera The JSON to parse
  24518. * @param scene The scene to instantiate the camera in
  24519. * @returns the newly constructed camera
  24520. */
  24521. static Parse(parsedCamera: any, scene: Scene): Camera;
  24522. }
  24523. }
  24524. declare module BABYLON {
  24525. /**
  24526. * Class containing static functions to help procedurally build meshes
  24527. */
  24528. export class DiscBuilder {
  24529. /**
  24530. * Creates a plane polygonal mesh. By default, this is a disc
  24531. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24532. * * 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
  24533. * * 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
  24534. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24535. * * 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
  24536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24537. * @param name defines the name of the mesh
  24538. * @param options defines the options used to create the mesh
  24539. * @param scene defines the hosting scene
  24540. * @returns the plane polygonal mesh
  24541. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24542. */
  24543. static CreateDisc(name: string, options: {
  24544. radius?: number;
  24545. tessellation?: number;
  24546. arc?: number;
  24547. updatable?: boolean;
  24548. sideOrientation?: number;
  24549. frontUVs?: Vector4;
  24550. backUVs?: Vector4;
  24551. }, scene?: Nullable<Scene>): Mesh;
  24552. }
  24553. }
  24554. declare module BABYLON {
  24555. /**
  24556. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24557. *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.
  24558. * The SPS is also a particle system. It provides some methods to manage the particles.
  24559. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24560. *
  24561. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  24562. */
  24563. export class SolidParticleSystem implements IDisposable {
  24564. /**
  24565. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24566. * Example : var p = SPS.particles[i];
  24567. */
  24568. particles: SolidParticle[];
  24569. /**
  24570. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24571. */
  24572. nbParticles: number;
  24573. /**
  24574. * If the particles must ever face the camera (default false). Useful for planar particles.
  24575. */
  24576. billboard: boolean;
  24577. /**
  24578. * Recompute normals when adding a shape
  24579. */
  24580. recomputeNormals: boolean;
  24581. /**
  24582. * This a counter ofr your own usage. It's not set by any SPS functions.
  24583. */
  24584. counter: number;
  24585. /**
  24586. * The SPS name. This name is also given to the underlying mesh.
  24587. */
  24588. name: string;
  24589. /**
  24590. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24591. */
  24592. mesh: Mesh;
  24593. /**
  24594. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24595. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  24596. */
  24597. vars: any;
  24598. /**
  24599. * This array is populated when the SPS is set as 'pickable'.
  24600. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24601. * Each element of this array is an object `{idx: int, faceId: int}`.
  24602. * `idx` is the picked particle index in the `SPS.particles` array
  24603. * `faceId` is the picked face index counted within this particle.
  24604. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  24605. */
  24606. pickedParticles: {
  24607. idx: number;
  24608. faceId: number;
  24609. }[];
  24610. /**
  24611. * This array is populated when `enableDepthSort` is set to true.
  24612. * Each element of this array is an instance of the class DepthSortedParticle.
  24613. */
  24614. depthSortedParticles: DepthSortedParticle[];
  24615. /**
  24616. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24617. * @hidden
  24618. */ private _bSphereOnly: boolean;
  24619. /**
  24620. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24621. * @hidden
  24622. */ private _bSphereRadiusFactor: number;
  24623. private _scene;
  24624. private _positions;
  24625. private _indices;
  24626. private _normals;
  24627. private _colors;
  24628. private _uvs;
  24629. private _indices32;
  24630. private _positions32;
  24631. private _normals32;
  24632. private _fixedNormal32;
  24633. private _colors32;
  24634. private _uvs32;
  24635. private _index;
  24636. private _updatable;
  24637. private _pickable;
  24638. private _isVisibilityBoxLocked;
  24639. private _alwaysVisible;
  24640. private _depthSort;
  24641. private _shapeCounter;
  24642. private _copy;
  24643. private _color;
  24644. private _computeParticleColor;
  24645. private _computeParticleTexture;
  24646. private _computeParticleRotation;
  24647. private _computeParticleVertex;
  24648. private _computeBoundingBox;
  24649. private _depthSortParticles;
  24650. private _camera;
  24651. private _mustUnrotateFixedNormals;
  24652. private _particlesIntersect;
  24653. private _needs32Bits;
  24654. /**
  24655. * Creates a SPS (Solid Particle System) object.
  24656. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24657. * @param scene (Scene) is the scene in which the SPS is added.
  24658. * @param options defines the options of the sps e.g.
  24659. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24660. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24661. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24662. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24663. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24664. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24665. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24666. */
  24667. constructor(name: string, scene: Scene, options?: {
  24668. updatable?: boolean;
  24669. isPickable?: boolean;
  24670. enableDepthSort?: boolean;
  24671. particleIntersection?: boolean;
  24672. boundingSphereOnly?: boolean;
  24673. bSphereRadiusFactor?: number;
  24674. });
  24675. /**
  24676. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24677. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24678. * @returns the created mesh
  24679. */
  24680. buildMesh(): Mesh;
  24681. /**
  24682. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24683. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24684. * Thus the particles generated from `digest()` have their property `position` set yet.
  24685. * @param mesh ( Mesh ) is the mesh to be digested
  24686. * @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
  24687. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24688. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24689. * @returns the current SPS
  24690. */
  24691. digest(mesh: Mesh, options?: {
  24692. facetNb?: number;
  24693. number?: number;
  24694. delta?: number;
  24695. }): SolidParticleSystem;
  24696. private _unrotateFixedNormals;
  24697. private _resetCopy;
  24698. private _meshBuilder;
  24699. private _posToShape;
  24700. private _uvsToShapeUV;
  24701. private _addParticle;
  24702. /**
  24703. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24704. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  24705. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24706. * @param nb (positive integer) the number of particles to be created from this model
  24707. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24708. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24709. * @returns the number of shapes in the system
  24710. */
  24711. addShape(mesh: Mesh, nb: number, options?: {
  24712. positionFunction?: any;
  24713. vertexFunction?: any;
  24714. }): number;
  24715. private _rebuildParticle;
  24716. /**
  24717. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24718. * @returns the SPS.
  24719. */
  24720. rebuildMesh(): SolidParticleSystem;
  24721. /**
  24722. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24723. * This method calls `updateParticle()` for each particle of the SPS.
  24724. * For an animated SPS, it is usually called within the render loop.
  24725. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24726. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24727. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24728. * @returns the SPS.
  24729. */
  24730. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24731. /**
  24732. * Disposes the SPS.
  24733. */
  24734. dispose(): void;
  24735. /**
  24736. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24737. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24738. * @returns the SPS.
  24739. */
  24740. refreshVisibleSize(): SolidParticleSystem;
  24741. /**
  24742. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24743. * @param size the size (float) of the visibility box
  24744. * note : this doesn't lock the SPS mesh bounding box.
  24745. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24746. */
  24747. setVisibilityBox(size: number): void;
  24748. /**
  24749. * Gets whether the SPS as always visible or not
  24750. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24751. */
  24752. /**
  24753. * Sets the SPS as always visible or not
  24754. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24755. */
  24756. isAlwaysVisible: boolean;
  24757. /**
  24758. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24759. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24760. */
  24761. /**
  24762. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24763. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24764. */
  24765. isVisibilityBoxLocked: boolean;
  24766. /**
  24767. * Tells to `setParticles()` to compute the particle rotations or not.
  24768. * Default value : true. The SPS is faster when it's set to false.
  24769. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24770. */
  24771. /**
  24772. * Gets if `setParticles()` computes the particle rotations or not.
  24773. * Default value : true. The SPS is faster when it's set to false.
  24774. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24775. */
  24776. computeParticleRotation: boolean;
  24777. /**
  24778. * Tells to `setParticles()` to compute the particle colors or not.
  24779. * Default value : true. The SPS is faster when it's set to false.
  24780. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24781. */
  24782. /**
  24783. * Gets if `setParticles()` computes the particle colors or not.
  24784. * Default value : true. The SPS is faster when it's set to false.
  24785. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24786. */
  24787. computeParticleColor: boolean;
  24788. /**
  24789. * Gets if `setParticles()` computes the particle textures or not.
  24790. * Default value : true. The SPS is faster when it's set to false.
  24791. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24792. */
  24793. computeParticleTexture: boolean;
  24794. /**
  24795. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24796. * Default value : false. The SPS is faster when it's set to false.
  24797. * Note : the particle custom vertex positions aren't stored values.
  24798. */
  24799. /**
  24800. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24801. * Default value : false. The SPS is faster when it's set to false.
  24802. * Note : the particle custom vertex positions aren't stored values.
  24803. */
  24804. computeParticleVertex: boolean;
  24805. /**
  24806. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24807. */
  24808. /**
  24809. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24810. */
  24811. computeBoundingBox: boolean;
  24812. /**
  24813. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24814. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24815. * Default : `true`
  24816. */
  24817. /**
  24818. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24819. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24820. * Default : `true`
  24821. */
  24822. depthSortParticles: boolean;
  24823. /**
  24824. * This function does nothing. It may be overwritten to set all the particle first values.
  24825. * The SPS doesn't call this function, you may have to call it by your own.
  24826. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  24827. */
  24828. initParticles(): void;
  24829. /**
  24830. * This function does nothing. It may be overwritten to recycle a particle.
  24831. * The SPS doesn't call this function, you may have to call it by your own.
  24832. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  24833. * @param particle The particle to recycle
  24834. * @returns the recycled particle
  24835. */
  24836. recycleParticle(particle: SolidParticle): SolidParticle;
  24837. /**
  24838. * Updates a particle : this function should be overwritten by the user.
  24839. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24840. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  24841. * @example : just set a particle position or velocity and recycle conditions
  24842. * @param particle The particle to update
  24843. * @returns the updated particle
  24844. */
  24845. updateParticle(particle: SolidParticle): SolidParticle;
  24846. /**
  24847. * Updates a vertex of a particle : it can be overwritten by the user.
  24848. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24849. * @param particle the current particle
  24850. * @param vertex the current index of the current particle
  24851. * @param pt the index of the current vertex in the particle shape
  24852. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  24853. * @example : just set a vertex particle position
  24854. * @returns the updated vertex
  24855. */
  24856. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24857. /**
  24858. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24859. * This does nothing and may be overwritten by the user.
  24860. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24861. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24862. * @param update the boolean update value actually passed to setParticles()
  24863. */
  24864. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24865. /**
  24866. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24867. * This will be passed three parameters.
  24868. * This does nothing and may be overwritten by the user.
  24869. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24870. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24871. * @param update the boolean update value actually passed to setParticles()
  24872. */
  24873. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24874. }
  24875. }
  24876. declare module BABYLON {
  24877. /**
  24878. * Represents one particle of a solid particle system.
  24879. */
  24880. export class SolidParticle {
  24881. /**
  24882. * particle global index
  24883. */
  24884. idx: number;
  24885. /**
  24886. * The color of the particle
  24887. */
  24888. color: Nullable<Color4>;
  24889. /**
  24890. * The world space position of the particle.
  24891. */
  24892. position: Vector3;
  24893. /**
  24894. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24895. */
  24896. rotation: Vector3;
  24897. /**
  24898. * The world space rotation quaternion of the particle.
  24899. */
  24900. rotationQuaternion: Nullable<Quaternion>;
  24901. /**
  24902. * The scaling of the particle.
  24903. */
  24904. scaling: Vector3;
  24905. /**
  24906. * The uvs of the particle.
  24907. */
  24908. uvs: Vector4;
  24909. /**
  24910. * The current speed of the particle.
  24911. */
  24912. velocity: Vector3;
  24913. /**
  24914. * The pivot point in the particle local space.
  24915. */
  24916. pivot: Vector3;
  24917. /**
  24918. * Must the particle be translated from its pivot point in its local space ?
  24919. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24920. * Default : false
  24921. */
  24922. translateFromPivot: boolean;
  24923. /**
  24924. * Is the particle active or not ?
  24925. */
  24926. alive: boolean;
  24927. /**
  24928. * Is the particle visible or not ?
  24929. */
  24930. isVisible: boolean;
  24931. /**
  24932. * Index of this particle in the global "positions" array (Internal use)
  24933. * @hidden
  24934. */ private _pos: number;
  24935. /**
  24936. * @hidden Index of this particle in the global "indices" array (Internal use)
  24937. */ private _ind: number;
  24938. /**
  24939. * @hidden ModelShape of this particle (Internal use)
  24940. */ private _model: ModelShape;
  24941. /**
  24942. * ModelShape id of this particle
  24943. */
  24944. shapeId: number;
  24945. /**
  24946. * Index of the particle in its shape id (Internal use)
  24947. */
  24948. idxInShape: number;
  24949. /**
  24950. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24951. */ private _modelBoundingInfo: BoundingInfo;
  24952. /**
  24953. * @hidden Particle BoundingInfo object (Internal use)
  24954. */ private _boundingInfo: BoundingInfo;
  24955. /**
  24956. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24957. */ private _sps: SolidParticleSystem;
  24958. /**
  24959. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24960. */ private _stillInvisible: boolean;
  24961. /**
  24962. * @hidden Last computed particle rotation matrix
  24963. */ private _rotationMatrix: number[];
  24964. /**
  24965. * Parent particle Id, if any.
  24966. * Default null.
  24967. */
  24968. parentId: Nullable<number>;
  24969. /**
  24970. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24971. * The possible values are :
  24972. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24973. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24974. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24975. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24976. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24977. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24978. * */
  24979. cullingStrategy: number;
  24980. /**
  24981. * @hidden Internal global position in the SPS.
  24982. */ private _globalPosition: Vector3;
  24983. /**
  24984. * Creates a Solid Particle object.
  24985. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24986. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24987. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24988. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24989. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24990. * @param shapeId (integer) is the model shape identifier in the SPS.
  24991. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24992. * @param sps defines the sps it is associated to
  24993. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24994. */
  24995. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24996. /**
  24997. * Legacy support, changed scale to scaling
  24998. */
  24999. /**
  25000. * Legacy support, changed scale to scaling
  25001. */
  25002. scale: Vector3;
  25003. /**
  25004. * Legacy support, changed quaternion to rotationQuaternion
  25005. */
  25006. /**
  25007. * Legacy support, changed quaternion to rotationQuaternion
  25008. */
  25009. quaternion: Nullable<Quaternion>;
  25010. /**
  25011. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25012. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25013. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25014. * @returns true if it intersects
  25015. */
  25016. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25017. /**
  25018. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25019. * A particle is in the frustum if its bounding box intersects the frustum
  25020. * @param frustumPlanes defines the frustum to test
  25021. * @returns true if the particle is in the frustum planes
  25022. */
  25023. isInFrustum(frustumPlanes: Plane[]): boolean;
  25024. /**
  25025. * get the rotation matrix of the particle
  25026. * @hidden
  25027. */
  25028. getRotationMatrix(m: Matrix): void;
  25029. }
  25030. /**
  25031. * Represents the shape of the model used by one particle of a solid particle system.
  25032. * SPS internal tool, don't use it manually.
  25033. */
  25034. export class ModelShape {
  25035. /**
  25036. * The shape id
  25037. * @hidden
  25038. */
  25039. shapeID: number;
  25040. /**
  25041. * flat array of model positions (internal use)
  25042. * @hidden
  25043. */ private _shape: Vector3[];
  25044. /**
  25045. * flat array of model UVs (internal use)
  25046. * @hidden
  25047. */ private _shapeUV: number[];
  25048. /**
  25049. * length of the shape in the model indices array (internal use)
  25050. * @hidden
  25051. */ private _indicesLength: number;
  25052. /**
  25053. * Custom position function (internal use)
  25054. * @hidden
  25055. */ private _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25056. /**
  25057. * Custom vertex function (internal use)
  25058. * @hidden
  25059. */ private _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25060. /**
  25061. * 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.
  25062. * SPS internal tool, don't use it manually.
  25063. * @hidden
  25064. */
  25065. 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>);
  25066. }
  25067. /**
  25068. * Represents a Depth Sorted Particle in the solid particle system.
  25069. */
  25070. export class DepthSortedParticle {
  25071. /**
  25072. * Index of the particle in the "indices" array
  25073. */
  25074. ind: number;
  25075. /**
  25076. * Length of the particle shape in the "indices" array
  25077. */
  25078. indicesLength: number;
  25079. /**
  25080. * Squared distance from the particle to the camera
  25081. */
  25082. sqDistance: number;
  25083. }
  25084. }
  25085. declare module BABYLON {
  25086. /**
  25087. * @hidden
  25088. */
  25089. export class _MeshCollisionData { private _checkCollisions: boolean; private _collisionMask: number; private _collisionGroup: number; private _collider: Nullable<Collider>; private _oldPositionForCollisions: Vector3; private _diffPositionForCollisions: Vector3; private _onCollideObserver: Nullable<Observer<AbstractMesh>>; private _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25090. }
  25091. }
  25092. declare module BABYLON {
  25093. /** @hidden */ private class _FacetDataStorage {
  25094. facetPositions: Vector3[];
  25095. facetNormals: Vector3[];
  25096. facetPartitioning: number[][];
  25097. facetNb: number;
  25098. partitioningSubdivisions: number;
  25099. partitioningBBoxRatio: number;
  25100. facetDataEnabled: boolean;
  25101. facetParameters: any;
  25102. bbSize: Vector3;
  25103. subDiv: {
  25104. max: number;
  25105. X: number;
  25106. Y: number;
  25107. Z: number;
  25108. };
  25109. facetDepthSort: boolean;
  25110. facetDepthSortEnabled: boolean;
  25111. depthSortedIndices: IndicesArray;
  25112. depthSortedFacets: {
  25113. ind: number;
  25114. sqDistance: number;
  25115. }[];
  25116. facetDepthSortFunction: (f1: {
  25117. ind: number;
  25118. sqDistance: number;
  25119. }, f2: {
  25120. ind: number;
  25121. sqDistance: number;
  25122. }) => number;
  25123. facetDepthSortFrom: Vector3;
  25124. facetDepthSortOrigin: Vector3;
  25125. invertedMatrix: Matrix;
  25126. }
  25127. /**
  25128. * @hidden
  25129. **/ private class _InternalAbstractMeshDataInfo { private _hasVertexAlpha: boolean; private _useVertexColors: boolean; private _numBoneInfluencers: number; private _applyFog: boolean; private _receiveShadows: boolean; private _facetData: _FacetDataStorage; private _visibility: number; private _skeleton: Nullable<Skeleton>; private _layerMask: number; private _computeBonesUsingShaders: boolean; private _isActive: boolean; private _onlyForInstances: boolean; private _isActiveIntermediate: boolean; private _onlyForInstancesIntermediate: boolean;
  25130. }
  25131. /**
  25132. * Class used to store all common mesh properties
  25133. */
  25134. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25135. /** No occlusion */
  25136. static OCCLUSION_TYPE_NONE: number;
  25137. /** Occlusion set to optimisitic */
  25138. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25139. /** Occlusion set to strict */
  25140. static OCCLUSION_TYPE_STRICT: number;
  25141. /** Use an accurante occlusion algorithm */
  25142. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25143. /** Use a conservative occlusion algorithm */
  25144. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25145. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25146. * Test order :
  25147. * Is the bounding sphere outside the frustum ?
  25148. * If not, are the bounding box vertices outside the frustum ?
  25149. * It not, then the cullable object is in the frustum.
  25150. */
  25151. static readonly CULLINGSTRATEGY_STANDARD: number;
  25152. /** Culling strategy : Bounding Sphere Only.
  25153. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25154. * It's also less accurate than the standard because some not visible objects can still be selected.
  25155. * Test : is the bounding sphere outside the frustum ?
  25156. * If not, then the cullable object is in the frustum.
  25157. */
  25158. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25159. /** Culling strategy : Optimistic Inclusion.
  25160. * This in an inclusion test first, then the standard exclusion test.
  25161. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25162. * 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.
  25163. * Anyway, it's as accurate as the standard strategy.
  25164. * Test :
  25165. * Is the cullable object bounding sphere center in the frustum ?
  25166. * If not, apply the default culling strategy.
  25167. */
  25168. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25169. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25170. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25171. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25172. * 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.
  25173. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25174. * Test :
  25175. * Is the cullable object bounding sphere center in the frustum ?
  25176. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25177. */
  25178. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25179. /**
  25180. * No billboard
  25181. */
  25182. static readonly BILLBOARDMODE_NONE: number;
  25183. /** Billboard on X axis */
  25184. static readonly BILLBOARDMODE_X: number;
  25185. /** Billboard on Y axis */
  25186. static readonly BILLBOARDMODE_Y: number;
  25187. /** Billboard on Z axis */
  25188. static readonly BILLBOARDMODE_Z: number;
  25189. /** Billboard on all axes */
  25190. static readonly BILLBOARDMODE_ALL: number;
  25191. /** Billboard on using position instead of orientation */
  25192. static readonly BILLBOARDMODE_USE_POSITION: number;
  25193. /** @hidden */ private _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25194. /**
  25195. * The culling strategy to use to check whether the mesh must be rendered or not.
  25196. * This value can be changed at any time and will be used on the next render mesh selection.
  25197. * The possible values are :
  25198. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25199. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25200. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25201. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25202. * Please read each static variable documentation to get details about the culling process.
  25203. * */
  25204. cullingStrategy: number;
  25205. /**
  25206. * Gets the number of facets in the mesh
  25207. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25208. */
  25209. readonly facetNb: number;
  25210. /**
  25211. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25212. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25213. */
  25214. partitioningSubdivisions: number;
  25215. /**
  25216. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25217. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25218. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25219. */
  25220. partitioningBBoxRatio: number;
  25221. /**
  25222. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25223. * Works only for updatable meshes.
  25224. * Doesn't work with multi-materials
  25225. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25226. */
  25227. mustDepthSortFacets: boolean;
  25228. /**
  25229. * The location (Vector3) where the facet depth sort must be computed from.
  25230. * By default, the active camera position.
  25231. * Used only when facet depth sort is enabled
  25232. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25233. */
  25234. facetDepthSortFrom: Vector3;
  25235. /**
  25236. * gets a boolean indicating if facetData is enabled
  25237. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25238. */
  25239. readonly isFacetDataEnabled: boolean;
  25240. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  25241. /**
  25242. * An event triggered when this mesh collides with another one
  25243. */
  25244. onCollideObservable: Observable<AbstractMesh>;
  25245. /** Set a function to call when this mesh collides with another one */
  25246. onCollide: () => void;
  25247. /**
  25248. * An event triggered when the collision's position changes
  25249. */
  25250. onCollisionPositionChangeObservable: Observable<Vector3>;
  25251. /** Set a function to call when the collision's position changes */
  25252. onCollisionPositionChange: () => void;
  25253. /**
  25254. * An event triggered when material is changed
  25255. */
  25256. onMaterialChangedObservable: Observable<AbstractMesh>;
  25257. /**
  25258. * Gets or sets the orientation for POV movement & rotation
  25259. */
  25260. definedFacingForward: boolean;
  25261. /** @hidden */ private _occlusionQuery: Nullable<WebGLQuery>;
  25262. /** @hidden */ private _renderingGroup: Nullable<RenderingGroup>;
  25263. /**
  25264. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25265. */
  25266. /**
  25267. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25268. */
  25269. visibility: number;
  25270. /** Gets or sets the alpha index used to sort transparent meshes
  25271. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25272. */
  25273. alphaIndex: number;
  25274. /**
  25275. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25276. */
  25277. isVisible: boolean;
  25278. /**
  25279. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25280. */
  25281. isPickable: boolean;
  25282. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25283. showSubMeshesBoundingBox: boolean;
  25284. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25285. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25286. */
  25287. isBlocker: boolean;
  25288. /**
  25289. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25290. */
  25291. enablePointerMoveEvents: boolean;
  25292. /**
  25293. * Specifies the rendering group id for this mesh (0 by default)
  25294. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25295. */
  25296. renderingGroupId: number;
  25297. private _material;
  25298. /** Gets or sets current material */
  25299. material: Nullable<Material>;
  25300. /**
  25301. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25302. * @see http://doc.babylonjs.com/babylon101/shadows
  25303. */
  25304. receiveShadows: boolean;
  25305. /** Defines color to use when rendering outline */
  25306. outlineColor: Color3;
  25307. /** Define width to use when rendering outline */
  25308. outlineWidth: number;
  25309. /** Defines color to use when rendering overlay */
  25310. overlayColor: Color3;
  25311. /** Defines alpha to use when rendering overlay */
  25312. overlayAlpha: number;
  25313. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25314. hasVertexAlpha: boolean;
  25315. /** 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) */
  25316. useVertexColors: boolean;
  25317. /**
  25318. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25319. */
  25320. computeBonesUsingShaders: boolean;
  25321. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25322. numBoneInfluencers: number;
  25323. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25324. applyFog: boolean;
  25325. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25326. useOctreeForRenderingSelection: boolean;
  25327. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25328. useOctreeForPicking: boolean;
  25329. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25330. useOctreeForCollisions: boolean;
  25331. /**
  25332. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25333. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25334. */
  25335. layerMask: number;
  25336. /**
  25337. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25338. */
  25339. alwaysSelectAsActiveMesh: boolean;
  25340. /**
  25341. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25342. */
  25343. doNotSyncBoundingInfo: boolean;
  25344. /**
  25345. * Gets or sets the current action manager
  25346. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25347. */
  25348. actionManager: Nullable<AbstractActionManager>;
  25349. private _meshCollisionData;
  25350. /**
  25351. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25352. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25353. */
  25354. ellipsoid: Vector3;
  25355. /**
  25356. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25357. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25358. */
  25359. ellipsoidOffset: Vector3;
  25360. /**
  25361. * Gets or sets a collision mask used to mask collisions (default is -1).
  25362. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25363. */
  25364. collisionMask: number;
  25365. /**
  25366. * Gets or sets the current collision group mask (-1 by default).
  25367. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25368. */
  25369. collisionGroup: number;
  25370. /**
  25371. * Defines edge width used when edgesRenderer is enabled
  25372. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25373. */
  25374. edgesWidth: number;
  25375. /**
  25376. * Defines edge color used when edgesRenderer is enabled
  25377. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25378. */
  25379. edgesColor: Color4;
  25380. /** @hidden */ private _edgesRenderer: Nullable<IEdgesRenderer>;
  25381. /** @hidden */ private _masterMesh: Nullable<AbstractMesh>;
  25382. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  25383. /** @hidden */ private _renderId: number;
  25384. /**
  25385. * Gets or sets the list of subMeshes
  25386. * @see http://doc.babylonjs.com/how_to/multi_materials
  25387. */
  25388. subMeshes: SubMesh[];
  25389. /** @hidden */ private _intersectionsInProgress: AbstractMesh[];
  25390. /** @hidden */ private _unIndexed: boolean;
  25391. /** @hidden */ private _lightSources: Light[];
  25392. /** Gets the list of lights affecting that mesh */
  25393. readonly lightSources: Light[];
  25394. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  25395. /** @hidden */ private _waitingData: {
  25396. lods: Nullable<any>;
  25397. actions: Nullable<any>;
  25398. freezeWorldMatrix: Nullable<boolean>;
  25399. };
  25400. /** @hidden */ private _bonesTransformMatrices: Nullable<Float32Array>;
  25401. /** @hidden */ private _transformMatrixTexture: Nullable<RawTexture>;
  25402. /**
  25403. * Gets or sets a skeleton to apply skining transformations
  25404. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25405. */
  25406. skeleton: Nullable<Skeleton>;
  25407. /**
  25408. * An event triggered when the mesh is rebuilt.
  25409. */
  25410. onRebuildObservable: Observable<AbstractMesh>;
  25411. /**
  25412. * Creates a new AbstractMesh
  25413. * @param name defines the name of the mesh
  25414. * @param scene defines the hosting scene
  25415. */
  25416. constructor(name: string, scene?: Nullable<Scene>);
  25417. /**
  25418. * Returns the string "AbstractMesh"
  25419. * @returns "AbstractMesh"
  25420. */
  25421. getClassName(): string;
  25422. /**
  25423. * Gets a string representation of the current mesh
  25424. * @param fullDetails defines a boolean indicating if full details must be included
  25425. * @returns a string representation of the current mesh
  25426. */
  25427. toString(fullDetails?: boolean): string;
  25428. /**
  25429. * @hidden
  25430. */
  25431. protected _getEffectiveParent(): Nullable<Node>;
  25432. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25433. /** @hidden */ private _rebuild(): void;
  25434. /** @hidden */ private _resyncLightSources(): void;
  25435. /** @hidden */ private _resyncLighSource(light: Light): void;
  25436. /** @hidden */ private _unBindEffect(): void;
  25437. /** @hidden */ private _removeLightSource(light: Light): void;
  25438. private _markSubMeshesAsDirty;
  25439. /** @hidden */ private _markSubMeshesAsLightDirty(): void;
  25440. /** @hidden */ private _markSubMeshesAsAttributesDirty(): void;
  25441. /** @hidden */ private _markSubMeshesAsMiscDirty(): void;
  25442. /**
  25443. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25444. */
  25445. scaling: Vector3;
  25446. /**
  25447. * Returns true if the mesh is blocked. Implemented by child classes
  25448. */
  25449. readonly isBlocked: boolean;
  25450. /**
  25451. * Returns the mesh itself by default. Implemented by child classes
  25452. * @param camera defines the camera to use to pick the right LOD level
  25453. * @returns the currentAbstractMesh
  25454. */
  25455. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25456. /**
  25457. * Returns 0 by default. Implemented by child classes
  25458. * @returns an integer
  25459. */
  25460. getTotalVertices(): number;
  25461. /**
  25462. * Returns a positive integer : the total number of indices in this mesh geometry.
  25463. * @returns the numner of indices or zero if the mesh has no geometry.
  25464. */
  25465. getTotalIndices(): number;
  25466. /**
  25467. * Returns null by default. Implemented by child classes
  25468. * @returns null
  25469. */
  25470. getIndices(): Nullable<IndicesArray>;
  25471. /**
  25472. * Returns the array of the requested vertex data kind. Implemented by child classes
  25473. * @param kind defines the vertex data kind to use
  25474. * @returns null
  25475. */
  25476. getVerticesData(kind: string): Nullable<FloatArray>;
  25477. /**
  25478. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25479. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25480. * Note that a new underlying VertexBuffer object is created each call.
  25481. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25482. * @param kind defines vertex data kind:
  25483. * * VertexBuffer.PositionKind
  25484. * * VertexBuffer.UVKind
  25485. * * VertexBuffer.UV2Kind
  25486. * * VertexBuffer.UV3Kind
  25487. * * VertexBuffer.UV4Kind
  25488. * * VertexBuffer.UV5Kind
  25489. * * VertexBuffer.UV6Kind
  25490. * * VertexBuffer.ColorKind
  25491. * * VertexBuffer.MatricesIndicesKind
  25492. * * VertexBuffer.MatricesIndicesExtraKind
  25493. * * VertexBuffer.MatricesWeightsKind
  25494. * * VertexBuffer.MatricesWeightsExtraKind
  25495. * @param data defines the data source
  25496. * @param updatable defines if the data must be flagged as updatable (or static)
  25497. * @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
  25498. * @returns the current mesh
  25499. */
  25500. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25501. /**
  25502. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25503. * If the mesh has no geometry, it is simply returned as it is.
  25504. * @param kind defines vertex data kind:
  25505. * * VertexBuffer.PositionKind
  25506. * * VertexBuffer.UVKind
  25507. * * VertexBuffer.UV2Kind
  25508. * * VertexBuffer.UV3Kind
  25509. * * VertexBuffer.UV4Kind
  25510. * * VertexBuffer.UV5Kind
  25511. * * VertexBuffer.UV6Kind
  25512. * * VertexBuffer.ColorKind
  25513. * * VertexBuffer.MatricesIndicesKind
  25514. * * VertexBuffer.MatricesIndicesExtraKind
  25515. * * VertexBuffer.MatricesWeightsKind
  25516. * * VertexBuffer.MatricesWeightsExtraKind
  25517. * @param data defines the data source
  25518. * @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
  25519. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25520. * @returns the current mesh
  25521. */
  25522. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25523. /**
  25524. * Sets the mesh indices,
  25525. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25526. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25527. * @param totalVertices Defines the total number of vertices
  25528. * @returns the current mesh
  25529. */
  25530. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25531. /**
  25532. * Gets a boolean indicating if specific vertex data is present
  25533. * @param kind defines the vertex data kind to use
  25534. * @returns true is data kind is present
  25535. */
  25536. isVerticesDataPresent(kind: string): boolean;
  25537. /**
  25538. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  25539. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  25540. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  25541. * @returns a BoundingInfo
  25542. */
  25543. getBoundingInfo(): BoundingInfo;
  25544. /**
  25545. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25546. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25547. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25548. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  25549. * @returns the current mesh
  25550. */
  25551. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  25552. /**
  25553. * Overwrite the current bounding info
  25554. * @param boundingInfo defines the new bounding info
  25555. * @returns the current mesh
  25556. */
  25557. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25558. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25559. readonly useBones: boolean;
  25560. /** @hidden */ private _preActivate(): void;
  25561. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): void;
  25562. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  25563. /** @hidden */ private _postActivate(): void;
  25564. /** @hidden */ private _freeze(): void;
  25565. /** @hidden */ private _unFreeze(): void;
  25566. /**
  25567. * Gets the current world matrix
  25568. * @returns a Matrix
  25569. */
  25570. getWorldMatrix(): Matrix;
  25571. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  25572. /**
  25573. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25574. */
  25575. readonly isAnInstance: boolean;
  25576. /**
  25577. * Gets a boolean indicating if this mesh has instances
  25578. */
  25579. readonly hasInstances: boolean;
  25580. /**
  25581. * Perform relative position change from the point of view of behind the front of the mesh.
  25582. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25583. * Supports definition of mesh facing forward or backward
  25584. * @param amountRight defines the distance on the right axis
  25585. * @param amountUp defines the distance on the up axis
  25586. * @param amountForward defines the distance on the forward axis
  25587. * @returns the current mesh
  25588. */
  25589. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25590. /**
  25591. * Calculate relative position change from the point of view of behind the front of the mesh.
  25592. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25593. * Supports definition of mesh facing forward or backward
  25594. * @param amountRight defines the distance on the right axis
  25595. * @param amountUp defines the distance on the up axis
  25596. * @param amountForward defines the distance on the forward axis
  25597. * @returns the new displacement vector
  25598. */
  25599. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25600. /**
  25601. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25602. * Supports definition of mesh facing forward or backward
  25603. * @param flipBack defines the flip
  25604. * @param twirlClockwise defines the twirl
  25605. * @param tiltRight defines the tilt
  25606. * @returns the current mesh
  25607. */
  25608. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25609. /**
  25610. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25611. * Supports definition of mesh facing forward or backward.
  25612. * @param flipBack defines the flip
  25613. * @param twirlClockwise defines the twirl
  25614. * @param tiltRight defines the tilt
  25615. * @returns the new rotation vector
  25616. */
  25617. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25618. /**
  25619. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25620. * This means the mesh underlying bounding box and sphere are recomputed.
  25621. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25622. * @returns the current mesh
  25623. */
  25624. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25625. /** @hidden */ private _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25626. /** @hidden */ private _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25627. /** @hidden */ private _updateBoundingInfo(): AbstractMesh;
  25628. /** @hidden */ private _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25629. /** @hidden */
  25630. protected _afterComputeWorldMatrix(): void;
  25631. /** @hidden */ protected readonly _effectiveMesh: AbstractMesh;
  25632. /**
  25633. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25634. * A mesh is in the frustum if its bounding box intersects the frustum
  25635. * @param frustumPlanes defines the frustum to test
  25636. * @returns true if the mesh is in the frustum planes
  25637. */
  25638. isInFrustum(frustumPlanes: Plane[]): boolean;
  25639. /**
  25640. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25641. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25642. * @param frustumPlanes defines the frustum to test
  25643. * @returns true if the mesh is completely in the frustum planes
  25644. */
  25645. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25646. /**
  25647. * True if the mesh intersects another mesh or a SolidParticle object
  25648. * @param mesh defines a target mesh or SolidParticle to test
  25649. * @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)
  25650. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25651. * @returns true if there is an intersection
  25652. */
  25653. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25654. /**
  25655. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25656. * @param point defines the point to test
  25657. * @returns true if there is an intersection
  25658. */
  25659. intersectsPoint(point: Vector3): boolean;
  25660. /**
  25661. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25662. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25663. */
  25664. checkCollisions: boolean;
  25665. /**
  25666. * Gets Collider object used to compute collisions (not physics)
  25667. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25668. */
  25669. readonly collider: Nullable<Collider>;
  25670. /**
  25671. * Move the mesh using collision engine
  25672. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25673. * @param displacement defines the requested displacement vector
  25674. * @returns the current mesh
  25675. */
  25676. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25677. private _onCollisionPositionChange;
  25678. /** @hidden */ private _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25679. /** @hidden */ private _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25680. /** @hidden */ private _checkCollision(collider: Collider): AbstractMesh;
  25681. /** @hidden */ private _generatePointsArray(): boolean;
  25682. /**
  25683. * Checks if the passed Ray intersects with the mesh
  25684. * @param ray defines the ray to use
  25685. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25686. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25687. * @returns the picking info
  25688. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25689. */
  25690. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25691. /**
  25692. * Clones the current mesh
  25693. * @param name defines the mesh name
  25694. * @param newParent defines the new mesh parent
  25695. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25696. * @returns the new mesh
  25697. */
  25698. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25699. /**
  25700. * Disposes all the submeshes of the current meshnp
  25701. * @returns the current mesh
  25702. */
  25703. releaseSubMeshes(): AbstractMesh;
  25704. /**
  25705. * Releases resources associated with this abstract mesh.
  25706. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25707. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25708. */
  25709. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25710. /**
  25711. * Adds the passed mesh as a child to the current mesh
  25712. * @param mesh defines the child mesh
  25713. * @returns the current mesh
  25714. */
  25715. addChild(mesh: AbstractMesh): AbstractMesh;
  25716. /**
  25717. * Removes the passed mesh from the current mesh children list
  25718. * @param mesh defines the child mesh
  25719. * @returns the current mesh
  25720. */
  25721. removeChild(mesh: AbstractMesh): AbstractMesh;
  25722. /** @hidden */
  25723. private _initFacetData;
  25724. /**
  25725. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25726. * This method can be called within the render loop.
  25727. * 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
  25728. * @returns the current mesh
  25729. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25730. */
  25731. updateFacetData(): AbstractMesh;
  25732. /**
  25733. * Returns the facetLocalNormals array.
  25734. * The normals are expressed in the mesh local spac
  25735. * @returns an array of Vector3
  25736. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25737. */
  25738. getFacetLocalNormals(): Vector3[];
  25739. /**
  25740. * Returns the facetLocalPositions array.
  25741. * The facet positions are expressed in the mesh local space
  25742. * @returns an array of Vector3
  25743. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25744. */
  25745. getFacetLocalPositions(): Vector3[];
  25746. /**
  25747. * Returns the facetLocalPartioning array
  25748. * @returns an array of array of numbers
  25749. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25750. */
  25751. getFacetLocalPartitioning(): number[][];
  25752. /**
  25753. * Returns the i-th facet position in the world system.
  25754. * This method allocates a new Vector3 per call
  25755. * @param i defines the facet index
  25756. * @returns a new Vector3
  25757. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25758. */
  25759. getFacetPosition(i: number): Vector3;
  25760. /**
  25761. * Sets the reference Vector3 with the i-th facet position in the world system
  25762. * @param i defines the facet index
  25763. * @param ref defines the target vector
  25764. * @returns the current mesh
  25765. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25766. */
  25767. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25768. /**
  25769. * Returns the i-th facet normal in the world system.
  25770. * This method allocates a new Vector3 per call
  25771. * @param i defines the facet index
  25772. * @returns a new Vector3
  25773. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25774. */
  25775. getFacetNormal(i: number): Vector3;
  25776. /**
  25777. * Sets the reference Vector3 with the i-th facet normal in the world system
  25778. * @param i defines the facet index
  25779. * @param ref defines the target vector
  25780. * @returns the current mesh
  25781. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25782. */
  25783. getFacetNormalToRef(i: number, ref: Vector3): this;
  25784. /**
  25785. * 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)
  25786. * @param x defines x coordinate
  25787. * @param y defines y coordinate
  25788. * @param z defines z coordinate
  25789. * @returns the array of facet indexes
  25790. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25791. */
  25792. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25793. /**
  25794. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25795. * @param projected sets as the (x,y,z) world projection on the facet
  25796. * @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
  25797. * @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
  25798. * @param x defines x coordinate
  25799. * @param y defines y coordinate
  25800. * @param z defines z coordinate
  25801. * @returns the face index if found (or null instead)
  25802. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25803. */
  25804. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25805. /**
  25806. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25807. * @param projected sets as the (x,y,z) local projection on the facet
  25808. * @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
  25809. * @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
  25810. * @param x defines x coordinate
  25811. * @param y defines y coordinate
  25812. * @param z defines z coordinate
  25813. * @returns the face index if found (or null instead)
  25814. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25815. */
  25816. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25817. /**
  25818. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25819. * @returns the parameters
  25820. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25821. */
  25822. getFacetDataParameters(): any;
  25823. /**
  25824. * Disables the feature FacetData and frees the related memory
  25825. * @returns the current mesh
  25826. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25827. */
  25828. disableFacetData(): AbstractMesh;
  25829. /**
  25830. * Updates the AbstractMesh indices array
  25831. * @param indices defines the data source
  25832. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25833. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  25834. * @returns the current mesh
  25835. */
  25836. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25837. /**
  25838. * Creates new normals data for the mesh
  25839. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25840. * @returns the current mesh
  25841. */
  25842. createNormals(updatable: boolean): AbstractMesh;
  25843. /**
  25844. * Align the mesh with a normal
  25845. * @param normal defines the normal to use
  25846. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25847. * @returns the current mesh
  25848. */
  25849. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25850. /** @hidden */ private _checkOcclusionQuery(): boolean;
  25851. /**
  25852. * Disables the mesh edge rendering mode
  25853. * @returns the currentAbstractMesh
  25854. */
  25855. disableEdgesRendering(): AbstractMesh;
  25856. /**
  25857. * Enables the edge rendering mode on the mesh.
  25858. * This mode makes the mesh edges visible
  25859. * @param epsilon defines the maximal distance between two angles to detect a face
  25860. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25861. * @returns the currentAbstractMesh
  25862. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25863. */
  25864. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25865. }
  25866. }
  25867. declare module BABYLON {
  25868. /**
  25869. * Interface used to define ActionEvent
  25870. */
  25871. export interface IActionEvent {
  25872. /** The mesh or sprite that triggered the action */
  25873. source: any;
  25874. /** The X mouse cursor position at the time of the event */
  25875. pointerX: number;
  25876. /** The Y mouse cursor position at the time of the event */
  25877. pointerY: number;
  25878. /** The mesh that is currently pointed at (can be null) */
  25879. meshUnderPointer: Nullable<AbstractMesh>;
  25880. /** the original (browser) event that triggered the ActionEvent */
  25881. sourceEvent?: any;
  25882. /** additional data for the event */
  25883. additionalData?: any;
  25884. }
  25885. /**
  25886. * ActionEvent is the event being sent when an action is triggered.
  25887. */
  25888. export class ActionEvent implements IActionEvent {
  25889. /** The mesh or sprite that triggered the action */
  25890. source: any;
  25891. /** The X mouse cursor position at the time of the event */
  25892. pointerX: number;
  25893. /** The Y mouse cursor position at the time of the event */
  25894. pointerY: number;
  25895. /** The mesh that is currently pointed at (can be null) */
  25896. meshUnderPointer: Nullable<AbstractMesh>;
  25897. /** the original (browser) event that triggered the ActionEvent */
  25898. sourceEvent?: any;
  25899. /** additional data for the event */
  25900. additionalData?: any;
  25901. /**
  25902. * Creates a new ActionEvent
  25903. * @param source The mesh or sprite that triggered the action
  25904. * @param pointerX The X mouse cursor position at the time of the event
  25905. * @param pointerY The Y mouse cursor position at the time of the event
  25906. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25907. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25908. * @param additionalData additional data for the event
  25909. */
  25910. constructor(
  25911. /** The mesh or sprite that triggered the action */
  25912. source: any,
  25913. /** The X mouse cursor position at the time of the event */
  25914. pointerX: number,
  25915. /** The Y mouse cursor position at the time of the event */
  25916. pointerY: number,
  25917. /** The mesh that is currently pointed at (can be null) */
  25918. meshUnderPointer: Nullable<AbstractMesh>,
  25919. /** the original (browser) event that triggered the ActionEvent */
  25920. sourceEvent?: any,
  25921. /** additional data for the event */
  25922. additionalData?: any);
  25923. /**
  25924. * Helper function to auto-create an ActionEvent from a source mesh.
  25925. * @param source The source mesh that triggered the event
  25926. * @param evt The original (browser) event
  25927. * @param additionalData additional data for the event
  25928. * @returns the new ActionEvent
  25929. */
  25930. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25931. /**
  25932. * Helper function to auto-create an ActionEvent from a source sprite
  25933. * @param source The source sprite that triggered the event
  25934. * @param scene Scene associated with the sprite
  25935. * @param evt The original (browser) event
  25936. * @param additionalData additional data for the event
  25937. * @returns the new ActionEvent
  25938. */
  25939. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25940. /**
  25941. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25942. * @param scene the scene where the event occurred
  25943. * @param evt The original (browser) event
  25944. * @returns the new ActionEvent
  25945. */
  25946. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25947. /**
  25948. * Helper function to auto-create an ActionEvent from a primitive
  25949. * @param prim defines the target primitive
  25950. * @param pointerPos defines the pointer position
  25951. * @param evt The original (browser) event
  25952. * @param additionalData additional data for the event
  25953. * @returns the new ActionEvent
  25954. */
  25955. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25956. }
  25957. }
  25958. declare module BABYLON {
  25959. /**
  25960. * Abstract class used to decouple action Manager from scene and meshes.
  25961. * Do not instantiate.
  25962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25963. */
  25964. export abstract class AbstractActionManager implements IDisposable {
  25965. /** Gets the list of active triggers */
  25966. static Triggers: {
  25967. [key: string]: number;
  25968. };
  25969. /** Gets the cursor to use when hovering items */
  25970. hoverCursor: string;
  25971. /** Gets the list of actions */
  25972. actions: IAction[];
  25973. /**
  25974. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25975. */
  25976. isRecursive: boolean;
  25977. /**
  25978. * Releases all associated resources
  25979. */
  25980. abstract dispose(): void;
  25981. /**
  25982. * Does this action manager has pointer triggers
  25983. */
  25984. abstract readonly hasPointerTriggers: boolean;
  25985. /**
  25986. * Does this action manager has pick triggers
  25987. */
  25988. abstract readonly hasPickTriggers: boolean;
  25989. /**
  25990. * Process a specific trigger
  25991. * @param trigger defines the trigger to process
  25992. * @param evt defines the event details to be processed
  25993. */
  25994. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25995. /**
  25996. * Does this action manager handles actions of any of the given triggers
  25997. * @param triggers defines the triggers to be tested
  25998. * @return a boolean indicating whether one (or more) of the triggers is handled
  25999. */
  26000. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26001. /**
  26002. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26003. * speed.
  26004. * @param triggerA defines the trigger to be tested
  26005. * @param triggerB defines the trigger to be tested
  26006. * @return a boolean indicating whether one (or more) of the triggers is handled
  26007. */
  26008. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26009. /**
  26010. * Does this action manager handles actions of a given trigger
  26011. * @param trigger defines the trigger to be tested
  26012. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26013. * @return whether the trigger is handled
  26014. */
  26015. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26016. /**
  26017. * Serialize this manager to a JSON object
  26018. * @param name defines the property name to store this manager
  26019. * @returns a JSON representation of this manager
  26020. */
  26021. abstract serialize(name: string): any;
  26022. /**
  26023. * Registers an action to this action manager
  26024. * @param action defines the action to be registered
  26025. * @return the action amended (prepared) after registration
  26026. */
  26027. abstract registerAction(action: IAction): Nullable<IAction>;
  26028. /**
  26029. * Unregisters an action to this action manager
  26030. * @param action defines the action to be unregistered
  26031. * @return a boolean indicating whether the action has been unregistered
  26032. */
  26033. abstract unregisterAction(action: IAction): Boolean;
  26034. /**
  26035. * Does exist one action manager with at least one trigger
  26036. **/
  26037. static readonly HasTriggers: boolean;
  26038. /**
  26039. * Does exist one action manager with at least one pick trigger
  26040. **/
  26041. static readonly HasPickTriggers: boolean;
  26042. /**
  26043. * Does exist one action manager that handles actions of a given trigger
  26044. * @param trigger defines the trigger to be tested
  26045. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26046. **/
  26047. static HasSpecificTrigger(trigger: number): boolean;
  26048. }
  26049. }
  26050. declare module BABYLON {
  26051. /**
  26052. * Defines how a node can be built from a string name.
  26053. */
  26054. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26055. /**
  26056. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26057. */
  26058. export class Node implements IBehaviorAware<Node> {
  26059. /** @hidden */ private static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26060. private static _NodeConstructors;
  26061. /**
  26062. * Add a new node constructor
  26063. * @param type defines the type name of the node to construct
  26064. * @param constructorFunc defines the constructor function
  26065. */
  26066. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26067. /**
  26068. * Returns a node constructor based on type name
  26069. * @param type defines the type name
  26070. * @param name defines the new node name
  26071. * @param scene defines the hosting scene
  26072. * @param options defines optional options to transmit to constructors
  26073. * @returns the new constructor or null
  26074. */
  26075. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26076. /**
  26077. * Gets or sets the name of the node
  26078. */
  26079. name: string;
  26080. /**
  26081. * Gets or sets the id of the node
  26082. */
  26083. id: string;
  26084. /**
  26085. * Gets or sets the unique id of the node
  26086. */
  26087. uniqueId: number;
  26088. /**
  26089. * Gets or sets a string used to store user defined state for the node
  26090. */
  26091. state: string;
  26092. /**
  26093. * Gets or sets an object used to store user defined information for the node
  26094. */
  26095. metadata: any;
  26096. /**
  26097. * For internal use only. Please do not use.
  26098. */
  26099. reservedDataStore: any;
  26100. /**
  26101. * List of inspectable custom properties (used by the Inspector)
  26102. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26103. */
  26104. inspectableCustomProperties: IInspectable[];
  26105. /**
  26106. * Gets or sets a boolean used to define if the node must be serialized
  26107. */
  26108. doNotSerialize: boolean;
  26109. /** @hidden */ private _isDisposed: boolean;
  26110. /**
  26111. * Gets a list of Animations associated with the node
  26112. */
  26113. animations: Animation[];
  26114. protected _ranges: {
  26115. [name: string]: Nullable<AnimationRange>;
  26116. };
  26117. /**
  26118. * Callback raised when the node is ready to be used
  26119. */
  26120. onReady: Nullable<(node: Node) => void>;
  26121. private _isEnabled;
  26122. private _isParentEnabled;
  26123. private _isReady;
  26124. /** @hidden */ private _currentRenderId: number;
  26125. private _parentUpdateId;
  26126. /** @hidden */ private _childUpdateId: number;
  26127. /** @hidden */ private _waitingParentId: Nullable<string>;
  26128. /** @hidden */ private _scene: Scene;
  26129. /** @hidden */ private _cache: any;
  26130. private _parentNode;
  26131. private _children;
  26132. /** @hidden */ private _worldMatrix: Matrix;
  26133. /** @hidden */ private _worldMatrixDeterminant: number;
  26134. /** @hidden */ private _worldMatrixDeterminantIsDirty: boolean;
  26135. /** @hidden */
  26136. private _sceneRootNodesIndex;
  26137. /**
  26138. * Gets a boolean indicating if the node has been disposed
  26139. * @returns true if the node was disposed
  26140. */
  26141. isDisposed(): boolean;
  26142. /**
  26143. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26144. * @see https://doc.babylonjs.com/how_to/parenting
  26145. */
  26146. parent: Nullable<Node>;
  26147. private addToSceneRootNodes;
  26148. private removeFromSceneRootNodes;
  26149. private _animationPropertiesOverride;
  26150. /**
  26151. * Gets or sets the animation properties override
  26152. */
  26153. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26154. /**
  26155. * Gets a string idenfifying the name of the class
  26156. * @returns "Node" string
  26157. */
  26158. getClassName(): string;
  26159. /** @hidden */ protected readonly _isNode: boolean;
  26160. /**
  26161. * An event triggered when the mesh is disposed
  26162. */
  26163. onDisposeObservable: Observable<Node>;
  26164. private _onDisposeObserver;
  26165. /**
  26166. * Sets a callback that will be raised when the node will be disposed
  26167. */
  26168. onDispose: () => void;
  26169. /**
  26170. * Creates a new Node
  26171. * @param name the name and id to be given to this node
  26172. * @param scene the scene this node will be added to
  26173. * @param addToRootNodes the node will be added to scene.rootNodes
  26174. */
  26175. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26176. /**
  26177. * Gets the scene of the node
  26178. * @returns a scene
  26179. */
  26180. getScene(): Scene;
  26181. /**
  26182. * Gets the engine of the node
  26183. * @returns a Engine
  26184. */
  26185. getEngine(): Engine;
  26186. private _behaviors;
  26187. /**
  26188. * Attach a behavior to the node
  26189. * @see http://doc.babylonjs.com/features/behaviour
  26190. * @param behavior defines the behavior to attach
  26191. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26192. * @returns the current Node
  26193. */
  26194. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26195. /**
  26196. * Remove an attached behavior
  26197. * @see http://doc.babylonjs.com/features/behaviour
  26198. * @param behavior defines the behavior to attach
  26199. * @returns the current Node
  26200. */
  26201. removeBehavior(behavior: Behavior<Node>): Node;
  26202. /**
  26203. * Gets the list of attached behaviors
  26204. * @see http://doc.babylonjs.com/features/behaviour
  26205. */
  26206. readonly behaviors: Behavior<Node>[];
  26207. /**
  26208. * Gets an attached behavior by name
  26209. * @param name defines the name of the behavior to look for
  26210. * @see http://doc.babylonjs.com/features/behaviour
  26211. * @returns null if behavior was not found else the requested behavior
  26212. */
  26213. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26214. /**
  26215. * Returns the latest update of the World matrix
  26216. * @returns a Matrix
  26217. */
  26218. getWorldMatrix(): Matrix;
  26219. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  26220. /**
  26221. * Returns directly the latest state of the mesh World matrix.
  26222. * A Matrix is returned.
  26223. */
  26224. readonly worldMatrixFromCache: Matrix;
  26225. /** @hidden */ private _initCache(): void;
  26226. /** @hidden */
  26227. updateCache(force?: boolean): void;
  26228. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26229. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  26230. /** @hidden */ private _isSynchronized(): boolean;
  26231. /** @hidden */ private _markSyncedWithParent(): void;
  26232. /** @hidden */
  26233. isSynchronizedWithParent(): boolean;
  26234. /** @hidden */
  26235. isSynchronized(): boolean;
  26236. /**
  26237. * Is this node ready to be used/rendered
  26238. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26239. * @return true if the node is ready
  26240. */
  26241. isReady(completeCheck?: boolean): boolean;
  26242. /**
  26243. * Is this node enabled?
  26244. * 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
  26245. * @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
  26246. * @return whether this node (and its parent) is enabled
  26247. */
  26248. isEnabled(checkAncestors?: boolean): boolean;
  26249. /** @hidden */
  26250. protected _syncParentEnabledState(): void;
  26251. /**
  26252. * Set the enabled state of this node
  26253. * @param value defines the new enabled state
  26254. */
  26255. setEnabled(value: boolean): void;
  26256. /**
  26257. * Is this node a descendant of the given node?
  26258. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26259. * @param ancestor defines the parent node to inspect
  26260. * @returns a boolean indicating if this node is a descendant of the given node
  26261. */
  26262. isDescendantOf(ancestor: Node): boolean;
  26263. /** @hidden */ private _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26264. /**
  26265. * Will return all nodes that have this node as ascendant
  26266. * @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
  26267. * @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
  26268. * @return all children nodes of all types
  26269. */
  26270. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26271. /**
  26272. * Get all child-meshes of this node
  26273. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  26274. * @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
  26275. * @returns an array of AbstractMesh
  26276. */
  26277. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26278. /**
  26279. * Get all direct children of this node
  26280. * @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
  26281. * @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)
  26282. * @returns an array of Node
  26283. */
  26284. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26285. /** @hidden */ private _setReady(state: boolean): void;
  26286. /**
  26287. * Get an animation by name
  26288. * @param name defines the name of the animation to look for
  26289. * @returns null if not found else the requested animation
  26290. */
  26291. getAnimationByName(name: string): Nullable<Animation>;
  26292. /**
  26293. * Creates an animation range for this node
  26294. * @param name defines the name of the range
  26295. * @param from defines the starting key
  26296. * @param to defines the end key
  26297. */
  26298. createAnimationRange(name: string, from: number, to: number): void;
  26299. /**
  26300. * Delete a specific animation range
  26301. * @param name defines the name of the range to delete
  26302. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26303. */
  26304. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26305. /**
  26306. * Get an animation range by name
  26307. * @param name defines the name of the animation range to look for
  26308. * @returns null if not found else the requested animation range
  26309. */
  26310. getAnimationRange(name: string): Nullable<AnimationRange>;
  26311. /**
  26312. * Gets the list of all animation ranges defined on this node
  26313. * @returns an array
  26314. */
  26315. getAnimationRanges(): Nullable<AnimationRange>[];
  26316. /**
  26317. * Will start the animation sequence
  26318. * @param name defines the range frames for animation sequence
  26319. * @param loop defines if the animation should loop (false by default)
  26320. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26321. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26322. * @returns the object created for this animation. If range does not exist, it will return null
  26323. */
  26324. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26325. /**
  26326. * Serialize animation ranges into a JSON compatible object
  26327. * @returns serialization object
  26328. */
  26329. serializeAnimationRanges(): any;
  26330. /**
  26331. * Computes the world matrix of the node
  26332. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26333. * @returns the world matrix
  26334. */
  26335. computeWorldMatrix(force?: boolean): Matrix;
  26336. /**
  26337. * Releases resources associated with this node.
  26338. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26339. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26340. */
  26341. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26342. /**
  26343. * Parse animation range data from a serialization object and store them into a given node
  26344. * @param node defines where to store the animation ranges
  26345. * @param parsedNode defines the serialization object to read data from
  26346. * @param scene defines the hosting scene
  26347. */
  26348. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26349. /**
  26350. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26351. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26352. * @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
  26353. * @returns the new bounding vectors
  26354. */
  26355. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26356. min: Vector3;
  26357. max: Vector3;
  26358. };
  26359. }
  26360. }
  26361. declare module BABYLON {
  26362. /**
  26363. * @hidden
  26364. */
  26365. export class _IAnimationState {
  26366. key: number;
  26367. repeatCount: number;
  26368. workValue?: any;
  26369. loopMode?: number;
  26370. offsetValue?: any;
  26371. highLimitValue?: any;
  26372. }
  26373. /**
  26374. * Class used to store any kind of animation
  26375. */
  26376. export class Animation {
  26377. /**Name of the animation */
  26378. name: string;
  26379. /**Property to animate */
  26380. targetProperty: string;
  26381. /**The frames per second of the animation */
  26382. framePerSecond: number;
  26383. /**The data type of the animation */
  26384. dataType: number;
  26385. /**The loop mode of the animation */
  26386. loopMode?: number | undefined;
  26387. /**Specifies if blending should be enabled */
  26388. enableBlending?: boolean | undefined;
  26389. /**
  26390. * Use matrix interpolation instead of using direct key value when animating matrices
  26391. */
  26392. static AllowMatricesInterpolation: boolean;
  26393. /**
  26394. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26395. */
  26396. static AllowMatrixDecomposeForInterpolation: boolean;
  26397. /**
  26398. * Stores the key frames of the animation
  26399. */
  26400. private _keys;
  26401. /**
  26402. * Stores the easing function of the animation
  26403. */
  26404. private _easingFunction;
  26405. /**
  26406. * @hidden Internal use only
  26407. */ private _runtimeAnimations: RuntimeAnimation[];
  26408. /**
  26409. * The set of event that will be linked to this animation
  26410. */
  26411. private _events;
  26412. /**
  26413. * Stores an array of target property paths
  26414. */
  26415. targetPropertyPath: string[];
  26416. /**
  26417. * Stores the blending speed of the animation
  26418. */
  26419. blendingSpeed: number;
  26420. /**
  26421. * Stores the animation ranges for the animation
  26422. */
  26423. private _ranges;
  26424. /**
  26425. * @hidden Internal use
  26426. */ private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26427. /**
  26428. * Sets up an animation
  26429. * @param property The property to animate
  26430. * @param animationType The animation type to apply
  26431. * @param framePerSecond The frames per second of the animation
  26432. * @param easingFunction The easing function used in the animation
  26433. * @returns The created animation
  26434. */
  26435. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26436. /**
  26437. * Create and start an animation on a node
  26438. * @param name defines the name of the global animation that will be run on all nodes
  26439. * @param node defines the root node where the animation will take place
  26440. * @param targetProperty defines property to animate
  26441. * @param framePerSecond defines the number of frame per second yo use
  26442. * @param totalFrame defines the number of frames in total
  26443. * @param from defines the initial value
  26444. * @param to defines the final value
  26445. * @param loopMode defines which loop mode you want to use (off by default)
  26446. * @param easingFunction defines the easing function to use (linear by default)
  26447. * @param onAnimationEnd defines the callback to call when animation end
  26448. * @returns the animatable created for this animation
  26449. */
  26450. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26451. /**
  26452. * Create and start an animation on a node and its descendants
  26453. * @param name defines the name of the global animation that will be run on all nodes
  26454. * @param node defines the root node where the animation will take place
  26455. * @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
  26456. * @param targetProperty defines property to animate
  26457. * @param framePerSecond defines the number of frame per second to use
  26458. * @param totalFrame defines the number of frames in total
  26459. * @param from defines the initial value
  26460. * @param to defines the final value
  26461. * @param loopMode defines which loop mode you want to use (off by default)
  26462. * @param easingFunction defines the easing function to use (linear by default)
  26463. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26464. * @returns the list of animatables created for all nodes
  26465. * @example https://www.babylonjs-playground.com/#MH0VLI
  26466. */
  26467. 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[]>;
  26468. /**
  26469. * Creates a new animation, merges it with the existing animations and starts it
  26470. * @param name Name of the animation
  26471. * @param node Node which contains the scene that begins the animations
  26472. * @param targetProperty Specifies which property to animate
  26473. * @param framePerSecond The frames per second of the animation
  26474. * @param totalFrame The total number of frames
  26475. * @param from The frame at the beginning of the animation
  26476. * @param to The frame at the end of the animation
  26477. * @param loopMode Specifies the loop mode of the animation
  26478. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26479. * @param onAnimationEnd Callback to run once the animation is complete
  26480. * @returns Nullable animation
  26481. */
  26482. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26483. /**
  26484. * Transition property of an host to the target Value
  26485. * @param property The property to transition
  26486. * @param targetValue The target Value of the property
  26487. * @param host The object where the property to animate belongs
  26488. * @param scene Scene used to run the animation
  26489. * @param frameRate Framerate (in frame/s) to use
  26490. * @param transition The transition type we want to use
  26491. * @param duration The duration of the animation, in milliseconds
  26492. * @param onAnimationEnd Callback trigger at the end of the animation
  26493. * @returns Nullable animation
  26494. */
  26495. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26496. /**
  26497. * Return the array of runtime animations currently using this animation
  26498. */
  26499. readonly runtimeAnimations: RuntimeAnimation[];
  26500. /**
  26501. * Specifies if any of the runtime animations are currently running
  26502. */
  26503. readonly hasRunningRuntimeAnimations: boolean;
  26504. /**
  26505. * Initializes the animation
  26506. * @param name Name of the animation
  26507. * @param targetProperty Property to animate
  26508. * @param framePerSecond The frames per second of the animation
  26509. * @param dataType The data type of the animation
  26510. * @param loopMode The loop mode of the animation
  26511. * @param enableBlending Specifies if blending should be enabled
  26512. */
  26513. constructor(
  26514. /**Name of the animation */
  26515. name: string,
  26516. /**Property to animate */
  26517. targetProperty: string,
  26518. /**The frames per second of the animation */
  26519. framePerSecond: number,
  26520. /**The data type of the animation */
  26521. dataType: number,
  26522. /**The loop mode of the animation */
  26523. loopMode?: number | undefined,
  26524. /**Specifies if blending should be enabled */
  26525. enableBlending?: boolean | undefined);
  26526. /**
  26527. * Converts the animation to a string
  26528. * @param fullDetails support for multiple levels of logging within scene loading
  26529. * @returns String form of the animation
  26530. */
  26531. toString(fullDetails?: boolean): string;
  26532. /**
  26533. * Add an event to this animation
  26534. * @param event Event to add
  26535. */
  26536. addEvent(event: AnimationEvent): void;
  26537. /**
  26538. * Remove all events found at the given frame
  26539. * @param frame The frame to remove events from
  26540. */
  26541. removeEvents(frame: number): void;
  26542. /**
  26543. * Retrieves all the events from the animation
  26544. * @returns Events from the animation
  26545. */
  26546. getEvents(): AnimationEvent[];
  26547. /**
  26548. * Creates an animation range
  26549. * @param name Name of the animation range
  26550. * @param from Starting frame of the animation range
  26551. * @param to Ending frame of the animation
  26552. */
  26553. createRange(name: string, from: number, to: number): void;
  26554. /**
  26555. * Deletes an animation range by name
  26556. * @param name Name of the animation range to delete
  26557. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26558. */
  26559. deleteRange(name: string, deleteFrames?: boolean): void;
  26560. /**
  26561. * Gets the animation range by name, or null if not defined
  26562. * @param name Name of the animation range
  26563. * @returns Nullable animation range
  26564. */
  26565. getRange(name: string): Nullable<AnimationRange>;
  26566. /**
  26567. * Gets the key frames from the animation
  26568. * @returns The key frames of the animation
  26569. */
  26570. getKeys(): Array<IAnimationKey>;
  26571. /**
  26572. * Gets the highest frame rate of the animation
  26573. * @returns Highest frame rate of the animation
  26574. */
  26575. getHighestFrame(): number;
  26576. /**
  26577. * Gets the easing function of the animation
  26578. * @returns Easing function of the animation
  26579. */
  26580. getEasingFunction(): IEasingFunction;
  26581. /**
  26582. * Sets the easing function of the animation
  26583. * @param easingFunction A custom mathematical formula for animation
  26584. */
  26585. setEasingFunction(easingFunction: EasingFunction): void;
  26586. /**
  26587. * Interpolates a scalar linearly
  26588. * @param startValue Start value of the animation curve
  26589. * @param endValue End value of the animation curve
  26590. * @param gradient Scalar amount to interpolate
  26591. * @returns Interpolated scalar value
  26592. */
  26593. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26594. /**
  26595. * Interpolates a scalar cubically
  26596. * @param startValue Start value of the animation curve
  26597. * @param outTangent End tangent of the animation
  26598. * @param endValue End value of the animation curve
  26599. * @param inTangent Start tangent of the animation curve
  26600. * @param gradient Scalar amount to interpolate
  26601. * @returns Interpolated scalar value
  26602. */
  26603. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26604. /**
  26605. * Interpolates a quaternion using a spherical linear interpolation
  26606. * @param startValue Start value of the animation curve
  26607. * @param endValue End value of the animation curve
  26608. * @param gradient Scalar amount to interpolate
  26609. * @returns Interpolated quaternion value
  26610. */
  26611. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26612. /**
  26613. * Interpolates a quaternion cubically
  26614. * @param startValue Start value of the animation curve
  26615. * @param outTangent End tangent of the animation curve
  26616. * @param endValue End value of the animation curve
  26617. * @param inTangent Start tangent of the animation curve
  26618. * @param gradient Scalar amount to interpolate
  26619. * @returns Interpolated quaternion value
  26620. */
  26621. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26622. /**
  26623. * Interpolates a Vector3 linearl
  26624. * @param startValue Start value of the animation curve
  26625. * @param endValue End value of the animation curve
  26626. * @param gradient Scalar amount to interpolate
  26627. * @returns Interpolated scalar value
  26628. */
  26629. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26630. /**
  26631. * Interpolates a Vector3 cubically
  26632. * @param startValue Start value of the animation curve
  26633. * @param outTangent End tangent of the animation
  26634. * @param endValue End value of the animation curve
  26635. * @param inTangent Start tangent of the animation curve
  26636. * @param gradient Scalar amount to interpolate
  26637. * @returns InterpolatedVector3 value
  26638. */
  26639. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26640. /**
  26641. * Interpolates a Vector2 linearly
  26642. * @param startValue Start value of the animation curve
  26643. * @param endValue End value of the animation curve
  26644. * @param gradient Scalar amount to interpolate
  26645. * @returns Interpolated Vector2 value
  26646. */
  26647. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26648. /**
  26649. * Interpolates a Vector2 cubically
  26650. * @param startValue Start value of the animation curve
  26651. * @param outTangent End tangent of the animation
  26652. * @param endValue End value of the animation curve
  26653. * @param inTangent Start tangent of the animation curve
  26654. * @param gradient Scalar amount to interpolate
  26655. * @returns Interpolated Vector2 value
  26656. */
  26657. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26658. /**
  26659. * Interpolates a size linearly
  26660. * @param startValue Start value of the animation curve
  26661. * @param endValue End value of the animation curve
  26662. * @param gradient Scalar amount to interpolate
  26663. * @returns Interpolated Size value
  26664. */
  26665. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26666. /**
  26667. * Interpolates a Color3 linearly
  26668. * @param startValue Start value of the animation curve
  26669. * @param endValue End value of the animation curve
  26670. * @param gradient Scalar amount to interpolate
  26671. * @returns Interpolated Color3 value
  26672. */
  26673. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26674. /**
  26675. * @hidden Internal use only
  26676. */ private _getKeyValue(value: any): any;
  26677. /**
  26678. * @hidden Internal use only
  26679. */ private _interpolate(currentFrame: number, state: _IAnimationState): any;
  26680. /**
  26681. * Defines the function to use to interpolate matrices
  26682. * @param startValue defines the start matrix
  26683. * @param endValue defines the end matrix
  26684. * @param gradient defines the gradient between both matrices
  26685. * @param result defines an optional target matrix where to store the interpolation
  26686. * @returns the interpolated matrix
  26687. */
  26688. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26689. /**
  26690. * Makes a copy of the animation
  26691. * @returns Cloned animation
  26692. */
  26693. clone(): Animation;
  26694. /**
  26695. * Sets the key frames of the animation
  26696. * @param values The animation key frames to set
  26697. */
  26698. setKeys(values: Array<IAnimationKey>): void;
  26699. /**
  26700. * Serializes the animation to an object
  26701. * @returns Serialized object
  26702. */
  26703. serialize(): any;
  26704. /**
  26705. * Float animation type
  26706. */
  26707. private static _ANIMATIONTYPE_FLOAT;
  26708. /**
  26709. * Vector3 animation type
  26710. */
  26711. private static _ANIMATIONTYPE_VECTOR3;
  26712. /**
  26713. * Quaternion animation type
  26714. */
  26715. private static _ANIMATIONTYPE_QUATERNION;
  26716. /**
  26717. * Matrix animation type
  26718. */
  26719. private static _ANIMATIONTYPE_MATRIX;
  26720. /**
  26721. * Color3 animation type
  26722. */
  26723. private static _ANIMATIONTYPE_COLOR3;
  26724. /**
  26725. * Vector2 animation type
  26726. */
  26727. private static _ANIMATIONTYPE_VECTOR2;
  26728. /**
  26729. * Size animation type
  26730. */
  26731. private static _ANIMATIONTYPE_SIZE;
  26732. /**
  26733. * Relative Loop Mode
  26734. */
  26735. private static _ANIMATIONLOOPMODE_RELATIVE;
  26736. /**
  26737. * Cycle Loop Mode
  26738. */
  26739. private static _ANIMATIONLOOPMODE_CYCLE;
  26740. /**
  26741. * Constant Loop Mode
  26742. */
  26743. private static _ANIMATIONLOOPMODE_CONSTANT;
  26744. /**
  26745. * Get the float animation type
  26746. */
  26747. static readonly ANIMATIONTYPE_FLOAT: number;
  26748. /**
  26749. * Get the Vector3 animation type
  26750. */
  26751. static readonly ANIMATIONTYPE_VECTOR3: number;
  26752. /**
  26753. * Get the Vector2 animation type
  26754. */
  26755. static readonly ANIMATIONTYPE_VECTOR2: number;
  26756. /**
  26757. * Get the Size animation type
  26758. */
  26759. static readonly ANIMATIONTYPE_SIZE: number;
  26760. /**
  26761. * Get the Quaternion animation type
  26762. */
  26763. static readonly ANIMATIONTYPE_QUATERNION: number;
  26764. /**
  26765. * Get the Matrix animation type
  26766. */
  26767. static readonly ANIMATIONTYPE_MATRIX: number;
  26768. /**
  26769. * Get the Color3 animation type
  26770. */
  26771. static readonly ANIMATIONTYPE_COLOR3: number;
  26772. /**
  26773. * Get the Relative Loop Mode
  26774. */
  26775. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26776. /**
  26777. * Get the Cycle Loop Mode
  26778. */
  26779. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26780. /**
  26781. * Get the Constant Loop Mode
  26782. */
  26783. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26784. /** @hidden */ private static _UniversalLerp(left: any, right: any, amount: number): any;
  26785. /**
  26786. * Parses an animation object and creates an animation
  26787. * @param parsedAnimation Parsed animation object
  26788. * @returns Animation object
  26789. */
  26790. static Parse(parsedAnimation: any): Animation;
  26791. /**
  26792. * Appends the serialized animations from the source animations
  26793. * @param source Source containing the animations
  26794. * @param destination Target to store the animations
  26795. */
  26796. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26797. }
  26798. }
  26799. declare module BABYLON {
  26800. /**
  26801. * Interface containing an array of animations
  26802. */
  26803. export interface IAnimatable {
  26804. /**
  26805. * Array of animations
  26806. */
  26807. animations: Nullable<Array<Animation>>;
  26808. }
  26809. }
  26810. declare module BABYLON {
  26811. /**
  26812. * This represents all the required information to add a fresnel effect on a material:
  26813. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26814. */
  26815. export class FresnelParameters {
  26816. private _isEnabled;
  26817. /**
  26818. * Define if the fresnel effect is enable or not.
  26819. */
  26820. isEnabled: boolean;
  26821. /**
  26822. * Define the color used on edges (grazing angle)
  26823. */
  26824. leftColor: Color3;
  26825. /**
  26826. * Define the color used on center
  26827. */
  26828. rightColor: Color3;
  26829. /**
  26830. * Define bias applied to computed fresnel term
  26831. */
  26832. bias: number;
  26833. /**
  26834. * Defined the power exponent applied to fresnel term
  26835. */
  26836. power: number;
  26837. /**
  26838. * Clones the current fresnel and its valuues
  26839. * @returns a clone fresnel configuration
  26840. */
  26841. clone(): FresnelParameters;
  26842. /**
  26843. * Serializes the current fresnel parameters to a JSON representation.
  26844. * @return the JSON serialization
  26845. */
  26846. serialize(): any;
  26847. /**
  26848. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26849. * @param parsedFresnelParameters Define the JSON representation
  26850. * @returns the parsed parameters
  26851. */
  26852. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26853. }
  26854. }
  26855. declare module BABYLON {
  26856. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  26857. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26858. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26859. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26860. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26861. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26862. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26863. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26864. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26865. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26866. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26867. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26868. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26869. /**
  26870. * Decorator used to define property that can be serialized as reference to a camera
  26871. * @param sourceName defines the name of the property to decorate
  26872. */
  26873. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26874. /**
  26875. * Class used to help serialization objects
  26876. */
  26877. export class SerializationHelper {
  26878. /** @hidden */ private static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  26879. /** @hidden */ private static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  26880. /** @hidden */ private static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  26881. /** @hidden */ private static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  26882. /**
  26883. * Appends the serialized animations from the source animations
  26884. * @param source Source containing the animations
  26885. * @param destination Target to store the animations
  26886. */
  26887. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26888. /**
  26889. * Static function used to serialized a specific entity
  26890. * @param entity defines the entity to serialize
  26891. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  26892. * @returns a JSON compatible object representing the serialization of the entity
  26893. */
  26894. static Serialize<T>(entity: T, serializationObject?: any): any;
  26895. /**
  26896. * Creates a new entity from a serialization data object
  26897. * @param creationFunction defines a function used to instanciated the new entity
  26898. * @param source defines the source serialization data
  26899. * @param scene defines the hosting scene
  26900. * @param rootUrl defines the root url for resources
  26901. * @returns a new entity
  26902. */
  26903. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  26904. /**
  26905. * Clones an object
  26906. * @param creationFunction defines the function used to instanciate the new object
  26907. * @param source defines the source object
  26908. * @returns the cloned object
  26909. */
  26910. static Clone<T>(creationFunction: () => T, source: T): T;
  26911. /**
  26912. * Instanciates a new object based on a source one (some data will be shared between both object)
  26913. * @param creationFunction defines the function used to instanciate the new object
  26914. * @param source defines the source object
  26915. * @returns the new object
  26916. */
  26917. static Instanciate<T>(creationFunction: () => T, source: T): T;
  26918. }
  26919. }
  26920. declare module BABYLON {
  26921. /**
  26922. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  26923. */
  26924. export interface CubeMapInfo {
  26925. /**
  26926. * The pixel array for the front face.
  26927. * This is stored in format, left to right, up to down format.
  26928. */
  26929. front: Nullable<ArrayBufferView>;
  26930. /**
  26931. * The pixel array for the back face.
  26932. * This is stored in format, left to right, up to down format.
  26933. */
  26934. back: Nullable<ArrayBufferView>;
  26935. /**
  26936. * The pixel array for the left face.
  26937. * This is stored in format, left to right, up to down format.
  26938. */
  26939. left: Nullable<ArrayBufferView>;
  26940. /**
  26941. * The pixel array for the right face.
  26942. * This is stored in format, left to right, up to down format.
  26943. */
  26944. right: Nullable<ArrayBufferView>;
  26945. /**
  26946. * The pixel array for the up face.
  26947. * This is stored in format, left to right, up to down format.
  26948. */
  26949. up: Nullable<ArrayBufferView>;
  26950. /**
  26951. * The pixel array for the down face.
  26952. * This is stored in format, left to right, up to down format.
  26953. */
  26954. down: Nullable<ArrayBufferView>;
  26955. /**
  26956. * The size of the cubemap stored.
  26957. *
  26958. * Each faces will be size * size pixels.
  26959. */
  26960. size: number;
  26961. /**
  26962. * The format of the texture.
  26963. *
  26964. * RGBA, RGB.
  26965. */
  26966. format: number;
  26967. /**
  26968. * The type of the texture data.
  26969. *
  26970. * UNSIGNED_INT, FLOAT.
  26971. */
  26972. type: number;
  26973. /**
  26974. * Specifies whether the texture is in gamma space.
  26975. */
  26976. gammaSpace: boolean;
  26977. }
  26978. /**
  26979. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  26980. */
  26981. export class PanoramaToCubeMapTools {
  26982. private static FACE_FRONT;
  26983. private static FACE_BACK;
  26984. private static FACE_RIGHT;
  26985. private static FACE_LEFT;
  26986. private static FACE_DOWN;
  26987. private static FACE_UP;
  26988. /**
  26989. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  26990. *
  26991. * @param float32Array The source data.
  26992. * @param inputWidth The width of the input panorama.
  26993. * @param inputHeight The height of the input panorama.
  26994. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  26995. * @return The cubemap data
  26996. */
  26997. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  26998. private static CreateCubemapTexture;
  26999. private static CalcProjectionSpherical;
  27000. }
  27001. }
  27002. declare module BABYLON {
  27003. /**
  27004. * Helper class dealing with the extraction of spherical polynomial dataArray
  27005. * from a cube map.
  27006. */
  27007. export class CubeMapToSphericalPolynomialTools {
  27008. private static FileFaces;
  27009. /**
  27010. * Converts a texture to the according Spherical Polynomial data.
  27011. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27012. *
  27013. * @param texture The texture to extract the information from.
  27014. * @return The Spherical Polynomial data.
  27015. */
  27016. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  27017. /**
  27018. * Converts a cubemap to the according Spherical Polynomial data.
  27019. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27020. *
  27021. * @param cubeInfo The Cube map to extract the information from.
  27022. * @return The Spherical Polynomial data.
  27023. */
  27024. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  27025. }
  27026. }
  27027. declare module BABYLON {
  27028. /**
  27029. * Class used to manipulate GUIDs
  27030. */
  27031. export class GUID {
  27032. /**
  27033. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27034. * Be aware Math.random() could cause collisions, but:
  27035. * "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"
  27036. * @returns a pseudo random id
  27037. */
  27038. static RandomId(): string;
  27039. }
  27040. }
  27041. declare module BABYLON {
  27042. /**
  27043. * Base class of all the textures in babylon.
  27044. * It groups all the common properties the materials, post process, lights... might need
  27045. * in order to make a correct use of the texture.
  27046. */
  27047. export class BaseTexture implements IAnimatable {
  27048. /**
  27049. * Default anisotropic filtering level for the application.
  27050. * It is set to 4 as a good tradeoff between perf and quality.
  27051. */
  27052. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27053. /**
  27054. * Gets or sets the unique id of the texture
  27055. */
  27056. uniqueId: number;
  27057. /**
  27058. * Define the name of the texture.
  27059. */
  27060. name: string;
  27061. /**
  27062. * Gets or sets an object used to store user defined information.
  27063. */
  27064. metadata: any;
  27065. /**
  27066. * For internal use only. Please do not use.
  27067. */
  27068. reservedDataStore: any;
  27069. private _hasAlpha;
  27070. /**
  27071. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27072. */
  27073. hasAlpha: boolean;
  27074. /**
  27075. * Defines if the alpha value should be determined via the rgb values.
  27076. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27077. */
  27078. getAlphaFromRGB: boolean;
  27079. /**
  27080. * Intensity or strength of the texture.
  27081. * It is commonly used by materials to fine tune the intensity of the texture
  27082. */
  27083. level: number;
  27084. /**
  27085. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27086. * This is part of the texture as textures usually maps to one uv set.
  27087. */
  27088. coordinatesIndex: number;
  27089. private _coordinatesMode;
  27090. /**
  27091. * How a texture is mapped.
  27092. *
  27093. * | Value | Type | Description |
  27094. * | ----- | ----------------------------------- | ----------- |
  27095. * | 0 | EXPLICIT_MODE | |
  27096. * | 1 | SPHERICAL_MODE | |
  27097. * | 2 | PLANAR_MODE | |
  27098. * | 3 | CUBIC_MODE | |
  27099. * | 4 | PROJECTION_MODE | |
  27100. * | 5 | SKYBOX_MODE | |
  27101. * | 6 | INVCUBIC_MODE | |
  27102. * | 7 | EQUIRECTANGULAR_MODE | |
  27103. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27104. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27105. */
  27106. coordinatesMode: number;
  27107. /**
  27108. * | Value | Type | Description |
  27109. * | ----- | ------------------ | ----------- |
  27110. * | 0 | CLAMP_ADDRESSMODE | |
  27111. * | 1 | WRAP_ADDRESSMODE | |
  27112. * | 2 | MIRROR_ADDRESSMODE | |
  27113. */
  27114. wrapU: number;
  27115. /**
  27116. * | Value | Type | Description |
  27117. * | ----- | ------------------ | ----------- |
  27118. * | 0 | CLAMP_ADDRESSMODE | |
  27119. * | 1 | WRAP_ADDRESSMODE | |
  27120. * | 2 | MIRROR_ADDRESSMODE | |
  27121. */
  27122. wrapV: number;
  27123. /**
  27124. * | Value | Type | Description |
  27125. * | ----- | ------------------ | ----------- |
  27126. * | 0 | CLAMP_ADDRESSMODE | |
  27127. * | 1 | WRAP_ADDRESSMODE | |
  27128. * | 2 | MIRROR_ADDRESSMODE | |
  27129. */
  27130. wrapR: number;
  27131. /**
  27132. * With compliant hardware and browser (supporting anisotropic filtering)
  27133. * this defines the level of anisotropic filtering in the texture.
  27134. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27135. */
  27136. anisotropicFilteringLevel: number;
  27137. /**
  27138. * Define if the texture is a cube texture or if false a 2d texture.
  27139. */
  27140. isCube: boolean;
  27141. /**
  27142. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27143. */
  27144. is3D: boolean;
  27145. /**
  27146. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27147. * HDR texture are usually stored in linear space.
  27148. * This only impacts the PBR and Background materials
  27149. */
  27150. gammaSpace: boolean;
  27151. /**
  27152. * Gets whether or not the texture contains RGBD data.
  27153. */
  27154. readonly isRGBD: boolean;
  27155. /**
  27156. * Is Z inverted in the texture (useful in a cube texture).
  27157. */
  27158. invertZ: boolean;
  27159. /**
  27160. * Are mip maps generated for this texture or not.
  27161. */
  27162. readonly noMipmap: boolean;
  27163. /**
  27164. * @hidden
  27165. */
  27166. lodLevelInAlpha: boolean;
  27167. /**
  27168. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27169. */
  27170. lodGenerationOffset: number;
  27171. /**
  27172. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27173. */
  27174. lodGenerationScale: number;
  27175. /**
  27176. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27177. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27178. * average roughness values.
  27179. */
  27180. linearSpecularLOD: boolean;
  27181. /**
  27182. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27183. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27184. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27185. */
  27186. irradianceTexture: Nullable<BaseTexture>;
  27187. /**
  27188. * Define if the texture is a render target.
  27189. */
  27190. isRenderTarget: boolean;
  27191. /**
  27192. * Define the unique id of the texture in the scene.
  27193. */
  27194. readonly uid: string;
  27195. /**
  27196. * Return a string representation of the texture.
  27197. * @returns the texture as a string
  27198. */
  27199. toString(): string;
  27200. /**
  27201. * Get the class name of the texture.
  27202. * @returns "BaseTexture"
  27203. */
  27204. getClassName(): string;
  27205. /**
  27206. * Define the list of animation attached to the texture.
  27207. */
  27208. animations: Animation[];
  27209. /**
  27210. * An event triggered when the texture is disposed.
  27211. */
  27212. onDisposeObservable: Observable<BaseTexture>;
  27213. private _onDisposeObserver;
  27214. /**
  27215. * Callback triggered when the texture has been disposed.
  27216. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27217. */
  27218. onDispose: () => void;
  27219. /**
  27220. * Define the current state of the loading sequence when in delayed load mode.
  27221. */
  27222. delayLoadState: number;
  27223. private _scene;
  27224. /** @hidden */ private _texture: Nullable<InternalTexture>;
  27225. private _uid;
  27226. /**
  27227. * Define if the texture is preventinga material to render or not.
  27228. * If not and the texture is not ready, the engine will use a default black texture instead.
  27229. */
  27230. readonly isBlocking: boolean;
  27231. /**
  27232. * Instantiates a new BaseTexture.
  27233. * Base class of all the textures in babylon.
  27234. * It groups all the common properties the materials, post process, lights... might need
  27235. * in order to make a correct use of the texture.
  27236. * @param scene Define the scene the texture blongs to
  27237. */
  27238. constructor(scene: Nullable<Scene>);
  27239. /**
  27240. * Get the scene the texture belongs to.
  27241. * @returns the scene or null if undefined
  27242. */
  27243. getScene(): Nullable<Scene>;
  27244. /**
  27245. * Get the texture transform matrix used to offset tile the texture for istance.
  27246. * @returns the transformation matrix
  27247. */
  27248. getTextureMatrix(): Matrix;
  27249. /**
  27250. * Get the texture reflection matrix used to rotate/transform the reflection.
  27251. * @returns the reflection matrix
  27252. */
  27253. getReflectionTextureMatrix(): Matrix;
  27254. /**
  27255. * Get the underlying lower level texture from Babylon.
  27256. * @returns the insternal texture
  27257. */
  27258. getInternalTexture(): Nullable<InternalTexture>;
  27259. /**
  27260. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27261. * @returns true if ready or not blocking
  27262. */
  27263. isReadyOrNotBlocking(): boolean;
  27264. /**
  27265. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27266. * @returns true if fully ready
  27267. */
  27268. isReady(): boolean;
  27269. private _cachedSize;
  27270. /**
  27271. * Get the size of the texture.
  27272. * @returns the texture size.
  27273. */
  27274. getSize(): ISize;
  27275. /**
  27276. * Get the base size of the texture.
  27277. * It can be different from the size if the texture has been resized for POT for instance
  27278. * @returns the base size
  27279. */
  27280. getBaseSize(): ISize;
  27281. /**
  27282. * Update the sampling mode of the texture.
  27283. * Default is Trilinear mode.
  27284. *
  27285. * | Value | Type | Description |
  27286. * | ----- | ------------------ | ----------- |
  27287. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27288. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27289. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27290. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27291. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27292. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27293. * | 7 | NEAREST_LINEAR | |
  27294. * | 8 | NEAREST_NEAREST | |
  27295. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27296. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27297. * | 11 | LINEAR_LINEAR | |
  27298. * | 12 | LINEAR_NEAREST | |
  27299. *
  27300. * > _mag_: magnification filter (close to the viewer)
  27301. * > _min_: minification filter (far from the viewer)
  27302. * > _mip_: filter used between mip map levels
  27303. *@param samplingMode Define the new sampling mode of the texture
  27304. */
  27305. updateSamplingMode(samplingMode: number): void;
  27306. /**
  27307. * Scales the texture if is `canRescale()`
  27308. * @param ratio the resize factor we want to use to rescale
  27309. */
  27310. scale(ratio: number): void;
  27311. /**
  27312. * Get if the texture can rescale.
  27313. */
  27314. readonly canRescale: boolean;
  27315. /** @hidden */ private _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27316. /** @hidden */ private _rebuild(): void;
  27317. /**
  27318. * Triggers the load sequence in delayed load mode.
  27319. */
  27320. delayLoad(): void;
  27321. /**
  27322. * Clones the texture.
  27323. * @returns the cloned texture
  27324. */
  27325. clone(): Nullable<BaseTexture>;
  27326. /**
  27327. * Get the texture underlying type (INT, FLOAT...)
  27328. */
  27329. readonly textureType: number;
  27330. /**
  27331. * Get the texture underlying format (RGB, RGBA...)
  27332. */
  27333. readonly textureFormat: number;
  27334. /**
  27335. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27336. * This will returns an RGBA array buffer containing either in values (0-255) or
  27337. * float values (0-1) depending of the underlying buffer type.
  27338. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27339. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27340. * @param buffer defines a user defined buffer to fill with data (can be null)
  27341. * @returns The Array buffer containing the pixels data.
  27342. */
  27343. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27344. /**
  27345. * Release and destroy the underlying lower level texture aka internalTexture.
  27346. */
  27347. releaseInternalTexture(): void;
  27348. /**
  27349. * Get the polynomial representation of the texture data.
  27350. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27351. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27352. */
  27353. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27354. /** @hidden */ protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  27355. /** @hidden */ protected readonly _lodTextureMid: Nullable<BaseTexture>;
  27356. /** @hidden */ protected readonly _lodTextureLow: Nullable<BaseTexture>;
  27357. /**
  27358. * Dispose the texture and release its associated resources.
  27359. */
  27360. dispose(): void;
  27361. /**
  27362. * Serialize the texture into a JSON representation that can be parsed later on.
  27363. * @returns the JSON representation of the texture
  27364. */
  27365. serialize(): any;
  27366. /**
  27367. * Helper function to be called back once a list of texture contains only ready textures.
  27368. * @param textures Define the list of textures to wait for
  27369. * @param callback Define the callback triggered once the entire list will be ready
  27370. */
  27371. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27372. }
  27373. }
  27374. declare module BABYLON {
  27375. /**
  27376. * Class used to store data associated with WebGL texture data for the engine
  27377. * This class should not be used directly
  27378. */
  27379. export class InternalTexture {
  27380. /** @hidden */ private static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  27381. /**
  27382. * The source of the texture data is unknown
  27383. */
  27384. static DATASOURCE_UNKNOWN: number;
  27385. /**
  27386. * Texture data comes from an URL
  27387. */
  27388. static DATASOURCE_URL: number;
  27389. /**
  27390. * Texture data is only used for temporary storage
  27391. */
  27392. static DATASOURCE_TEMP: number;
  27393. /**
  27394. * Texture data comes from raw data (ArrayBuffer)
  27395. */
  27396. static DATASOURCE_RAW: number;
  27397. /**
  27398. * Texture content is dynamic (video or dynamic texture)
  27399. */
  27400. static DATASOURCE_DYNAMIC: number;
  27401. /**
  27402. * Texture content is generated by rendering to it
  27403. */
  27404. static DATASOURCE_RENDERTARGET: number;
  27405. /**
  27406. * Texture content is part of a multi render target process
  27407. */
  27408. static DATASOURCE_MULTIRENDERTARGET: number;
  27409. /**
  27410. * Texture data comes from a cube data file
  27411. */
  27412. static DATASOURCE_CUBE: number;
  27413. /**
  27414. * Texture data comes from a raw cube data
  27415. */
  27416. static DATASOURCE_CUBERAW: number;
  27417. /**
  27418. * Texture data come from a prefiltered cube data file
  27419. */
  27420. static DATASOURCE_CUBEPREFILTERED: number;
  27421. /**
  27422. * Texture content is raw 3D data
  27423. */
  27424. static DATASOURCE_RAW3D: number;
  27425. /**
  27426. * Texture content is a depth texture
  27427. */
  27428. static DATASOURCE_DEPTHTEXTURE: number;
  27429. /**
  27430. * Texture data comes from a raw cube data encoded with RGBD
  27431. */
  27432. static DATASOURCE_CUBERAW_RGBD: number;
  27433. /**
  27434. * Defines if the texture is ready
  27435. */
  27436. isReady: boolean;
  27437. /**
  27438. * Defines if the texture is a cube texture
  27439. */
  27440. isCube: boolean;
  27441. /**
  27442. * Defines if the texture contains 3D data
  27443. */
  27444. is3D: boolean;
  27445. /**
  27446. * Defines if the texture contains multiview data
  27447. */
  27448. isMultiview: boolean;
  27449. /**
  27450. * Gets the URL used to load this texture
  27451. */
  27452. url: string;
  27453. /**
  27454. * Gets the sampling mode of the texture
  27455. */
  27456. samplingMode: number;
  27457. /**
  27458. * Gets a boolean indicating if the texture needs mipmaps generation
  27459. */
  27460. generateMipMaps: boolean;
  27461. /**
  27462. * Gets the number of samples used by the texture (WebGL2+ only)
  27463. */
  27464. samples: number;
  27465. /**
  27466. * Gets the type of the texture (int, float...)
  27467. */
  27468. type: number;
  27469. /**
  27470. * Gets the format of the texture (RGB, RGBA...)
  27471. */
  27472. format: number;
  27473. /**
  27474. * Observable called when the texture is loaded
  27475. */
  27476. onLoadedObservable: Observable<InternalTexture>;
  27477. /**
  27478. * Gets the width of the texture
  27479. */
  27480. width: number;
  27481. /**
  27482. * Gets the height of the texture
  27483. */
  27484. height: number;
  27485. /**
  27486. * Gets the depth of the texture
  27487. */
  27488. depth: number;
  27489. /**
  27490. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  27491. */
  27492. baseWidth: number;
  27493. /**
  27494. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  27495. */
  27496. baseHeight: number;
  27497. /**
  27498. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  27499. */
  27500. baseDepth: number;
  27501. /**
  27502. * Gets a boolean indicating if the texture is inverted on Y axis
  27503. */
  27504. invertY: boolean;
  27505. /** @hidden */ private _invertVScale: boolean;
  27506. /** @hidden */ private _associatedChannel: number;
  27507. /** @hidden */ private _dataSource: number;
  27508. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  27509. /** @hidden */ private _bufferView: Nullable<ArrayBufferView>;
  27510. /** @hidden */ private _bufferViewArray: Nullable<ArrayBufferView[]>;
  27511. /** @hidden */ private _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  27512. /** @hidden */ private _size: number;
  27513. /** @hidden */ private _extension: string;
  27514. /** @hidden */ private _files: Nullable<string[]>;
  27515. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement>;
  27516. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D>;
  27517. /** @hidden */ private _framebuffer: Nullable<WebGLFramebuffer>;
  27518. /** @hidden */ private _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  27519. /** @hidden */ private _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  27520. /** @hidden */ private _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  27521. /** @hidden */ private _attachments: Nullable<number[]>;
  27522. /** @hidden */ private _cachedCoordinatesMode: Nullable<number>;
  27523. /** @hidden */ private _cachedWrapU: Nullable<number>;
  27524. /** @hidden */ private _cachedWrapV: Nullable<number>;
  27525. /** @hidden */ private _cachedWrapR: Nullable<number>;
  27526. /** @hidden */ private _cachedAnisotropicFilteringLevel: Nullable<number>;
  27527. /** @hidden */ private _isDisabled: boolean;
  27528. /** @hidden */ private _compression: Nullable<string>;
  27529. /** @hidden */ private _generateStencilBuffer: boolean;
  27530. /** @hidden */ private _generateDepthBuffer: boolean;
  27531. /** @hidden */ private _comparisonFunction: number;
  27532. /** @hidden */ private _sphericalPolynomial: Nullable<SphericalPolynomial>;
  27533. /** @hidden */ private _lodGenerationScale: number;
  27534. /** @hidden */ private _lodGenerationOffset: number;
  27535. /** @hidden */ private _colorTextureArray: Nullable<WebGLTexture>;
  27536. /** @hidden */ private _depthStencilTextureArray: Nullable<WebGLTexture>;
  27537. /** @hidden */ private _lodTextureHigh: Nullable<BaseTexture>;
  27538. /** @hidden */ private _lodTextureMid: Nullable<BaseTexture>;
  27539. /** @hidden */ private _lodTextureLow: Nullable<BaseTexture>;
  27540. /** @hidden */ private _isRGBD: boolean;
  27541. /** @hidden */ private _linearSpecularLOD: boolean;
  27542. /** @hidden */ private _irradianceTexture: Nullable<BaseTexture>;
  27543. /** @hidden */ private _webGLTexture: Nullable<WebGLTexture>;
  27544. /** @hidden */ private _references: number;
  27545. private _engine;
  27546. /**
  27547. * Gets the Engine the texture belongs to.
  27548. * @returns The babylon engine
  27549. */
  27550. getEngine(): Engine;
  27551. /**
  27552. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  27553. */
  27554. readonly dataSource: number;
  27555. /**
  27556. * Creates a new InternalTexture
  27557. * @param engine defines the engine to use
  27558. * @param dataSource defines the type of data that will be used
  27559. * @param delayAllocation if the texture allocation should be delayed (default: false)
  27560. */
  27561. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  27562. /**
  27563. * Increments the number of references (ie. the number of Texture that point to it)
  27564. */
  27565. incrementReferences(): void;
  27566. /**
  27567. * Change the size of the texture (not the size of the content)
  27568. * @param width defines the new width
  27569. * @param height defines the new height
  27570. * @param depth defines the new depth (1 by default)
  27571. */
  27572. updateSize(width: int, height: int, depth?: int): void;
  27573. /** @hidden */ private _rebuild(): void;
  27574. /** @hidden */ private _swapAndDie(target: InternalTexture): void;
  27575. /**
  27576. * Dispose the current allocated resources
  27577. */
  27578. dispose(): void;
  27579. }
  27580. }
  27581. declare module BABYLON {
  27582. /**
  27583. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  27584. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  27585. */
  27586. export class EffectFallbacks {
  27587. private _defines;
  27588. private _currentRank;
  27589. private _maxRank;
  27590. private _mesh;
  27591. /**
  27592. * Removes the fallback from the bound mesh.
  27593. */
  27594. unBindMesh(): void;
  27595. /**
  27596. * Adds a fallback on the specified property.
  27597. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  27598. * @param define The name of the define in the shader
  27599. */
  27600. addFallback(rank: number, define: string): void;
  27601. /**
  27602. * Sets the mesh to use CPU skinning when needing to fallback.
  27603. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  27604. * @param mesh The mesh to use the fallbacks.
  27605. */
  27606. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  27607. /**
  27608. * Checks to see if more fallbacks are still availible.
  27609. */
  27610. readonly isMoreFallbacks: boolean;
  27611. /**
  27612. * Removes the defines that should be removed when falling back.
  27613. * @param currentDefines defines the current define statements for the shader.
  27614. * @param effect defines the current effect we try to compile
  27615. * @returns The resulting defines with defines of the current rank removed.
  27616. */
  27617. reduce(currentDefines: string, effect: Effect): string;
  27618. }
  27619. /**
  27620. * Options to be used when creating an effect.
  27621. */
  27622. export class EffectCreationOptions {
  27623. /**
  27624. * Atrributes that will be used in the shader.
  27625. */
  27626. attributes: string[];
  27627. /**
  27628. * Uniform varible names that will be set in the shader.
  27629. */
  27630. uniformsNames: string[];
  27631. /**
  27632. * Uniform buffer varible names that will be set in the shader.
  27633. */
  27634. uniformBuffersNames: string[];
  27635. /**
  27636. * Sampler texture variable names that will be set in the shader.
  27637. */
  27638. samplers: string[];
  27639. /**
  27640. * Define statements that will be set in the shader.
  27641. */
  27642. defines: any;
  27643. /**
  27644. * Possible fallbacks for this effect to improve performance when needed.
  27645. */
  27646. fallbacks: Nullable<EffectFallbacks>;
  27647. /**
  27648. * Callback that will be called when the shader is compiled.
  27649. */
  27650. onCompiled: Nullable<(effect: Effect) => void>;
  27651. /**
  27652. * Callback that will be called if an error occurs during shader compilation.
  27653. */
  27654. onError: Nullable<(effect: Effect, errors: string) => void>;
  27655. /**
  27656. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  27657. */
  27658. indexParameters: any;
  27659. /**
  27660. * Max number of lights that can be used in the shader.
  27661. */
  27662. maxSimultaneousLights: number;
  27663. /**
  27664. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  27665. */
  27666. transformFeedbackVaryings: Nullable<string[]>;
  27667. }
  27668. /**
  27669. * Effect containing vertex and fragment shader that can be executed on an object.
  27670. */
  27671. export class Effect implements IDisposable {
  27672. /**
  27673. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27674. */
  27675. static ShadersRepository: string;
  27676. /**
  27677. * Name of the effect.
  27678. */
  27679. name: any;
  27680. /**
  27681. * String container all the define statements that should be set on the shader.
  27682. */
  27683. defines: string;
  27684. /**
  27685. * Callback that will be called when the shader is compiled.
  27686. */
  27687. onCompiled: Nullable<(effect: Effect) => void>;
  27688. /**
  27689. * Callback that will be called if an error occurs during shader compilation.
  27690. */
  27691. onError: Nullable<(effect: Effect, errors: string) => void>;
  27692. /**
  27693. * Callback that will be called when effect is bound.
  27694. */
  27695. onBind: Nullable<(effect: Effect) => void>;
  27696. /**
  27697. * Unique ID of the effect.
  27698. */
  27699. uniqueId: number;
  27700. /**
  27701. * Observable that will be called when the shader is compiled.
  27702. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  27703. */
  27704. onCompileObservable: Observable<Effect>;
  27705. /**
  27706. * Observable that will be called if an error occurs during shader compilation.
  27707. */
  27708. onErrorObservable: Observable<Effect>;
  27709. /** @hidden */ private _onBindObservable: Nullable<Observable<Effect>>;
  27710. /**
  27711. * Observable that will be called when effect is bound.
  27712. */
  27713. readonly onBindObservable: Observable<Effect>;
  27714. /** @hidden */ private _bonesComputationForcedToCPU: boolean;
  27715. private static _uniqueIdSeed;
  27716. private _engine;
  27717. private _uniformBuffersNames;
  27718. private _uniformsNames;
  27719. private _samplerList;
  27720. private _samplers;
  27721. private _isReady;
  27722. private _compilationError;
  27723. private _attributesNames;
  27724. private _attributes;
  27725. private _uniforms;
  27726. /**
  27727. * Key for the effect.
  27728. * @hidden
  27729. */ private _key: string;
  27730. private _indexParameters;
  27731. private _fallbacks;
  27732. private _vertexSourceCode;
  27733. private _fragmentSourceCode;
  27734. private _vertexSourceCodeOverride;
  27735. private _fragmentSourceCodeOverride;
  27736. private _transformFeedbackVaryings;
  27737. /**
  27738. * Compiled shader to webGL program.
  27739. * @hidden
  27740. */ private _pipelineContext: Nullable<IPipelineContext>;
  27741. private _valueCache;
  27742. private static _baseCache;
  27743. /**
  27744. * Instantiates an effect.
  27745. * An effect can be used to create/manage/execute vertex and fragment shaders.
  27746. * @param baseName Name of the effect.
  27747. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  27748. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  27749. * @param samplers List of sampler variables that will be passed to the shader.
  27750. * @param engine Engine to be used to render the effect
  27751. * @param defines Define statements to be added to the shader.
  27752. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  27753. * @param onCompiled Callback that will be called when the shader is compiled.
  27754. * @param onError Callback that will be called if an error occurs during shader compilation.
  27755. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  27756. */
  27757. 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);
  27758. private _useFinalCode;
  27759. /**
  27760. * Unique key for this effect
  27761. */
  27762. readonly key: string;
  27763. /**
  27764. * If the effect has been compiled and prepared.
  27765. * @returns if the effect is compiled and prepared.
  27766. */
  27767. isReady(): boolean;
  27768. private _isReadyInternal;
  27769. /**
  27770. * The engine the effect was initialized with.
  27771. * @returns the engine.
  27772. */
  27773. getEngine(): Engine;
  27774. /**
  27775. * The pipeline context for this effect
  27776. * @returns the associated pipeline context
  27777. */
  27778. getPipelineContext(): Nullable<IPipelineContext>;
  27779. /**
  27780. * The set of names of attribute variables for the shader.
  27781. * @returns An array of attribute names.
  27782. */
  27783. getAttributesNames(): string[];
  27784. /**
  27785. * Returns the attribute at the given index.
  27786. * @param index The index of the attribute.
  27787. * @returns The location of the attribute.
  27788. */
  27789. getAttributeLocation(index: number): number;
  27790. /**
  27791. * Returns the attribute based on the name of the variable.
  27792. * @param name of the attribute to look up.
  27793. * @returns the attribute location.
  27794. */
  27795. getAttributeLocationByName(name: string): number;
  27796. /**
  27797. * The number of attributes.
  27798. * @returns the numnber of attributes.
  27799. */
  27800. getAttributesCount(): number;
  27801. /**
  27802. * Gets the index of a uniform variable.
  27803. * @param uniformName of the uniform to look up.
  27804. * @returns the index.
  27805. */
  27806. getUniformIndex(uniformName: string): number;
  27807. /**
  27808. * Returns the attribute based on the name of the variable.
  27809. * @param uniformName of the uniform to look up.
  27810. * @returns the location of the uniform.
  27811. */
  27812. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  27813. /**
  27814. * Returns an array of sampler variable names
  27815. * @returns The array of sampler variable neames.
  27816. */
  27817. getSamplers(): string[];
  27818. /**
  27819. * The error from the last compilation.
  27820. * @returns the error string.
  27821. */
  27822. getCompilationError(): string;
  27823. /**
  27824. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  27825. * @param func The callback to be used.
  27826. */
  27827. executeWhenCompiled(func: (effect: Effect) => void): void;
  27828. private _checkIsReady;
  27829. /** @hidden */ private _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  27830. /** @hidden */ private _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  27831. /** @hidden */ private _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  27832. /**
  27833. * Recompiles the webGL program
  27834. * @param vertexSourceCode The source code for the vertex shader.
  27835. * @param fragmentSourceCode The source code for the fragment shader.
  27836. * @param onCompiled Callback called when completed.
  27837. * @param onError Callback called on error.
  27838. * @hidden
  27839. */ private _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  27840. /**
  27841. * Prepares the effect
  27842. * @hidden
  27843. */ private _prepareEffect(): void;
  27844. private _processCompilationErrors;
  27845. /**
  27846. * Checks if the effect is supported. (Must be called after compilation)
  27847. */
  27848. readonly isSupported: boolean;
  27849. /**
  27850. * Binds a texture to the engine to be used as output of the shader.
  27851. * @param channel Name of the output variable.
  27852. * @param texture Texture to bind.
  27853. * @hidden
  27854. */ private _bindTexture(channel: string, texture: InternalTexture): void;
  27855. /**
  27856. * Sets a texture on the engine to be used in the shader.
  27857. * @param channel Name of the sampler variable.
  27858. * @param texture Texture to set.
  27859. */
  27860. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  27861. /**
  27862. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  27863. * @param channel Name of the sampler variable.
  27864. * @param texture Texture to set.
  27865. */
  27866. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  27867. /**
  27868. * Sets an array of textures on the engine to be used in the shader.
  27869. * @param channel Name of the variable.
  27870. * @param textures Textures to set.
  27871. */
  27872. setTextureArray(channel: string, textures: BaseTexture[]): void;
  27873. /**
  27874. * 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)
  27875. * @param channel Name of the sampler variable.
  27876. * @param postProcess Post process to get the input texture from.
  27877. */
  27878. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  27879. /**
  27880. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  27881. * 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)
  27882. * @param channel Name of the sampler variable.
  27883. * @param postProcess Post process to get the output texture from.
  27884. */
  27885. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  27886. /** @hidden */ private _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  27887. /** @hidden */ private _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  27888. /** @hidden */ private _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  27889. /** @hidden */ private _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  27890. /**
  27891. * Binds a buffer to a uniform.
  27892. * @param buffer Buffer to bind.
  27893. * @param name Name of the uniform variable to bind to.
  27894. */
  27895. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  27896. /**
  27897. * Binds block to a uniform.
  27898. * @param blockName Name of the block to bind.
  27899. * @param index Index to bind.
  27900. */
  27901. bindUniformBlock(blockName: string, index: number): void;
  27902. /**
  27903. * Sets an interger value on a uniform variable.
  27904. * @param uniformName Name of the variable.
  27905. * @param value Value to be set.
  27906. * @returns this effect.
  27907. */
  27908. setInt(uniformName: string, value: number): Effect;
  27909. /**
  27910. * Sets an int array on a uniform variable.
  27911. * @param uniformName Name of the variable.
  27912. * @param array array to be set.
  27913. * @returns this effect.
  27914. */
  27915. setIntArray(uniformName: string, array: Int32Array): Effect;
  27916. /**
  27917. * 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)
  27918. * @param uniformName Name of the variable.
  27919. * @param array array to be set.
  27920. * @returns this effect.
  27921. */
  27922. setIntArray2(uniformName: string, array: Int32Array): Effect;
  27923. /**
  27924. * 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)
  27925. * @param uniformName Name of the variable.
  27926. * @param array array to be set.
  27927. * @returns this effect.
  27928. */
  27929. setIntArray3(uniformName: string, array: Int32Array): Effect;
  27930. /**
  27931. * 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)
  27932. * @param uniformName Name of the variable.
  27933. * @param array array to be set.
  27934. * @returns this effect.
  27935. */
  27936. setIntArray4(uniformName: string, array: Int32Array): Effect;
  27937. /**
  27938. * Sets an float array on a uniform variable.
  27939. * @param uniformName Name of the variable.
  27940. * @param array array to be set.
  27941. * @returns this effect.
  27942. */
  27943. setFloatArray(uniformName: string, array: Float32Array): Effect;
  27944. /**
  27945. * 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)
  27946. * @param uniformName Name of the variable.
  27947. * @param array array to be set.
  27948. * @returns this effect.
  27949. */
  27950. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  27951. /**
  27952. * 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)
  27953. * @param uniformName Name of the variable.
  27954. * @param array array to be set.
  27955. * @returns this effect.
  27956. */
  27957. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  27958. /**
  27959. * 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)
  27960. * @param uniformName Name of the variable.
  27961. * @param array array to be set.
  27962. * @returns this effect.
  27963. */
  27964. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  27965. /**
  27966. * Sets an array on a uniform variable.
  27967. * @param uniformName Name of the variable.
  27968. * @param array array to be set.
  27969. * @returns this effect.
  27970. */
  27971. setArray(uniformName: string, array: number[]): Effect;
  27972. /**
  27973. * 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)
  27974. * @param uniformName Name of the variable.
  27975. * @param array array to be set.
  27976. * @returns this effect.
  27977. */
  27978. setArray2(uniformName: string, array: number[]): Effect;
  27979. /**
  27980. * 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)
  27981. * @param uniformName Name of the variable.
  27982. * @param array array to be set.
  27983. * @returns this effect.
  27984. */
  27985. setArray3(uniformName: string, array: number[]): Effect;
  27986. /**
  27987. * 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)
  27988. * @param uniformName Name of the variable.
  27989. * @param array array to be set.
  27990. * @returns this effect.
  27991. */
  27992. setArray4(uniformName: string, array: number[]): Effect;
  27993. /**
  27994. * Sets matrices on a uniform variable.
  27995. * @param uniformName Name of the variable.
  27996. * @param matrices matrices to be set.
  27997. * @returns this effect.
  27998. */
  27999. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28000. /**
  28001. * Sets matrix on a uniform variable.
  28002. * @param uniformName Name of the variable.
  28003. * @param matrix matrix to be set.
  28004. * @returns this effect.
  28005. */
  28006. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28007. /**
  28008. * 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)
  28009. * @param uniformName Name of the variable.
  28010. * @param matrix matrix to be set.
  28011. * @returns this effect.
  28012. */
  28013. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28014. /**
  28015. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28016. * @param uniformName Name of the variable.
  28017. * @param matrix matrix to be set.
  28018. * @returns this effect.
  28019. */
  28020. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28021. /**
  28022. * Sets a float on a uniform variable.
  28023. * @param uniformName Name of the variable.
  28024. * @param value value to be set.
  28025. * @returns this effect.
  28026. */
  28027. setFloat(uniformName: string, value: number): Effect;
  28028. /**
  28029. * Sets a boolean on a uniform variable.
  28030. * @param uniformName Name of the variable.
  28031. * @param bool value to be set.
  28032. * @returns this effect.
  28033. */
  28034. setBool(uniformName: string, bool: boolean): Effect;
  28035. /**
  28036. * Sets a Vector2 on a uniform variable.
  28037. * @param uniformName Name of the variable.
  28038. * @param vector2 vector2 to be set.
  28039. * @returns this effect.
  28040. */
  28041. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28042. /**
  28043. * Sets a float2 on a uniform variable.
  28044. * @param uniformName Name of the variable.
  28045. * @param x First float in float2.
  28046. * @param y Second float in float2.
  28047. * @returns this effect.
  28048. */
  28049. setFloat2(uniformName: string, x: number, y: number): Effect;
  28050. /**
  28051. * Sets a Vector3 on a uniform variable.
  28052. * @param uniformName Name of the variable.
  28053. * @param vector3 Value to be set.
  28054. * @returns this effect.
  28055. */
  28056. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28057. /**
  28058. * Sets a float3 on a uniform variable.
  28059. * @param uniformName Name of the variable.
  28060. * @param x First float in float3.
  28061. * @param y Second float in float3.
  28062. * @param z Third float in float3.
  28063. * @returns this effect.
  28064. */
  28065. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28066. /**
  28067. * Sets a Vector4 on a uniform variable.
  28068. * @param uniformName Name of the variable.
  28069. * @param vector4 Value to be set.
  28070. * @returns this effect.
  28071. */
  28072. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28073. /**
  28074. * Sets a float4 on a uniform variable.
  28075. * @param uniformName Name of the variable.
  28076. * @param x First float in float4.
  28077. * @param y Second float in float4.
  28078. * @param z Third float in float4.
  28079. * @param w Fourth float in float4.
  28080. * @returns this effect.
  28081. */
  28082. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28083. /**
  28084. * Sets a Color3 on a uniform variable.
  28085. * @param uniformName Name of the variable.
  28086. * @param color3 Value to be set.
  28087. * @returns this effect.
  28088. */
  28089. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28090. /**
  28091. * Sets a Color4 on a uniform variable.
  28092. * @param uniformName Name of the variable.
  28093. * @param color3 Value to be set.
  28094. * @param alpha Alpha value to be set.
  28095. * @returns this effect.
  28096. */
  28097. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28098. /**
  28099. * Sets a Color4 on a uniform variable
  28100. * @param uniformName defines the name of the variable
  28101. * @param color4 defines the value to be set
  28102. * @returns this effect.
  28103. */
  28104. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28105. /** Release all associated resources */
  28106. dispose(): void;
  28107. /**
  28108. * This function will add a new shader to the shader store
  28109. * @param name the name of the shader
  28110. * @param pixelShader optional pixel shader content
  28111. * @param vertexShader optional vertex shader content
  28112. */
  28113. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28114. /**
  28115. * Store of each shader (The can be looked up using effect.key)
  28116. */
  28117. static ShadersStore: {
  28118. [key: string]: string;
  28119. };
  28120. /**
  28121. * Store of each included file for a shader (The can be looked up using effect.key)
  28122. */
  28123. static IncludesShadersStore: {
  28124. [key: string]: string;
  28125. };
  28126. /**
  28127. * Resets the cache of effects.
  28128. */
  28129. static ResetCache(): void;
  28130. }
  28131. }
  28132. declare module BABYLON {
  28133. /**
  28134. * Uniform buffer objects.
  28135. *
  28136. * Handles blocks of uniform on the GPU.
  28137. *
  28138. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28139. *
  28140. * For more information, please refer to :
  28141. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28142. */
  28143. export class UniformBuffer {
  28144. private _engine;
  28145. private _buffer;
  28146. private _data;
  28147. private _bufferData;
  28148. private _dynamic?;
  28149. private _uniformLocations;
  28150. private _uniformSizes;
  28151. private _uniformLocationPointer;
  28152. private _needSync;
  28153. private _noUBO;
  28154. private _currentEffect;
  28155. private static _MAX_UNIFORM_SIZE;
  28156. private static _tempBuffer;
  28157. /**
  28158. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  28159. * This is dynamic to allow compat with webgl 1 and 2.
  28160. * You will need to pass the name of the uniform as well as the value.
  28161. */
  28162. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  28163. /**
  28164. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  28165. * This is dynamic to allow compat with webgl 1 and 2.
  28166. * You will need to pass the name of the uniform as well as the value.
  28167. */
  28168. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  28169. /**
  28170. * Lambda to Update a single float in a uniform buffer.
  28171. * This is dynamic to allow compat with webgl 1 and 2.
  28172. * You will need to pass the name of the uniform as well as the value.
  28173. */
  28174. updateFloat: (name: string, x: number) => void;
  28175. /**
  28176. * Lambda to Update a vec2 of float in a uniform buffer.
  28177. * This is dynamic to allow compat with webgl 1 and 2.
  28178. * You will need to pass the name of the uniform as well as the value.
  28179. */
  28180. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  28181. /**
  28182. * Lambda to Update a vec3 of float in a uniform buffer.
  28183. * This is dynamic to allow compat with webgl 1 and 2.
  28184. * You will need to pass the name of the uniform as well as the value.
  28185. */
  28186. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  28187. /**
  28188. * Lambda to Update a vec4 of float in a uniform buffer.
  28189. * This is dynamic to allow compat with webgl 1 and 2.
  28190. * You will need to pass the name of the uniform as well as the value.
  28191. */
  28192. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  28193. /**
  28194. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  28195. * This is dynamic to allow compat with webgl 1 and 2.
  28196. * You will need to pass the name of the uniform as well as the value.
  28197. */
  28198. updateMatrix: (name: string, mat: Matrix) => void;
  28199. /**
  28200. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  28201. * This is dynamic to allow compat with webgl 1 and 2.
  28202. * You will need to pass the name of the uniform as well as the value.
  28203. */
  28204. updateVector3: (name: string, vector: Vector3) => void;
  28205. /**
  28206. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  28207. * This is dynamic to allow compat with webgl 1 and 2.
  28208. * You will need to pass the name of the uniform as well as the value.
  28209. */
  28210. updateVector4: (name: string, vector: Vector4) => void;
  28211. /**
  28212. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  28213. * This is dynamic to allow compat with webgl 1 and 2.
  28214. * You will need to pass the name of the uniform as well as the value.
  28215. */
  28216. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  28217. /**
  28218. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  28219. * This is dynamic to allow compat with webgl 1 and 2.
  28220. * You will need to pass the name of the uniform as well as the value.
  28221. */
  28222. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  28223. /**
  28224. * Instantiates a new Uniform buffer objects.
  28225. *
  28226. * Handles blocks of uniform on the GPU.
  28227. *
  28228. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28229. *
  28230. * For more information, please refer to :
  28231. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28232. * @param engine Define the engine the buffer is associated with
  28233. * @param data Define the data contained in the buffer
  28234. * @param dynamic Define if the buffer is updatable
  28235. */
  28236. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  28237. /**
  28238. * Indicates if the buffer is using the WebGL2 UBO implementation,
  28239. * or just falling back on setUniformXXX calls.
  28240. */
  28241. readonly useUbo: boolean;
  28242. /**
  28243. * Indicates if the WebGL underlying uniform buffer is in sync
  28244. * with the javascript cache data.
  28245. */
  28246. readonly isSync: boolean;
  28247. /**
  28248. * Indicates if the WebGL underlying uniform buffer is dynamic.
  28249. * Also, a dynamic UniformBuffer will disable cache verification and always
  28250. * update the underlying WebGL uniform buffer to the GPU.
  28251. * @returns if Dynamic, otherwise false
  28252. */
  28253. isDynamic(): boolean;
  28254. /**
  28255. * The data cache on JS side.
  28256. * @returns the underlying data as a float array
  28257. */
  28258. getData(): Float32Array;
  28259. /**
  28260. * The underlying WebGL Uniform buffer.
  28261. * @returns the webgl buffer
  28262. */
  28263. getBuffer(): Nullable<DataBuffer>;
  28264. /**
  28265. * std140 layout specifies how to align data within an UBO structure.
  28266. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  28267. * for specs.
  28268. */
  28269. private _fillAlignment;
  28270. /**
  28271. * Adds an uniform in the buffer.
  28272. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  28273. * for the layout to be correct !
  28274. * @param name Name of the uniform, as used in the uniform block in the shader.
  28275. * @param size Data size, or data directly.
  28276. */
  28277. addUniform(name: string, size: number | number[]): void;
  28278. /**
  28279. * Adds a Matrix 4x4 to the uniform buffer.
  28280. * @param name Name of the uniform, as used in the uniform block in the shader.
  28281. * @param mat A 4x4 matrix.
  28282. */
  28283. addMatrix(name: string, mat: Matrix): void;
  28284. /**
  28285. * Adds a vec2 to the uniform buffer.
  28286. * @param name Name of the uniform, as used in the uniform block in the shader.
  28287. * @param x Define the x component value of the vec2
  28288. * @param y Define the y component value of the vec2
  28289. */
  28290. addFloat2(name: string, x: number, y: number): void;
  28291. /**
  28292. * Adds a vec3 to the uniform buffer.
  28293. * @param name Name of the uniform, as used in the uniform block in the shader.
  28294. * @param x Define the x component value of the vec3
  28295. * @param y Define the y component value of the vec3
  28296. * @param z Define the z component value of the vec3
  28297. */
  28298. addFloat3(name: string, x: number, y: number, z: number): void;
  28299. /**
  28300. * Adds a vec3 to the uniform buffer.
  28301. * @param name Name of the uniform, as used in the uniform block in the shader.
  28302. * @param color Define the vec3 from a Color
  28303. */
  28304. addColor3(name: string, color: Color3): void;
  28305. /**
  28306. * Adds a vec4 to the uniform buffer.
  28307. * @param name Name of the uniform, as used in the uniform block in the shader.
  28308. * @param color Define the rgb components from a Color
  28309. * @param alpha Define the a component of the vec4
  28310. */
  28311. addColor4(name: string, color: Color3, alpha: number): void;
  28312. /**
  28313. * Adds a vec3 to the uniform buffer.
  28314. * @param name Name of the uniform, as used in the uniform block in the shader.
  28315. * @param vector Define the vec3 components from a Vector
  28316. */
  28317. addVector3(name: string, vector: Vector3): void;
  28318. /**
  28319. * Adds a Matrix 3x3 to the uniform buffer.
  28320. * @param name Name of the uniform, as used in the uniform block in the shader.
  28321. */
  28322. addMatrix3x3(name: string): void;
  28323. /**
  28324. * Adds a Matrix 2x2 to the uniform buffer.
  28325. * @param name Name of the uniform, as used in the uniform block in the shader.
  28326. */
  28327. addMatrix2x2(name: string): void;
  28328. /**
  28329. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  28330. */
  28331. create(): void;
  28332. /** @hidden */ private _rebuild(): void;
  28333. /**
  28334. * Updates the WebGL Uniform Buffer on the GPU.
  28335. * If the `dynamic` flag is set to true, no cache comparison is done.
  28336. * Otherwise, the buffer will be updated only if the cache differs.
  28337. */
  28338. update(): void;
  28339. /**
  28340. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  28341. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28342. * @param data Define the flattened data
  28343. * @param size Define the size of the data.
  28344. */
  28345. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  28346. private _valueCache;
  28347. private _cacheMatrix;
  28348. private _updateMatrix3x3ForUniform;
  28349. private _updateMatrix3x3ForEffect;
  28350. private _updateMatrix2x2ForEffect;
  28351. private _updateMatrix2x2ForUniform;
  28352. private _updateFloatForEffect;
  28353. private _updateFloatForUniform;
  28354. private _updateFloat2ForEffect;
  28355. private _updateFloat2ForUniform;
  28356. private _updateFloat3ForEffect;
  28357. private _updateFloat3ForUniform;
  28358. private _updateFloat4ForEffect;
  28359. private _updateFloat4ForUniform;
  28360. private _updateMatrixForEffect;
  28361. private _updateMatrixForUniform;
  28362. private _updateVector3ForEffect;
  28363. private _updateVector3ForUniform;
  28364. private _updateVector4ForEffect;
  28365. private _updateVector4ForUniform;
  28366. private _updateColor3ForEffect;
  28367. private _updateColor3ForUniform;
  28368. private _updateColor4ForEffect;
  28369. private _updateColor4ForUniform;
  28370. /**
  28371. * Sets a sampler uniform on the effect.
  28372. * @param name Define the name of the sampler.
  28373. * @param texture Define the texture to set in the sampler
  28374. */
  28375. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  28376. /**
  28377. * Directly updates the value of the uniform in the cache AND on the GPU.
  28378. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28379. * @param data Define the flattened data
  28380. */
  28381. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  28382. /**
  28383. * Binds this uniform buffer to an effect.
  28384. * @param effect Define the effect to bind the buffer to
  28385. * @param name Name of the uniform block in the shader.
  28386. */
  28387. bindToEffect(effect: Effect, name: string): void;
  28388. /**
  28389. * Disposes the uniform buffer.
  28390. */
  28391. dispose(): void;
  28392. }
  28393. }
  28394. declare module BABYLON {
  28395. /**
  28396. * Class used to work with sound analyzer using fast fourier transform (FFT)
  28397. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28398. */
  28399. export class Analyser {
  28400. /**
  28401. * Gets or sets the smoothing
  28402. * @ignorenaming
  28403. */
  28404. SMOOTHING: number;
  28405. /**
  28406. * Gets or sets the FFT table size
  28407. * @ignorenaming
  28408. */
  28409. FFT_SIZE: number;
  28410. /**
  28411. * Gets or sets the bar graph amplitude
  28412. * @ignorenaming
  28413. */
  28414. BARGRAPHAMPLITUDE: number;
  28415. /**
  28416. * Gets or sets the position of the debug canvas
  28417. * @ignorenaming
  28418. */
  28419. DEBUGCANVASPOS: {
  28420. x: number;
  28421. y: number;
  28422. };
  28423. /**
  28424. * Gets or sets the debug canvas size
  28425. * @ignorenaming
  28426. */
  28427. DEBUGCANVASSIZE: {
  28428. width: number;
  28429. height: number;
  28430. };
  28431. private _byteFreqs;
  28432. private _byteTime;
  28433. private _floatFreqs;
  28434. private _webAudioAnalyser;
  28435. private _debugCanvas;
  28436. private _debugCanvasContext;
  28437. private _scene;
  28438. private _registerFunc;
  28439. private _audioEngine;
  28440. /**
  28441. * Creates a new analyser
  28442. * @param scene defines hosting scene
  28443. */
  28444. constructor(scene: Scene);
  28445. /**
  28446. * Get the number of data values you will have to play with for the visualization
  28447. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  28448. * @returns a number
  28449. */
  28450. getFrequencyBinCount(): number;
  28451. /**
  28452. * Gets the current frequency data as a byte array
  28453. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  28454. * @returns a Uint8Array
  28455. */
  28456. getByteFrequencyData(): Uint8Array;
  28457. /**
  28458. * Gets the current waveform as a byte array
  28459. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  28460. * @returns a Uint8Array
  28461. */
  28462. getByteTimeDomainData(): Uint8Array;
  28463. /**
  28464. * Gets the current frequency data as a float array
  28465. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  28466. * @returns a Float32Array
  28467. */
  28468. getFloatFrequencyData(): Float32Array;
  28469. /**
  28470. * Renders the debug canvas
  28471. */
  28472. drawDebugCanvas(): void;
  28473. /**
  28474. * Stops rendering the debug canvas and removes it
  28475. */
  28476. stopDebugCanvas(): void;
  28477. /**
  28478. * Connects two audio nodes
  28479. * @param inputAudioNode defines first node to connect
  28480. * @param outputAudioNode defines second node to connect
  28481. */
  28482. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  28483. /**
  28484. * Releases all associated resources
  28485. */
  28486. dispose(): void;
  28487. }
  28488. }
  28489. declare module BABYLON {
  28490. /**
  28491. * This represents an audio engine and it is responsible
  28492. * to play, synchronize and analyse sounds throughout the application.
  28493. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28494. */
  28495. export interface IAudioEngine extends IDisposable {
  28496. /**
  28497. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  28498. */
  28499. readonly canUseWebAudio: boolean;
  28500. /**
  28501. * Gets the current AudioContext if available.
  28502. */
  28503. readonly audioContext: Nullable<AudioContext>;
  28504. /**
  28505. * The master gain node defines the global audio volume of your audio engine.
  28506. */
  28507. readonly masterGain: GainNode;
  28508. /**
  28509. * Gets whether or not mp3 are supported by your browser.
  28510. */
  28511. readonly isMP3supported: boolean;
  28512. /**
  28513. * Gets whether or not ogg are supported by your browser.
  28514. */
  28515. readonly isOGGsupported: boolean;
  28516. /**
  28517. * Defines if Babylon should emit a warning if WebAudio is not supported.
  28518. * @ignoreNaming
  28519. */
  28520. WarnedWebAudioUnsupported: boolean;
  28521. /**
  28522. * Defines if the audio engine relies on a custom unlocked button.
  28523. * In this case, the embedded button will not be displayed.
  28524. */
  28525. useCustomUnlockedButton: boolean;
  28526. /**
  28527. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  28528. */
  28529. readonly unlocked: boolean;
  28530. /**
  28531. * Event raised when audio has been unlocked on the browser.
  28532. */
  28533. onAudioUnlockedObservable: Observable<AudioEngine>;
  28534. /**
  28535. * Event raised when audio has been locked on the browser.
  28536. */
  28537. onAudioLockedObservable: Observable<AudioEngine>;
  28538. /**
  28539. * Flags the audio engine in Locked state.
  28540. * This happens due to new browser policies preventing audio to autoplay.
  28541. */
  28542. lock(): void;
  28543. /**
  28544. * Unlocks the audio engine once a user action has been done on the dom.
  28545. * This is helpful to resume play once browser policies have been satisfied.
  28546. */
  28547. unlock(): void;
  28548. }
  28549. /**
  28550. * This represents the default audio engine used in babylon.
  28551. * It is responsible to play, synchronize and analyse sounds throughout the application.
  28552. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28553. */
  28554. export class AudioEngine implements IAudioEngine {
  28555. private _audioContext;
  28556. private _audioContextInitialized;
  28557. private _muteButton;
  28558. private _hostElement;
  28559. /**
  28560. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  28561. */
  28562. canUseWebAudio: boolean;
  28563. /**
  28564. * The master gain node defines the global audio volume of your audio engine.
  28565. */
  28566. masterGain: GainNode;
  28567. /**
  28568. * Defines if Babylon should emit a warning if WebAudio is not supported.
  28569. * @ignoreNaming
  28570. */
  28571. WarnedWebAudioUnsupported: boolean;
  28572. /**
  28573. * Gets whether or not mp3 are supported by your browser.
  28574. */
  28575. isMP3supported: boolean;
  28576. /**
  28577. * Gets whether or not ogg are supported by your browser.
  28578. */
  28579. isOGGsupported: boolean;
  28580. /**
  28581. * Gets whether audio has been unlocked on the device.
  28582. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  28583. * a user interaction has happened.
  28584. */
  28585. unlocked: boolean;
  28586. /**
  28587. * Defines if the audio engine relies on a custom unlocked button.
  28588. * In this case, the embedded button will not be displayed.
  28589. */
  28590. useCustomUnlockedButton: boolean;
  28591. /**
  28592. * Event raised when audio has been unlocked on the browser.
  28593. */
  28594. onAudioUnlockedObservable: Observable<AudioEngine>;
  28595. /**
  28596. * Event raised when audio has been locked on the browser.
  28597. */
  28598. onAudioLockedObservable: Observable<AudioEngine>;
  28599. /**
  28600. * Gets the current AudioContext if available.
  28601. */
  28602. readonly audioContext: Nullable<AudioContext>;
  28603. private _connectedAnalyser;
  28604. /**
  28605. * Instantiates a new audio engine.
  28606. *
  28607. * There should be only one per page as some browsers restrict the number
  28608. * of audio contexts you can create.
  28609. * @param hostElement defines the host element where to display the mute icon if necessary
  28610. */
  28611. constructor(hostElement?: Nullable<HTMLElement>);
  28612. /**
  28613. * Flags the audio engine in Locked state.
  28614. * This happens due to new browser policies preventing audio to autoplay.
  28615. */
  28616. lock(): void;
  28617. /**
  28618. * Unlocks the audio engine once a user action has been done on the dom.
  28619. * This is helpful to resume play once browser policies have been satisfied.
  28620. */
  28621. unlock(): void;
  28622. private _resumeAudioContext;
  28623. private _initializeAudioContext;
  28624. private _tryToRun;
  28625. private _triggerRunningState;
  28626. private _triggerSuspendedState;
  28627. private _displayMuteButton;
  28628. private _moveButtonToTopLeft;
  28629. private _onResize;
  28630. private _hideMuteButton;
  28631. /**
  28632. * Destroy and release the resources associated with the audio ccontext.
  28633. */
  28634. dispose(): void;
  28635. /**
  28636. * Gets the global volume sets on the master gain.
  28637. * @returns the global volume if set or -1 otherwise
  28638. */
  28639. getGlobalVolume(): number;
  28640. /**
  28641. * Sets the global volume of your experience (sets on the master gain).
  28642. * @param newVolume Defines the new global volume of the application
  28643. */
  28644. setGlobalVolume(newVolume: number): void;
  28645. /**
  28646. * Connect the audio engine to an audio analyser allowing some amazing
  28647. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  28648. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  28649. * @param analyser The analyser to connect to the engine
  28650. */
  28651. connectToAnalyser(analyser: Analyser): void;
  28652. }
  28653. }
  28654. declare module BABYLON {
  28655. /**
  28656. * Interface used to present a loading screen while loading a scene
  28657. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28658. */
  28659. export interface ILoadingScreen {
  28660. /**
  28661. * Function called to display the loading screen
  28662. */
  28663. displayLoadingUI: () => void;
  28664. /**
  28665. * Function called to hide the loading screen
  28666. */
  28667. hideLoadingUI: () => void;
  28668. /**
  28669. * Gets or sets the color to use for the background
  28670. */
  28671. loadingUIBackgroundColor: string;
  28672. /**
  28673. * Gets or sets the text to display while loading
  28674. */
  28675. loadingUIText: string;
  28676. }
  28677. /**
  28678. * Class used for the default loading screen
  28679. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28680. */
  28681. export class DefaultLoadingScreen implements ILoadingScreen {
  28682. private _renderingCanvas;
  28683. private _loadingText;
  28684. private _loadingDivBackgroundColor;
  28685. private _loadingDiv;
  28686. private _loadingTextDiv;
  28687. /** Gets or sets the logo url to use for the default loading screen */
  28688. static DefaultLogoUrl: string;
  28689. /** Gets or sets the spinner url to use for the default loading screen */
  28690. static DefaultSpinnerUrl: string;
  28691. /**
  28692. * Creates a new default loading screen
  28693. * @param _renderingCanvas defines the canvas used to render the scene
  28694. * @param _loadingText defines the default text to display
  28695. * @param _loadingDivBackgroundColor defines the default background color
  28696. */
  28697. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  28698. /**
  28699. * Function called to display the loading screen
  28700. */
  28701. displayLoadingUI(): void;
  28702. /**
  28703. * Function called to hide the loading screen
  28704. */
  28705. hideLoadingUI(): void;
  28706. /**
  28707. * Gets or sets the text to display while loading
  28708. */
  28709. loadingUIText: string;
  28710. /**
  28711. * Gets or sets the color to use for the background
  28712. */
  28713. loadingUIBackgroundColor: string;
  28714. private _resizeLoadingUI;
  28715. }
  28716. }
  28717. declare module BABYLON {
  28718. /** @hidden */
  28719. export class WebGLPipelineContext implements IPipelineContext {
  28720. engine: Engine;
  28721. program: Nullable<WebGLProgram>;
  28722. context?: WebGLRenderingContext;
  28723. vertexShader?: WebGLShader;
  28724. fragmentShader?: WebGLShader;
  28725. isParallelCompiled: boolean;
  28726. onCompiled?: () => void;
  28727. transformFeedback?: WebGLTransformFeedback | null;
  28728. readonly isAsync: boolean;
  28729. readonly isReady: boolean; private _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  28730. }
  28731. }
  28732. declare module BABYLON {
  28733. /** @hidden */
  28734. export class WebGLDataBuffer extends DataBuffer {
  28735. private _buffer;
  28736. constructor(resource: WebGLBuffer);
  28737. readonly underlyingResource: any;
  28738. }
  28739. }
  28740. declare module BABYLON {
  28741. /** @hidden */
  28742. export class WebGL2ShaderProcessor implements IShaderProcessor {
  28743. attributeProcessor(attribute: string): string;
  28744. varyingProcessor(varying: string, isFragment: boolean): string;
  28745. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  28746. }
  28747. }
  28748. declare module BABYLON {
  28749. /**
  28750. * This class is used to track a performance counter which is number based.
  28751. * The user has access to many properties which give statistics of different nature.
  28752. *
  28753. * The implementer can track two kinds of Performance Counter: time and count.
  28754. * 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.
  28755. * 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.
  28756. */
  28757. export class PerfCounter {
  28758. /**
  28759. * Gets or sets a global boolean to turn on and off all the counters
  28760. */
  28761. static Enabled: boolean;
  28762. /**
  28763. * Returns the smallest value ever
  28764. */
  28765. readonly min: number;
  28766. /**
  28767. * Returns the biggest value ever
  28768. */
  28769. readonly max: number;
  28770. /**
  28771. * Returns the average value since the performance counter is running
  28772. */
  28773. readonly average: number;
  28774. /**
  28775. * Returns the average value of the last second the counter was monitored
  28776. */
  28777. readonly lastSecAverage: number;
  28778. /**
  28779. * Returns the current value
  28780. */
  28781. readonly current: number;
  28782. /**
  28783. * Gets the accumulated total
  28784. */
  28785. readonly total: number;
  28786. /**
  28787. * Gets the total value count
  28788. */
  28789. readonly count: number;
  28790. /**
  28791. * Creates a new counter
  28792. */
  28793. constructor();
  28794. /**
  28795. * Call this method to start monitoring a new frame.
  28796. * 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.
  28797. */
  28798. fetchNewFrame(): void;
  28799. /**
  28800. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  28801. * @param newCount the count value to add to the monitored count
  28802. * @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.
  28803. */
  28804. addCount(newCount: number, fetchResult: boolean): void;
  28805. /**
  28806. * Start monitoring this performance counter
  28807. */
  28808. beginMonitoring(): void;
  28809. /**
  28810. * Compute the time lapsed since the previous beginMonitoring() call.
  28811. * @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
  28812. */
  28813. endMonitoring(newFrame?: boolean): void;
  28814. private _fetchResult;
  28815. private _startMonitoringTime;
  28816. private _min;
  28817. private _max;
  28818. private _average;
  28819. private _current;
  28820. private _totalValueCount;
  28821. private _totalAccumulated;
  28822. private _lastSecAverage;
  28823. private _lastSecAccumulated;
  28824. private _lastSecTime;
  28825. private _lastSecValueCount;
  28826. }
  28827. }
  28828. declare module BABYLON {
  28829. /**
  28830. * Interface for any object that can request an animation frame
  28831. */
  28832. export interface ICustomAnimationFrameRequester {
  28833. /**
  28834. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  28835. */
  28836. renderFunction?: Function;
  28837. /**
  28838. * Called to request the next frame to render to
  28839. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  28840. */
  28841. requestAnimationFrame: Function;
  28842. /**
  28843. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  28844. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  28845. */
  28846. requestID?: number;
  28847. }
  28848. }
  28849. declare module BABYLON {
  28850. /**
  28851. * Settings for finer control over video usage
  28852. */
  28853. export interface VideoTextureSettings {
  28854. /**
  28855. * Applies `autoplay` to video, if specified
  28856. */
  28857. autoPlay?: boolean;
  28858. /**
  28859. * Applies `loop` to video, if specified
  28860. */
  28861. loop?: boolean;
  28862. /**
  28863. * Automatically updates internal texture from video at every frame in the render loop
  28864. */
  28865. autoUpdateTexture: boolean;
  28866. /**
  28867. * Image src displayed during the video loading or until the user interacts with the video.
  28868. */
  28869. poster?: string;
  28870. }
  28871. /**
  28872. * If you want to display a video in your scene, this is the special texture for that.
  28873. * This special texture works similar to other textures, with the exception of a few parameters.
  28874. * @see https://doc.babylonjs.com/how_to/video_texture
  28875. */
  28876. export class VideoTexture extends Texture {
  28877. /**
  28878. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  28879. */
  28880. readonly autoUpdateTexture: boolean;
  28881. /**
  28882. * The video instance used by the texture internally
  28883. */
  28884. readonly video: HTMLVideoElement;
  28885. private _onUserActionRequestedObservable;
  28886. /**
  28887. * Event triggerd when a dom action is required by the user to play the video.
  28888. * This happens due to recent changes in browser policies preventing video to auto start.
  28889. */
  28890. readonly onUserActionRequestedObservable: Observable<Texture>;
  28891. private _generateMipMaps;
  28892. private _engine;
  28893. private _stillImageCaptured;
  28894. private _displayingPosterTexture;
  28895. private _settings;
  28896. private _createInternalTextureOnEvent;
  28897. /**
  28898. * Creates a video texture.
  28899. * If you want to display a video in your scene, this is the special texture for that.
  28900. * This special texture works similar to other textures, with the exception of a few parameters.
  28901. * @see https://doc.babylonjs.com/how_to/video_texture
  28902. * @param name optional name, will detect from video source, if not defined
  28903. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  28904. * @param scene is obviously the current scene.
  28905. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  28906. * @param invertY is false by default but can be used to invert video on Y axis
  28907. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  28908. * @param settings allows finer control over video usage
  28909. */
  28910. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  28911. private _getName;
  28912. private _getVideo;
  28913. private _createInternalTexture;
  28914. private reset;
  28915. /**
  28916. * @hidden Internal method to initiate `update`.
  28917. */ private _rebuild(): void;
  28918. /**
  28919. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  28920. */
  28921. update(): void;
  28922. /**
  28923. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  28924. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  28925. */
  28926. updateTexture(isVisible: boolean): void;
  28927. protected _updateInternalTexture: () => void;
  28928. /**
  28929. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  28930. * @param url New url.
  28931. */
  28932. updateURL(url: string): void;
  28933. /**
  28934. * Dispose the texture and release its associated resources.
  28935. */
  28936. dispose(): void;
  28937. /**
  28938. * Creates a video texture straight from a stream.
  28939. * @param scene Define the scene the texture should be created in
  28940. * @param stream Define the stream the texture should be created from
  28941. * @returns The created video texture as a promise
  28942. */
  28943. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  28944. /**
  28945. * Creates a video texture straight from your WebCam video feed.
  28946. * @param scene Define the scene the texture should be created in
  28947. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28948. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28949. * @returns The created video texture as a promise
  28950. */
  28951. static CreateFromWebCamAsync(scene: Scene, constraints: {
  28952. minWidth: number;
  28953. maxWidth: number;
  28954. minHeight: number;
  28955. maxHeight: number;
  28956. deviceId: string;
  28957. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  28958. /**
  28959. * Creates a video texture straight from your WebCam video feed.
  28960. * @param scene Define the scene the texture should be created in
  28961. * @param onReady Define a callback to triggered once the texture will be ready
  28962. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28963. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28964. */
  28965. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  28966. minWidth: number;
  28967. maxWidth: number;
  28968. minHeight: number;
  28969. maxHeight: number;
  28970. deviceId: string;
  28971. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  28972. }
  28973. }
  28974. declare module BABYLON {
  28975. /**
  28976. * Defines the interface used by objects containing a viewport (like a camera)
  28977. */
  28978. interface IViewportOwnerLike {
  28979. /**
  28980. * Gets or sets the viewport
  28981. */
  28982. viewport: IViewportLike;
  28983. }
  28984. /**
  28985. * Interface for attribute information associated with buffer instanciation
  28986. */
  28987. export class InstancingAttributeInfo {
  28988. /**
  28989. * Index/offset of the attribute in the vertex shader
  28990. */
  28991. index: number;
  28992. /**
  28993. * size of the attribute, 1, 2, 3 or 4
  28994. */
  28995. attributeSize: number;
  28996. /**
  28997. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  28998. * default is FLOAT
  28999. */
  29000. attribyteType: number;
  29001. /**
  29002. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29003. */
  29004. normalized: boolean;
  29005. /**
  29006. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29007. */
  29008. offset: number;
  29009. /**
  29010. * Name of the GLSL attribute, for debugging purpose only
  29011. */
  29012. attributeName: string;
  29013. }
  29014. /**
  29015. * Define options used to create a depth texture
  29016. */
  29017. export class DepthTextureCreationOptions {
  29018. /** Specifies whether or not a stencil should be allocated in the texture */
  29019. generateStencil?: boolean;
  29020. /** Specifies whether or not bilinear filtering is enable on the texture */
  29021. bilinearFiltering?: boolean;
  29022. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  29023. comparisonFunction?: number;
  29024. /** Specifies if the created texture is a cube texture */
  29025. isCube?: boolean;
  29026. }
  29027. /**
  29028. * Class used to describe the capabilities of the engine relatively to the current browser
  29029. */
  29030. export class EngineCapabilities {
  29031. /** Maximum textures units per fragment shader */
  29032. maxTexturesImageUnits: number;
  29033. /** Maximum texture units per vertex shader */
  29034. maxVertexTextureImageUnits: number;
  29035. /** Maximum textures units in the entire pipeline */
  29036. maxCombinedTexturesImageUnits: number;
  29037. /** Maximum texture size */
  29038. maxTextureSize: number;
  29039. /** Maximum cube texture size */
  29040. maxCubemapTextureSize: number;
  29041. /** Maximum render texture size */
  29042. maxRenderTextureSize: number;
  29043. /** Maximum number of vertex attributes */
  29044. maxVertexAttribs: number;
  29045. /** Maximum number of varyings */
  29046. maxVaryingVectors: number;
  29047. /** Maximum number of uniforms per vertex shader */
  29048. maxVertexUniformVectors: number;
  29049. /** Maximum number of uniforms per fragment shader */
  29050. maxFragmentUniformVectors: number;
  29051. /** Defines if standard derivates (dx/dy) are supported */
  29052. standardDerivatives: boolean;
  29053. /** Defines if s3tc texture compression is supported */
  29054. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29055. /** Defines if pvrtc texture compression is supported */
  29056. pvrtc: any;
  29057. /** Defines if etc1 texture compression is supported */
  29058. etc1: any;
  29059. /** Defines if etc2 texture compression is supported */
  29060. etc2: any;
  29061. /** Defines if astc texture compression is supported */
  29062. astc: any;
  29063. /** Defines if float textures are supported */
  29064. textureFloat: boolean;
  29065. /** Defines if vertex array objects are supported */
  29066. vertexArrayObject: boolean;
  29067. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29068. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29069. /** Gets the maximum level of anisotropy supported */
  29070. maxAnisotropy: number;
  29071. /** Defines if instancing is supported */
  29072. instancedArrays: boolean;
  29073. /** Defines if 32 bits indices are supported */
  29074. uintIndices: boolean;
  29075. /** Defines if high precision shaders are supported */
  29076. highPrecisionShaderSupported: boolean;
  29077. /** Defines if depth reading in the fragment shader is supported */
  29078. fragmentDepthSupported: boolean;
  29079. /** Defines if float texture linear filtering is supported*/
  29080. textureFloatLinearFiltering: boolean;
  29081. /** Defines if rendering to float textures is supported */
  29082. textureFloatRender: boolean;
  29083. /** Defines if half float textures are supported*/
  29084. textureHalfFloat: boolean;
  29085. /** Defines if half float texture linear filtering is supported*/
  29086. textureHalfFloatLinearFiltering: boolean;
  29087. /** Defines if rendering to half float textures is supported */
  29088. textureHalfFloatRender: boolean;
  29089. /** Defines if textureLOD shader command is supported */
  29090. textureLOD: boolean;
  29091. /** Defines if draw buffers extension is supported */
  29092. drawBuffersExtension: boolean;
  29093. /** Defines if depth textures are supported */
  29094. depthTextureExtension: boolean;
  29095. /** Defines if float color buffer are supported */
  29096. colorBufferFloat: boolean;
  29097. /** Gets disjoint timer query extension (null if not supported) */
  29098. timerQuery: EXT_disjoint_timer_query;
  29099. /** Defines if timestamp can be used with timer query */
  29100. canUseTimestampForTimerQuery: boolean;
  29101. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29102. multiview: any;
  29103. /** Function used to let the system compiles shaders in background */
  29104. parallelShaderCompile: {
  29105. COMPLETION_STATUS_KHR: number;
  29106. };
  29107. /** Max number of texture samples for MSAA */
  29108. maxMSAASamples: number;
  29109. }
  29110. /** Interface defining initialization parameters for Engine class */
  29111. export interface EngineOptions extends WebGLContextAttributes {
  29112. /**
  29113. * Defines if the engine should no exceed a specified device ratio
  29114. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29115. */
  29116. limitDeviceRatio?: number;
  29117. /**
  29118. * Defines if webvr should be enabled automatically
  29119. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29120. */
  29121. autoEnableWebVR?: boolean;
  29122. /**
  29123. * Defines if webgl2 should be turned off even if supported
  29124. * @see http://doc.babylonjs.com/features/webgl2
  29125. */
  29126. disableWebGL2Support?: boolean;
  29127. /**
  29128. * Defines if webaudio should be initialized as well
  29129. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29130. */
  29131. audioEngine?: boolean;
  29132. /**
  29133. * Defines if animations should run using a deterministic lock step
  29134. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29135. */
  29136. deterministicLockstep?: boolean;
  29137. /** Defines the maximum steps to use with deterministic lock step mode */
  29138. lockstepMaxSteps?: number;
  29139. /**
  29140. * Defines that engine should ignore context lost events
  29141. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29142. */
  29143. doNotHandleContextLost?: boolean;
  29144. /**
  29145. * Defines that engine should ignore modifying touch action attribute and style
  29146. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29147. */
  29148. doNotHandleTouchAction?: boolean;
  29149. /**
  29150. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29151. */
  29152. useHighPrecisionFloats?: boolean;
  29153. }
  29154. /**
  29155. * Defines the interface used by display changed events
  29156. */
  29157. export interface IDisplayChangedEventArgs {
  29158. /** Gets the vrDisplay object (if any) */
  29159. vrDisplay: Nullable<any>;
  29160. /** Gets a boolean indicating if webVR is supported */
  29161. vrSupported: boolean;
  29162. }
  29163. /**
  29164. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  29165. */
  29166. export class Engine {
  29167. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29168. static ExceptionList: ({
  29169. key: string;
  29170. capture: string;
  29171. captureConstraint: number;
  29172. targets: string[];
  29173. } | {
  29174. key: string;
  29175. capture: null;
  29176. captureConstraint: null;
  29177. targets: string[];
  29178. })[];
  29179. /** Gets the list of created engines */
  29180. static readonly Instances: Engine[];
  29181. /**
  29182. * Gets the latest created engine
  29183. */
  29184. static readonly LastCreatedEngine: Nullable<Engine>;
  29185. /**
  29186. * Gets the latest created scene
  29187. */
  29188. static readonly LastCreatedScene: Nullable<Scene>;
  29189. /**
  29190. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  29191. * @param flag defines which part of the materials must be marked as dirty
  29192. * @param predicate defines a predicate used to filter which materials should be affected
  29193. */
  29194. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  29195. /** @hidden */ private static _TextureLoaders: IInternalTextureLoader[];
  29196. /** Defines that alpha blending is disabled */
  29197. static readonly ALPHA_DISABLE: number;
  29198. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  29199. static readonly ALPHA_ADD: number;
  29200. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  29201. static readonly ALPHA_COMBINE: number;
  29202. /** Defines that alpha blending to DEST - SRC * DEST */
  29203. static readonly ALPHA_SUBTRACT: number;
  29204. /** Defines that alpha blending to SRC * DEST */
  29205. static readonly ALPHA_MULTIPLY: number;
  29206. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  29207. static readonly ALPHA_MAXIMIZED: number;
  29208. /** Defines that alpha blending to SRC + DEST */
  29209. static readonly ALPHA_ONEONE: number;
  29210. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  29211. static readonly ALPHA_PREMULTIPLIED: number;
  29212. /**
  29213. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  29214. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  29215. */
  29216. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  29217. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  29218. static readonly ALPHA_INTERPOLATE: number;
  29219. /**
  29220. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  29221. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  29222. */
  29223. static readonly ALPHA_SCREENMODE: number;
  29224. /** Defines that the ressource is not delayed*/
  29225. static readonly DELAYLOADSTATE_NONE: number;
  29226. /** Defines that the ressource was successfully delay loaded */
  29227. static readonly DELAYLOADSTATE_LOADED: number;
  29228. /** Defines that the ressource is currently delay loading */
  29229. static readonly DELAYLOADSTATE_LOADING: number;
  29230. /** Defines that the ressource is delayed and has not started loading */
  29231. static readonly DELAYLOADSTATE_NOTLOADED: number;
  29232. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  29233. static readonly NEVER: number;
  29234. /** 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 */
  29235. static readonly ALWAYS: number;
  29236. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  29237. static readonly LESS: number;
  29238. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  29239. static readonly EQUAL: number;
  29240. /** 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 */
  29241. static readonly LEQUAL: number;
  29242. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  29243. static readonly GREATER: number;
  29244. /** 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 */
  29245. static readonly GEQUAL: number;
  29246. /** 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 */
  29247. static readonly NOTEQUAL: number;
  29248. /** Passed to stencilOperation to specify that stencil value must be kept */
  29249. static readonly KEEP: number;
  29250. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29251. static readonly REPLACE: number;
  29252. /** Passed to stencilOperation to specify that stencil value must be incremented */
  29253. static readonly INCR: number;
  29254. /** Passed to stencilOperation to specify that stencil value must be decremented */
  29255. static readonly DECR: number;
  29256. /** Passed to stencilOperation to specify that stencil value must be inverted */
  29257. static readonly INVERT: number;
  29258. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  29259. static readonly INCR_WRAP: number;
  29260. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  29261. static readonly DECR_WRAP: number;
  29262. /** Texture is not repeating outside of 0..1 UVs */
  29263. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  29264. /** Texture is repeating outside of 0..1 UVs */
  29265. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  29266. /** Texture is repeating and mirrored */
  29267. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  29268. /** ALPHA */
  29269. static readonly TEXTUREFORMAT_ALPHA: number;
  29270. /** LUMINANCE */
  29271. static readonly TEXTUREFORMAT_LUMINANCE: number;
  29272. /** LUMINANCE_ALPHA */
  29273. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  29274. /** RGB */
  29275. static readonly TEXTUREFORMAT_RGB: number;
  29276. /** RGBA */
  29277. static readonly TEXTUREFORMAT_RGBA: number;
  29278. /** RED */
  29279. static readonly TEXTUREFORMAT_RED: number;
  29280. /** RED (2nd reference) */
  29281. static readonly TEXTUREFORMAT_R: number;
  29282. /** RG */
  29283. static readonly TEXTUREFORMAT_RG: number;
  29284. /** RED_INTEGER */
  29285. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  29286. /** RED_INTEGER (2nd reference) */
  29287. static readonly TEXTUREFORMAT_R_INTEGER: number;
  29288. /** RG_INTEGER */
  29289. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  29290. /** RGB_INTEGER */
  29291. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  29292. /** RGBA_INTEGER */
  29293. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  29294. /** UNSIGNED_BYTE */
  29295. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  29296. /** UNSIGNED_BYTE (2nd reference) */
  29297. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  29298. /** FLOAT */
  29299. static readonly TEXTURETYPE_FLOAT: number;
  29300. /** HALF_FLOAT */
  29301. static readonly TEXTURETYPE_HALF_FLOAT: number;
  29302. /** BYTE */
  29303. static readonly TEXTURETYPE_BYTE: number;
  29304. /** SHORT */
  29305. static readonly TEXTURETYPE_SHORT: number;
  29306. /** UNSIGNED_SHORT */
  29307. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  29308. /** INT */
  29309. static readonly TEXTURETYPE_INT: number;
  29310. /** UNSIGNED_INT */
  29311. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  29312. /** UNSIGNED_SHORT_4_4_4_4 */
  29313. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  29314. /** UNSIGNED_SHORT_5_5_5_1 */
  29315. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  29316. /** UNSIGNED_SHORT_5_6_5 */
  29317. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  29318. /** UNSIGNED_INT_2_10_10_10_REV */
  29319. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  29320. /** UNSIGNED_INT_24_8 */
  29321. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  29322. /** UNSIGNED_INT_10F_11F_11F_REV */
  29323. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  29324. /** UNSIGNED_INT_5_9_9_9_REV */
  29325. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  29326. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  29327. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  29328. /** nearest is mag = nearest and min = nearest and mip = linear */
  29329. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  29330. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29331. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  29332. /** Trilinear is mag = linear and min = linear and mip = linear */
  29333. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  29334. /** nearest is mag = nearest and min = nearest and mip = linear */
  29335. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  29336. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29337. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  29338. /** Trilinear is mag = linear and min = linear and mip = linear */
  29339. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  29340. /** mag = nearest and min = nearest and mip = nearest */
  29341. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  29342. /** mag = nearest and min = linear and mip = nearest */
  29343. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  29344. /** mag = nearest and min = linear and mip = linear */
  29345. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  29346. /** mag = nearest and min = linear and mip = none */
  29347. static readonly TEXTURE_NEAREST_LINEAR: number;
  29348. /** mag = nearest and min = nearest and mip = none */
  29349. static readonly TEXTURE_NEAREST_NEAREST: number;
  29350. /** mag = linear and min = nearest and mip = nearest */
  29351. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  29352. /** mag = linear and min = nearest and mip = linear */
  29353. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  29354. /** mag = linear and min = linear and mip = none */
  29355. static readonly TEXTURE_LINEAR_LINEAR: number;
  29356. /** mag = linear and min = nearest and mip = none */
  29357. static readonly TEXTURE_LINEAR_NEAREST: number;
  29358. /** Explicit coordinates mode */
  29359. static readonly TEXTURE_EXPLICIT_MODE: number;
  29360. /** Spherical coordinates mode */
  29361. static readonly TEXTURE_SPHERICAL_MODE: number;
  29362. /** Planar coordinates mode */
  29363. static readonly TEXTURE_PLANAR_MODE: number;
  29364. /** Cubic coordinates mode */
  29365. static readonly TEXTURE_CUBIC_MODE: number;
  29366. /** Projection coordinates mode */
  29367. static readonly TEXTURE_PROJECTION_MODE: number;
  29368. /** Skybox coordinates mode */
  29369. static readonly TEXTURE_SKYBOX_MODE: number;
  29370. /** Inverse Cubic coordinates mode */
  29371. static readonly TEXTURE_INVCUBIC_MODE: number;
  29372. /** Equirectangular coordinates mode */
  29373. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  29374. /** Equirectangular Fixed coordinates mode */
  29375. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  29376. /** Equirectangular Fixed Mirrored coordinates mode */
  29377. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  29378. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  29379. static readonly SCALEMODE_FLOOR: number;
  29380. /** Defines that texture rescaling will look for the nearest power of 2 size */
  29381. static readonly SCALEMODE_NEAREST: number;
  29382. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  29383. static readonly SCALEMODE_CEILING: number;
  29384. /**
  29385. * Returns the current npm package of the sdk
  29386. */
  29387. static readonly NpmPackage: string;
  29388. /**
  29389. * Returns the current version of the framework
  29390. */
  29391. static readonly Version: string;
  29392. /**
  29393. * Returns a string describing the current engine
  29394. */
  29395. readonly description: string;
  29396. /**
  29397. * Gets or sets the epsilon value used by collision engine
  29398. */
  29399. static CollisionsEpsilon: number;
  29400. /**
  29401. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29402. */
  29403. static ShadersRepository: string;
  29404. /**
  29405. * Method called to create the default loading screen.
  29406. * This can be overriden in your own app.
  29407. * @param canvas The rendering canvas element
  29408. * @returns The loading screen
  29409. */
  29410. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  29411. /**
  29412. * Method called to create the default rescale post process on each engine.
  29413. */ private static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  29414. /** @hidden */ private _shaderProcessor: IShaderProcessor;
  29415. /**
  29416. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29417. */
  29418. forcePOTTextures: boolean;
  29419. /**
  29420. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29421. */
  29422. isFullscreen: boolean;
  29423. /**
  29424. * Gets a boolean indicating if the pointer is currently locked
  29425. */
  29426. isPointerLock: boolean;
  29427. /**
  29428. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29429. */
  29430. cullBackFaces: boolean;
  29431. /**
  29432. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29433. */
  29434. renderEvenInBackground: boolean;
  29435. /**
  29436. * Gets or sets a boolean indicating that cache can be kept between frames
  29437. */
  29438. preventCacheWipeBetweenFrames: boolean;
  29439. /**
  29440. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  29441. **/
  29442. enableOfflineSupport: boolean;
  29443. /**
  29444. * 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)
  29445. **/
  29446. disableManifestCheck: boolean;
  29447. /**
  29448. * Gets the list of created scenes
  29449. */
  29450. scenes: Scene[];
  29451. /**
  29452. * Event raised when a new scene is created
  29453. */
  29454. onNewSceneAddedObservable: Observable<Scene>;
  29455. /**
  29456. * Gets the list of created postprocesses
  29457. */
  29458. postProcesses: PostProcess[];
  29459. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29460. validateShaderPrograms: boolean;
  29461. /**
  29462. * Observable event triggered each time the rendering canvas is resized
  29463. */
  29464. onResizeObservable: Observable<Engine>;
  29465. /**
  29466. * Observable event triggered each time the canvas loses focus
  29467. */
  29468. onCanvasBlurObservable: Observable<Engine>;
  29469. /**
  29470. * Observable event triggered each time the canvas gains focus
  29471. */
  29472. onCanvasFocusObservable: Observable<Engine>;
  29473. /**
  29474. * Observable event triggered each time the canvas receives pointerout event
  29475. */
  29476. onCanvasPointerOutObservable: Observable<PointerEvent>;
  29477. /**
  29478. * Observable event triggered before each texture is initialized
  29479. */
  29480. onBeforeTextureInitObservable: Observable<Texture>;
  29481. /**
  29482. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29483. */
  29484. disableUniformBuffers: boolean;
  29485. /** @hidden */ private _uniformBuffers: UniformBuffer[];
  29486. /**
  29487. * Gets a boolean indicating that the engine supports uniform buffers
  29488. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29489. */
  29490. readonly supportsUniformBuffers: boolean;
  29491. /**
  29492. * Observable raised when the engine begins a new frame
  29493. */
  29494. onBeginFrameObservable: Observable<Engine>;
  29495. /**
  29496. * If set, will be used to request the next animation frame for the render loop
  29497. */
  29498. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  29499. /**
  29500. * Observable raised when the engine ends the current frame
  29501. */
  29502. onEndFrameObservable: Observable<Engine>;
  29503. /**
  29504. * Observable raised when the engine is about to compile a shader
  29505. */
  29506. onBeforeShaderCompilationObservable: Observable<Engine>;
  29507. /**
  29508. * Observable raised when the engine has jsut compiled a shader
  29509. */
  29510. onAfterShaderCompilationObservable: Observable<Engine>;
  29511. /** @hidden */ private _gl: WebGLRenderingContext;
  29512. private _renderingCanvas;
  29513. private _windowIsBackground;
  29514. private _webGLVersion;
  29515. protected _highPrecisionShadersAllowed: boolean;
  29516. /** @hidden */ protected readonly _shouldUseHighPrecisionShader: boolean;
  29517. /**
  29518. * Gets a boolean indicating that only power of 2 textures are supported
  29519. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  29520. */
  29521. readonly needPOTTextures: boolean;
  29522. /** @hidden */ private _badOS: boolean;
  29523. /** @hidden */ private _badDesktopOS: boolean;
  29524. /**
  29525. * Gets the audio engine
  29526. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29527. * @ignorenaming
  29528. */
  29529. static audioEngine: IAudioEngine;
  29530. /**
  29531. * Default AudioEngine factory responsible of creating the Audio Engine.
  29532. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  29533. */
  29534. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  29535. /**
  29536. * Default offline support factory responsible of creating a tool used to store data locally.
  29537. * By default, this will create a Database object if the workload has been embedded.
  29538. */
  29539. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  29540. private _onFocus;
  29541. private _onBlur;
  29542. private _onCanvasPointerOut;
  29543. private _onCanvasBlur;
  29544. private _onCanvasFocus;
  29545. private _onFullscreenChange;
  29546. private _onPointerLockChange;
  29547. private _hardwareScalingLevel;
  29548. /** @hidden */ private _caps: EngineCapabilities;
  29549. private _pointerLockRequested;
  29550. private _isStencilEnable;
  29551. private _colorWrite;
  29552. private _loadingScreen;
  29553. /** @hidden */ private _drawCalls: PerfCounter;
  29554. private _glVersion;
  29555. private _glRenderer;
  29556. private _glVendor;
  29557. private _videoTextureSupported;
  29558. private _renderingQueueLaunched;
  29559. private _activeRenderLoops;
  29560. private _deterministicLockstep;
  29561. private _lockstepMaxSteps;
  29562. /**
  29563. * Observable signaled when a context lost event is raised
  29564. */
  29565. onContextLostObservable: Observable<Engine>;
  29566. /**
  29567. * Observable signaled when a context restored event is raised
  29568. */
  29569. onContextRestoredObservable: Observable<Engine>;
  29570. private _onContextLost;
  29571. private _onContextRestored;
  29572. private _contextWasLost;
  29573. /** @hidden */ private _doNotHandleContextLost: boolean;
  29574. /**
  29575. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  29576. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  29577. */
  29578. doNotHandleContextLost: boolean;
  29579. private _performanceMonitor;
  29580. private _fps;
  29581. private _deltaTime;
  29582. /**
  29583. * Turn this value on if you want to pause FPS computation when in background
  29584. */
  29585. disablePerformanceMonitorInBackground: boolean;
  29586. /**
  29587. * Gets the performance monitor attached to this engine
  29588. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  29589. */
  29590. readonly performanceMonitor: PerformanceMonitor;
  29591. /**
  29592. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  29593. */
  29594. disableVertexArrayObjects: boolean;
  29595. /** @hidden */
  29596. protected _depthCullingState: _DepthCullingState;
  29597. /** @hidden */
  29598. protected _stencilState: _StencilState;
  29599. /** @hidden */
  29600. protected _alphaState: _AlphaState;
  29601. /** @hidden */
  29602. protected _alphaMode: number;
  29603. /** @hidden */ private _internalTexturesCache: InternalTexture[];
  29604. /** @hidden */
  29605. protected _activeChannel: number;
  29606. private _currentTextureChannel;
  29607. /** @hidden */
  29608. protected _boundTexturesCache: {
  29609. [key: string]: Nullable<InternalTexture>;
  29610. };
  29611. /** @hidden */
  29612. protected _currentEffect: Nullable<Effect>;
  29613. /** @hidden */
  29614. protected _currentProgram: Nullable<WebGLProgram>;
  29615. private _compiledEffects;
  29616. private _vertexAttribArraysEnabled;
  29617. /** @hidden */
  29618. protected _cachedViewport: Nullable<IViewportLike>;
  29619. private _cachedVertexArrayObject;
  29620. /** @hidden */
  29621. protected _cachedVertexBuffers: any;
  29622. /** @hidden */
  29623. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  29624. /** @hidden */
  29625. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  29626. /** @hidden */ private _currentRenderTarget: Nullable<InternalTexture>;
  29627. private _uintIndicesCurrentlySet;
  29628. private _currentBoundBuffer;
  29629. /** @hidden */
  29630. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  29631. private _currentBufferPointers;
  29632. private _currentInstanceLocations;
  29633. private _currentInstanceBuffers;
  29634. private _textureUnits;
  29635. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement>;
  29636. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D>;
  29637. private _rescalePostProcess;
  29638. private _dummyFramebuffer;
  29639. private _externalData;
  29640. /** @hidden */ private _bindedRenderFunction: any;
  29641. private _vaoRecordInProgress;
  29642. private _mustWipeVertexAttributes;
  29643. private _emptyTexture;
  29644. private _emptyCubeTexture;
  29645. private _emptyTexture3D;
  29646. /** @hidden */ private _frameHandler: number;
  29647. private _nextFreeTextureSlots;
  29648. private _maxSimultaneousTextures;
  29649. private _activeRequests;
  29650. private _texturesSupported;
  29651. /** @hidden */ private _textureFormatInUse: Nullable<string>;
  29652. /**
  29653. * Gets the list of texture formats supported
  29654. */
  29655. readonly texturesSupported: Array<string>;
  29656. /**
  29657. * Gets the list of texture formats in use
  29658. */
  29659. readonly textureFormatInUse: Nullable<string>;
  29660. /**
  29661. * Gets the current viewport
  29662. */
  29663. readonly currentViewport: Nullable<IViewportLike>;
  29664. /**
  29665. * Gets the default empty texture
  29666. */
  29667. readonly emptyTexture: InternalTexture;
  29668. /**
  29669. * Gets the default empty 3D texture
  29670. */
  29671. readonly emptyTexture3D: InternalTexture;
  29672. /**
  29673. * Gets the default empty cube texture
  29674. */
  29675. readonly emptyCubeTexture: InternalTexture;
  29676. /**
  29677. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  29678. */
  29679. readonly premultipliedAlpha: boolean;
  29680. /**
  29681. * Creates a new engine
  29682. * @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
  29683. * @param antialias defines enable antialiasing (default: false)
  29684. * @param options defines further options to be sent to the getContext() function
  29685. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  29686. */
  29687. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  29688. /**
  29689. * Initializes a webVR display and starts listening to display change events
  29690. * The onVRDisplayChangedObservable will be notified upon these changes
  29691. * @returns The onVRDisplayChangedObservable
  29692. */
  29693. initWebVR(): Observable<IDisplayChangedEventArgs>;
  29694. /** @hidden */ private _prepareVRComponent(): void;
  29695. /** @hidden */ private _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  29696. /** @hidden */ private _submitVRFrame(): void;
  29697. /**
  29698. * Call this function to leave webVR mode
  29699. * Will do nothing if webVR is not supported or if there is no webVR device
  29700. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29701. */
  29702. disableVR(): void;
  29703. /**
  29704. * Gets a boolean indicating that the system is in VR mode and is presenting
  29705. * @returns true if VR mode is engaged
  29706. */
  29707. isVRPresenting(): boolean;
  29708. /** @hidden */ private _requestVRFrame(): void;
  29709. private _disableTouchAction;
  29710. private _rebuildInternalTextures;
  29711. private _rebuildEffects;
  29712. /**
  29713. * Gets a boolean indicating if all created effects are ready
  29714. * @returns true if all effects are ready
  29715. */
  29716. areAllEffectsReady(): boolean;
  29717. private _rebuildBuffers;
  29718. private _initGLContext;
  29719. /**
  29720. * Gets version of the current webGL context
  29721. */
  29722. readonly webGLVersion: number;
  29723. /**
  29724. * Gets a string idenfifying the name of the class
  29725. * @returns "Engine" string
  29726. */
  29727. getClassName(): string;
  29728. /**
  29729. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  29730. */
  29731. readonly isStencilEnable: boolean;
  29732. /** @hidden */ private _prepareWorkingCanvas(): void;
  29733. /**
  29734. * Reset the texture cache to empty state
  29735. */
  29736. resetTextureCache(): void;
  29737. /**
  29738. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  29739. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29740. * @returns true if engine is in deterministic lock step mode
  29741. */
  29742. isDeterministicLockStep(): boolean;
  29743. /**
  29744. * Gets the max steps when engine is running in deterministic lock step
  29745. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29746. * @returns the max steps
  29747. */
  29748. getLockstepMaxSteps(): number;
  29749. /**
  29750. * Gets an object containing information about the current webGL context
  29751. * @returns an object containing the vender, the renderer and the version of the current webGL context
  29752. */
  29753. getGlInfo(): {
  29754. vendor: string;
  29755. renderer: string;
  29756. version: string;
  29757. };
  29758. /**
  29759. * Gets current aspect ratio
  29760. * @param viewportOwner defines the camera to use to get the aspect ratio
  29761. * @param useScreen defines if screen size must be used (or the current render target if any)
  29762. * @returns a number defining the aspect ratio
  29763. */
  29764. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  29765. /**
  29766. * Gets current screen aspect ratio
  29767. * @returns a number defining the aspect ratio
  29768. */
  29769. getScreenAspectRatio(): number;
  29770. /**
  29771. * Gets the current render width
  29772. * @param useScreen defines if screen size must be used (or the current render target if any)
  29773. * @returns a number defining the current render width
  29774. */
  29775. getRenderWidth(useScreen?: boolean): number;
  29776. /**
  29777. * Gets the current render height
  29778. * @param useScreen defines if screen size must be used (or the current render target if any)
  29779. * @returns a number defining the current render height
  29780. */
  29781. getRenderHeight(useScreen?: boolean): number;
  29782. /**
  29783. * Gets the HTML canvas attached with the current webGL context
  29784. * @returns a HTML canvas
  29785. */
  29786. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  29787. /**
  29788. * Gets host window
  29789. * @returns the host window object
  29790. */
  29791. getHostWindow(): Window;
  29792. /**
  29793. * Gets host document
  29794. * @returns the host document object
  29795. */
  29796. getHostDocument(): Document;
  29797. /**
  29798. * Gets the client rect of the HTML canvas attached with the current webGL context
  29799. * @returns a client rectanglee
  29800. */
  29801. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  29802. /**
  29803. * Defines the hardware scaling level.
  29804. * By default the hardware scaling level is computed from the window device ratio.
  29805. * 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.
  29806. * @param level defines the level to use
  29807. */
  29808. setHardwareScalingLevel(level: number): void;
  29809. /**
  29810. * Gets the current hardware scaling level.
  29811. * By default the hardware scaling level is computed from the window device ratio.
  29812. * 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.
  29813. * @returns a number indicating the current hardware scaling level
  29814. */
  29815. getHardwareScalingLevel(): number;
  29816. /**
  29817. * Gets the list of loaded textures
  29818. * @returns an array containing all loaded textures
  29819. */
  29820. getLoadedTexturesCache(): InternalTexture[];
  29821. /**
  29822. * Gets the object containing all engine capabilities
  29823. * @returns the EngineCapabilities object
  29824. */
  29825. getCaps(): EngineCapabilities;
  29826. /**
  29827. * Gets the current depth function
  29828. * @returns a number defining the depth function
  29829. */
  29830. getDepthFunction(): Nullable<number>;
  29831. /**
  29832. * Sets the current depth function
  29833. * @param depthFunc defines the function to use
  29834. */
  29835. setDepthFunction(depthFunc: number): void;
  29836. /**
  29837. * Sets the current depth function to GREATER
  29838. */
  29839. setDepthFunctionToGreater(): void;
  29840. /**
  29841. * Sets the current depth function to GEQUAL
  29842. */
  29843. setDepthFunctionToGreaterOrEqual(): void;
  29844. /**
  29845. * Sets the current depth function to LESS
  29846. */
  29847. setDepthFunctionToLess(): void;
  29848. private _cachedStencilBuffer;
  29849. private _cachedStencilFunction;
  29850. private _cachedStencilMask;
  29851. private _cachedStencilOperationPass;
  29852. private _cachedStencilOperationFail;
  29853. private _cachedStencilOperationDepthFail;
  29854. private _cachedStencilReference;
  29855. /**
  29856. * Caches the the state of the stencil buffer
  29857. */
  29858. cacheStencilState(): void;
  29859. /**
  29860. * Restores the state of the stencil buffer
  29861. */
  29862. restoreStencilState(): void;
  29863. /**
  29864. * Sets the current depth function to LEQUAL
  29865. */
  29866. setDepthFunctionToLessOrEqual(): void;
  29867. /**
  29868. * Gets a boolean indicating if stencil buffer is enabled
  29869. * @returns the current stencil buffer state
  29870. */
  29871. getStencilBuffer(): boolean;
  29872. /**
  29873. * Enable or disable the stencil buffer
  29874. * @param enable defines if the stencil buffer must be enabled or disabled
  29875. */
  29876. setStencilBuffer(enable: boolean): void;
  29877. /**
  29878. * Gets the current stencil mask
  29879. * @returns a number defining the new stencil mask to use
  29880. */
  29881. getStencilMask(): number;
  29882. /**
  29883. * Sets the current stencil mask
  29884. * @param mask defines the new stencil mask to use
  29885. */
  29886. setStencilMask(mask: number): void;
  29887. /**
  29888. * Gets the current stencil function
  29889. * @returns a number defining the stencil function to use
  29890. */
  29891. getStencilFunction(): number;
  29892. /**
  29893. * Gets the current stencil reference value
  29894. * @returns a number defining the stencil reference value to use
  29895. */
  29896. getStencilFunctionReference(): number;
  29897. /**
  29898. * Gets the current stencil mask
  29899. * @returns a number defining the stencil mask to use
  29900. */
  29901. getStencilFunctionMask(): number;
  29902. /**
  29903. * Sets the current stencil function
  29904. * @param stencilFunc defines the new stencil function to use
  29905. */
  29906. setStencilFunction(stencilFunc: number): void;
  29907. /**
  29908. * Sets the current stencil reference
  29909. * @param reference defines the new stencil reference to use
  29910. */
  29911. setStencilFunctionReference(reference: number): void;
  29912. /**
  29913. * Sets the current stencil mask
  29914. * @param mask defines the new stencil mask to use
  29915. */
  29916. setStencilFunctionMask(mask: number): void;
  29917. /**
  29918. * Gets the current stencil operation when stencil fails
  29919. * @returns a number defining stencil operation to use when stencil fails
  29920. */
  29921. getStencilOperationFail(): number;
  29922. /**
  29923. * Gets the current stencil operation when depth fails
  29924. * @returns a number defining stencil operation to use when depth fails
  29925. */
  29926. getStencilOperationDepthFail(): number;
  29927. /**
  29928. * Gets the current stencil operation when stencil passes
  29929. * @returns a number defining stencil operation to use when stencil passes
  29930. */
  29931. getStencilOperationPass(): number;
  29932. /**
  29933. * Sets the stencil operation to use when stencil fails
  29934. * @param operation defines the stencil operation to use when stencil fails
  29935. */
  29936. setStencilOperationFail(operation: number): void;
  29937. /**
  29938. * Sets the stencil operation to use when depth fails
  29939. * @param operation defines the stencil operation to use when depth fails
  29940. */
  29941. setStencilOperationDepthFail(operation: number): void;
  29942. /**
  29943. * Sets the stencil operation to use when stencil passes
  29944. * @param operation defines the stencil operation to use when stencil passes
  29945. */
  29946. setStencilOperationPass(operation: number): void;
  29947. /**
  29948. * Sets a boolean indicating if the dithering state is enabled or disabled
  29949. * @param value defines the dithering state
  29950. */
  29951. setDitheringState(value: boolean): void;
  29952. /**
  29953. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  29954. * @param value defines the rasterizer state
  29955. */
  29956. setRasterizerState(value: boolean): void;
  29957. /**
  29958. * stop executing a render loop function and remove it from the execution array
  29959. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29960. */
  29961. stopRenderLoop(renderFunction?: () => void): void;
  29962. /** @hidden */ private _renderLoop(): void;
  29963. /**
  29964. * Register and execute a render loop. The engine can have more than one render function
  29965. * @param renderFunction defines the function to continuously execute
  29966. */
  29967. runRenderLoop(renderFunction: () => void): void;
  29968. /**
  29969. * Toggle full screen mode
  29970. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29971. */
  29972. switchFullscreen(requestPointerLock: boolean): void;
  29973. /**
  29974. * Enters full screen mode
  29975. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29976. */
  29977. enterFullscreen(requestPointerLock: boolean): void;
  29978. /**
  29979. * Exits full screen mode
  29980. */
  29981. exitFullscreen(): void;
  29982. /**
  29983. * Enters Pointerlock mode
  29984. */
  29985. enterPointerlock(): void;
  29986. /**
  29987. * Exits Pointerlock mode
  29988. */
  29989. exitPointerlock(): void;
  29990. /**
  29991. * Clear the current render buffer or the current render target (if any is set up)
  29992. * @param color defines the color to use
  29993. * @param backBuffer defines if the back buffer must be cleared
  29994. * @param depth defines if the depth buffer must be cleared
  29995. * @param stencil defines if the stencil buffer must be cleared
  29996. */
  29997. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29998. /**
  29999. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  30000. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30001. * @param y defines the y-coordinate of the corner of the clear rectangle
  30002. * @param width defines the width of the clear rectangle
  30003. * @param height defines the height of the clear rectangle
  30004. * @param clearColor defines the clear color
  30005. */
  30006. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  30007. /**
  30008. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  30009. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30010. * @param y defines the y-coordinate of the corner of the clear rectangle
  30011. * @param width defines the width of the clear rectangle
  30012. * @param height defines the height of the clear rectangle
  30013. */
  30014. enableScissor(x: number, y: number, width: number, height: number): void;
  30015. /**
  30016. * Disable previously set scissor test rectangle
  30017. */
  30018. disableScissor(): void;
  30019. private _viewportCached;
  30020. /** @hidden */ private _viewport(x: number, y: number, width: number, height: number): void;
  30021. /**
  30022. * Set the WebGL's viewport
  30023. * @param viewport defines the viewport element to be used
  30024. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30025. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30026. */
  30027. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30028. /**
  30029. * Directly set the WebGL Viewport
  30030. * @param x defines the x coordinate of the viewport (in screen space)
  30031. * @param y defines the y coordinate of the viewport (in screen space)
  30032. * @param width defines the width of the viewport (in screen space)
  30033. * @param height defines the height of the viewport (in screen space)
  30034. * @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
  30035. */
  30036. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  30037. /**
  30038. * Begin a new frame
  30039. */
  30040. beginFrame(): void;
  30041. /**
  30042. * Enf the current frame
  30043. */
  30044. endFrame(): void;
  30045. /**
  30046. * Resize the view according to the canvas' size
  30047. */
  30048. resize(): void;
  30049. /**
  30050. * Force a specific size of the canvas
  30051. * @param width defines the new canvas' width
  30052. * @param height defines the new canvas' height
  30053. */
  30054. setSize(width: number, height: number): void;
  30055. /**
  30056. * Binds the frame buffer to the specified texture.
  30057. * @param texture The texture to render to or null for the default canvas
  30058. * @param faceIndex The face of the texture to render to in case of cube texture
  30059. * @param requiredWidth The width of the target to render to
  30060. * @param requiredHeight The height of the target to render to
  30061. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30062. * @param depthStencilTexture The depth stencil texture to use to render
  30063. * @param lodLevel defines le lod level to bind to the frame buffer
  30064. */
  30065. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30066. /** @hidden */ private _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30067. /**
  30068. * Unbind the current render target texture from the webGL context
  30069. * @param texture defines the render target texture to unbind
  30070. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30071. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30072. */
  30073. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30074. /**
  30075. * Force the mipmap generation for the given render target texture
  30076. * @param texture defines the render target texture to use
  30077. */
  30078. generateMipMapsForCubemap(texture: InternalTexture): void;
  30079. /**
  30080. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30081. */
  30082. flushFramebuffer(): void;
  30083. /**
  30084. * Unbind the current render target and bind the default framebuffer
  30085. */
  30086. restoreDefaultFramebuffer(): void;
  30087. /**
  30088. * Create an uniform buffer
  30089. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30090. * @param elements defines the content of the uniform buffer
  30091. * @returns the webGL uniform buffer
  30092. */
  30093. createUniformBuffer(elements: FloatArray): DataBuffer;
  30094. /**
  30095. * Create a dynamic uniform buffer
  30096. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30097. * @param elements defines the content of the uniform buffer
  30098. * @returns the webGL uniform buffer
  30099. */
  30100. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  30101. /**
  30102. * Update an existing uniform buffer
  30103. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30104. * @param uniformBuffer defines the target uniform buffer
  30105. * @param elements defines the content to update
  30106. * @param offset defines the offset in the uniform buffer where update should start
  30107. * @param count defines the size of the data to update
  30108. */
  30109. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  30110. private _resetVertexBufferBinding;
  30111. /**
  30112. * Creates a vertex buffer
  30113. * @param data the data for the vertex buffer
  30114. * @returns the new WebGL static buffer
  30115. */
  30116. createVertexBuffer(data: DataArray): DataBuffer;
  30117. /**
  30118. * Creates a dynamic vertex buffer
  30119. * @param data the data for the dynamic vertex buffer
  30120. * @returns the new WebGL dynamic buffer
  30121. */
  30122. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30123. /**
  30124. * Update a dynamic index buffer
  30125. * @param indexBuffer defines the target index buffer
  30126. * @param indices defines the data to update
  30127. * @param offset defines the offset in the target index buffer where update should start
  30128. */
  30129. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  30130. /**
  30131. * Updates a dynamic vertex buffer.
  30132. * @param vertexBuffer the vertex buffer to update
  30133. * @param data the data used to update the vertex buffer
  30134. * @param byteOffset the byte offset of the data
  30135. * @param byteLength the byte length of the data
  30136. */
  30137. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30138. private _resetIndexBufferBinding;
  30139. /**
  30140. * Creates a new index buffer
  30141. * @param indices defines the content of the index buffer
  30142. * @param updatable defines if the index buffer must be updatable
  30143. * @returns a new webGL buffer
  30144. */
  30145. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30146. /**
  30147. * Bind a webGL buffer to the webGL context
  30148. * @param buffer defines the buffer to bind
  30149. */
  30150. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30151. /**
  30152. * Bind an uniform buffer to the current webGL context
  30153. * @param buffer defines the buffer to bind
  30154. */
  30155. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  30156. /**
  30157. * Bind a buffer to the current webGL context at a given location
  30158. * @param buffer defines the buffer to bind
  30159. * @param location defines the index where to bind the buffer
  30160. */
  30161. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  30162. /**
  30163. * Bind a specific block at a given index in a specific shader program
  30164. * @param pipelineContext defines the pipeline context to use
  30165. * @param blockName defines the block name
  30166. * @param index defines the index where to bind the block
  30167. */
  30168. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  30169. private bindIndexBuffer;
  30170. private bindBuffer;
  30171. /**
  30172. * update the bound buffer with the given data
  30173. * @param data defines the data to update
  30174. */
  30175. updateArrayBuffer(data: Float32Array): void;
  30176. private _vertexAttribPointer;
  30177. private _bindIndexBufferWithCache;
  30178. private _bindVertexBuffersAttributes;
  30179. /**
  30180. * Records a vertex array object
  30181. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30182. * @param vertexBuffers defines the list of vertex buffers to store
  30183. * @param indexBuffer defines the index buffer to store
  30184. * @param effect defines the effect to store
  30185. * @returns the new vertex array object
  30186. */
  30187. recordVertexArrayObject(vertexBuffers: {
  30188. [key: string]: VertexBuffer;
  30189. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30190. /**
  30191. * Bind a specific vertex array object
  30192. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30193. * @param vertexArrayObject defines the vertex array object to bind
  30194. * @param indexBuffer defines the index buffer to bind
  30195. */
  30196. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30197. /**
  30198. * Bind webGl buffers directly to the webGL context
  30199. * @param vertexBuffer defines the vertex buffer to bind
  30200. * @param indexBuffer defines the index buffer to bind
  30201. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30202. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30203. * @param effect defines the effect associated with the vertex buffer
  30204. */
  30205. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30206. private _unbindVertexArrayObject;
  30207. /**
  30208. * Bind a list of vertex buffers to the webGL context
  30209. * @param vertexBuffers defines the list of vertex buffers to bind
  30210. * @param indexBuffer defines the index buffer to bind
  30211. * @param effect defines the effect associated with the vertex buffers
  30212. */
  30213. bindBuffers(vertexBuffers: {
  30214. [key: string]: Nullable<VertexBuffer>;
  30215. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30216. /**
  30217. * Unbind all instance attributes
  30218. */
  30219. unbindInstanceAttributes(): void;
  30220. /**
  30221. * Release and free the memory of a vertex array object
  30222. * @param vao defines the vertex array object to delete
  30223. */
  30224. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30225. /** @hidden */ private _releaseBuffer(buffer: DataBuffer): boolean;
  30226. /**
  30227. * Creates a webGL buffer to use with instanciation
  30228. * @param capacity defines the size of the buffer
  30229. * @returns the webGL buffer
  30230. */
  30231. createInstancesBuffer(capacity: number): DataBuffer;
  30232. /**
  30233. * Delete a webGL buffer used with instanciation
  30234. * @param buffer defines the webGL buffer to delete
  30235. */
  30236. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30237. /**
  30238. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30239. * @param instancesBuffer defines the webGL buffer to update and bind
  30240. * @param data defines the data to store in the buffer
  30241. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30242. */
  30243. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30244. /**
  30245. * Apply all cached states (depth, culling, stencil and alpha)
  30246. */
  30247. applyStates(): void;
  30248. /**
  30249. * Send a draw order
  30250. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30251. * @param indexStart defines the starting index
  30252. * @param indexCount defines the number of index to draw
  30253. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30254. */
  30255. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30256. /**
  30257. * Draw a list of points
  30258. * @param verticesStart defines the index of first vertex to draw
  30259. * @param verticesCount defines the count of vertices to draw
  30260. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30261. */
  30262. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30263. /**
  30264. * Draw a list of unindexed primitives
  30265. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30266. * @param verticesStart defines the index of first vertex to draw
  30267. * @param verticesCount defines the count of vertices to draw
  30268. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30269. */
  30270. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30271. /**
  30272. * Draw a list of indexed primitives
  30273. * @param fillMode defines the primitive to use
  30274. * @param indexStart defines the starting index
  30275. * @param indexCount defines the number of index to draw
  30276. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30277. */
  30278. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30279. /**
  30280. * Draw a list of unindexed primitives
  30281. * @param fillMode defines the primitive to use
  30282. * @param verticesStart defines the index of first vertex to draw
  30283. * @param verticesCount defines the count of vertices to draw
  30284. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30285. */
  30286. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30287. private _drawMode;
  30288. /** @hidden */ private _releaseEffect(effect: Effect): void;
  30289. /** @hidden */ private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30290. /**
  30291. * Create a new effect (used to store vertex/fragment shaders)
  30292. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30293. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30294. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30295. * @param samplers defines an array of string used to represent textures
  30296. * @param defines defines the string containing the defines to use to compile the shaders
  30297. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30298. * @param onCompiled defines a function to call when the effect creation is successful
  30299. * @param onError defines a function to call when the effect creation has failed
  30300. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30301. * @returns the new Effect
  30302. */
  30303. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  30304. private _compileShader;
  30305. private _compileRawShader;
  30306. /**
  30307. * Directly creates a webGL program
  30308. * @param pipelineContext defines the pipeline context to attach to
  30309. * @param vertexCode defines the vertex shader code to use
  30310. * @param fragmentCode defines the fragment shader code to use
  30311. * @param context defines the webGL context to use (if not set, the current one will be used)
  30312. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30313. * @returns the new webGL program
  30314. */
  30315. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30316. /**
  30317. * Creates a webGL program
  30318. * @param pipelineContext defines the pipeline context to attach to
  30319. * @param vertexCode defines the vertex shader code to use
  30320. * @param fragmentCode defines the fragment shader code to use
  30321. * @param defines defines the string containing the defines to use to compile the shaders
  30322. * @param context defines the webGL context to use (if not set, the current one will be used)
  30323. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30324. * @returns the new webGL program
  30325. */
  30326. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30327. /**
  30328. * Creates a new pipeline context
  30329. * @returns the new pipeline
  30330. */
  30331. createPipelineContext(): WebGLPipelineContext;
  30332. private _createShaderProgram;
  30333. private _finalizePipelineContext;
  30334. /** @hidden */ private _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30335. /** @hidden */ private _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30336. /** @hidden */ private _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30337. /**
  30338. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30339. * @param pipelineContext defines the pipeline context to use
  30340. * @param uniformsNames defines the list of uniform names
  30341. * @returns an array of webGL uniform locations
  30342. */
  30343. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30344. /**
  30345. * Gets the lsit of active attributes for a given webGL program
  30346. * @param pipelineContext defines the pipeline context to use
  30347. * @param attributesNames defines the list of attribute names to get
  30348. * @returns an array of indices indicating the offset of each attribute
  30349. */
  30350. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30351. /**
  30352. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30353. * @param effect defines the effect to activate
  30354. */
  30355. enableEffect(effect: Nullable<Effect>): void;
  30356. /**
  30357. * Set the value of an uniform to an array of int32
  30358. * @param uniform defines the webGL uniform location where to store the value
  30359. * @param array defines the array of int32 to store
  30360. */
  30361. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30362. /**
  30363. * Set the value of an uniform to an array of int32 (stored as vec2)
  30364. * @param uniform defines the webGL uniform location where to store the value
  30365. * @param array defines the array of int32 to store
  30366. */
  30367. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30368. /**
  30369. * Set the value of an uniform to an array of int32 (stored as vec3)
  30370. * @param uniform defines the webGL uniform location where to store the value
  30371. * @param array defines the array of int32 to store
  30372. */
  30373. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30374. /**
  30375. * Set the value of an uniform to an array of int32 (stored as vec4)
  30376. * @param uniform defines the webGL uniform location where to store the value
  30377. * @param array defines the array of int32 to store
  30378. */
  30379. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30380. /**
  30381. * Set the value of an uniform to an array of float32
  30382. * @param uniform defines the webGL uniform location where to store the value
  30383. * @param array defines the array of float32 to store
  30384. */
  30385. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30386. /**
  30387. * Set the value of an uniform to an array of float32 (stored as vec2)
  30388. * @param uniform defines the webGL uniform location where to store the value
  30389. * @param array defines the array of float32 to store
  30390. */
  30391. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30392. /**
  30393. * Set the value of an uniform to an array of float32 (stored as vec3)
  30394. * @param uniform defines the webGL uniform location where to store the value
  30395. * @param array defines the array of float32 to store
  30396. */
  30397. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30398. /**
  30399. * Set the value of an uniform to an array of float32 (stored as vec4)
  30400. * @param uniform defines the webGL uniform location where to store the value
  30401. * @param array defines the array of float32 to store
  30402. */
  30403. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30404. /**
  30405. * Set the value of an uniform to an array of number
  30406. * @param uniform defines the webGL uniform location where to store the value
  30407. * @param array defines the array of number to store
  30408. */
  30409. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30410. /**
  30411. * Set the value of an uniform to an array of number (stored as vec2)
  30412. * @param uniform defines the webGL uniform location where to store the value
  30413. * @param array defines the array of number to store
  30414. */
  30415. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30416. /**
  30417. * Set the value of an uniform to an array of number (stored as vec3)
  30418. * @param uniform defines the webGL uniform location where to store the value
  30419. * @param array defines the array of number to store
  30420. */
  30421. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30422. /**
  30423. * Set the value of an uniform to an array of number (stored as vec4)
  30424. * @param uniform defines the webGL uniform location where to store the value
  30425. * @param array defines the array of number to store
  30426. */
  30427. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30428. /**
  30429. * Set the value of an uniform to an array of float32 (stored as matrices)
  30430. * @param uniform defines the webGL uniform location where to store the value
  30431. * @param matrices defines the array of float32 to store
  30432. */
  30433. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30434. /**
  30435. * Set the value of an uniform to a matrix (3x3)
  30436. * @param uniform defines the webGL uniform location where to store the value
  30437. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30438. */
  30439. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30440. /**
  30441. * Set the value of an uniform to a matrix (2x2)
  30442. * @param uniform defines the webGL uniform location where to store the value
  30443. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30444. */
  30445. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30446. /**
  30447. * Set the value of an uniform to a number (int)
  30448. * @param uniform defines the webGL uniform location where to store the value
  30449. * @param value defines the int number to store
  30450. */
  30451. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30452. /**
  30453. * Set the value of an uniform to a number (float)
  30454. * @param uniform defines the webGL uniform location where to store the value
  30455. * @param value defines the float number to store
  30456. */
  30457. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30458. /**
  30459. * Set the value of an uniform to a vec2
  30460. * @param uniform defines the webGL uniform location where to store the value
  30461. * @param x defines the 1st component of the value
  30462. * @param y defines the 2nd component of the value
  30463. */
  30464. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30465. /**
  30466. * Set the value of an uniform to a vec3
  30467. * @param uniform defines the webGL uniform location where to store the value
  30468. * @param x defines the 1st component of the value
  30469. * @param y defines the 2nd component of the value
  30470. * @param z defines the 3rd component of the value
  30471. */
  30472. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30473. /**
  30474. * Set the value of an uniform to a boolean
  30475. * @param uniform defines the webGL uniform location where to store the value
  30476. * @param bool defines the boolean to store
  30477. */
  30478. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  30479. /**
  30480. * Set the value of an uniform to a vec4
  30481. * @param uniform defines the webGL uniform location where to store the value
  30482. * @param x defines the 1st component of the value
  30483. * @param y defines the 2nd component of the value
  30484. * @param z defines the 3rd component of the value
  30485. * @param w defines the 4th component of the value
  30486. */
  30487. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30488. /**
  30489. * Sets a Color4 on a uniform variable
  30490. * @param uniform defines the uniform location
  30491. * @param color4 defines the value to be set
  30492. */
  30493. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  30494. /**
  30495. * Set various states to the webGL context
  30496. * @param culling defines backface culling state
  30497. * @param zOffset defines the value to apply to zOffset (0 by default)
  30498. * @param force defines if states must be applied even if cache is up to date
  30499. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  30500. */
  30501. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  30502. /**
  30503. * Set the z offset to apply to current rendering
  30504. * @param value defines the offset to apply
  30505. */
  30506. setZOffset(value: number): void;
  30507. /**
  30508. * Gets the current value of the zOffset
  30509. * @returns the current zOffset state
  30510. */
  30511. getZOffset(): number;
  30512. /**
  30513. * Enable or disable depth buffering
  30514. * @param enable defines the state to set
  30515. */
  30516. setDepthBuffer(enable: boolean): void;
  30517. /**
  30518. * Gets a boolean indicating if depth writing is enabled
  30519. * @returns the current depth writing state
  30520. */
  30521. getDepthWrite(): boolean;
  30522. /**
  30523. * Enable or disable depth writing
  30524. * @param enable defines the state to set
  30525. */
  30526. setDepthWrite(enable: boolean): void;
  30527. /**
  30528. * Enable or disable color writing
  30529. * @param enable defines the state to set
  30530. */
  30531. setColorWrite(enable: boolean): void;
  30532. /**
  30533. * Gets a boolean indicating if color writing is enabled
  30534. * @returns the current color writing state
  30535. */
  30536. getColorWrite(): boolean;
  30537. /**
  30538. * Sets alpha constants used by some alpha blending modes
  30539. * @param r defines the red component
  30540. * @param g defines the green component
  30541. * @param b defines the blue component
  30542. * @param a defines the alpha component
  30543. */
  30544. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  30545. /**
  30546. * Sets the current alpha mode
  30547. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  30548. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  30549. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30550. */
  30551. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  30552. /**
  30553. * Gets the current alpha mode
  30554. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30555. * @returns the current alpha mode
  30556. */
  30557. getAlphaMode(): number;
  30558. /**
  30559. * Clears the list of texture accessible through engine.
  30560. * This can help preventing texture load conflict due to name collision.
  30561. */
  30562. clearInternalTexturesCache(): void;
  30563. /**
  30564. * Force the entire cache to be cleared
  30565. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30566. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30567. */
  30568. wipeCaches(bruteForce?: boolean): void;
  30569. /**
  30570. * Set the compressed texture format to use, based on the formats you have, and the formats
  30571. * supported by the hardware / browser.
  30572. *
  30573. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  30574. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  30575. * to API arguments needed to compressed textures. This puts the burden on the container
  30576. * generator to house the arcane code for determining these for current & future formats.
  30577. *
  30578. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  30579. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  30580. *
  30581. * Note: The result of this call is not taken into account when a texture is base64.
  30582. *
  30583. * @param formatsAvailable defines the list of those format families you have created
  30584. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  30585. *
  30586. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  30587. * @returns The extension selected.
  30588. */
  30589. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  30590. /** @hidden */ private _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30591. min: number;
  30592. mag: number;
  30593. };
  30594. /** @hidden */ private _createTexture(): WebGLTexture;
  30595. /**
  30596. * Usually called from Texture.ts.
  30597. * Passed information to create a WebGLTexture
  30598. * @param urlArg defines a value which contains one of the following:
  30599. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30600. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30601. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30602. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30603. * @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)
  30604. * @param scene needed for loading to the correct scene
  30605. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30606. * @param onLoad optional callback to be called upon successful completion
  30607. * @param onError optional callback to be called upon failure
  30608. * @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
  30609. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30610. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30611. * @param forcedExtension defines the extension to use to pick the right loader
  30612. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30613. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30614. */
  30615. 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;
  30616. /**
  30617. * @hidden
  30618. * Rescales a texture
  30619. * @param source input texutre
  30620. * @param destination destination texture
  30621. * @param scene scene to use to render the resize
  30622. * @param internalFormat format to use when resizing
  30623. * @param onComplete callback to be called when resize has completed
  30624. */ private _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  30625. private _unpackFlipYCached;
  30626. /**
  30627. * In case you are sharing the context with other applications, it might
  30628. * be interested to not cache the unpack flip y state to ensure a consistent
  30629. * value would be set.
  30630. */
  30631. enableUnpackFlipYCached: boolean;
  30632. /** @hidden */ private _unpackFlipY(value: boolean): void;
  30633. /** @hidden */ private _getUnpackAlignement(): number;
  30634. /**
  30635. * Creates a dynamic texture
  30636. * @param width defines the width of the texture
  30637. * @param height defines the height of the texture
  30638. * @param generateMipMaps defines if the engine should generate the mip levels
  30639. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30640. * @returns the dynamic texture inside an InternalTexture
  30641. */
  30642. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  30643. /**
  30644. * Update the sampling mode of a given texture
  30645. * @param samplingMode defines the required sampling mode
  30646. * @param texture defines the texture to update
  30647. */
  30648. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30649. /**
  30650. * Update the content of a dynamic texture
  30651. * @param texture defines the texture to update
  30652. * @param canvas defines the canvas containing the source
  30653. * @param invertY defines if data must be stored with Y axis inverted
  30654. * @param premulAlpha defines if alpha is stored as premultiplied
  30655. * @param format defines the format of the data
  30656. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  30657. */
  30658. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  30659. /**
  30660. * Update a video texture
  30661. * @param texture defines the texture to update
  30662. * @param video defines the video element to use
  30663. * @param invertY defines if data must be stored with Y axis inverted
  30664. */
  30665. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30666. /**
  30667. * Updates a depth texture Comparison Mode and Function.
  30668. * If the comparison Function is equal to 0, the mode will be set to none.
  30669. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  30670. * @param texture The texture to set the comparison function for
  30671. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  30672. */
  30673. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  30674. /** @hidden */ private _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30675. width: number;
  30676. height: number;
  30677. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30678. /**
  30679. * Creates a depth stencil texture.
  30680. * This is only available in WebGL 2 or with the depth texture extension available.
  30681. * @param size The size of face edge in the texture.
  30682. * @param options The options defining the texture.
  30683. * @returns The texture
  30684. */
  30685. createDepthStencilTexture(size: number | {
  30686. width: number;
  30687. height: number;
  30688. }, options: DepthTextureCreationOptions): InternalTexture;
  30689. /**
  30690. * Creates a depth stencil texture.
  30691. * This is only available in WebGL 2 or with the depth texture extension available.
  30692. * @param size The size of face edge in the texture.
  30693. * @param options The options defining the texture.
  30694. * @returns The texture
  30695. */
  30696. private _createDepthStencilTexture;
  30697. /**
  30698. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  30699. * @param renderTarget The render target to set the frame buffer for
  30700. */
  30701. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  30702. /**
  30703. * Creates a new render target texture
  30704. * @param size defines the size of the texture
  30705. * @param options defines the options used to create the texture
  30706. * @returns a new render target texture stored in an InternalTexture
  30707. */
  30708. createRenderTargetTexture(size: number | {
  30709. width: number;
  30710. height: number;
  30711. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  30712. /** @hidden */ private _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30713. /**
  30714. * Updates the sample count of a render target texture
  30715. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  30716. * @param texture defines the texture to update
  30717. * @param samples defines the sample count to set
  30718. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  30719. */
  30720. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  30721. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30722. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30723. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30724. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  30725. /**
  30726. * @hidden
  30727. */ private _setCubeMapTextureParams(loadMipmap: boolean): void;
  30728. private _prepareWebGLTextureContinuation;
  30729. private _prepareWebGLTexture;
  30730. /** @hidden */ private _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  30731. /** @hidden */ private _releaseFramebufferObjects(texture: InternalTexture): void;
  30732. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  30733. private setProgram;
  30734. private _boundUniforms;
  30735. /**
  30736. * Binds an effect to the webGL context
  30737. * @param effect defines the effect to bind
  30738. */
  30739. bindSamplers(effect: Effect): void;
  30740. private _activateCurrentTexture;
  30741. /** @hidden */ private _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  30742. /** @hidden */ private _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  30743. /**
  30744. * Sets a texture to the webGL context from a postprocess
  30745. * @param channel defines the channel to use
  30746. * @param postProcess defines the source postprocess
  30747. */
  30748. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  30749. /**
  30750. * Binds the output of the passed in post process to the texture channel specified
  30751. * @param channel The channel the texture should be bound to
  30752. * @param postProcess The post process which's output should be bound
  30753. */
  30754. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  30755. /**
  30756. * Unbind all textures from the webGL context
  30757. */
  30758. unbindAllTextures(): void;
  30759. /**
  30760. * Sets a texture to the according uniform.
  30761. * @param channel The texture channel
  30762. * @param uniform The uniform to set
  30763. * @param texture The texture to apply
  30764. */
  30765. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  30766. /**
  30767. * Sets a depth stencil texture from a render target to the according uniform.
  30768. * @param channel The texture channel
  30769. * @param uniform The uniform to set
  30770. * @param texture The render target texture containing the depth stencil texture to apply
  30771. */
  30772. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  30773. private _bindSamplerUniformToChannel;
  30774. private _getTextureWrapMode;
  30775. private _setTexture;
  30776. /**
  30777. * Sets an array of texture to the webGL context
  30778. * @param channel defines the channel where the texture array must be set
  30779. * @param uniform defines the associated uniform location
  30780. * @param textures defines the array of textures to bind
  30781. */
  30782. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  30783. /** @hidden */ private _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  30784. private _setTextureParameterFloat;
  30785. private _setTextureParameterInteger;
  30786. /**
  30787. * Reads pixels from the current frame buffer. Please note that this function can be slow
  30788. * @param x defines the x coordinate of the rectangle where pixels must be read
  30789. * @param y defines the y coordinate of the rectangle where pixels must be read
  30790. * @param width defines the width of the rectangle where pixels must be read
  30791. * @param height defines the height of the rectangle where pixels must be read
  30792. * @returns a Uint8Array containing RGBA colors
  30793. */
  30794. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  30795. /**
  30796. * Add an externaly attached data from its key.
  30797. * This method call will fail and return false, if such key already exists.
  30798. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  30799. * @param key the unique key that identifies the data
  30800. * @param data the data object to associate to the key for this Engine instance
  30801. * @return true if no such key were already present and the data was added successfully, false otherwise
  30802. */
  30803. addExternalData<T>(key: string, data: T): boolean;
  30804. /**
  30805. * Get an externaly attached data from its key
  30806. * @param key the unique key that identifies the data
  30807. * @return the associated data, if present (can be null), or undefined if not present
  30808. */
  30809. getExternalData<T>(key: string): T;
  30810. /**
  30811. * Get an externaly attached data from its key, create it using a factory if it's not already present
  30812. * @param key the unique key that identifies the data
  30813. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  30814. * @return the associated data, can be null if the factory returned null.
  30815. */
  30816. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  30817. /**
  30818. * Remove an externaly attached data from the Engine instance
  30819. * @param key the unique key that identifies the data
  30820. * @return true if the data was successfully removed, false if it doesn't exist
  30821. */
  30822. removeExternalData(key: string): boolean;
  30823. /**
  30824. * Unbind all vertex attributes from the webGL context
  30825. */
  30826. unbindAllAttributes(): void;
  30827. /**
  30828. * 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
  30829. */
  30830. releaseEffects(): void;
  30831. /**
  30832. * Dispose and release all associated resources
  30833. */
  30834. dispose(): void;
  30835. /**
  30836. * Display the loading screen
  30837. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30838. */
  30839. displayLoadingUI(): void;
  30840. /**
  30841. * Hide the loading screen
  30842. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30843. */
  30844. hideLoadingUI(): void;
  30845. /**
  30846. * Gets the current loading screen object
  30847. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30848. */
  30849. /**
  30850. * Sets the current loading screen object
  30851. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30852. */
  30853. loadingScreen: ILoadingScreen;
  30854. /**
  30855. * Sets the current loading screen text
  30856. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30857. */
  30858. loadingUIText: string;
  30859. /**
  30860. * Sets the current loading screen background color
  30861. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30862. */
  30863. loadingUIBackgroundColor: string;
  30864. /**
  30865. * Attach a new callback raised when context lost event is fired
  30866. * @param callback defines the callback to call
  30867. */
  30868. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30869. /**
  30870. * Attach a new callback raised when context restored event is fired
  30871. * @param callback defines the callback to call
  30872. */
  30873. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30874. /**
  30875. * Gets the source code of the vertex shader associated with a specific webGL program
  30876. * @param program defines the program to use
  30877. * @returns a string containing the source code of the vertex shader associated with the program
  30878. */
  30879. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  30880. /**
  30881. * Gets the source code of the fragment shader associated with a specific webGL program
  30882. * @param program defines the program to use
  30883. * @returns a string containing the source code of the fragment shader associated with the program
  30884. */
  30885. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  30886. /**
  30887. * Get the current error code of the webGL context
  30888. * @returns the error code
  30889. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30890. */
  30891. getError(): number;
  30892. /**
  30893. * Gets the current framerate
  30894. * @returns a number representing the framerate
  30895. */
  30896. getFps(): number;
  30897. /**
  30898. * Gets the time spent between current and previous frame
  30899. * @returns a number representing the delta time in ms
  30900. */
  30901. getDeltaTime(): number;
  30902. private _measureFps;
  30903. /** @hidden */ private _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  30904. private _canRenderToFloatFramebuffer;
  30905. private _canRenderToHalfFloatFramebuffer;
  30906. private _canRenderToFramebuffer;
  30907. /** @hidden */ private _getWebGLTextureType(type: number): number;
  30908. /** @hidden */ private _getInternalFormat(format: number): number;
  30909. /** @hidden */ private _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30910. /** @hidden */ private _getRGBAMultiSampleBufferFormat(type: number): number;
  30911. /** @hidden */ private _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  30912. /** @hidden */ private _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  30913. /**
  30914. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30915. * @returns true if the engine can be created
  30916. * @ignorenaming
  30917. */
  30918. static isSupported(): boolean;
  30919. /**
  30920. * Find the next highest power of two.
  30921. * @param x Number to start search from.
  30922. * @return Next highest power of two.
  30923. */
  30924. static CeilingPOT(x: number): number;
  30925. /**
  30926. * Find the next lowest power of two.
  30927. * @param x Number to start search from.
  30928. * @return Next lowest power of two.
  30929. */
  30930. static FloorPOT(x: number): number;
  30931. /**
  30932. * Find the nearest power of two.
  30933. * @param x Number to start search from.
  30934. * @return Next nearest power of two.
  30935. */
  30936. static NearestPOT(x: number): number;
  30937. /**
  30938. * Get the closest exponent of two
  30939. * @param value defines the value to approximate
  30940. * @param max defines the maximum value to return
  30941. * @param mode defines how to define the closest value
  30942. * @returns closest exponent of two of the given value
  30943. */
  30944. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30945. /**
  30946. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30947. * @param func - the function to be called
  30948. * @param requester - the object that will request the next frame. Falls back to window.
  30949. * @returns frame number
  30950. */
  30951. static QueueNewFrame(func: () => void, requester?: any): number;
  30952. /**
  30953. * Ask the browser to promote the current element to pointerlock mode
  30954. * @param element defines the DOM element to promote
  30955. */ private static _RequestPointerlock(element: HTMLElement): void;
  30956. /**
  30957. * Asks the browser to exit pointerlock mode
  30958. */ private static _ExitPointerlock(): void;
  30959. /**
  30960. * Ask the browser to promote the current element to fullscreen rendering mode
  30961. * @param element defines the DOM element to promote
  30962. */ private static _RequestFullscreen(element: HTMLElement): void;
  30963. /**
  30964. * Asks the browser to exit fullscreen mode
  30965. */ private static _ExitFullscreen(): void;
  30966. }
  30967. }
  30968. declare module BABYLON {
  30969. /**
  30970. * The engine store class is responsible to hold all the instances of Engine and Scene created
  30971. * during the life time of the application.
  30972. */
  30973. export class EngineStore {
  30974. /** Gets the list of created engines */
  30975. static Instances: Engine[];
  30976. /** @hidden */ private static _LastCreatedScene: Nullable<Scene>;
  30977. /**
  30978. * Gets the latest created engine
  30979. */
  30980. static readonly LastCreatedEngine: Nullable<Engine>;
  30981. /**
  30982. * Gets the latest created scene
  30983. */
  30984. static readonly LastCreatedScene: Nullable<Scene>;
  30985. /**
  30986. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30987. * @ignorenaming
  30988. */
  30989. static UseFallbackTexture: boolean;
  30990. /**
  30991. * Texture content used if a texture cannot loaded
  30992. * @ignorenaming
  30993. */
  30994. static FallbackTexture: string;
  30995. }
  30996. }
  30997. declare module BABYLON {
  30998. /**
  30999. * Helper class that provides a small promise polyfill
  31000. */
  31001. export class PromisePolyfill {
  31002. /**
  31003. * Static function used to check if the polyfill is required
  31004. * If this is the case then the function will inject the polyfill to window.Promise
  31005. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31006. */
  31007. static Apply(force?: boolean): void;
  31008. }
  31009. }
  31010. declare module BABYLON {
  31011. /**
  31012. * Interface for screenshot methods with describe argument called `size` as object with options
  31013. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31014. */
  31015. export interface IScreenshotSize {
  31016. /**
  31017. * number in pixels for canvas height
  31018. */
  31019. height?: number;
  31020. /**
  31021. * multiplier allowing render at a higher or lower resolution
  31022. * If value is defined then height and width will be ignored and taken from camera
  31023. */
  31024. precision?: number;
  31025. /**
  31026. * number in pixels for canvas width
  31027. */
  31028. width?: number;
  31029. }
  31030. }
  31031. declare module BABYLON {
  31032. interface IColor4Like {
  31033. r: float;
  31034. g: float;
  31035. b: float;
  31036. a: float;
  31037. }
  31038. /**
  31039. * Class containing a set of static utilities functions
  31040. */
  31041. export class Tools {
  31042. /**
  31043. * Gets or sets the base URL to use to load assets
  31044. */
  31045. static BaseUrl: string;
  31046. /**
  31047. * Enable/Disable Custom HTTP Request Headers globally.
  31048. * default = false
  31049. * @see CustomRequestHeaders
  31050. */
  31051. static UseCustomRequestHeaders: boolean;
  31052. /**
  31053. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31054. * i.e. when loading files, where the server/service expects an Authorization header
  31055. */
  31056. static CustomRequestHeaders: {
  31057. [key: string]: string;
  31058. };
  31059. /**
  31060. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31061. */
  31062. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31063. /**
  31064. * Default behaviour for cors in the application.
  31065. * It can be a string if the expected behavior is identical in the entire app.
  31066. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31067. */
  31068. static CorsBehavior: string | ((url: string | string[]) => string);
  31069. /**
  31070. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31071. * @ignorenaming
  31072. */
  31073. static UseFallbackTexture: boolean;
  31074. /**
  31075. * Use this object to register external classes like custom textures or material
  31076. * to allow the laoders to instantiate them
  31077. */
  31078. static RegisteredExternalClasses: {
  31079. [key: string]: Object;
  31080. };
  31081. /**
  31082. * Texture content used if a texture cannot loaded
  31083. * @ignorenaming
  31084. */
  31085. static fallbackTexture: string;
  31086. /**
  31087. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31088. * @param u defines the coordinate on X axis
  31089. * @param v defines the coordinate on Y axis
  31090. * @param width defines the width of the source data
  31091. * @param height defines the height of the source data
  31092. * @param pixels defines the source byte array
  31093. * @param color defines the output color
  31094. */
  31095. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31096. /**
  31097. * Interpolates between a and b via alpha
  31098. * @param a The lower value (returned when alpha = 0)
  31099. * @param b The upper value (returned when alpha = 1)
  31100. * @param alpha The interpolation-factor
  31101. * @return The mixed value
  31102. */
  31103. static Mix(a: number, b: number, alpha: number): number;
  31104. /**
  31105. * Tries to instantiate a new object from a given class name
  31106. * @param className defines the class name to instantiate
  31107. * @returns the new object or null if the system was not able to do the instantiation
  31108. */
  31109. static Instantiate(className: string): any;
  31110. /**
  31111. * Provides a slice function that will work even on IE
  31112. * @param data defines the array to slice
  31113. * @param start defines the start of the data (optional)
  31114. * @param end defines the end of the data (optional)
  31115. * @returns the new sliced array
  31116. */
  31117. static Slice<T>(data: T, start?: number, end?: number): T;
  31118. /**
  31119. * Polyfill for setImmediate
  31120. * @param action defines the action to execute after the current execution block
  31121. */
  31122. static SetImmediate(action: () => void): void;
  31123. /**
  31124. * Function indicating if a number is an exponent of 2
  31125. * @param value defines the value to test
  31126. * @returns true if the value is an exponent of 2
  31127. */
  31128. static IsExponentOfTwo(value: number): boolean;
  31129. private static _tmpFloatArray;
  31130. /**
  31131. * Returns the nearest 32-bit single precision float representation of a Number
  31132. * @param value A Number. If the parameter is of a different type, it will get converted
  31133. * to a number or to NaN if it cannot be converted
  31134. * @returns number
  31135. */
  31136. static FloatRound(value: number): number;
  31137. /**
  31138. * Extracts the filename from a path
  31139. * @param path defines the path to use
  31140. * @returns the filename
  31141. */
  31142. static GetFilename(path: string): string;
  31143. /**
  31144. * Extracts the "folder" part of a path (everything before the filename).
  31145. * @param uri The URI to extract the info from
  31146. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31147. * @returns The "folder" part of the path
  31148. */
  31149. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31150. /**
  31151. * Extracts text content from a DOM element hierarchy
  31152. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31153. */
  31154. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31155. /**
  31156. * Convert an angle in radians to degrees
  31157. * @param angle defines the angle to convert
  31158. * @returns the angle in degrees
  31159. */
  31160. static ToDegrees(angle: number): number;
  31161. /**
  31162. * Convert an angle in degrees to radians
  31163. * @param angle defines the angle to convert
  31164. * @returns the angle in radians
  31165. */
  31166. static ToRadians(angle: number): number;
  31167. /**
  31168. * Encode a buffer to a base64 string
  31169. * @param buffer defines the buffer to encode
  31170. * @returns the encoded string
  31171. */
  31172. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31173. /**
  31174. * Returns an array if obj is not an array
  31175. * @param obj defines the object to evaluate as an array
  31176. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31177. * @returns either obj directly if obj is an array or a new array containing obj
  31178. */
  31179. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31180. /**
  31181. * Gets the pointer prefix to use
  31182. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31183. */
  31184. static GetPointerPrefix(): string;
  31185. /**
  31186. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31187. * @param url define the url we are trying
  31188. * @param element define the dom element where to configure the cors policy
  31189. */
  31190. static SetCorsBehavior(url: string | string[], element: {
  31191. crossOrigin: string | null;
  31192. }): void;
  31193. /**
  31194. * Removes unwanted characters from an url
  31195. * @param url defines the url to clean
  31196. * @returns the cleaned url
  31197. */
  31198. static CleanUrl(url: string): string;
  31199. /**
  31200. * Gets or sets a function used to pre-process url before using them to load assets
  31201. */
  31202. static PreprocessUrl: (url: string) => string;
  31203. /**
  31204. * Loads an image as an HTMLImageElement.
  31205. * @param input url string, ArrayBuffer, or Blob to load
  31206. * @param onLoad callback called when the image successfully loads
  31207. * @param onError callback called when the image fails to load
  31208. * @param offlineProvider offline provider for caching
  31209. * @returns the HTMLImageElement of the loaded image
  31210. */
  31211. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31212. /**
  31213. * Loads a file
  31214. * @param url url string, ArrayBuffer, or Blob to load
  31215. * @param onSuccess callback called when the file successfully loads
  31216. * @param onProgress callback called while file is loading (if the server supports this mode)
  31217. * @param offlineProvider defines the offline provider for caching
  31218. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31219. * @param onError callback called when the file fails to load
  31220. * @returns a file request object
  31221. */
  31222. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  31223. /**
  31224. * Loads a file from a url
  31225. * @param url the file url to load
  31226. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  31227. */
  31228. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  31229. /**
  31230. * Load a script (identified by an url). When the url returns, the
  31231. * content of this file is added into a new script element, attached to the DOM (body element)
  31232. * @param scriptUrl defines the url of the script to laod
  31233. * @param onSuccess defines the callback called when the script is loaded
  31234. * @param onError defines the callback to call if an error occurs
  31235. * @param scriptId defines the id of the script element
  31236. */
  31237. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31238. /**
  31239. * Load an asynchronous script (identified by an url). When the url returns, the
  31240. * content of this file is added into a new script element, attached to the DOM (body element)
  31241. * @param scriptUrl defines the url of the script to laod
  31242. * @param scriptId defines the id of the script element
  31243. * @returns a promise request object
  31244. */
  31245. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31246. /**
  31247. * Loads a file from a blob
  31248. * @param fileToLoad defines the blob to use
  31249. * @param callback defines the callback to call when data is loaded
  31250. * @param progressCallback defines the callback to call during loading process
  31251. * @returns a file request object
  31252. */
  31253. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31254. /**
  31255. * Loads a file
  31256. * @param fileToLoad defines the file to load
  31257. * @param callback defines the callback to call when data is loaded
  31258. * @param progressCallBack defines the callback to call during loading process
  31259. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31260. * @returns a file request object
  31261. */
  31262. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31263. /**
  31264. * Creates a data url from a given string content
  31265. * @param content defines the content to convert
  31266. * @returns the new data url link
  31267. */
  31268. static FileAsURL(content: string): string;
  31269. /**
  31270. * Format the given number to a specific decimal format
  31271. * @param value defines the number to format
  31272. * @param decimals defines the number of decimals to use
  31273. * @returns the formatted string
  31274. */
  31275. static Format(value: number, decimals?: number): string;
  31276. /**
  31277. * Tries to copy an object by duplicating every property
  31278. * @param source defines the source object
  31279. * @param destination defines the target object
  31280. * @param doNotCopyList defines a list of properties to avoid
  31281. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31282. */
  31283. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31284. /**
  31285. * Gets a boolean indicating if the given object has no own property
  31286. * @param obj defines the object to test
  31287. * @returns true if object has no own property
  31288. */
  31289. static IsEmpty(obj: any): boolean;
  31290. /**
  31291. * Function used to register events at window level
  31292. * @param windowElement defines the Window object to use
  31293. * @param events defines the events to register
  31294. */
  31295. static RegisterTopRootEvents(windowElement: Window, events: {
  31296. name: string;
  31297. handler: Nullable<(e: FocusEvent) => any>;
  31298. }[]): void;
  31299. /**
  31300. * Function used to unregister events from window level
  31301. * @param windowElement defines the Window object to use
  31302. * @param events defines the events to unregister
  31303. */
  31304. static UnregisterTopRootEvents(windowElement: Window, events: {
  31305. name: string;
  31306. handler: Nullable<(e: FocusEvent) => any>;
  31307. }[]): void;
  31308. /**
  31309. * @ignore
  31310. */ private static _ScreenshotCanvas: HTMLCanvasElement;
  31311. /**
  31312. * Dumps the current bound framebuffer
  31313. * @param width defines the rendering width
  31314. * @param height defines the rendering height
  31315. * @param engine defines the hosting engine
  31316. * @param successCallback defines the callback triggered once the data are available
  31317. * @param mimeType defines the mime type of the result
  31318. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31319. */
  31320. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31321. /**
  31322. * Converts the canvas data to blob.
  31323. * This acts as a polyfill for browsers not supporting the to blob function.
  31324. * @param canvas Defines the canvas to extract the data from
  31325. * @param successCallback Defines the callback triggered once the data are available
  31326. * @param mimeType Defines the mime type of the result
  31327. */
  31328. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31329. /**
  31330. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31331. * @param successCallback defines the callback triggered once the data are available
  31332. * @param mimeType defines the mime type of the result
  31333. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31334. */
  31335. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31336. /**
  31337. * Downloads a blob in the browser
  31338. * @param blob defines the blob to download
  31339. * @param fileName defines the name of the downloaded file
  31340. */
  31341. static Download(blob: Blob, fileName: string): void;
  31342. /**
  31343. * Captures a screenshot of the current rendering
  31344. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31345. * @param engine defines the rendering engine
  31346. * @param camera defines the source camera
  31347. * @param size This parameter can be set to a single number or to an object with the
  31348. * following (optional) properties: precision, width, height. If a single number is passed,
  31349. * it will be used for both width and height. If an object is passed, the screenshot size
  31350. * will be derived from the parameters. The precision property is a multiplier allowing
  31351. * rendering at a higher or lower resolution
  31352. * @param successCallback defines the callback receives a single parameter which contains the
  31353. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31354. * src parameter of an <img> to display it
  31355. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31356. * Check your browser for supported MIME types
  31357. */
  31358. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  31359. /**
  31360. * Captures a screenshot of the current rendering
  31361. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31362. * @param engine defines the rendering engine
  31363. * @param camera defines the source camera
  31364. * @param size This parameter can be set to a single number or to an object with the
  31365. * following (optional) properties: precision, width, height. If a single number is passed,
  31366. * it will be used for both width and height. If an object is passed, the screenshot size
  31367. * will be derived from the parameters. The precision property is a multiplier allowing
  31368. * rendering at a higher or lower resolution
  31369. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31370. * Check your browser for supported MIME types
  31371. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31372. * to the src parameter of an <img> to display it
  31373. */
  31374. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  31375. /**
  31376. * Generates an image screenshot from the specified camera.
  31377. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31378. * @param engine The engine to use for rendering
  31379. * @param camera The camera to use for rendering
  31380. * @param size This parameter can be set to a single number or to an object with the
  31381. * following (optional) properties: precision, width, height. If a single number is passed,
  31382. * it will be used for both width and height. If an object is passed, the screenshot size
  31383. * will be derived from the parameters. The precision property is a multiplier allowing
  31384. * rendering at a higher or lower resolution
  31385. * @param successCallback The callback receives a single parameter which contains the
  31386. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31387. * src parameter of an <img> to display it
  31388. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31389. * Check your browser for supported MIME types
  31390. * @param samples Texture samples (default: 1)
  31391. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31392. * @param fileName A name for for the downloaded file.
  31393. */
  31394. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31395. /**
  31396. * Generates an image screenshot from the specified camera.
  31397. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31398. * @param engine The engine to use for rendering
  31399. * @param camera The camera to use for rendering
  31400. * @param size This parameter can be set to a single number or to an object with the
  31401. * following (optional) properties: precision, width, height. If a single number is passed,
  31402. * it will be used for both width and height. If an object is passed, the screenshot size
  31403. * will be derived from the parameters. The precision property is a multiplier allowing
  31404. * rendering at a higher or lower resolution
  31405. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31406. * Check your browser for supported MIME types
  31407. * @param samples Texture samples (default: 1)
  31408. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31409. * @param fileName A name for for the downloaded file.
  31410. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31411. * to the src parameter of an <img> to display it
  31412. */
  31413. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  31414. /**
  31415. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31416. * Be aware Math.random() could cause collisions, but:
  31417. * "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"
  31418. * @returns a pseudo random id
  31419. */
  31420. static RandomId(): string;
  31421. /**
  31422. * Test if the given uri is a base64 string
  31423. * @param uri The uri to test
  31424. * @return True if the uri is a base64 string or false otherwise
  31425. */
  31426. static IsBase64(uri: string): boolean;
  31427. /**
  31428. * Decode the given base64 uri.
  31429. * @param uri The uri to decode
  31430. * @return The decoded base64 data.
  31431. */
  31432. static DecodeBase64(uri: string): ArrayBuffer;
  31433. /**
  31434. * Gets the absolute url.
  31435. * @param url the input url
  31436. * @return the absolute url
  31437. */
  31438. static GetAbsoluteUrl(url: string): string;
  31439. /**
  31440. * No log
  31441. */
  31442. static readonly NoneLogLevel: number;
  31443. /**
  31444. * Only message logs
  31445. */
  31446. static readonly MessageLogLevel: number;
  31447. /**
  31448. * Only warning logs
  31449. */
  31450. static readonly WarningLogLevel: number;
  31451. /**
  31452. * Only error logs
  31453. */
  31454. static readonly ErrorLogLevel: number;
  31455. /**
  31456. * All logs
  31457. */
  31458. static readonly AllLogLevel: number;
  31459. /**
  31460. * Gets a value indicating the number of loading errors
  31461. * @ignorenaming
  31462. */
  31463. static readonly errorsCount: number;
  31464. /**
  31465. * Callback called when a new log is added
  31466. */
  31467. static OnNewCacheEntry: (entry: string) => void;
  31468. /**
  31469. * Log a message to the console
  31470. * @param message defines the message to log
  31471. */
  31472. static Log(message: string): void;
  31473. /**
  31474. * Write a warning message to the console
  31475. * @param message defines the message to log
  31476. */
  31477. static Warn(message: string): void;
  31478. /**
  31479. * Write an error message to the console
  31480. * @param message defines the message to log
  31481. */
  31482. static Error(message: string): void;
  31483. /**
  31484. * Gets current log cache (list of logs)
  31485. */
  31486. static readonly LogCache: string;
  31487. /**
  31488. * Clears the log cache
  31489. */
  31490. static ClearLogCache(): void;
  31491. /**
  31492. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31493. */
  31494. static LogLevels: number;
  31495. /**
  31496. * Checks if the window object exists
  31497. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31498. */
  31499. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31500. /**
  31501. * No performance log
  31502. */
  31503. static readonly PerformanceNoneLogLevel: number;
  31504. /**
  31505. * Use user marks to log performance
  31506. */
  31507. static readonly PerformanceUserMarkLogLevel: number;
  31508. /**
  31509. * Log performance to the console
  31510. */
  31511. static readonly PerformanceConsoleLogLevel: number;
  31512. private static _performance;
  31513. /**
  31514. * Sets the current performance log level
  31515. */
  31516. static PerformanceLogLevel: number;
  31517. private static _StartPerformanceCounterDisabled;
  31518. private static _EndPerformanceCounterDisabled;
  31519. private static _StartUserMark;
  31520. private static _EndUserMark;
  31521. private static _StartPerformanceConsole;
  31522. private static _EndPerformanceConsole;
  31523. /**
  31524. * Starts a performance counter
  31525. */
  31526. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31527. /**
  31528. * Ends a specific performance coutner
  31529. */
  31530. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31531. /**
  31532. * Gets either window.performance.now() if supported or Date.now() else
  31533. */
  31534. static readonly Now: number;
  31535. /**
  31536. * This method will return the name of the class used to create the instance of the given object.
  31537. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31538. * @param object the object to get the class name from
  31539. * @param isType defines if the object is actually a type
  31540. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31541. */
  31542. static GetClassName(object: any, isType?: boolean): string;
  31543. /**
  31544. * Gets the first element of an array satisfying a given predicate
  31545. * @param array defines the array to browse
  31546. * @param predicate defines the predicate to use
  31547. * @returns null if not found or the element
  31548. */
  31549. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31550. /**
  31551. * This method will return the name of the full name of the class, including its owning module (if any).
  31552. * 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).
  31553. * @param object the object to get the class name from
  31554. * @param isType defines if the object is actually a type
  31555. * @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.
  31556. * @ignorenaming
  31557. */
  31558. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31559. /**
  31560. * Returns a promise that resolves after the given amount of time.
  31561. * @param delay Number of milliseconds to delay
  31562. * @returns Promise that resolves after the given amount of time
  31563. */
  31564. static DelayAsync(delay: number): Promise<void>;
  31565. }
  31566. /**
  31567. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31568. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31569. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31570. * @param name The name of the class, case should be preserved
  31571. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31572. */
  31573. export function className(name: string, module?: string): (target: Object) => void;
  31574. /**
  31575. * An implementation of a loop for asynchronous functions.
  31576. */
  31577. export class AsyncLoop {
  31578. /**
  31579. * Defines the number of iterations for the loop
  31580. */
  31581. iterations: number;
  31582. /**
  31583. * Defines the current index of the loop.
  31584. */
  31585. index: number;
  31586. private _done;
  31587. private _fn;
  31588. private _successCallback;
  31589. /**
  31590. * Constructor.
  31591. * @param iterations the number of iterations.
  31592. * @param func the function to run each iteration
  31593. * @param successCallback the callback that will be called upon succesful execution
  31594. * @param offset starting offset.
  31595. */
  31596. constructor(
  31597. /**
  31598. * Defines the number of iterations for the loop
  31599. */
  31600. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31601. /**
  31602. * Execute the next iteration. Must be called after the last iteration was finished.
  31603. */
  31604. executeNext(): void;
  31605. /**
  31606. * Break the loop and run the success callback.
  31607. */
  31608. breakLoop(): void;
  31609. /**
  31610. * Create and run an async loop.
  31611. * @param iterations the number of iterations.
  31612. * @param fn the function to run each iteration
  31613. * @param successCallback the callback that will be called upon succesful execution
  31614. * @param offset starting offset.
  31615. * @returns the created async loop object
  31616. */
  31617. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31618. /**
  31619. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31620. * @param iterations total number of iterations
  31621. * @param syncedIterations number of synchronous iterations in each async iteration.
  31622. * @param fn the function to call each iteration.
  31623. * @param callback a success call back that will be called when iterating stops.
  31624. * @param breakFunction a break condition (optional)
  31625. * @param timeout timeout settings for the setTimeout function. default - 0.
  31626. * @returns the created async loop object
  31627. */
  31628. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31629. }
  31630. }
  31631. declare module BABYLON {
  31632. /** @hidden */
  31633. export interface ICollisionCoordinator {
  31634. createCollider(): Collider;
  31635. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31636. init(scene: Scene): void;
  31637. }
  31638. /** @hidden */
  31639. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31640. private _scene;
  31641. private _scaledPosition;
  31642. private _scaledVelocity;
  31643. private _finalPosition;
  31644. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31645. createCollider(): Collider;
  31646. init(scene: Scene): void;
  31647. private _collideWithWorld;
  31648. }
  31649. }
  31650. declare module BABYLON {
  31651. /**
  31652. * Class used to manage all inputs for the scene.
  31653. */
  31654. export class InputManager {
  31655. /** The distance in pixel that you have to move to prevent some events */
  31656. static DragMovementThreshold: number;
  31657. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31658. static LongPressDelay: number;
  31659. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31660. static DoubleClickDelay: number;
  31661. /** If you need to check double click without raising a single click at first click, enable this flag */
  31662. static ExclusiveDoubleClickMode: boolean;
  31663. private _wheelEventName;
  31664. private _onPointerMove;
  31665. private _onPointerDown;
  31666. private _onPointerUp;
  31667. private _initClickEvent;
  31668. private _initActionManager;
  31669. private _delayedSimpleClick;
  31670. private _delayedSimpleClickTimeout;
  31671. private _previousDelayedSimpleClickTimeout;
  31672. private _meshPickProceed;
  31673. private _previousButtonPressed;
  31674. private _currentPickResult;
  31675. private _previousPickResult;
  31676. private _totalPointersPressed;
  31677. private _doubleClickOccured;
  31678. private _pointerOverMesh;
  31679. private _pickedDownMesh;
  31680. private _pickedUpMesh;
  31681. private _pointerX;
  31682. private _pointerY;
  31683. private _unTranslatedPointerX;
  31684. private _unTranslatedPointerY;
  31685. private _startingPointerPosition;
  31686. private _previousStartingPointerPosition;
  31687. private _startingPointerTime;
  31688. private _previousStartingPointerTime;
  31689. private _pointerCaptures;
  31690. private _onKeyDown;
  31691. private _onKeyUp;
  31692. private _onCanvasFocusObserver;
  31693. private _onCanvasBlurObserver;
  31694. private _scene;
  31695. /**
  31696. * Creates a new InputManager
  31697. * @param scene defines the hosting scene
  31698. */
  31699. constructor(scene: Scene);
  31700. /**
  31701. * Gets the mesh that is currently under the pointer
  31702. */
  31703. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31704. /**
  31705. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  31706. */
  31707. readonly unTranslatedPointer: Vector2;
  31708. /**
  31709. * Gets or sets the current on-screen X position of the pointer
  31710. */
  31711. pointerX: number;
  31712. /**
  31713. * Gets or sets the current on-screen Y position of the pointer
  31714. */
  31715. pointerY: number;
  31716. private _updatePointerPosition;
  31717. private _processPointerMove;
  31718. private _setRayOnPointerInfo;
  31719. private _checkPrePointerObservable;
  31720. /**
  31721. * Use this method to simulate a pointer move on a mesh
  31722. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31723. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31724. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31725. */
  31726. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31727. /**
  31728. * Use this method to simulate a pointer down on a mesh
  31729. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31730. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31731. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31732. */
  31733. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31734. private _processPointerDown;
  31735. /** @hidden */ private _isPointerSwiping(): boolean;
  31736. /**
  31737. * Use this method to simulate a pointer up on a mesh
  31738. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31739. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31740. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31741. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31742. */
  31743. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  31744. private _processPointerUp;
  31745. /**
  31746. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31747. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31748. * @returns true if the pointer was captured
  31749. */
  31750. isPointerCaptured(pointerId?: number): boolean;
  31751. /**
  31752. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31753. * @param attachUp defines if you want to attach events to pointerup
  31754. * @param attachDown defines if you want to attach events to pointerdown
  31755. * @param attachMove defines if you want to attach events to pointermove
  31756. */
  31757. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  31758. /**
  31759. * Detaches all event handlers
  31760. */
  31761. detachControl(): void;
  31762. /**
  31763. * Force the value of meshUnderPointer
  31764. * @param mesh defines the mesh to use
  31765. */
  31766. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  31767. /**
  31768. * Gets the mesh under the pointer
  31769. * @returns a Mesh or null if no mesh is under the pointer
  31770. */
  31771. getPointerOverMesh(): Nullable<AbstractMesh>;
  31772. }
  31773. }
  31774. declare module BABYLON {
  31775. /**
  31776. * Helper class used to generate session unique ID
  31777. */
  31778. export class UniqueIdGenerator {
  31779. private static _UniqueIdCounter;
  31780. /**
  31781. * Gets an unique (relatively to the current scene) Id
  31782. */
  31783. static readonly UniqueId: number;
  31784. }
  31785. }
  31786. declare module BABYLON {
  31787. /**
  31788. * This class defines the direct association between an animation and a target
  31789. */
  31790. export class TargetedAnimation {
  31791. /**
  31792. * Animation to perform
  31793. */
  31794. animation: Animation;
  31795. /**
  31796. * Target to animate
  31797. */
  31798. target: any;
  31799. /**
  31800. * Serialize the object
  31801. * @returns the JSON object representing the current entity
  31802. */
  31803. serialize(): any;
  31804. }
  31805. /**
  31806. * Use this class to create coordinated animations on multiple targets
  31807. */
  31808. export class AnimationGroup implements IDisposable {
  31809. /** The name of the animation group */
  31810. name: string;
  31811. private _scene;
  31812. private _targetedAnimations;
  31813. private _animatables;
  31814. private _from;
  31815. private _to;
  31816. private _isStarted;
  31817. private _isPaused;
  31818. private _speedRatio;
  31819. private _loopAnimation;
  31820. /**
  31821. * Gets or sets the unique id of the node
  31822. */
  31823. uniqueId: number;
  31824. /**
  31825. * This observable will notify when one animation have ended
  31826. */
  31827. onAnimationEndObservable: Observable<TargetedAnimation>;
  31828. /**
  31829. * Observer raised when one animation loops
  31830. */
  31831. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31832. /**
  31833. * This observable will notify when all animations have ended.
  31834. */
  31835. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31836. /**
  31837. * This observable will notify when all animations have paused.
  31838. */
  31839. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31840. /**
  31841. * This observable will notify when all animations are playing.
  31842. */
  31843. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31844. /**
  31845. * Gets the first frame
  31846. */
  31847. readonly from: number;
  31848. /**
  31849. * Gets the last frame
  31850. */
  31851. readonly to: number;
  31852. /**
  31853. * Define if the animations are started
  31854. */
  31855. readonly isStarted: boolean;
  31856. /**
  31857. * Gets a value indicating that the current group is playing
  31858. */
  31859. readonly isPlaying: boolean;
  31860. /**
  31861. * Gets or sets the speed ratio to use for all animations
  31862. */
  31863. /**
  31864. * Gets or sets the speed ratio to use for all animations
  31865. */
  31866. speedRatio: number;
  31867. /**
  31868. * Gets or sets if all animations should loop or not
  31869. */
  31870. loopAnimation: boolean;
  31871. /**
  31872. * Gets the targeted animations for this animation group
  31873. */
  31874. readonly targetedAnimations: Array<TargetedAnimation>;
  31875. /**
  31876. * returning the list of animatables controlled by this animation group.
  31877. */
  31878. readonly animatables: Array<Animatable>;
  31879. /**
  31880. * Instantiates a new Animation Group.
  31881. * This helps managing several animations at once.
  31882. * @see http://doc.babylonjs.com/how_to/group
  31883. * @param name Defines the name of the group
  31884. * @param scene Defines the scene the group belongs to
  31885. */
  31886. constructor(
  31887. /** The name of the animation group */
  31888. name: string, scene?: Nullable<Scene>);
  31889. /**
  31890. * Add an animation (with its target) in the group
  31891. * @param animation defines the animation we want to add
  31892. * @param target defines the target of the animation
  31893. * @returns the TargetedAnimation object
  31894. */
  31895. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31896. /**
  31897. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31898. * It can add constant keys at begin or end
  31899. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31900. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31901. * @returns the animation group
  31902. */
  31903. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31904. /**
  31905. * Start all animations on given targets
  31906. * @param loop defines if animations must loop
  31907. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31908. * @param from defines the from key (optional)
  31909. * @param to defines the to key (optional)
  31910. * @returns the current animation group
  31911. */
  31912. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31913. /**
  31914. * Pause all animations
  31915. * @returns the animation group
  31916. */
  31917. pause(): AnimationGroup;
  31918. /**
  31919. * Play all animations to initial state
  31920. * This function will start() the animations if they were not started or will restart() them if they were paused
  31921. * @param loop defines if animations must loop
  31922. * @returns the animation group
  31923. */
  31924. play(loop?: boolean): AnimationGroup;
  31925. /**
  31926. * Reset all animations to initial state
  31927. * @returns the animation group
  31928. */
  31929. reset(): AnimationGroup;
  31930. /**
  31931. * Restart animations from key 0
  31932. * @returns the animation group
  31933. */
  31934. restart(): AnimationGroup;
  31935. /**
  31936. * Stop all animations
  31937. * @returns the animation group
  31938. */
  31939. stop(): AnimationGroup;
  31940. /**
  31941. * Set animation weight for all animatables
  31942. * @param weight defines the weight to use
  31943. * @return the animationGroup
  31944. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31945. */
  31946. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31947. /**
  31948. * Synchronize and normalize all animatables with a source animatable
  31949. * @param root defines the root animatable to synchronize with
  31950. * @return the animationGroup
  31951. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31952. */
  31953. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31954. /**
  31955. * Goes to a specific frame in this animation group
  31956. * @param frame the frame number to go to
  31957. * @return the animationGroup
  31958. */
  31959. goToFrame(frame: number): AnimationGroup;
  31960. /**
  31961. * Dispose all associated resources
  31962. */
  31963. dispose(): void;
  31964. private _checkAnimationGroupEnded;
  31965. /**
  31966. * Clone the current animation group and returns a copy
  31967. * @param newName defines the name of the new group
  31968. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31969. * @returns the new aniamtion group
  31970. */
  31971. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31972. /**
  31973. * Serializes the animationGroup to an object
  31974. * @returns Serialized object
  31975. */
  31976. serialize(): any;
  31977. /**
  31978. * Returns a new AnimationGroup object parsed from the source provided.
  31979. * @param parsedAnimationGroup defines the source
  31980. * @param scene defines the scene that will receive the animationGroup
  31981. * @returns a new AnimationGroup
  31982. */
  31983. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31984. /**
  31985. * Returns the string "AnimationGroup"
  31986. * @returns "AnimationGroup"
  31987. */
  31988. getClassName(): string;
  31989. /**
  31990. * Creates a detailled string about the object
  31991. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31992. * @returns a string representing the object
  31993. */
  31994. toString(fullDetails?: boolean): string;
  31995. }
  31996. }
  31997. declare module BABYLON {
  31998. /**
  31999. * Define an interface for all classes that will hold resources
  32000. */
  32001. export interface IDisposable {
  32002. /**
  32003. * Releases all held resources
  32004. */
  32005. dispose(): void;
  32006. }
  32007. /** Interface defining initialization parameters for Scene class */
  32008. export interface SceneOptions {
  32009. /**
  32010. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32011. * It will improve performance when the number of geometries becomes important.
  32012. */
  32013. useGeometryUniqueIdsMap?: boolean;
  32014. /**
  32015. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32016. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32017. */
  32018. useMaterialMeshMap?: boolean;
  32019. /**
  32020. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32021. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32022. */
  32023. useClonedMeshhMap?: boolean;
  32024. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32025. virtual?: boolean;
  32026. }
  32027. /**
  32028. * Represents a scene to be rendered by the engine.
  32029. * @see http://doc.babylonjs.com/features/scene
  32030. */
  32031. export class Scene extends AbstractScene implements IAnimatable {
  32032. /** The fog is deactivated */
  32033. static readonly FOGMODE_NONE: number;
  32034. /** The fog density is following an exponential function */
  32035. static readonly FOGMODE_EXP: number;
  32036. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32037. static readonly FOGMODE_EXP2: number;
  32038. /** The fog density is following a linear function. */
  32039. static readonly FOGMODE_LINEAR: number;
  32040. /**
  32041. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32042. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32043. */
  32044. static MinDeltaTime: number;
  32045. /**
  32046. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32047. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32048. */
  32049. static MaxDeltaTime: number;
  32050. /**
  32051. * Factory used to create the default material.
  32052. * @param name The name of the material to create
  32053. * @param scene The scene to create the material for
  32054. * @returns The default material
  32055. */
  32056. static DefaultMaterialFactory(scene: Scene): Material;
  32057. /**
  32058. * Factory used to create the a collision coordinator.
  32059. * @returns The collision coordinator
  32060. */
  32061. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32062. /** @hidden */ private _inputManager: InputManager;
  32063. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32064. cameraToUseForPointers: Nullable<Camera>;
  32065. /** @hidden */ protected readonly _isScene: boolean;
  32066. /**
  32067. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32068. */
  32069. autoClear: boolean;
  32070. /**
  32071. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32072. */
  32073. autoClearDepthAndStencil: boolean;
  32074. /**
  32075. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32076. */
  32077. clearColor: Color4;
  32078. /**
  32079. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32080. */
  32081. ambientColor: Color3;
  32082. /**
  32083. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32084. * It should only be one of the following (if not the default embedded one):
  32085. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32086. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32087. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32088. * The material properties need to be setup according to the type of texture in use.
  32089. */
  32090. environmentBRDFTexture: BaseTexture;
  32091. /** @hidden */
  32092. protected _environmentTexture: Nullable<BaseTexture>;
  32093. /**
  32094. * Texture used in all pbr material as the reflection texture.
  32095. * As in the majority of the scene they are the same (exception for multi room and so on),
  32096. * this is easier to reference from here than from all the materials.
  32097. */
  32098. /**
  32099. * Texture used in all pbr material as the reflection texture.
  32100. * As in the majority of the scene they are the same (exception for multi room and so on),
  32101. * this is easier to set here than in all the materials.
  32102. */
  32103. environmentTexture: Nullable<BaseTexture>;
  32104. /** @hidden */
  32105. protected _environmentIntensity: number;
  32106. /**
  32107. * Intensity of the environment in all pbr material.
  32108. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32109. * As in the majority of the scene they are the same (exception for multi room and so on),
  32110. * this is easier to reference from here than from all the materials.
  32111. */
  32112. /**
  32113. * Intensity of the environment in all pbr material.
  32114. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32115. * As in the majority of the scene they are the same (exception for multi room and so on),
  32116. * this is easier to set here than in all the materials.
  32117. */
  32118. environmentIntensity: number;
  32119. /** @hidden */
  32120. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32121. /**
  32122. * Default image processing configuration used either in the rendering
  32123. * Forward main pass or through the imageProcessingPostProcess if present.
  32124. * As in the majority of the scene they are the same (exception for multi camera),
  32125. * this is easier to reference from here than from all the materials and post process.
  32126. *
  32127. * No setter as we it is a shared configuration, you can set the values instead.
  32128. */
  32129. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32130. private _forceWireframe;
  32131. /**
  32132. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32133. */
  32134. forceWireframe: boolean;
  32135. private _forcePointsCloud;
  32136. /**
  32137. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32138. */
  32139. forcePointsCloud: boolean;
  32140. /**
  32141. * Gets or sets the active clipplane 1
  32142. */
  32143. clipPlane: Nullable<Plane>;
  32144. /**
  32145. * Gets or sets the active clipplane 2
  32146. */
  32147. clipPlane2: Nullable<Plane>;
  32148. /**
  32149. * Gets or sets the active clipplane 3
  32150. */
  32151. clipPlane3: Nullable<Plane>;
  32152. /**
  32153. * Gets or sets the active clipplane 4
  32154. */
  32155. clipPlane4: Nullable<Plane>;
  32156. /**
  32157. * Gets or sets a boolean indicating if animations are enabled
  32158. */
  32159. animationsEnabled: boolean;
  32160. private _animationPropertiesOverride;
  32161. /**
  32162. * Gets or sets the animation properties override
  32163. */
  32164. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32165. /**
  32166. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32167. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32168. */
  32169. useConstantAnimationDeltaTime: boolean;
  32170. /**
  32171. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32172. * Please note that it requires to run a ray cast through the scene on every frame
  32173. */
  32174. constantlyUpdateMeshUnderPointer: boolean;
  32175. /**
  32176. * Defines the HTML cursor to use when hovering over interactive elements
  32177. */
  32178. hoverCursor: string;
  32179. /**
  32180. * Defines the HTML default cursor to use (empty by default)
  32181. */
  32182. defaultCursor: string;
  32183. /**
  32184. * This is used to call preventDefault() on pointer down
  32185. * in order to block unwanted artifacts like system double clicks
  32186. */
  32187. preventDefaultOnPointerDown: boolean;
  32188. /**
  32189. * This is used to call preventDefault() on pointer up
  32190. * in order to block unwanted artifacts like system double clicks
  32191. */
  32192. preventDefaultOnPointerUp: boolean;
  32193. /**
  32194. * Gets or sets user defined metadata
  32195. */
  32196. metadata: any;
  32197. /**
  32198. * For internal use only. Please do not use.
  32199. */
  32200. reservedDataStore: any;
  32201. /**
  32202. * Gets the name of the plugin used to load this scene (null by default)
  32203. */
  32204. loadingPluginName: string;
  32205. /**
  32206. * Use this array to add regular expressions used to disable offline support for specific urls
  32207. */
  32208. disableOfflineSupportExceptionRules: RegExp[];
  32209. /**
  32210. * An event triggered when the scene is disposed.
  32211. */
  32212. onDisposeObservable: Observable<Scene>;
  32213. private _onDisposeObserver;
  32214. /** Sets a function to be executed when this scene is disposed. */
  32215. onDispose: () => void;
  32216. /**
  32217. * An event triggered before rendering the scene (right after animations and physics)
  32218. */
  32219. onBeforeRenderObservable: Observable<Scene>;
  32220. private _onBeforeRenderObserver;
  32221. /** Sets a function to be executed before rendering this scene */
  32222. beforeRender: Nullable<() => void>;
  32223. /**
  32224. * An event triggered after rendering the scene
  32225. */
  32226. onAfterRenderObservable: Observable<Scene>;
  32227. /**
  32228. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  32229. */
  32230. onAfterRenderCameraObservable: Observable<Camera>;
  32231. private _onAfterRenderObserver;
  32232. /** Sets a function to be executed after rendering this scene */
  32233. afterRender: Nullable<() => void>;
  32234. /**
  32235. * An event triggered before animating the scene
  32236. */
  32237. onBeforeAnimationsObservable: Observable<Scene>;
  32238. /**
  32239. * An event triggered after animations processing
  32240. */
  32241. onAfterAnimationsObservable: Observable<Scene>;
  32242. /**
  32243. * An event triggered before draw calls are ready to be sent
  32244. */
  32245. onBeforeDrawPhaseObservable: Observable<Scene>;
  32246. /**
  32247. * An event triggered after draw calls have been sent
  32248. */
  32249. onAfterDrawPhaseObservable: Observable<Scene>;
  32250. /**
  32251. * An event triggered when the scene is ready
  32252. */
  32253. onReadyObservable: Observable<Scene>;
  32254. /**
  32255. * An event triggered before rendering a camera
  32256. */
  32257. onBeforeCameraRenderObservable: Observable<Camera>;
  32258. private _onBeforeCameraRenderObserver;
  32259. /** Sets a function to be executed before rendering a camera*/
  32260. beforeCameraRender: () => void;
  32261. /**
  32262. * An event triggered after rendering a camera
  32263. */
  32264. onAfterCameraRenderObservable: Observable<Camera>;
  32265. private _onAfterCameraRenderObserver;
  32266. /** Sets a function to be executed after rendering a camera*/
  32267. afterCameraRender: () => void;
  32268. /**
  32269. * An event triggered when active meshes evaluation is about to start
  32270. */
  32271. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32272. /**
  32273. * An event triggered when active meshes evaluation is done
  32274. */
  32275. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32276. /**
  32277. * An event triggered when particles rendering is about to start
  32278. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32279. */
  32280. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32281. /**
  32282. * An event triggered when particles rendering is done
  32283. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32284. */
  32285. onAfterParticlesRenderingObservable: Observable<Scene>;
  32286. /**
  32287. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32288. */
  32289. onDataLoadedObservable: Observable<Scene>;
  32290. /**
  32291. * An event triggered when a camera is created
  32292. */
  32293. onNewCameraAddedObservable: Observable<Camera>;
  32294. /**
  32295. * An event triggered when a camera is removed
  32296. */
  32297. onCameraRemovedObservable: Observable<Camera>;
  32298. /**
  32299. * An event triggered when a light is created
  32300. */
  32301. onNewLightAddedObservable: Observable<Light>;
  32302. /**
  32303. * An event triggered when a light is removed
  32304. */
  32305. onLightRemovedObservable: Observable<Light>;
  32306. /**
  32307. * An event triggered when a geometry is created
  32308. */
  32309. onNewGeometryAddedObservable: Observable<Geometry>;
  32310. /**
  32311. * An event triggered when a geometry is removed
  32312. */
  32313. onGeometryRemovedObservable: Observable<Geometry>;
  32314. /**
  32315. * An event triggered when a transform node is created
  32316. */
  32317. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32318. /**
  32319. * An event triggered when a transform node is removed
  32320. */
  32321. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32322. /**
  32323. * An event triggered when a mesh is created
  32324. */
  32325. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32326. /**
  32327. * An event triggered when a mesh is removed
  32328. */
  32329. onMeshRemovedObservable: Observable<AbstractMesh>;
  32330. /**
  32331. * An event triggered when a skeleton is created
  32332. */
  32333. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32334. /**
  32335. * An event triggered when a skeleton is removed
  32336. */
  32337. onSkeletonRemovedObservable: Observable<Skeleton>;
  32338. /**
  32339. * An event triggered when a material is created
  32340. */
  32341. onNewMaterialAddedObservable: Observable<Material>;
  32342. /**
  32343. * An event triggered when a material is removed
  32344. */
  32345. onMaterialRemovedObservable: Observable<Material>;
  32346. /**
  32347. * An event triggered when a texture is created
  32348. */
  32349. onNewTextureAddedObservable: Observable<BaseTexture>;
  32350. /**
  32351. * An event triggered when a texture is removed
  32352. */
  32353. onTextureRemovedObservable: Observable<BaseTexture>;
  32354. /**
  32355. * An event triggered when render targets are about to be rendered
  32356. * Can happen multiple times per frame.
  32357. */
  32358. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32359. /**
  32360. * An event triggered when render targets were rendered.
  32361. * Can happen multiple times per frame.
  32362. */
  32363. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32364. /**
  32365. * An event triggered before calculating deterministic simulation step
  32366. */
  32367. onBeforeStepObservable: Observable<Scene>;
  32368. /**
  32369. * An event triggered after calculating deterministic simulation step
  32370. */
  32371. onAfterStepObservable: Observable<Scene>;
  32372. /**
  32373. * An event triggered when the activeCamera property is updated
  32374. */
  32375. onActiveCameraChanged: Observable<Scene>;
  32376. /**
  32377. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32378. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32379. * 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)
  32380. */
  32381. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32382. /**
  32383. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32384. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32385. * 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)
  32386. */
  32387. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32388. /**
  32389. * This Observable will when a mesh has been imported into the scene.
  32390. */
  32391. onMeshImportedObservable: Observable<AbstractMesh>;
  32392. /**
  32393. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32394. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32395. */
  32396. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32397. /** @hidden */ private _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32398. /**
  32399. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32400. */
  32401. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32402. /**
  32403. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32404. */
  32405. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32406. /**
  32407. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32408. */
  32409. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32410. /** Callback called when a pointer move is detected */
  32411. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32412. /** Callback called when a pointer down is detected */
  32413. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32414. /** Callback called when a pointer up is detected */
  32415. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32416. /** Callback called when a pointer pick is detected */
  32417. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32418. /**
  32419. * 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).
  32420. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32421. */
  32422. onPrePointerObservable: Observable<PointerInfoPre>;
  32423. /**
  32424. * Observable event triggered each time an input event is received from the rendering canvas
  32425. */
  32426. onPointerObservable: Observable<PointerInfo>;
  32427. /**
  32428. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32429. */
  32430. readonly unTranslatedPointer: Vector2;
  32431. /**
  32432. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32433. */
  32434. static DragMovementThreshold: number;
  32435. /**
  32436. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32437. */
  32438. static LongPressDelay: number;
  32439. /**
  32440. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32441. */
  32442. static DoubleClickDelay: number;
  32443. /** If you need to check double click without raising a single click at first click, enable this flag */
  32444. static ExclusiveDoubleClickMode: boolean;
  32445. /** @hidden */ private _mirroredCameraPosition: Nullable<Vector3>;
  32446. /**
  32447. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32448. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32449. */
  32450. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32451. /**
  32452. * Observable event triggered each time an keyboard event is received from the hosting window
  32453. */
  32454. onKeyboardObservable: Observable<KeyboardInfo>;
  32455. private _useRightHandedSystem;
  32456. /**
  32457. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32458. */
  32459. useRightHandedSystem: boolean;
  32460. private _timeAccumulator;
  32461. private _currentStepId;
  32462. private _currentInternalStep;
  32463. /**
  32464. * Sets the step Id used by deterministic lock step
  32465. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32466. * @param newStepId defines the step Id
  32467. */
  32468. setStepId(newStepId: number): void;
  32469. /**
  32470. * Gets the step Id used by deterministic lock step
  32471. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32472. * @returns the step Id
  32473. */
  32474. getStepId(): number;
  32475. /**
  32476. * Gets the internal step used by deterministic lock step
  32477. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32478. * @returns the internal step
  32479. */
  32480. getInternalStep(): number;
  32481. private _fogEnabled;
  32482. /**
  32483. * Gets or sets a boolean indicating if fog is enabled on this scene
  32484. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32485. * (Default is true)
  32486. */
  32487. fogEnabled: boolean;
  32488. private _fogMode;
  32489. /**
  32490. * Gets or sets the fog mode to use
  32491. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32492. * | mode | value |
  32493. * | --- | --- |
  32494. * | FOGMODE_NONE | 0 |
  32495. * | FOGMODE_EXP | 1 |
  32496. * | FOGMODE_EXP2 | 2 |
  32497. * | FOGMODE_LINEAR | 3 |
  32498. */
  32499. fogMode: number;
  32500. /**
  32501. * Gets or sets the fog color to use
  32502. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32503. * (Default is Color3(0.2, 0.2, 0.3))
  32504. */
  32505. fogColor: Color3;
  32506. /**
  32507. * Gets or sets the fog density to use
  32508. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32509. * (Default is 0.1)
  32510. */
  32511. fogDensity: number;
  32512. /**
  32513. * Gets or sets the fog start distance to use
  32514. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32515. * (Default is 0)
  32516. */
  32517. fogStart: number;
  32518. /**
  32519. * Gets or sets the fog end distance to use
  32520. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32521. * (Default is 1000)
  32522. */
  32523. fogEnd: number;
  32524. private _shadowsEnabled;
  32525. /**
  32526. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32527. */
  32528. shadowsEnabled: boolean;
  32529. private _lightsEnabled;
  32530. /**
  32531. * Gets or sets a boolean indicating if lights are enabled on this scene
  32532. */
  32533. lightsEnabled: boolean;
  32534. /** All of the active cameras added to this scene. */
  32535. activeCameras: Camera[];
  32536. /** @hidden */ private _activeCamera: Nullable<Camera>;
  32537. /** Gets or sets the current active camera */
  32538. activeCamera: Nullable<Camera>;
  32539. private _defaultMaterial;
  32540. /** The default material used on meshes when no material is affected */
  32541. /** The default material used on meshes when no material is affected */
  32542. defaultMaterial: Material;
  32543. private _texturesEnabled;
  32544. /**
  32545. * Gets or sets a boolean indicating if textures are enabled on this scene
  32546. */
  32547. texturesEnabled: boolean;
  32548. /**
  32549. * Gets or sets a boolean indicating if particles are enabled on this scene
  32550. */
  32551. particlesEnabled: boolean;
  32552. /**
  32553. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32554. */
  32555. spritesEnabled: boolean;
  32556. private _skeletonsEnabled;
  32557. /**
  32558. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32559. */
  32560. skeletonsEnabled: boolean;
  32561. /**
  32562. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32563. */
  32564. lensFlaresEnabled: boolean;
  32565. /**
  32566. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32567. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32568. */
  32569. collisionsEnabled: boolean;
  32570. private _collisionCoordinator;
  32571. /** @hidden */
  32572. readonly collisionCoordinator: ICollisionCoordinator;
  32573. /**
  32574. * Defines the gravity applied to this scene (used only for collisions)
  32575. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32576. */
  32577. gravity: Vector3;
  32578. /**
  32579. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32580. */
  32581. postProcessesEnabled: boolean;
  32582. /**
  32583. * The list of postprocesses added to the scene
  32584. */
  32585. postProcesses: PostProcess[];
  32586. /**
  32587. * Gets the current postprocess manager
  32588. */
  32589. postProcessManager: PostProcessManager;
  32590. /**
  32591. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32592. */
  32593. renderTargetsEnabled: boolean;
  32594. /**
  32595. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32596. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32597. */
  32598. dumpNextRenderTargets: boolean;
  32599. /**
  32600. * The list of user defined render targets added to the scene
  32601. */
  32602. customRenderTargets: RenderTargetTexture[];
  32603. /**
  32604. * Defines if texture loading must be delayed
  32605. * If true, textures will only be loaded when they need to be rendered
  32606. */
  32607. useDelayedTextureLoading: boolean;
  32608. /**
  32609. * Gets the list of meshes imported to the scene through SceneLoader
  32610. */
  32611. importedMeshesFiles: String[];
  32612. /**
  32613. * Gets or sets a boolean indicating if probes are enabled on this scene
  32614. */
  32615. probesEnabled: boolean;
  32616. /**
  32617. * Gets or sets the current offline provider to use to store scene data
  32618. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32619. */
  32620. offlineProvider: IOfflineProvider;
  32621. /**
  32622. * Gets or sets the action manager associated with the scene
  32623. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32624. */
  32625. actionManager: AbstractActionManager;
  32626. private _meshesForIntersections;
  32627. /**
  32628. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32629. */
  32630. proceduralTexturesEnabled: boolean;
  32631. private _engine;
  32632. private _totalVertices;
  32633. /** @hidden */ private _activeIndices: PerfCounter;
  32634. /** @hidden */ private _activeParticles: PerfCounter;
  32635. /** @hidden */ private _activeBones: PerfCounter;
  32636. private _animationRatio;
  32637. /** @hidden */ private _animationTimeLast: number;
  32638. /** @hidden */ private _animationTime: number;
  32639. /**
  32640. * Gets or sets a general scale for animation speed
  32641. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32642. */
  32643. animationTimeScale: number;
  32644. /** @hidden */ private _cachedMaterial: Nullable<Material>;
  32645. /** @hidden */ private _cachedEffect: Nullable<Effect>;
  32646. /** @hidden */ private _cachedVisibility: Nullable<number>;
  32647. private _renderId;
  32648. private _frameId;
  32649. private _executeWhenReadyTimeoutId;
  32650. private _intermediateRendering;
  32651. private _viewUpdateFlag;
  32652. private _projectionUpdateFlag;
  32653. /** @hidden */ private _toBeDisposed: Nullable<IDisposable>[];
  32654. private _activeRequests;
  32655. /** @hidden */ private _pendingData: any[];
  32656. private _isDisposed;
  32657. /**
  32658. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32659. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32660. */
  32661. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32662. private _activeMeshes;
  32663. private _processedMaterials;
  32664. private _renderTargets;
  32665. /** @hidden */ private _activeParticleSystems: SmartArray<IParticleSystem>;
  32666. private _activeSkeletons;
  32667. private _softwareSkinnedMeshes;
  32668. private _renderingManager;
  32669. /** @hidden */ private _activeAnimatables: Animatable[];
  32670. private _transformMatrix;
  32671. private _sceneUbo;
  32672. /** @hidden */ private _viewMatrix: Matrix;
  32673. private _projectionMatrix;
  32674. /** @hidden */ private _forcedViewPosition: Nullable<Vector3>;
  32675. /** @hidden */ private _frustumPlanes: Plane[];
  32676. /**
  32677. * Gets the list of frustum planes (built from the active camera)
  32678. */
  32679. readonly frustumPlanes: Plane[];
  32680. /**
  32681. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32682. * This is useful if there are more lights that the maximum simulteanous authorized
  32683. */
  32684. requireLightSorting: boolean;
  32685. /** @hidden */
  32686. readonly useMaterialMeshMap: boolean;
  32687. /** @hidden */
  32688. readonly useClonedMeshhMap: boolean;
  32689. private _externalData;
  32690. private _uid;
  32691. /**
  32692. * @hidden
  32693. * Backing store of defined scene components.
  32694. */ private _components: ISceneComponent[];
  32695. /**
  32696. * @hidden
  32697. * Backing store of defined scene components.
  32698. */ private _serializableComponents: ISceneSerializableComponent[];
  32699. /**
  32700. * List of components to register on the next registration step.
  32701. */
  32702. private _transientComponents;
  32703. /**
  32704. * Registers the transient components if needed.
  32705. */
  32706. private _registerTransientComponents;
  32707. /**
  32708. * @hidden
  32709. * Add a component to the scene.
  32710. * Note that the ccomponent could be registered on th next frame if this is called after
  32711. * the register component stage.
  32712. * @param component Defines the component to add to the scene
  32713. */ private _addComponent(component: ISceneComponent): void;
  32714. /**
  32715. * @hidden
  32716. * Gets a component from the scene.
  32717. * @param name defines the name of the component to retrieve
  32718. * @returns the component or null if not present
  32719. */ private _getComponent(name: string): Nullable<ISceneComponent>;
  32720. /**
  32721. * @hidden
  32722. * Defines the actions happening before camera updates.
  32723. */ private _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32724. /**
  32725. * @hidden
  32726. * Defines the actions happening before clear the canvas.
  32727. */ private _beforeClearStage: Stage<SimpleStageAction>;
  32728. /**
  32729. * @hidden
  32730. * Defines the actions when collecting render targets for the frame.
  32731. */ private _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32732. /**
  32733. * @hidden
  32734. * Defines the actions happening for one camera in the frame.
  32735. */ private _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32736. /**
  32737. * @hidden
  32738. * Defines the actions happening during the per mesh ready checks.
  32739. */ private _isReadyForMeshStage: Stage<MeshStageAction>;
  32740. /**
  32741. * @hidden
  32742. * Defines the actions happening before evaluate active mesh checks.
  32743. */ private _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32744. /**
  32745. * @hidden
  32746. * Defines the actions happening during the evaluate sub mesh checks.
  32747. */ private _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32748. /**
  32749. * @hidden
  32750. * Defines the actions happening during the active mesh stage.
  32751. */ private _activeMeshStage: Stage<ActiveMeshStageAction>;
  32752. /**
  32753. * @hidden
  32754. * Defines the actions happening during the per camera render target step.
  32755. */ private _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  32756. /**
  32757. * @hidden
  32758. * Defines the actions happening just before the active camera is drawing.
  32759. */ private _beforeCameraDrawStage: Stage<CameraStageAction>;
  32760. /**
  32761. * @hidden
  32762. * Defines the actions happening just before a render target is drawing.
  32763. */ private _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32764. /**
  32765. * @hidden
  32766. * Defines the actions happening just before a rendering group is drawing.
  32767. */ private _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32768. /**
  32769. * @hidden
  32770. * Defines the actions happening just before a mesh is drawing.
  32771. */ private _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32772. /**
  32773. * @hidden
  32774. * Defines the actions happening just after a mesh has been drawn.
  32775. */ private _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32776. /**
  32777. * @hidden
  32778. * Defines the actions happening just after a rendering group has been drawn.
  32779. */ private _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32780. /**
  32781. * @hidden
  32782. * Defines the actions happening just after the active camera has been drawn.
  32783. */ private _afterCameraDrawStage: Stage<CameraStageAction>;
  32784. /**
  32785. * @hidden
  32786. * Defines the actions happening just after a render target has been drawn.
  32787. */ private _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32788. /**
  32789. * @hidden
  32790. * Defines the actions happening just after rendering all cameras and computing intersections.
  32791. */ private _afterRenderStage: Stage<SimpleStageAction>;
  32792. /**
  32793. * @hidden
  32794. * Defines the actions happening when a pointer move event happens.
  32795. */ private _pointerMoveStage: Stage<PointerMoveStageAction>;
  32796. /**
  32797. * @hidden
  32798. * Defines the actions happening when a pointer down event happens.
  32799. */ private _pointerDownStage: Stage<PointerUpDownStageAction>;
  32800. /**
  32801. * @hidden
  32802. * Defines the actions happening when a pointer up event happens.
  32803. */ private _pointerUpStage: Stage<PointerUpDownStageAction>;
  32804. /**
  32805. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32806. */
  32807. private geometriesByUniqueId;
  32808. /**
  32809. * Creates a new Scene
  32810. * @param engine defines the engine to use to render this scene
  32811. * @param options defines the scene options
  32812. */
  32813. constructor(engine: Engine, options?: SceneOptions);
  32814. /**
  32815. * Gets a string idenfifying the name of the class
  32816. * @returns "Scene" string
  32817. */
  32818. getClassName(): string;
  32819. private _defaultMeshCandidates;
  32820. /**
  32821. * @hidden
  32822. */ private _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32823. private _defaultSubMeshCandidates;
  32824. /**
  32825. * @hidden
  32826. */ private _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32827. /**
  32828. * Sets the default candidate providers for the scene.
  32829. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32830. * and getCollidingSubMeshCandidates to their default function
  32831. */
  32832. setDefaultCandidateProviders(): void;
  32833. /**
  32834. * Gets the mesh that is currently under the pointer
  32835. */
  32836. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32837. /**
  32838. * Gets or sets the current on-screen X position of the pointer
  32839. */
  32840. pointerX: number;
  32841. /**
  32842. * Gets or sets the current on-screen Y position of the pointer
  32843. */
  32844. pointerY: number;
  32845. /**
  32846. * Gets the cached material (ie. the latest rendered one)
  32847. * @returns the cached material
  32848. */
  32849. getCachedMaterial(): Nullable<Material>;
  32850. /**
  32851. * Gets the cached effect (ie. the latest rendered one)
  32852. * @returns the cached effect
  32853. */
  32854. getCachedEffect(): Nullable<Effect>;
  32855. /**
  32856. * Gets the cached visibility state (ie. the latest rendered one)
  32857. * @returns the cached visibility state
  32858. */
  32859. getCachedVisibility(): Nullable<number>;
  32860. /**
  32861. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32862. * @param material defines the current material
  32863. * @param effect defines the current effect
  32864. * @param visibility defines the current visibility state
  32865. * @returns true if one parameter is not cached
  32866. */
  32867. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32868. /**
  32869. * Gets the engine associated with the scene
  32870. * @returns an Engine
  32871. */
  32872. getEngine(): Engine;
  32873. /**
  32874. * Gets the total number of vertices rendered per frame
  32875. * @returns the total number of vertices rendered per frame
  32876. */
  32877. getTotalVertices(): number;
  32878. /**
  32879. * Gets the performance counter for total vertices
  32880. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32881. */
  32882. readonly totalVerticesPerfCounter: PerfCounter;
  32883. /**
  32884. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32885. * @returns the total number of active indices rendered per frame
  32886. */
  32887. getActiveIndices(): number;
  32888. /**
  32889. * Gets the performance counter for active indices
  32890. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32891. */
  32892. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32893. /**
  32894. * Gets the total number of active particles rendered per frame
  32895. * @returns the total number of active particles rendered per frame
  32896. */
  32897. getActiveParticles(): number;
  32898. /**
  32899. * Gets the performance counter for active particles
  32900. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32901. */
  32902. readonly activeParticlesPerfCounter: PerfCounter;
  32903. /**
  32904. * Gets the total number of active bones rendered per frame
  32905. * @returns the total number of active bones rendered per frame
  32906. */
  32907. getActiveBones(): number;
  32908. /**
  32909. * Gets the performance counter for active bones
  32910. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32911. */
  32912. readonly activeBonesPerfCounter: PerfCounter;
  32913. /**
  32914. * Gets the array of active meshes
  32915. * @returns an array of AbstractMesh
  32916. */
  32917. getActiveMeshes(): SmartArray<AbstractMesh>;
  32918. /**
  32919. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32920. * @returns a number
  32921. */
  32922. getAnimationRatio(): number;
  32923. /**
  32924. * Gets an unique Id for the current render phase
  32925. * @returns a number
  32926. */
  32927. getRenderId(): number;
  32928. /**
  32929. * Gets an unique Id for the current frame
  32930. * @returns a number
  32931. */
  32932. getFrameId(): number;
  32933. /** Call this function if you want to manually increment the render Id*/
  32934. incrementRenderId(): void;
  32935. private _createUbo;
  32936. /**
  32937. * Use this method to simulate a pointer move on a mesh
  32938. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32939. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32940. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32941. * @returns the current scene
  32942. */
  32943. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32944. /**
  32945. * Use this method to simulate a pointer down on a mesh
  32946. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32947. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32948. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32949. * @returns the current scene
  32950. */
  32951. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32952. /**
  32953. * Use this method to simulate a pointer up on a mesh
  32954. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32955. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32956. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32957. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32958. * @returns the current scene
  32959. */
  32960. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32961. /**
  32962. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32963. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32964. * @returns true if the pointer was captured
  32965. */
  32966. isPointerCaptured(pointerId?: number): boolean;
  32967. /**
  32968. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32969. * @param attachUp defines if you want to attach events to pointerup
  32970. * @param attachDown defines if you want to attach events to pointerdown
  32971. * @param attachMove defines if you want to attach events to pointermove
  32972. */
  32973. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32974. /** Detaches all event handlers*/
  32975. detachControl(): void;
  32976. /**
  32977. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32978. * Delay loaded resources are not taking in account
  32979. * @return true if all required resources are ready
  32980. */
  32981. isReady(): boolean;
  32982. /** Resets all cached information relative to material (including effect and visibility) */
  32983. resetCachedMaterial(): void;
  32984. /**
  32985. * Registers a function to be called before every frame render
  32986. * @param func defines the function to register
  32987. */
  32988. registerBeforeRender(func: () => void): void;
  32989. /**
  32990. * Unregisters a function called before every frame render
  32991. * @param func defines the function to unregister
  32992. */
  32993. unregisterBeforeRender(func: () => void): void;
  32994. /**
  32995. * Registers a function to be called after every frame render
  32996. * @param func defines the function to register
  32997. */
  32998. registerAfterRender(func: () => void): void;
  32999. /**
  33000. * Unregisters a function called after every frame render
  33001. * @param func defines the function to unregister
  33002. */
  33003. unregisterAfterRender(func: () => void): void;
  33004. private _executeOnceBeforeRender;
  33005. /**
  33006. * The provided function will run before render once and will be disposed afterwards.
  33007. * A timeout delay can be provided so that the function will be executed in N ms.
  33008. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33009. * @param func The function to be executed.
  33010. * @param timeout optional delay in ms
  33011. */
  33012. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33013. /** @hidden */ private _addPendingData(data: any): void;
  33014. /** @hidden */ private _removePendingData(data: any): void;
  33015. /**
  33016. * Returns the number of items waiting to be loaded
  33017. * @returns the number of items waiting to be loaded
  33018. */
  33019. getWaitingItemsCount(): number;
  33020. /**
  33021. * Returns a boolean indicating if the scene is still loading data
  33022. */
  33023. readonly isLoading: boolean;
  33024. /**
  33025. * Registers a function to be executed when the scene is ready
  33026. * @param {Function} func - the function to be executed
  33027. */
  33028. executeWhenReady(func: () => void): void;
  33029. /**
  33030. * Returns a promise that resolves when the scene is ready
  33031. * @returns A promise that resolves when the scene is ready
  33032. */
  33033. whenReadyAsync(): Promise<void>;
  33034. /** @hidden */ private _checkIsReady(): void;
  33035. /**
  33036. * Gets all animatable attached to the scene
  33037. */
  33038. readonly animatables: Animatable[];
  33039. /**
  33040. * Resets the last animation time frame.
  33041. * Useful to override when animations start running when loading a scene for the first time.
  33042. */
  33043. resetLastAnimationTimeFrame(): void;
  33044. /**
  33045. * Gets the current view matrix
  33046. * @returns a Matrix
  33047. */
  33048. getViewMatrix(): Matrix;
  33049. /**
  33050. * Gets the current projection matrix
  33051. * @returns a Matrix
  33052. */
  33053. getProjectionMatrix(): Matrix;
  33054. /**
  33055. * Gets the current transform matrix
  33056. * @returns a Matrix made of View * Projection
  33057. */
  33058. getTransformMatrix(): Matrix;
  33059. /**
  33060. * Sets the current transform matrix
  33061. * @param viewL defines the View matrix to use
  33062. * @param projectionL defines the Projection matrix to use
  33063. * @param viewR defines the right View matrix to use (if provided)
  33064. * @param projectionR defines the right Projection matrix to use (if provided)
  33065. */
  33066. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33067. /**
  33068. * Gets the uniform buffer used to store scene data
  33069. * @returns a UniformBuffer
  33070. */
  33071. getSceneUniformBuffer(): UniformBuffer;
  33072. /**
  33073. * Gets an unique (relatively to the current scene) Id
  33074. * @returns an unique number for the scene
  33075. */
  33076. getUniqueId(): number;
  33077. /**
  33078. * Add a mesh to the list of scene's meshes
  33079. * @param newMesh defines the mesh to add
  33080. * @param recursive if all child meshes should also be added to the scene
  33081. */
  33082. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33083. /**
  33084. * Remove a mesh for the list of scene's meshes
  33085. * @param toRemove defines the mesh to remove
  33086. * @param recursive if all child meshes should also be removed from the scene
  33087. * @returns the index where the mesh was in the mesh list
  33088. */
  33089. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33090. /**
  33091. * Add a transform node to the list of scene's transform nodes
  33092. * @param newTransformNode defines the transform node to add
  33093. */
  33094. addTransformNode(newTransformNode: TransformNode): void;
  33095. /**
  33096. * Remove a transform node for the list of scene's transform nodes
  33097. * @param toRemove defines the transform node to remove
  33098. * @returns the index where the transform node was in the transform node list
  33099. */
  33100. removeTransformNode(toRemove: TransformNode): number;
  33101. /**
  33102. * Remove a skeleton for the list of scene's skeletons
  33103. * @param toRemove defines the skeleton to remove
  33104. * @returns the index where the skeleton was in the skeleton list
  33105. */
  33106. removeSkeleton(toRemove: Skeleton): number;
  33107. /**
  33108. * Remove a morph target for the list of scene's morph targets
  33109. * @param toRemove defines the morph target to remove
  33110. * @returns the index where the morph target was in the morph target list
  33111. */
  33112. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33113. /**
  33114. * Remove a light for the list of scene's lights
  33115. * @param toRemove defines the light to remove
  33116. * @returns the index where the light was in the light list
  33117. */
  33118. removeLight(toRemove: Light): number;
  33119. /**
  33120. * Remove a camera for the list of scene's cameras
  33121. * @param toRemove defines the camera to remove
  33122. * @returns the index where the camera was in the camera list
  33123. */
  33124. removeCamera(toRemove: Camera): number;
  33125. /**
  33126. * Remove a particle system for the list of scene's particle systems
  33127. * @param toRemove defines the particle system to remove
  33128. * @returns the index where the particle system was in the particle system list
  33129. */
  33130. removeParticleSystem(toRemove: IParticleSystem): number;
  33131. /**
  33132. * Remove a animation for the list of scene's animations
  33133. * @param toRemove defines the animation to remove
  33134. * @returns the index where the animation was in the animation list
  33135. */
  33136. removeAnimation(toRemove: Animation): number;
  33137. /**
  33138. * Will stop the animation of the given target
  33139. * @param target - the target
  33140. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33141. * @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)
  33142. */
  33143. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33144. /**
  33145. * Removes the given animation group from this scene.
  33146. * @param toRemove The animation group to remove
  33147. * @returns The index of the removed animation group
  33148. */
  33149. removeAnimationGroup(toRemove: AnimationGroup): number;
  33150. /**
  33151. * Removes the given multi-material from this scene.
  33152. * @param toRemove The multi-material to remove
  33153. * @returns The index of the removed multi-material
  33154. */
  33155. removeMultiMaterial(toRemove: MultiMaterial): number;
  33156. /**
  33157. * Removes the given material from this scene.
  33158. * @param toRemove The material to remove
  33159. * @returns The index of the removed material
  33160. */
  33161. removeMaterial(toRemove: Material): number;
  33162. /**
  33163. * Removes the given action manager from this scene.
  33164. * @param toRemove The action manager to remove
  33165. * @returns The index of the removed action manager
  33166. */
  33167. removeActionManager(toRemove: AbstractActionManager): number;
  33168. /**
  33169. * Removes the given texture from this scene.
  33170. * @param toRemove The texture to remove
  33171. * @returns The index of the removed texture
  33172. */
  33173. removeTexture(toRemove: BaseTexture): number;
  33174. /**
  33175. * Adds the given light to this scene
  33176. * @param newLight The light to add
  33177. */
  33178. addLight(newLight: Light): void;
  33179. /**
  33180. * Sorts the list list based on light priorities
  33181. */
  33182. sortLightsByPriority(): void;
  33183. /**
  33184. * Adds the given camera to this scene
  33185. * @param newCamera The camera to add
  33186. */
  33187. addCamera(newCamera: Camera): void;
  33188. /**
  33189. * Adds the given skeleton to this scene
  33190. * @param newSkeleton The skeleton to add
  33191. */
  33192. addSkeleton(newSkeleton: Skeleton): void;
  33193. /**
  33194. * Adds the given particle system to this scene
  33195. * @param newParticleSystem The particle system to add
  33196. */
  33197. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33198. /**
  33199. * Adds the given animation to this scene
  33200. * @param newAnimation The animation to add
  33201. */
  33202. addAnimation(newAnimation: Animation): void;
  33203. /**
  33204. * Adds the given animation group to this scene.
  33205. * @param newAnimationGroup The animation group to add
  33206. */
  33207. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33208. /**
  33209. * Adds the given multi-material to this scene
  33210. * @param newMultiMaterial The multi-material to add
  33211. */
  33212. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33213. /**
  33214. * Adds the given material to this scene
  33215. * @param newMaterial The material to add
  33216. */
  33217. addMaterial(newMaterial: Material): void;
  33218. /**
  33219. * Adds the given morph target to this scene
  33220. * @param newMorphTargetManager The morph target to add
  33221. */
  33222. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33223. /**
  33224. * Adds the given geometry to this scene
  33225. * @param newGeometry The geometry to add
  33226. */
  33227. addGeometry(newGeometry: Geometry): void;
  33228. /**
  33229. * Adds the given action manager to this scene
  33230. * @param newActionManager The action manager to add
  33231. */
  33232. addActionManager(newActionManager: AbstractActionManager): void;
  33233. /**
  33234. * Adds the given texture to this scene.
  33235. * @param newTexture The texture to add
  33236. */
  33237. addTexture(newTexture: BaseTexture): void;
  33238. /**
  33239. * Switch active camera
  33240. * @param newCamera defines the new active camera
  33241. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33242. */
  33243. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33244. /**
  33245. * sets the active camera of the scene using its ID
  33246. * @param id defines the camera's ID
  33247. * @return the new active camera or null if none found.
  33248. */
  33249. setActiveCameraByID(id: string): Nullable<Camera>;
  33250. /**
  33251. * sets the active camera of the scene using its name
  33252. * @param name defines the camera's name
  33253. * @returns the new active camera or null if none found.
  33254. */
  33255. setActiveCameraByName(name: string): Nullable<Camera>;
  33256. /**
  33257. * get an animation group using its name
  33258. * @param name defines the material's name
  33259. * @return the animation group or null if none found.
  33260. */
  33261. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33262. /**
  33263. * Get a material using its unique id
  33264. * @param uniqueId defines the material's unique id
  33265. * @return the material or null if none found.
  33266. */
  33267. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33268. /**
  33269. * get a material using its id
  33270. * @param id defines the material's ID
  33271. * @return the material or null if none found.
  33272. */
  33273. getMaterialByID(id: string): Nullable<Material>;
  33274. /**
  33275. * Gets a the last added material using a given id
  33276. * @param id defines the material's ID
  33277. * @return the last material with the given id or null if none found.
  33278. */
  33279. getLastMaterialByID(id: string): Nullable<Material>;
  33280. /**
  33281. * Gets a material using its name
  33282. * @param name defines the material's name
  33283. * @return the material or null if none found.
  33284. */
  33285. getMaterialByName(name: string): Nullable<Material>;
  33286. /**
  33287. * Get a texture using its unique id
  33288. * @param uniqueId defines the texture's unique id
  33289. * @return the texture or null if none found.
  33290. */
  33291. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  33292. /**
  33293. * Gets a camera using its id
  33294. * @param id defines the id to look for
  33295. * @returns the camera or null if not found
  33296. */
  33297. getCameraByID(id: string): Nullable<Camera>;
  33298. /**
  33299. * Gets a camera using its unique id
  33300. * @param uniqueId defines the unique id to look for
  33301. * @returns the camera or null if not found
  33302. */
  33303. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33304. /**
  33305. * Gets a camera using its name
  33306. * @param name defines the camera's name
  33307. * @return the camera or null if none found.
  33308. */
  33309. getCameraByName(name: string): Nullable<Camera>;
  33310. /**
  33311. * Gets a bone using its id
  33312. * @param id defines the bone's id
  33313. * @return the bone or null if not found
  33314. */
  33315. getBoneByID(id: string): Nullable<Bone>;
  33316. /**
  33317. * Gets a bone using its id
  33318. * @param name defines the bone's name
  33319. * @return the bone or null if not found
  33320. */
  33321. getBoneByName(name: string): Nullable<Bone>;
  33322. /**
  33323. * Gets a light node using its name
  33324. * @param name defines the the light's name
  33325. * @return the light or null if none found.
  33326. */
  33327. getLightByName(name: string): Nullable<Light>;
  33328. /**
  33329. * Gets a light node using its id
  33330. * @param id defines the light's id
  33331. * @return the light or null if none found.
  33332. */
  33333. getLightByID(id: string): Nullable<Light>;
  33334. /**
  33335. * Gets a light node using its scene-generated unique ID
  33336. * @param uniqueId defines the light's unique id
  33337. * @return the light or null if none found.
  33338. */
  33339. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33340. /**
  33341. * Gets a particle system by id
  33342. * @param id defines the particle system id
  33343. * @return the corresponding system or null if none found
  33344. */
  33345. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33346. /**
  33347. * Gets a geometry using its ID
  33348. * @param id defines the geometry's id
  33349. * @return the geometry or null if none found.
  33350. */
  33351. getGeometryByID(id: string): Nullable<Geometry>;
  33352. private _getGeometryByUniqueID;
  33353. /**
  33354. * Add a new geometry to this scene
  33355. * @param geometry defines the geometry to be added to the scene.
  33356. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33357. * @return a boolean defining if the geometry was added or not
  33358. */
  33359. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33360. /**
  33361. * Removes an existing geometry
  33362. * @param geometry defines the geometry to be removed from the scene
  33363. * @return a boolean defining if the geometry was removed or not
  33364. */
  33365. removeGeometry(geometry: Geometry): boolean;
  33366. /**
  33367. * Gets the list of geometries attached to the scene
  33368. * @returns an array of Geometry
  33369. */
  33370. getGeometries(): Geometry[];
  33371. /**
  33372. * Gets the first added mesh found of a given ID
  33373. * @param id defines the id to search for
  33374. * @return the mesh found or null if not found at all
  33375. */
  33376. getMeshByID(id: string): Nullable<AbstractMesh>;
  33377. /**
  33378. * Gets a list of meshes using their id
  33379. * @param id defines the id to search for
  33380. * @returns a list of meshes
  33381. */
  33382. getMeshesByID(id: string): Array<AbstractMesh>;
  33383. /**
  33384. * Gets the first added transform node found of a given ID
  33385. * @param id defines the id to search for
  33386. * @return the found transform node or null if not found at all.
  33387. */
  33388. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33389. /**
  33390. * Gets a transform node with its auto-generated unique id
  33391. * @param uniqueId efines the unique id to search for
  33392. * @return the found transform node or null if not found at all.
  33393. */
  33394. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33395. /**
  33396. * Gets a list of transform nodes using their id
  33397. * @param id defines the id to search for
  33398. * @returns a list of transform nodes
  33399. */
  33400. getTransformNodesByID(id: string): Array<TransformNode>;
  33401. /**
  33402. * Gets a mesh with its auto-generated unique id
  33403. * @param uniqueId defines the unique id to search for
  33404. * @return the found mesh or null if not found at all.
  33405. */
  33406. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33407. /**
  33408. * Gets a the last added mesh using a given id
  33409. * @param id defines the id to search for
  33410. * @return the found mesh or null if not found at all.
  33411. */
  33412. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33413. /**
  33414. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33415. * @param id defines the id to search for
  33416. * @return the found node or null if not found at all
  33417. */
  33418. getLastEntryByID(id: string): Nullable<Node>;
  33419. /**
  33420. * Gets a node (Mesh, Camera, Light) using a given id
  33421. * @param id defines the id to search for
  33422. * @return the found node or null if not found at all
  33423. */
  33424. getNodeByID(id: string): Nullable<Node>;
  33425. /**
  33426. * Gets a node (Mesh, Camera, Light) using a given name
  33427. * @param name defines the name to search for
  33428. * @return the found node or null if not found at all.
  33429. */
  33430. getNodeByName(name: string): Nullable<Node>;
  33431. /**
  33432. * Gets a mesh using a given name
  33433. * @param name defines the name to search for
  33434. * @return the found mesh or null if not found at all.
  33435. */
  33436. getMeshByName(name: string): Nullable<AbstractMesh>;
  33437. /**
  33438. * Gets a transform node using a given name
  33439. * @param name defines the name to search for
  33440. * @return the found transform node or null if not found at all.
  33441. */
  33442. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33443. /**
  33444. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33445. * @param id defines the id to search for
  33446. * @return the found skeleton or null if not found at all.
  33447. */
  33448. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33449. /**
  33450. * Gets a skeleton using a given auto generated unique id
  33451. * @param uniqueId defines the unique id to search for
  33452. * @return the found skeleton or null if not found at all.
  33453. */
  33454. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33455. /**
  33456. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33457. * @param id defines the id to search for
  33458. * @return the found skeleton or null if not found at all.
  33459. */
  33460. getSkeletonById(id: string): Nullable<Skeleton>;
  33461. /**
  33462. * Gets a skeleton using a given name
  33463. * @param name defines the name to search for
  33464. * @return the found skeleton or null if not found at all.
  33465. */
  33466. getSkeletonByName(name: string): Nullable<Skeleton>;
  33467. /**
  33468. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33469. * @param id defines the id to search for
  33470. * @return the found morph target manager or null if not found at all.
  33471. */
  33472. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33473. /**
  33474. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33475. * @param id defines the id to search for
  33476. * @return the found morph target or null if not found at all.
  33477. */
  33478. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33479. /**
  33480. * Gets a boolean indicating if the given mesh is active
  33481. * @param mesh defines the mesh to look for
  33482. * @returns true if the mesh is in the active list
  33483. */
  33484. isActiveMesh(mesh: AbstractMesh): boolean;
  33485. /**
  33486. * Return a unique id as a string which can serve as an identifier for the scene
  33487. */
  33488. readonly uid: string;
  33489. /**
  33490. * Add an externaly attached data from its key.
  33491. * This method call will fail and return false, if such key already exists.
  33492. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33493. * @param key the unique key that identifies the data
  33494. * @param data the data object to associate to the key for this Engine instance
  33495. * @return true if no such key were already present and the data was added successfully, false otherwise
  33496. */
  33497. addExternalData<T>(key: string, data: T): boolean;
  33498. /**
  33499. * Get an externaly attached data from its key
  33500. * @param key the unique key that identifies the data
  33501. * @return the associated data, if present (can be null), or undefined if not present
  33502. */
  33503. getExternalData<T>(key: string): Nullable<T>;
  33504. /**
  33505. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33506. * @param key the unique key that identifies the data
  33507. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33508. * @return the associated data, can be null if the factory returned null.
  33509. */
  33510. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33511. /**
  33512. * Remove an externaly attached data from the Engine instance
  33513. * @param key the unique key that identifies the data
  33514. * @return true if the data was successfully removed, false if it doesn't exist
  33515. */
  33516. removeExternalData(key: string): boolean;
  33517. private _evaluateSubMesh;
  33518. /**
  33519. * Clear the processed materials smart array preventing retention point in material dispose.
  33520. */
  33521. freeProcessedMaterials(): void;
  33522. private _preventFreeActiveMeshesAndRenderingGroups;
  33523. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33524. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33525. * when disposing several meshes in a row or a hierarchy of meshes.
  33526. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33527. */
  33528. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33529. /**
  33530. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33531. */
  33532. freeActiveMeshes(): void;
  33533. /**
  33534. * Clear the info related to rendering groups preventing retention points during dispose.
  33535. */
  33536. freeRenderingGroups(): void;
  33537. /** @hidden */ private _isInIntermediateRendering(): boolean;
  33538. /**
  33539. * Lambda returning the list of potentially active meshes.
  33540. */
  33541. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33542. /**
  33543. * Lambda returning the list of potentially active sub meshes.
  33544. */
  33545. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33546. /**
  33547. * Lambda returning the list of potentially intersecting sub meshes.
  33548. */
  33549. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33550. /**
  33551. * Lambda returning the list of potentially colliding sub meshes.
  33552. */
  33553. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33554. private _activeMeshesFrozen;
  33555. /**
  33556. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33557. * @returns the current scene
  33558. */
  33559. freezeActiveMeshes(): Scene;
  33560. /**
  33561. * Use this function to restart evaluating active meshes on every frame
  33562. * @returns the current scene
  33563. */
  33564. unfreezeActiveMeshes(): Scene;
  33565. private _evaluateActiveMeshes;
  33566. private _activeMesh;
  33567. /**
  33568. * Update the transform matrix to update from the current active camera
  33569. * @param force defines a boolean used to force the update even if cache is up to date
  33570. */
  33571. updateTransformMatrix(force?: boolean): void;
  33572. private _bindFrameBuffer;
  33573. /** @hidden */ private _allowPostProcessClearColor: boolean;
  33574. /** @hidden */ private _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33575. private _processSubCameras;
  33576. private _checkIntersections;
  33577. /** @hidden */ private _advancePhysicsEngineStep(step: number): void;
  33578. /**
  33579. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33580. */
  33581. getDeterministicFrameTime: () => number;
  33582. /** @hidden */ private _animate(): void;
  33583. /** Execute all animations (for a frame) */
  33584. animate(): void;
  33585. /**
  33586. * Render the scene
  33587. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33588. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  33589. */
  33590. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  33591. /**
  33592. * Freeze all materials
  33593. * A frozen material will not be updatable but should be faster to render
  33594. */
  33595. freezeMaterials(): void;
  33596. /**
  33597. * Unfreeze all materials
  33598. * A frozen material will not be updatable but should be faster to render
  33599. */
  33600. unfreezeMaterials(): void;
  33601. /**
  33602. * Releases all held ressources
  33603. */
  33604. dispose(): void;
  33605. /**
  33606. * Gets if the scene is already disposed
  33607. */
  33608. readonly isDisposed: boolean;
  33609. /**
  33610. * Call this function to reduce memory footprint of the scene.
  33611. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33612. */
  33613. clearCachedVertexData(): void;
  33614. /**
  33615. * This function will remove the local cached buffer data from texture.
  33616. * It will save memory but will prevent the texture from being rebuilt
  33617. */
  33618. cleanCachedTextureBuffer(): void;
  33619. /**
  33620. * Get the world extend vectors with an optional filter
  33621. *
  33622. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33623. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33624. */
  33625. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33626. min: Vector3;
  33627. max: Vector3;
  33628. };
  33629. /**
  33630. * Creates a ray that can be used to pick in the scene
  33631. * @param x defines the x coordinate of the origin (on-screen)
  33632. * @param y defines the y coordinate of the origin (on-screen)
  33633. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33634. * @param camera defines the camera to use for the picking
  33635. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33636. * @returns a Ray
  33637. */
  33638. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33639. /**
  33640. * Creates a ray that can be used to pick in the scene
  33641. * @param x defines the x coordinate of the origin (on-screen)
  33642. * @param y defines the y coordinate of the origin (on-screen)
  33643. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33644. * @param result defines the ray where to store the picking ray
  33645. * @param camera defines the camera to use for the picking
  33646. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33647. * @returns the current scene
  33648. */
  33649. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33650. /**
  33651. * Creates a ray that can be used to pick in the scene
  33652. * @param x defines the x coordinate of the origin (on-screen)
  33653. * @param y defines the y coordinate of the origin (on-screen)
  33654. * @param camera defines the camera to use for the picking
  33655. * @returns a Ray
  33656. */
  33657. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33658. /**
  33659. * Creates a ray that can be used to pick in the scene
  33660. * @param x defines the x coordinate of the origin (on-screen)
  33661. * @param y defines the y coordinate of the origin (on-screen)
  33662. * @param result defines the ray where to store the picking ray
  33663. * @param camera defines the camera to use for the picking
  33664. * @returns the current scene
  33665. */
  33666. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33667. /** Launch a ray to try to pick a mesh in the scene
  33668. * @param x position on screen
  33669. * @param y position on screen
  33670. * @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
  33671. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33672. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33673. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33674. * @returns a PickingInfo
  33675. */
  33676. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33677. /** Use the given ray to pick a mesh in the scene
  33678. * @param ray The ray to use to pick meshes
  33679. * @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
  33680. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33681. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33682. * @returns a PickingInfo
  33683. */
  33684. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33685. /**
  33686. * Launch a ray to try to pick a mesh in the scene
  33687. * @param x X position on screen
  33688. * @param y Y position on screen
  33689. * @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
  33690. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33691. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33692. * @returns an array of PickingInfo
  33693. */
  33694. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33695. /**
  33696. * Launch a ray to try to pick a mesh in the scene
  33697. * @param ray Ray to use
  33698. * @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
  33699. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33700. * @returns an array of PickingInfo
  33701. */
  33702. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33703. /**
  33704. * Force the value of meshUnderPointer
  33705. * @param mesh defines the mesh to use
  33706. */
  33707. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33708. /**
  33709. * Gets the mesh under the pointer
  33710. * @returns a Mesh or null if no mesh is under the pointer
  33711. */
  33712. getPointerOverMesh(): Nullable<AbstractMesh>;
  33713. /** @hidden */ private _rebuildGeometries(): void;
  33714. /** @hidden */ private _rebuildTextures(): void;
  33715. private _getByTags;
  33716. /**
  33717. * Get a list of meshes by tags
  33718. * @param tagsQuery defines the tags query to use
  33719. * @param forEach defines a predicate used to filter results
  33720. * @returns an array of Mesh
  33721. */
  33722. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33723. /**
  33724. * Get a list of cameras by tags
  33725. * @param tagsQuery defines the tags query to use
  33726. * @param forEach defines a predicate used to filter results
  33727. * @returns an array of Camera
  33728. */
  33729. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33730. /**
  33731. * Get a list of lights by tags
  33732. * @param tagsQuery defines the tags query to use
  33733. * @param forEach defines a predicate used to filter results
  33734. * @returns an array of Light
  33735. */
  33736. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33737. /**
  33738. * Get a list of materials by tags
  33739. * @param tagsQuery defines the tags query to use
  33740. * @param forEach defines a predicate used to filter results
  33741. * @returns an array of Material
  33742. */
  33743. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33744. /**
  33745. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33746. * This allowed control for front to back rendering or reversly depending of the special needs.
  33747. *
  33748. * @param renderingGroupId The rendering group id corresponding to its index
  33749. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33750. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33751. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33752. */
  33753. 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;
  33754. /**
  33755. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33756. *
  33757. * @param renderingGroupId The rendering group id corresponding to its index
  33758. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33759. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33760. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33761. */
  33762. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33763. /**
  33764. * Gets the current auto clear configuration for one rendering group of the rendering
  33765. * manager.
  33766. * @param index the rendering group index to get the information for
  33767. * @returns The auto clear setup for the requested rendering group
  33768. */
  33769. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33770. private _blockMaterialDirtyMechanism;
  33771. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33772. blockMaterialDirtyMechanism: boolean;
  33773. /**
  33774. * Will flag all materials as dirty to trigger new shader compilation
  33775. * @param flag defines the flag used to specify which material part must be marked as dirty
  33776. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33777. */
  33778. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33779. /** @hidden */ private _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  33780. /** @hidden */ private _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33781. }
  33782. }
  33783. declare module BABYLON {
  33784. /**
  33785. * Set of assets to keep when moving a scene into an asset container.
  33786. */
  33787. export class KeepAssets extends AbstractScene {
  33788. }
  33789. /**
  33790. * Container with a set of assets that can be added or removed from a scene.
  33791. */
  33792. export class AssetContainer extends AbstractScene {
  33793. /**
  33794. * The scene the AssetContainer belongs to.
  33795. */
  33796. scene: Scene;
  33797. /**
  33798. * Instantiates an AssetContainer.
  33799. * @param scene The scene the AssetContainer belongs to.
  33800. */
  33801. constructor(scene: Scene);
  33802. /**
  33803. * Adds all the assets from the container to the scene.
  33804. */
  33805. addAllToScene(): void;
  33806. /**
  33807. * Removes all the assets in the container from the scene
  33808. */
  33809. removeAllFromScene(): void;
  33810. /**
  33811. * Disposes all the assets in the container
  33812. */
  33813. dispose(): void;
  33814. private _moveAssets;
  33815. /**
  33816. * Removes all the assets contained in the scene and adds them to the container.
  33817. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33818. */
  33819. moveAllFromScene(keepAssets?: KeepAssets): void;
  33820. /**
  33821. * 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.
  33822. * @returns the root mesh
  33823. */
  33824. createRootMesh(): Mesh;
  33825. }
  33826. }
  33827. declare module BABYLON {
  33828. /**
  33829. * Defines how the parser contract is defined.
  33830. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33831. */
  33832. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33833. /**
  33834. * Defines how the individual parser contract is defined.
  33835. * These parser can parse an individual asset
  33836. */
  33837. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33838. /**
  33839. * Base class of the scene acting as a container for the different elements composing a scene.
  33840. * This class is dynamically extended by the different components of the scene increasing
  33841. * flexibility and reducing coupling
  33842. */
  33843. export abstract class AbstractScene {
  33844. /**
  33845. * Stores the list of available parsers in the application.
  33846. */
  33847. private static _BabylonFileParsers;
  33848. /**
  33849. * Stores the list of available individual parsers in the application.
  33850. */
  33851. private static _IndividualBabylonFileParsers;
  33852. /**
  33853. * Adds a parser in the list of available ones
  33854. * @param name Defines the name of the parser
  33855. * @param parser Defines the parser to add
  33856. */
  33857. static AddParser(name: string, parser: BabylonFileParser): void;
  33858. /**
  33859. * Gets a general parser from the list of avaialble ones
  33860. * @param name Defines the name of the parser
  33861. * @returns the requested parser or null
  33862. */
  33863. static GetParser(name: string): Nullable<BabylonFileParser>;
  33864. /**
  33865. * Adds n individual parser in the list of available ones
  33866. * @param name Defines the name of the parser
  33867. * @param parser Defines the parser to add
  33868. */
  33869. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33870. /**
  33871. * Gets an individual parser from the list of avaialble ones
  33872. * @param name Defines the name of the parser
  33873. * @returns the requested parser or null
  33874. */
  33875. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33876. /**
  33877. * Parser json data and populate both a scene and its associated container object
  33878. * @param jsonData Defines the data to parse
  33879. * @param scene Defines the scene to parse the data for
  33880. * @param container Defines the container attached to the parsing sequence
  33881. * @param rootUrl Defines the root url of the data
  33882. */
  33883. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33884. /**
  33885. * Gets the list of root nodes (ie. nodes with no parent)
  33886. */
  33887. rootNodes: Node[];
  33888. /** All of the cameras added to this scene
  33889. * @see http://doc.babylonjs.com/babylon101/cameras
  33890. */
  33891. cameras: Camera[];
  33892. /**
  33893. * All of the lights added to this scene
  33894. * @see http://doc.babylonjs.com/babylon101/lights
  33895. */
  33896. lights: Light[];
  33897. /**
  33898. * All of the (abstract) meshes added to this scene
  33899. */
  33900. meshes: AbstractMesh[];
  33901. /**
  33902. * The list of skeletons added to the scene
  33903. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33904. */
  33905. skeletons: Skeleton[];
  33906. /**
  33907. * All of the particle systems added to this scene
  33908. * @see http://doc.babylonjs.com/babylon101/particles
  33909. */
  33910. particleSystems: IParticleSystem[];
  33911. /**
  33912. * Gets a list of Animations associated with the scene
  33913. */
  33914. animations: Animation[];
  33915. /**
  33916. * All of the animation groups added to this scene
  33917. * @see http://doc.babylonjs.com/how_to/group
  33918. */
  33919. animationGroups: AnimationGroup[];
  33920. /**
  33921. * All of the multi-materials added to this scene
  33922. * @see http://doc.babylonjs.com/how_to/multi_materials
  33923. */
  33924. multiMaterials: MultiMaterial[];
  33925. /**
  33926. * All of the materials added to this scene
  33927. * In the context of a Scene, it is not supposed to be modified manually.
  33928. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33929. * Note also that the order of the Material wihin the array is not significant and might change.
  33930. * @see http://doc.babylonjs.com/babylon101/materials
  33931. */
  33932. materials: Material[];
  33933. /**
  33934. * The list of morph target managers added to the scene
  33935. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33936. */
  33937. morphTargetManagers: MorphTargetManager[];
  33938. /**
  33939. * The list of geometries used in the scene.
  33940. */
  33941. geometries: Geometry[];
  33942. /**
  33943. * All of the tranform nodes added to this scene
  33944. * In the context of a Scene, it is not supposed to be modified manually.
  33945. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33946. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33947. * @see http://doc.babylonjs.com/how_to/transformnode
  33948. */
  33949. transformNodes: TransformNode[];
  33950. /**
  33951. * ActionManagers available on the scene.
  33952. */
  33953. actionManagers: AbstractActionManager[];
  33954. /**
  33955. * Textures to keep.
  33956. */
  33957. textures: BaseTexture[];
  33958. /**
  33959. * Environment texture for the scene
  33960. */
  33961. environmentTexture: Nullable<BaseTexture>;
  33962. }
  33963. }
  33964. declare module BABYLON {
  33965. /**
  33966. * Interface used to define options for Sound class
  33967. */
  33968. export interface ISoundOptions {
  33969. /**
  33970. * Does the sound autoplay once loaded.
  33971. */
  33972. autoplay?: boolean;
  33973. /**
  33974. * Does the sound loop after it finishes playing once.
  33975. */
  33976. loop?: boolean;
  33977. /**
  33978. * Sound's volume
  33979. */
  33980. volume?: number;
  33981. /**
  33982. * Is it a spatial sound?
  33983. */
  33984. spatialSound?: boolean;
  33985. /**
  33986. * Maximum distance to hear that sound
  33987. */
  33988. maxDistance?: number;
  33989. /**
  33990. * Uses user defined attenuation function
  33991. */
  33992. useCustomAttenuation?: boolean;
  33993. /**
  33994. * Define the roll off factor of spatial sounds.
  33995. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33996. */
  33997. rolloffFactor?: number;
  33998. /**
  33999. * Define the reference distance the sound should be heard perfectly.
  34000. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34001. */
  34002. refDistance?: number;
  34003. /**
  34004. * Define the distance attenuation model the sound will follow.
  34005. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34006. */
  34007. distanceModel?: string;
  34008. /**
  34009. * Defines the playback speed (1 by default)
  34010. */
  34011. playbackRate?: number;
  34012. /**
  34013. * Defines if the sound is from a streaming source
  34014. */
  34015. streaming?: boolean;
  34016. /**
  34017. * Defines an optional length (in seconds) inside the sound file
  34018. */
  34019. length?: number;
  34020. /**
  34021. * Defines an optional offset (in seconds) inside the sound file
  34022. */
  34023. offset?: number;
  34024. /**
  34025. * If true, URLs will not be required to state the audio file codec to use.
  34026. */
  34027. skipCodecCheck?: boolean;
  34028. }
  34029. /**
  34030. * Defines a sound that can be played in the application.
  34031. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34032. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34033. */
  34034. export class Sound {
  34035. /**
  34036. * The name of the sound in the scene.
  34037. */
  34038. name: string;
  34039. /**
  34040. * Does the sound autoplay once loaded.
  34041. */
  34042. autoplay: boolean;
  34043. /**
  34044. * Does the sound loop after it finishes playing once.
  34045. */
  34046. loop: boolean;
  34047. /**
  34048. * Does the sound use a custom attenuation curve to simulate the falloff
  34049. * happening when the source gets further away from the camera.
  34050. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34051. */
  34052. useCustomAttenuation: boolean;
  34053. /**
  34054. * The sound track id this sound belongs to.
  34055. */
  34056. soundTrackId: number;
  34057. /**
  34058. * Is this sound currently played.
  34059. */
  34060. isPlaying: boolean;
  34061. /**
  34062. * Is this sound currently paused.
  34063. */
  34064. isPaused: boolean;
  34065. /**
  34066. * Does this sound enables spatial sound.
  34067. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34068. */
  34069. spatialSound: boolean;
  34070. /**
  34071. * Define the reference distance the sound should be heard perfectly.
  34072. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34073. */
  34074. refDistance: number;
  34075. /**
  34076. * Define the roll off factor of spatial sounds.
  34077. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34078. */
  34079. rolloffFactor: number;
  34080. /**
  34081. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34082. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34083. */
  34084. maxDistance: number;
  34085. /**
  34086. * Define the distance attenuation model the sound will follow.
  34087. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34088. */
  34089. distanceModel: string;
  34090. /**
  34091. * @hidden
  34092. * Back Compat
  34093. **/
  34094. onended: () => any;
  34095. /**
  34096. * Observable event when the current playing sound finishes.
  34097. */
  34098. onEndedObservable: Observable<Sound>;
  34099. private _panningModel;
  34100. private _playbackRate;
  34101. private _streaming;
  34102. private _startTime;
  34103. private _startOffset;
  34104. private _position;
  34105. /** @hidden */ private _positionInEmitterSpace: boolean;
  34106. private _localDirection;
  34107. private _volume;
  34108. private _isReadyToPlay;
  34109. private _isDirectional;
  34110. private _readyToPlayCallback;
  34111. private _audioBuffer;
  34112. private _soundSource;
  34113. private _streamingSource;
  34114. private _soundPanner;
  34115. private _soundGain;
  34116. private _inputAudioNode;
  34117. private _outputAudioNode;
  34118. private _coneInnerAngle;
  34119. private _coneOuterAngle;
  34120. private _coneOuterGain;
  34121. private _scene;
  34122. private _connectedTransformNode;
  34123. private _customAttenuationFunction;
  34124. private _registerFunc;
  34125. private _isOutputConnected;
  34126. private _htmlAudioElement;
  34127. private _urlType;
  34128. private _length?;
  34129. private _offset?;
  34130. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  34131. /**
  34132. * Create a sound and attach it to a scene
  34133. * @param name Name of your sound
  34134. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34135. * @param scene defines the scene the sound belongs to
  34136. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34137. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34138. */
  34139. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  34140. /**
  34141. * Release the sound and its associated resources
  34142. */
  34143. dispose(): void;
  34144. /**
  34145. * Gets if the sounds is ready to be played or not.
  34146. * @returns true if ready, otherwise false
  34147. */
  34148. isReady(): boolean;
  34149. private _soundLoaded;
  34150. /**
  34151. * Sets the data of the sound from an audiobuffer
  34152. * @param audioBuffer The audioBuffer containing the data
  34153. */
  34154. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34155. /**
  34156. * Updates the current sounds options such as maxdistance, loop...
  34157. * @param options A JSON object containing values named as the object properties
  34158. */
  34159. updateOptions(options: ISoundOptions): void;
  34160. private _createSpatialParameters;
  34161. private _updateSpatialParameters;
  34162. /**
  34163. * Switch the panning model to HRTF:
  34164. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34165. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34166. */
  34167. switchPanningModelToHRTF(): void;
  34168. /**
  34169. * Switch the panning model to Equal Power:
  34170. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34171. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34172. */
  34173. switchPanningModelToEqualPower(): void;
  34174. private _switchPanningModel;
  34175. /**
  34176. * Connect this sound to a sound track audio node like gain...
  34177. * @param soundTrackAudioNode the sound track audio node to connect to
  34178. */
  34179. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34180. /**
  34181. * Transform this sound into a directional source
  34182. * @param coneInnerAngle Size of the inner cone in degree
  34183. * @param coneOuterAngle Size of the outer cone in degree
  34184. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34185. */
  34186. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34187. /**
  34188. * Gets or sets the inner angle for the directional cone.
  34189. */
  34190. /**
  34191. * Gets or sets the inner angle for the directional cone.
  34192. */
  34193. directionalConeInnerAngle: number;
  34194. /**
  34195. * Gets or sets the outer angle for the directional cone.
  34196. */
  34197. /**
  34198. * Gets or sets the outer angle for the directional cone.
  34199. */
  34200. directionalConeOuterAngle: number;
  34201. /**
  34202. * Sets the position of the emitter if spatial sound is enabled
  34203. * @param newPosition Defines the new posisiton
  34204. */
  34205. setPosition(newPosition: Vector3): void;
  34206. /**
  34207. * Sets the local direction of the emitter if spatial sound is enabled
  34208. * @param newLocalDirection Defines the new local direction
  34209. */
  34210. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34211. private _updateDirection;
  34212. /** @hidden */
  34213. updateDistanceFromListener(): void;
  34214. /**
  34215. * Sets a new custom attenuation function for the sound.
  34216. * @param callback Defines the function used for the attenuation
  34217. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34218. */
  34219. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34220. /**
  34221. * Play the sound
  34222. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34223. * @param offset (optional) Start the sound at a specific time in seconds
  34224. * @param length (optional) Sound duration (in seconds)
  34225. */
  34226. play(time?: number, offset?: number, length?: number): void;
  34227. private _onended;
  34228. /**
  34229. * Stop the sound
  34230. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34231. */
  34232. stop(time?: number): void;
  34233. /**
  34234. * Put the sound in pause
  34235. */
  34236. pause(): void;
  34237. /**
  34238. * Sets a dedicated volume for this sounds
  34239. * @param newVolume Define the new volume of the sound
  34240. * @param time Define time for gradual change to new volume
  34241. */
  34242. setVolume(newVolume: number, time?: number): void;
  34243. /**
  34244. * Set the sound play back rate
  34245. * @param newPlaybackRate Define the playback rate the sound should be played at
  34246. */
  34247. setPlaybackRate(newPlaybackRate: number): void;
  34248. /**
  34249. * Gets the volume of the sound.
  34250. * @returns the volume of the sound
  34251. */
  34252. getVolume(): number;
  34253. /**
  34254. * Attach the sound to a dedicated mesh
  34255. * @param transformNode The transform node to connect the sound with
  34256. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34257. */
  34258. attachToMesh(transformNode: TransformNode): void;
  34259. /**
  34260. * Detach the sound from the previously attached mesh
  34261. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34262. */
  34263. detachFromMesh(): void;
  34264. private _onRegisterAfterWorldMatrixUpdate;
  34265. /**
  34266. * Clone the current sound in the scene.
  34267. * @returns the new sound clone
  34268. */
  34269. clone(): Nullable<Sound>;
  34270. /**
  34271. * Gets the current underlying audio buffer containing the data
  34272. * @returns the audio buffer
  34273. */
  34274. getAudioBuffer(): Nullable<AudioBuffer>;
  34275. /**
  34276. * Serializes the Sound in a JSON representation
  34277. * @returns the JSON representation of the sound
  34278. */
  34279. serialize(): any;
  34280. /**
  34281. * Parse a JSON representation of a sound to innstantiate in a given scene
  34282. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34283. * @param scene Define the scene the new parsed sound should be created in
  34284. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34285. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34286. * @returns the newly parsed sound
  34287. */
  34288. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34289. }
  34290. }
  34291. declare module BABYLON {
  34292. /**
  34293. * This defines an action helpful to play a defined sound on a triggered action.
  34294. */
  34295. export class PlaySoundAction extends Action {
  34296. private _sound;
  34297. /**
  34298. * Instantiate the action
  34299. * @param triggerOptions defines the trigger options
  34300. * @param sound defines the sound to play
  34301. * @param condition defines the trigger related conditions
  34302. */
  34303. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34304. /** @hidden */ private _prepare(): void;
  34305. /**
  34306. * Execute the action and play the sound.
  34307. */
  34308. execute(): void;
  34309. /**
  34310. * Serializes the actions and its related information.
  34311. * @param parent defines the object to serialize in
  34312. * @returns the serialized object
  34313. */
  34314. serialize(parent: any): any;
  34315. }
  34316. /**
  34317. * This defines an action helpful to stop a defined sound on a triggered action.
  34318. */
  34319. export class StopSoundAction extends Action {
  34320. private _sound;
  34321. /**
  34322. * Instantiate the action
  34323. * @param triggerOptions defines the trigger options
  34324. * @param sound defines the sound to stop
  34325. * @param condition defines the trigger related conditions
  34326. */
  34327. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34328. /** @hidden */ private _prepare(): void;
  34329. /**
  34330. * Execute the action and stop the sound.
  34331. */
  34332. execute(): void;
  34333. /**
  34334. * Serializes the actions and its related information.
  34335. * @param parent defines the object to serialize in
  34336. * @returns the serialized object
  34337. */
  34338. serialize(parent: any): any;
  34339. }
  34340. }
  34341. declare module BABYLON {
  34342. /**
  34343. * This defines an action responsible to change the value of a property
  34344. * by interpolating between its current value and the newly set one once triggered.
  34345. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34346. */
  34347. export class InterpolateValueAction extends Action {
  34348. /**
  34349. * Defines the path of the property where the value should be interpolated
  34350. */
  34351. propertyPath: string;
  34352. /**
  34353. * Defines the target value at the end of the interpolation.
  34354. */
  34355. value: any;
  34356. /**
  34357. * Defines the time it will take for the property to interpolate to the value.
  34358. */
  34359. duration: number;
  34360. /**
  34361. * Defines if the other scene animations should be stopped when the action has been triggered
  34362. */
  34363. stopOtherAnimations?: boolean;
  34364. /**
  34365. * Defines a callback raised once the interpolation animation has been done.
  34366. */
  34367. onInterpolationDone?: () => void;
  34368. /**
  34369. * Observable triggered once the interpolation animation has been done.
  34370. */
  34371. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34372. private _target;
  34373. private _effectiveTarget;
  34374. private _property;
  34375. /**
  34376. * Instantiate the action
  34377. * @param triggerOptions defines the trigger options
  34378. * @param target defines the object containing the value to interpolate
  34379. * @param propertyPath defines the path to the property in the target object
  34380. * @param value defines the target value at the end of the interpolation
  34381. * @param duration deines the time it will take for the property to interpolate to the value.
  34382. * @param condition defines the trigger related conditions
  34383. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34384. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34385. */
  34386. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34387. /** @hidden */ private _prepare(): void;
  34388. /**
  34389. * Execute the action starts the value interpolation.
  34390. */
  34391. execute(): void;
  34392. /**
  34393. * Serializes the actions and its related information.
  34394. * @param parent defines the object to serialize in
  34395. * @returns the serialized object
  34396. */
  34397. serialize(parent: any): any;
  34398. }
  34399. }
  34400. declare module BABYLON {
  34401. /**
  34402. * Options allowed during the creation of a sound track.
  34403. */
  34404. export interface ISoundTrackOptions {
  34405. /**
  34406. * The volume the sound track should take during creation
  34407. */
  34408. volume?: number;
  34409. /**
  34410. * Define if the sound track is the main sound track of the scene
  34411. */
  34412. mainTrack?: boolean;
  34413. }
  34414. /**
  34415. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34416. * It will be also used in a future release to apply effects on a specific track.
  34417. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34418. */
  34419. export class SoundTrack {
  34420. /**
  34421. * The unique identifier of the sound track in the scene.
  34422. */
  34423. id: number;
  34424. /**
  34425. * The list of sounds included in the sound track.
  34426. */
  34427. soundCollection: Array<Sound>;
  34428. private _outputAudioNode;
  34429. private _scene;
  34430. private _isMainTrack;
  34431. private _connectedAnalyser;
  34432. private _options;
  34433. private _isInitialized;
  34434. /**
  34435. * Creates a new sound track.
  34436. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34437. * @param scene Define the scene the sound track belongs to
  34438. * @param options
  34439. */
  34440. constructor(scene: Scene, options?: ISoundTrackOptions);
  34441. private _initializeSoundTrackAudioGraph;
  34442. /**
  34443. * Release the sound track and its associated resources
  34444. */
  34445. dispose(): void;
  34446. /**
  34447. * Adds a sound to this sound track
  34448. * @param sound define the cound to add
  34449. * @ignoreNaming
  34450. */
  34451. AddSound(sound: Sound): void;
  34452. /**
  34453. * Removes a sound to this sound track
  34454. * @param sound define the cound to remove
  34455. * @ignoreNaming
  34456. */
  34457. RemoveSound(sound: Sound): void;
  34458. /**
  34459. * Set a global volume for the full sound track.
  34460. * @param newVolume Define the new volume of the sound track
  34461. */
  34462. setVolume(newVolume: number): void;
  34463. /**
  34464. * Switch the panning model to HRTF:
  34465. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34466. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34467. */
  34468. switchPanningModelToHRTF(): void;
  34469. /**
  34470. * Switch the panning model to Equal Power:
  34471. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34472. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34473. */
  34474. switchPanningModelToEqualPower(): void;
  34475. /**
  34476. * Connect the sound track to an audio analyser allowing some amazing
  34477. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34478. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34479. * @param analyser The analyser to connect to the engine
  34480. */
  34481. connectToAnalyser(analyser: Analyser): void;
  34482. }
  34483. }
  34484. declare module BABYLON {
  34485. interface AbstractScene {
  34486. /**
  34487. * The list of sounds used in the scene.
  34488. */
  34489. sounds: Nullable<Array<Sound>>;
  34490. }
  34491. interface Scene {
  34492. /**
  34493. * @hidden
  34494. * Backing field
  34495. */ private _mainSoundTrack: SoundTrack;
  34496. /**
  34497. * The main sound track played by the scene.
  34498. * It cotains your primary collection of sounds.
  34499. */
  34500. mainSoundTrack: SoundTrack;
  34501. /**
  34502. * The list of sound tracks added to the scene
  34503. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34504. */
  34505. soundTracks: Nullable<Array<SoundTrack>>;
  34506. /**
  34507. * Gets a sound using a given name
  34508. * @param name defines the name to search for
  34509. * @return the found sound or null if not found at all.
  34510. */
  34511. getSoundByName(name: string): Nullable<Sound>;
  34512. /**
  34513. * Gets or sets if audio support is enabled
  34514. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34515. */
  34516. audioEnabled: boolean;
  34517. /**
  34518. * Gets or sets if audio will be output to headphones
  34519. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34520. */
  34521. headphone: boolean;
  34522. /**
  34523. * Gets or sets custom audio listener position provider
  34524. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34525. */
  34526. audioListenerPositionProvider: Nullable<() => Vector3>;
  34527. }
  34528. /**
  34529. * Defines the sound scene component responsible to manage any sounds
  34530. * in a given scene.
  34531. */
  34532. export class AudioSceneComponent implements ISceneSerializableComponent {
  34533. /**
  34534. * The component name helpfull to identify the component in the list of scene components.
  34535. */
  34536. readonly name: string;
  34537. /**
  34538. * The scene the component belongs to.
  34539. */
  34540. scene: Scene;
  34541. private _audioEnabled;
  34542. /**
  34543. * Gets whether audio is enabled or not.
  34544. * Please use related enable/disable method to switch state.
  34545. */
  34546. readonly audioEnabled: boolean;
  34547. private _headphone;
  34548. /**
  34549. * Gets whether audio is outputing to headphone or not.
  34550. * Please use the according Switch methods to change output.
  34551. */
  34552. readonly headphone: boolean;
  34553. private _audioListenerPositionProvider;
  34554. /**
  34555. * Gets the current audio listener position provider
  34556. */
  34557. /**
  34558. * Sets a custom listener position for all sounds in the scene
  34559. * By default, this is the position of the first active camera
  34560. */
  34561. audioListenerPositionProvider: Nullable<() => Vector3>;
  34562. /**
  34563. * Creates a new instance of the component for the given scene
  34564. * @param scene Defines the scene to register the component in
  34565. */
  34566. constructor(scene: Scene);
  34567. /**
  34568. * Registers the component in a given scene
  34569. */
  34570. register(): void;
  34571. /**
  34572. * Rebuilds the elements related to this component in case of
  34573. * context lost for instance.
  34574. */
  34575. rebuild(): void;
  34576. /**
  34577. * Serializes the component data to the specified json object
  34578. * @param serializationObject The object to serialize to
  34579. */
  34580. serialize(serializationObject: any): void;
  34581. /**
  34582. * Adds all the elements from the container to the scene
  34583. * @param container the container holding the elements
  34584. */
  34585. addFromContainer(container: AbstractScene): void;
  34586. /**
  34587. * Removes all the elements in the container from the scene
  34588. * @param container contains the elements to remove
  34589. * @param dispose if the removed element should be disposed (default: false)
  34590. */
  34591. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34592. /**
  34593. * Disposes the component and the associated ressources.
  34594. */
  34595. dispose(): void;
  34596. /**
  34597. * Disables audio in the associated scene.
  34598. */
  34599. disableAudio(): void;
  34600. /**
  34601. * Enables audio in the associated scene.
  34602. */
  34603. enableAudio(): void;
  34604. /**
  34605. * Switch audio to headphone output.
  34606. */
  34607. switchAudioModeForHeadphones(): void;
  34608. /**
  34609. * Switch audio to normal speakers.
  34610. */
  34611. switchAudioModeForNormalSpeakers(): void;
  34612. private _afterRender;
  34613. }
  34614. }
  34615. declare module BABYLON {
  34616. /**
  34617. * Wraps one or more Sound objects and selects one with random weight for playback.
  34618. */
  34619. export class WeightedSound {
  34620. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34621. loop: boolean;
  34622. private _coneInnerAngle;
  34623. private _coneOuterAngle;
  34624. private _volume;
  34625. /** A Sound is currently playing. */
  34626. isPlaying: boolean;
  34627. /** A Sound is currently paused. */
  34628. isPaused: boolean;
  34629. private _sounds;
  34630. private _weights;
  34631. private _currentIndex?;
  34632. /**
  34633. * Creates a new WeightedSound from the list of sounds given.
  34634. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34635. * @param sounds Array of Sounds that will be selected from.
  34636. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34637. */
  34638. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34639. /**
  34640. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34641. */
  34642. /**
  34643. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34644. */
  34645. directionalConeInnerAngle: number;
  34646. /**
  34647. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34648. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34649. */
  34650. /**
  34651. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34652. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34653. */
  34654. directionalConeOuterAngle: number;
  34655. /**
  34656. * Playback volume.
  34657. */
  34658. /**
  34659. * Playback volume.
  34660. */
  34661. volume: number;
  34662. private _onended;
  34663. /**
  34664. * Suspend playback
  34665. */
  34666. pause(): void;
  34667. /**
  34668. * Stop playback
  34669. */
  34670. stop(): void;
  34671. /**
  34672. * Start playback.
  34673. * @param startOffset Position the clip head at a specific time in seconds.
  34674. */
  34675. play(startOffset?: number): void;
  34676. }
  34677. }
  34678. declare module BABYLON {
  34679. /**
  34680. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34681. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34682. */
  34683. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34684. /**
  34685. * Gets the name of the behavior.
  34686. */
  34687. readonly name: string;
  34688. /**
  34689. * The easing function used by animations
  34690. */
  34691. static EasingFunction: BackEase;
  34692. /**
  34693. * The easing mode used by animations
  34694. */
  34695. static EasingMode: number;
  34696. /**
  34697. * The duration of the animation, in milliseconds
  34698. */
  34699. transitionDuration: number;
  34700. /**
  34701. * Length of the distance animated by the transition when lower radius is reached
  34702. */
  34703. lowerRadiusTransitionRange: number;
  34704. /**
  34705. * Length of the distance animated by the transition when upper radius is reached
  34706. */
  34707. upperRadiusTransitionRange: number;
  34708. private _autoTransitionRange;
  34709. /**
  34710. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34711. */
  34712. /**
  34713. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34714. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34715. */
  34716. autoTransitionRange: boolean;
  34717. private _attachedCamera;
  34718. private _onAfterCheckInputsObserver;
  34719. private _onMeshTargetChangedObserver;
  34720. /**
  34721. * Initializes the behavior.
  34722. */
  34723. init(): void;
  34724. /**
  34725. * Attaches the behavior to its arc rotate camera.
  34726. * @param camera Defines the camera to attach the behavior to
  34727. */
  34728. attach(camera: ArcRotateCamera): void;
  34729. /**
  34730. * Detaches the behavior from its current arc rotate camera.
  34731. */
  34732. detach(): void;
  34733. private _radiusIsAnimating;
  34734. private _radiusBounceTransition;
  34735. private _animatables;
  34736. private _cachedWheelPrecision;
  34737. /**
  34738. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34739. * @param radiusLimit The limit to check against.
  34740. * @return Bool to indicate if at limit.
  34741. */
  34742. private _isRadiusAtLimit;
  34743. /**
  34744. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34745. * @param radiusDelta The delta by which to animate to. Can be negative.
  34746. */
  34747. private _applyBoundRadiusAnimation;
  34748. /**
  34749. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34750. */
  34751. protected _clearAnimationLocks(): void;
  34752. /**
  34753. * Stops and removes all animations that have been applied to the camera
  34754. */
  34755. stopAllAnimations(): void;
  34756. }
  34757. }
  34758. declare module BABYLON {
  34759. /**
  34760. * 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.
  34761. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34762. */
  34763. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34764. /**
  34765. * Gets the name of the behavior.
  34766. */
  34767. readonly name: string;
  34768. private _mode;
  34769. private _radiusScale;
  34770. private _positionScale;
  34771. private _defaultElevation;
  34772. private _elevationReturnTime;
  34773. private _elevationReturnWaitTime;
  34774. private _zoomStopsAnimation;
  34775. private _framingTime;
  34776. /**
  34777. * The easing function used by animations
  34778. */
  34779. static EasingFunction: ExponentialEase;
  34780. /**
  34781. * The easing mode used by animations
  34782. */
  34783. static EasingMode: number;
  34784. /**
  34785. * Sets the current mode used by the behavior
  34786. */
  34787. /**
  34788. * Gets current mode used by the behavior.
  34789. */
  34790. mode: number;
  34791. /**
  34792. * Sets the scale applied to the radius (1 by default)
  34793. */
  34794. /**
  34795. * Gets the scale applied to the radius
  34796. */
  34797. radiusScale: number;
  34798. /**
  34799. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34800. */
  34801. /**
  34802. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34803. */
  34804. positionScale: number;
  34805. /**
  34806. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34807. * behaviour is triggered, in radians.
  34808. */
  34809. /**
  34810. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34811. * behaviour is triggered, in radians.
  34812. */
  34813. defaultElevation: number;
  34814. /**
  34815. * Sets the time (in milliseconds) taken to return to the default beta position.
  34816. * Negative value indicates camera should not return to default.
  34817. */
  34818. /**
  34819. * Gets the time (in milliseconds) taken to return to the default beta position.
  34820. * Negative value indicates camera should not return to default.
  34821. */
  34822. elevationReturnTime: number;
  34823. /**
  34824. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34825. */
  34826. /**
  34827. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34828. */
  34829. elevationReturnWaitTime: number;
  34830. /**
  34831. * Sets the flag that indicates if user zooming should stop animation.
  34832. */
  34833. /**
  34834. * Gets the flag that indicates if user zooming should stop animation.
  34835. */
  34836. zoomStopsAnimation: boolean;
  34837. /**
  34838. * Sets the transition time when framing the mesh, in milliseconds
  34839. */
  34840. /**
  34841. * Gets the transition time when framing the mesh, in milliseconds
  34842. */
  34843. framingTime: number;
  34844. /**
  34845. * Define if the behavior should automatically change the configured
  34846. * camera limits and sensibilities.
  34847. */
  34848. autoCorrectCameraLimitsAndSensibility: boolean;
  34849. private _onPrePointerObservableObserver;
  34850. private _onAfterCheckInputsObserver;
  34851. private _onMeshTargetChangedObserver;
  34852. private _attachedCamera;
  34853. private _isPointerDown;
  34854. private _lastInteractionTime;
  34855. /**
  34856. * Initializes the behavior.
  34857. */
  34858. init(): void;
  34859. /**
  34860. * Attaches the behavior to its arc rotate camera.
  34861. * @param camera Defines the camera to attach the behavior to
  34862. */
  34863. attach(camera: ArcRotateCamera): void;
  34864. /**
  34865. * Detaches the behavior from its current arc rotate camera.
  34866. */
  34867. detach(): void;
  34868. private _animatables;
  34869. private _betaIsAnimating;
  34870. private _betaTransition;
  34871. private _radiusTransition;
  34872. private _vectorTransition;
  34873. /**
  34874. * Targets the given mesh and updates zoom level accordingly.
  34875. * @param mesh The mesh to target.
  34876. * @param radius Optional. If a cached radius position already exists, overrides default.
  34877. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34878. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34879. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34880. */
  34881. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34882. /**
  34883. * Targets the given mesh with its children and updates zoom level accordingly.
  34884. * @param mesh The mesh to target.
  34885. * @param radius Optional. If a cached radius position already exists, overrides default.
  34886. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34887. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34888. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34889. */
  34890. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34891. /**
  34892. * Targets the given meshes with their children and updates zoom level accordingly.
  34893. * @param meshes The mesh to target.
  34894. * @param radius Optional. If a cached radius position already exists, overrides default.
  34895. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34896. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34897. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34898. */
  34899. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34900. /**
  34901. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34902. * @param minimumWorld Determines the smaller position of the bounding box extend
  34903. * @param maximumWorld Determines the bigger position of the bounding box extend
  34904. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34905. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34906. */
  34907. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34908. /**
  34909. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34910. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34911. * frustum width.
  34912. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34913. * to fully enclose the mesh in the viewing frustum.
  34914. */
  34915. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34916. /**
  34917. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34918. * is automatically returned to its default position (expected to be above ground plane).
  34919. */
  34920. private _maintainCameraAboveGround;
  34921. /**
  34922. * Returns the frustum slope based on the canvas ratio and camera FOV
  34923. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34924. */
  34925. private _getFrustumSlope;
  34926. /**
  34927. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34928. */
  34929. private _clearAnimationLocks;
  34930. /**
  34931. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34932. */
  34933. private _applyUserInteraction;
  34934. /**
  34935. * Stops and removes all animations that have been applied to the camera
  34936. */
  34937. stopAllAnimations(): void;
  34938. /**
  34939. * Gets a value indicating if the user is moving the camera
  34940. */
  34941. readonly isUserIsMoving: boolean;
  34942. /**
  34943. * The camera can move all the way towards the mesh.
  34944. */
  34945. static IgnoreBoundsSizeMode: number;
  34946. /**
  34947. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34948. */
  34949. static FitFrustumSidesMode: number;
  34950. }
  34951. }
  34952. declare module BABYLON {
  34953. /**
  34954. * Base class for Camera Pointer Inputs.
  34955. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34956. * for example usage.
  34957. */
  34958. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34959. /**
  34960. * Defines the camera the input is attached to.
  34961. */
  34962. abstract camera: Camera;
  34963. /**
  34964. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34965. */
  34966. protected _altKey: boolean;
  34967. protected _ctrlKey: boolean;
  34968. protected _metaKey: boolean;
  34969. protected _shiftKey: boolean;
  34970. /**
  34971. * Which mouse buttons were pressed at time of last mouse event.
  34972. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34973. */
  34974. protected _buttonsPressed: number;
  34975. /**
  34976. * Defines the buttons associated with the input to handle camera move.
  34977. */
  34978. buttons: number[];
  34979. /**
  34980. * Attach the input controls to a specific dom element to get the input from.
  34981. * @param element Defines the element the controls should be listened from
  34982. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34983. */
  34984. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34985. /**
  34986. * Detach the current controls from the specified dom element.
  34987. * @param element Defines the element to stop listening the inputs from
  34988. */
  34989. detachControl(element: Nullable<HTMLElement>): void;
  34990. /**
  34991. * Gets the class name of the current input.
  34992. * @returns the class name
  34993. */
  34994. getClassName(): string;
  34995. /**
  34996. * Get the friendly name associated with the input class.
  34997. * @returns the input friendly name
  34998. */
  34999. getSimpleName(): string;
  35000. /**
  35001. * Called on pointer POINTERDOUBLETAP event.
  35002. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35003. */
  35004. protected onDoubleTap(type: string): void;
  35005. /**
  35006. * Called on pointer POINTERMOVE event if only a single touch is active.
  35007. * Override this method to provide functionality.
  35008. */
  35009. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35010. /**
  35011. * Called on pointer POINTERMOVE event if multiple touches are active.
  35012. * Override this method to provide functionality.
  35013. */
  35014. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35015. /**
  35016. * Called on JS contextmenu event.
  35017. * Override this method to provide functionality.
  35018. */
  35019. protected onContextMenu(evt: PointerEvent): void;
  35020. /**
  35021. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35022. * press.
  35023. * Override this method to provide functionality.
  35024. */
  35025. protected onButtonDown(evt: PointerEvent): void;
  35026. /**
  35027. * Called each time a new POINTERUP event occurs. Ie, for each button
  35028. * release.
  35029. * Override this method to provide functionality.
  35030. */
  35031. protected onButtonUp(evt: PointerEvent): void;
  35032. /**
  35033. * Called when window becomes inactive.
  35034. * Override this method to provide functionality.
  35035. */
  35036. protected onLostFocus(): void;
  35037. private _pointerInput;
  35038. private _observer;
  35039. private _onLostFocus;
  35040. private pointA;
  35041. private pointB;
  35042. }
  35043. }
  35044. declare module BABYLON {
  35045. /**
  35046. * Manage the pointers inputs to control an arc rotate camera.
  35047. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35048. */
  35049. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35050. /**
  35051. * Defines the camera the input is attached to.
  35052. */
  35053. camera: ArcRotateCamera;
  35054. /**
  35055. * Gets the class name of the current input.
  35056. * @returns the class name
  35057. */
  35058. getClassName(): string;
  35059. /**
  35060. * Defines the buttons associated with the input to handle camera move.
  35061. */
  35062. buttons: number[];
  35063. /**
  35064. * Defines the pointer angular sensibility along the X axis or how fast is
  35065. * the camera rotating.
  35066. */
  35067. angularSensibilityX: number;
  35068. /**
  35069. * Defines the pointer angular sensibility along the Y axis or how fast is
  35070. * the camera rotating.
  35071. */
  35072. angularSensibilityY: number;
  35073. /**
  35074. * Defines the pointer pinch precision or how fast is the camera zooming.
  35075. */
  35076. pinchPrecision: number;
  35077. /**
  35078. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35079. * from 0.
  35080. * It defines the percentage of current camera.radius to use as delta when
  35081. * pinch zoom is used.
  35082. */
  35083. pinchDeltaPercentage: number;
  35084. /**
  35085. * Defines the pointer panning sensibility or how fast is the camera moving.
  35086. */
  35087. panningSensibility: number;
  35088. /**
  35089. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35090. */
  35091. multiTouchPanning: boolean;
  35092. /**
  35093. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35094. * zoom (pinch) through multitouch.
  35095. */
  35096. multiTouchPanAndZoom: boolean;
  35097. /**
  35098. * Revers pinch action direction.
  35099. */
  35100. pinchInwards: boolean;
  35101. private _isPanClick;
  35102. private _twoFingerActivityCount;
  35103. private _isPinching;
  35104. /**
  35105. * Called on pointer POINTERMOVE event if only a single touch is active.
  35106. */
  35107. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35108. /**
  35109. * Called on pointer POINTERDOUBLETAP event.
  35110. */
  35111. protected onDoubleTap(type: string): void;
  35112. /**
  35113. * Called on pointer POINTERMOVE event if multiple touches are active.
  35114. */
  35115. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35116. /**
  35117. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35118. * press.
  35119. */
  35120. protected onButtonDown(evt: PointerEvent): void;
  35121. /**
  35122. * Called each time a new POINTERUP event occurs. Ie, for each button
  35123. * release.
  35124. */
  35125. protected onButtonUp(evt: PointerEvent): void;
  35126. /**
  35127. * Called when window becomes inactive.
  35128. */
  35129. protected onLostFocus(): void;
  35130. }
  35131. }
  35132. declare module BABYLON {
  35133. /**
  35134. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35135. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35136. */
  35137. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35138. /**
  35139. * Defines the camera the input is attached to.
  35140. */
  35141. camera: ArcRotateCamera;
  35142. /**
  35143. * Defines the list of key codes associated with the up action (increase alpha)
  35144. */
  35145. keysUp: number[];
  35146. /**
  35147. * Defines the list of key codes associated with the down action (decrease alpha)
  35148. */
  35149. keysDown: number[];
  35150. /**
  35151. * Defines the list of key codes associated with the left action (increase beta)
  35152. */
  35153. keysLeft: number[];
  35154. /**
  35155. * Defines the list of key codes associated with the right action (decrease beta)
  35156. */
  35157. keysRight: number[];
  35158. /**
  35159. * Defines the list of key codes associated with the reset action.
  35160. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35161. */
  35162. keysReset: number[];
  35163. /**
  35164. * Defines the panning sensibility of the inputs.
  35165. * (How fast is the camera paning)
  35166. */
  35167. panningSensibility: number;
  35168. /**
  35169. * Defines the zooming sensibility of the inputs.
  35170. * (How fast is the camera zooming)
  35171. */
  35172. zoomingSensibility: number;
  35173. /**
  35174. * Defines wether maintaining the alt key down switch the movement mode from
  35175. * orientation to zoom.
  35176. */
  35177. useAltToZoom: boolean;
  35178. /**
  35179. * Rotation speed of the camera
  35180. */
  35181. angularSpeed: number;
  35182. private _keys;
  35183. private _ctrlPressed;
  35184. private _altPressed;
  35185. private _onCanvasBlurObserver;
  35186. private _onKeyboardObserver;
  35187. private _engine;
  35188. private _scene;
  35189. /**
  35190. * Attach the input controls to a specific dom element to get the input from.
  35191. * @param element Defines the element the controls should be listened from
  35192. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35193. */
  35194. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35195. /**
  35196. * Detach the current controls from the specified dom element.
  35197. * @param element Defines the element to stop listening the inputs from
  35198. */
  35199. detachControl(element: Nullable<HTMLElement>): void;
  35200. /**
  35201. * Update the current camera state depending on the inputs that have been used this frame.
  35202. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35203. */
  35204. checkInputs(): void;
  35205. /**
  35206. * Gets the class name of the current intput.
  35207. * @returns the class name
  35208. */
  35209. getClassName(): string;
  35210. /**
  35211. * Get the friendly name associated with the input class.
  35212. * @returns the input friendly name
  35213. */
  35214. getSimpleName(): string;
  35215. }
  35216. }
  35217. declare module BABYLON {
  35218. /**
  35219. * Manage the mouse wheel inputs to control an arc rotate camera.
  35220. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35221. */
  35222. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35223. /**
  35224. * Defines the camera the input is attached to.
  35225. */
  35226. camera: ArcRotateCamera;
  35227. /**
  35228. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35229. */
  35230. wheelPrecision: number;
  35231. /**
  35232. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35233. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35234. */
  35235. wheelDeltaPercentage: number;
  35236. private _wheel;
  35237. private _observer;
  35238. private computeDeltaFromMouseWheelLegacyEvent;
  35239. /**
  35240. * Attach the input controls to a specific dom element to get the input from.
  35241. * @param element Defines the element the controls should be listened from
  35242. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35243. */
  35244. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35245. /**
  35246. * Detach the current controls from the specified dom element.
  35247. * @param element Defines the element to stop listening the inputs from
  35248. */
  35249. detachControl(element: Nullable<HTMLElement>): void;
  35250. /**
  35251. * Gets the class name of the current intput.
  35252. * @returns the class name
  35253. */
  35254. getClassName(): string;
  35255. /**
  35256. * Get the friendly name associated with the input class.
  35257. * @returns the input friendly name
  35258. */
  35259. getSimpleName(): string;
  35260. }
  35261. }
  35262. declare module BABYLON {
  35263. /**
  35264. * Default Inputs manager for the ArcRotateCamera.
  35265. * It groups all the default supported inputs for ease of use.
  35266. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35267. */
  35268. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35269. /**
  35270. * Instantiates a new ArcRotateCameraInputsManager.
  35271. * @param camera Defines the camera the inputs belong to
  35272. */
  35273. constructor(camera: ArcRotateCamera);
  35274. /**
  35275. * Add mouse wheel input support to the input manager.
  35276. * @returns the current input manager
  35277. */
  35278. addMouseWheel(): ArcRotateCameraInputsManager;
  35279. /**
  35280. * Add pointers input support to the input manager.
  35281. * @returns the current input manager
  35282. */
  35283. addPointers(): ArcRotateCameraInputsManager;
  35284. /**
  35285. * Add keyboard input support to the input manager.
  35286. * @returns the current input manager
  35287. */
  35288. addKeyboard(): ArcRotateCameraInputsManager;
  35289. }
  35290. }
  35291. declare module BABYLON {
  35292. /**
  35293. * This represents an orbital type of camera.
  35294. *
  35295. * 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.
  35296. * 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.
  35297. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35298. */
  35299. export class ArcRotateCamera extends TargetCamera {
  35300. /**
  35301. * Defines the rotation angle of the camera along the longitudinal axis.
  35302. */
  35303. alpha: number;
  35304. /**
  35305. * Defines the rotation angle of the camera along the latitudinal axis.
  35306. */
  35307. beta: number;
  35308. /**
  35309. * Defines the radius of the camera from it s target point.
  35310. */
  35311. radius: number;
  35312. protected _target: Vector3;
  35313. protected _targetHost: Nullable<AbstractMesh>;
  35314. /**
  35315. * Defines the target point of the camera.
  35316. * The camera looks towards it form the radius distance.
  35317. */
  35318. target: Vector3;
  35319. /**
  35320. * Define the current local position of the camera in the scene
  35321. */
  35322. position: Vector3;
  35323. protected _upVector: Vector3;
  35324. protected _upToYMatrix: Matrix;
  35325. protected _YToUpMatrix: Matrix;
  35326. /**
  35327. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35328. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35329. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35330. */
  35331. upVector: Vector3;
  35332. /**
  35333. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35334. */
  35335. setMatUp(): void;
  35336. /**
  35337. * Current inertia value on the longitudinal axis.
  35338. * The bigger this number the longer it will take for the camera to stop.
  35339. */
  35340. inertialAlphaOffset: number;
  35341. /**
  35342. * Current inertia value on the latitudinal axis.
  35343. * The bigger this number the longer it will take for the camera to stop.
  35344. */
  35345. inertialBetaOffset: number;
  35346. /**
  35347. * Current inertia value on the radius axis.
  35348. * The bigger this number the longer it will take for the camera to stop.
  35349. */
  35350. inertialRadiusOffset: number;
  35351. /**
  35352. * Minimum allowed angle on the longitudinal axis.
  35353. * This can help limiting how the Camera is able to move in the scene.
  35354. */
  35355. lowerAlphaLimit: Nullable<number>;
  35356. /**
  35357. * Maximum allowed angle on the longitudinal axis.
  35358. * This can help limiting how the Camera is able to move in the scene.
  35359. */
  35360. upperAlphaLimit: Nullable<number>;
  35361. /**
  35362. * Minimum allowed angle on the latitudinal axis.
  35363. * This can help limiting how the Camera is able to move in the scene.
  35364. */
  35365. lowerBetaLimit: number;
  35366. /**
  35367. * Maximum allowed angle on the latitudinal axis.
  35368. * This can help limiting how the Camera is able to move in the scene.
  35369. */
  35370. upperBetaLimit: number;
  35371. /**
  35372. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35373. * This can help limiting how the Camera is able to move in the scene.
  35374. */
  35375. lowerRadiusLimit: Nullable<number>;
  35376. /**
  35377. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35378. * This can help limiting how the Camera is able to move in the scene.
  35379. */
  35380. upperRadiusLimit: Nullable<number>;
  35381. /**
  35382. * Defines the current inertia value used during panning of the camera along the X axis.
  35383. */
  35384. inertialPanningX: number;
  35385. /**
  35386. * Defines the current inertia value used during panning of the camera along the Y axis.
  35387. */
  35388. inertialPanningY: number;
  35389. /**
  35390. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35391. * Basically if your fingers moves away from more than this distance you will be considered
  35392. * in pinch mode.
  35393. */
  35394. pinchToPanMaxDistance: number;
  35395. /**
  35396. * Defines the maximum distance the camera can pan.
  35397. * This could help keeping the cammera always in your scene.
  35398. */
  35399. panningDistanceLimit: Nullable<number>;
  35400. /**
  35401. * Defines the target of the camera before paning.
  35402. */
  35403. panningOriginTarget: Vector3;
  35404. /**
  35405. * Defines the value of the inertia used during panning.
  35406. * 0 would mean stop inertia and one would mean no decelleration at all.
  35407. */
  35408. panningInertia: number;
  35409. /**
  35410. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35411. */
  35412. angularSensibilityX: number;
  35413. /**
  35414. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35415. */
  35416. angularSensibilityY: number;
  35417. /**
  35418. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35419. */
  35420. pinchPrecision: number;
  35421. /**
  35422. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35423. * It will be used instead of pinchDeltaPrecision if different from 0.
  35424. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35425. */
  35426. pinchDeltaPercentage: number;
  35427. /**
  35428. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35429. */
  35430. panningSensibility: number;
  35431. /**
  35432. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35433. */
  35434. keysUp: number[];
  35435. /**
  35436. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35437. */
  35438. keysDown: number[];
  35439. /**
  35440. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35441. */
  35442. keysLeft: number[];
  35443. /**
  35444. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35445. */
  35446. keysRight: number[];
  35447. /**
  35448. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35449. */
  35450. wheelPrecision: number;
  35451. /**
  35452. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35453. * It will be used instead of pinchDeltaPrecision if different from 0.
  35454. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35455. */
  35456. wheelDeltaPercentage: number;
  35457. /**
  35458. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35459. */
  35460. zoomOnFactor: number;
  35461. /**
  35462. * Defines a screen offset for the camera position.
  35463. */
  35464. targetScreenOffset: Vector2;
  35465. /**
  35466. * Allows the camera to be completely reversed.
  35467. * If false the camera can not arrive upside down.
  35468. */
  35469. allowUpsideDown: boolean;
  35470. /**
  35471. * Define if double tap/click is used to restore the previously saved state of the camera.
  35472. */
  35473. useInputToRestoreState: boolean;
  35474. /** @hidden */ private _viewMatrix: Matrix;
  35475. /** @hidden */ private _useCtrlForPanning: boolean;
  35476. /** @hidden */ private _panningMouseButton: number;
  35477. /**
  35478. * Defines the input associated to the camera.
  35479. */
  35480. inputs: ArcRotateCameraInputsManager;
  35481. /** @hidden */ private _reset: () => void;
  35482. /**
  35483. * Defines the allowed panning axis.
  35484. */
  35485. panningAxis: Vector3;
  35486. protected _localDirection: Vector3;
  35487. protected _transformedDirection: Vector3;
  35488. private _bouncingBehavior;
  35489. /**
  35490. * Gets the bouncing behavior of the camera if it has been enabled.
  35491. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35492. */
  35493. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35494. /**
  35495. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35496. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35497. */
  35498. useBouncingBehavior: boolean;
  35499. private _framingBehavior;
  35500. /**
  35501. * Gets the framing behavior of the camera if it has been enabled.
  35502. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35503. */
  35504. readonly framingBehavior: Nullable<FramingBehavior>;
  35505. /**
  35506. * Defines if the framing behavior of the camera is enabled on the camera.
  35507. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35508. */
  35509. useFramingBehavior: boolean;
  35510. private _autoRotationBehavior;
  35511. /**
  35512. * Gets the auto rotation behavior of the camera if it has been enabled.
  35513. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35514. */
  35515. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35516. /**
  35517. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35518. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35519. */
  35520. useAutoRotationBehavior: boolean;
  35521. /**
  35522. * Observable triggered when the mesh target has been changed on the camera.
  35523. */
  35524. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35525. /**
  35526. * Event raised when the camera is colliding with a mesh.
  35527. */
  35528. onCollide: (collidedMesh: AbstractMesh) => void;
  35529. /**
  35530. * Defines whether the camera should check collision with the objects oh the scene.
  35531. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35532. */
  35533. checkCollisions: boolean;
  35534. /**
  35535. * Defines the collision radius of the camera.
  35536. * This simulates a sphere around the camera.
  35537. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35538. */
  35539. collisionRadius: Vector3;
  35540. protected _collider: Collider;
  35541. protected _previousPosition: Vector3;
  35542. protected _collisionVelocity: Vector3;
  35543. protected _newPosition: Vector3;
  35544. protected _previousAlpha: number;
  35545. protected _previousBeta: number;
  35546. protected _previousRadius: number;
  35547. protected _collisionTriggered: boolean;
  35548. protected _targetBoundingCenter: Nullable<Vector3>;
  35549. private _computationVector;
  35550. /**
  35551. * Instantiates a new ArcRotateCamera in a given scene
  35552. * @param name Defines the name of the camera
  35553. * @param alpha Defines the camera rotation along the logitudinal axis
  35554. * @param beta Defines the camera rotation along the latitudinal axis
  35555. * @param radius Defines the camera distance from its target
  35556. * @param target Defines the camera target
  35557. * @param scene Defines the scene the camera belongs to
  35558. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35559. */
  35560. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35561. /** @hidden */ private _initCache(): void;
  35562. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  35563. protected _getTargetPosition(): Vector3;
  35564. private _storedAlpha;
  35565. private _storedBeta;
  35566. private _storedRadius;
  35567. private _storedTarget;
  35568. /**
  35569. * Stores the current state of the camera (alpha, beta, radius and target)
  35570. * @returns the camera itself
  35571. */
  35572. storeState(): Camera;
  35573. /**
  35574. * @hidden
  35575. * Restored camera state. You must call storeState() first
  35576. */ private _restoreStateValues(): boolean;
  35577. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  35578. /**
  35579. * Attached controls to the current camera.
  35580. * @param element Defines the element the controls should be listened from
  35581. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35582. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35583. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35584. */
  35585. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35586. /**
  35587. * Detach the current controls from the camera.
  35588. * The camera will stop reacting to inputs.
  35589. * @param element Defines the element to stop listening the inputs from
  35590. */
  35591. detachControl(element: HTMLElement): void;
  35592. /** @hidden */ private _checkInputs(): void;
  35593. protected _checkLimits(): void;
  35594. /**
  35595. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35596. */
  35597. rebuildAnglesAndRadius(): void;
  35598. /**
  35599. * Use a position to define the current camera related information like aplha, beta and radius
  35600. * @param position Defines the position to set the camera at
  35601. */
  35602. setPosition(position: Vector3): void;
  35603. /**
  35604. * Defines the target the camera should look at.
  35605. * This will automatically adapt alpha beta and radius to fit within the new target.
  35606. * @param target Defines the new target as a Vector or a mesh
  35607. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35608. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35609. */
  35610. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35611. /** @hidden */ private _getViewMatrix(): Matrix;
  35612. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35613. /**
  35614. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35615. * @param meshes Defines the mesh to zoom on
  35616. * @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)
  35617. */
  35618. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35619. /**
  35620. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35621. * The target will be changed but the radius
  35622. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35623. * @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)
  35624. */
  35625. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35626. min: Vector3;
  35627. max: Vector3;
  35628. distance: number;
  35629. }, doNotUpdateMaxZ?: boolean): void;
  35630. /**
  35631. * @override
  35632. * Override Camera.createRigCamera
  35633. */
  35634. createRigCamera(name: string, cameraIndex: number): Camera;
  35635. /**
  35636. * @hidden
  35637. * @override
  35638. * Override Camera._updateRigCameras
  35639. */ private _updateRigCameras(): void;
  35640. /**
  35641. * Destroy the camera and release the current resources hold by it.
  35642. */
  35643. dispose(): void;
  35644. /**
  35645. * Gets the current object class name.
  35646. * @return the class name
  35647. */
  35648. getClassName(): string;
  35649. }
  35650. }
  35651. declare module BABYLON {
  35652. /**
  35653. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35654. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35655. */
  35656. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35657. /**
  35658. * Gets the name of the behavior.
  35659. */
  35660. readonly name: string;
  35661. private _zoomStopsAnimation;
  35662. private _idleRotationSpeed;
  35663. private _idleRotationWaitTime;
  35664. private _idleRotationSpinupTime;
  35665. /**
  35666. * Sets the flag that indicates if user zooming should stop animation.
  35667. */
  35668. /**
  35669. * Gets the flag that indicates if user zooming should stop animation.
  35670. */
  35671. zoomStopsAnimation: boolean;
  35672. /**
  35673. * Sets the default speed at which the camera rotates around the model.
  35674. */
  35675. /**
  35676. * Gets the default speed at which the camera rotates around the model.
  35677. */
  35678. idleRotationSpeed: number;
  35679. /**
  35680. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35681. */
  35682. /**
  35683. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35684. */
  35685. idleRotationWaitTime: number;
  35686. /**
  35687. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35688. */
  35689. /**
  35690. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35691. */
  35692. idleRotationSpinupTime: number;
  35693. /**
  35694. * Gets a value indicating if the camera is currently rotating because of this behavior
  35695. */
  35696. readonly rotationInProgress: boolean;
  35697. private _onPrePointerObservableObserver;
  35698. private _onAfterCheckInputsObserver;
  35699. private _attachedCamera;
  35700. private _isPointerDown;
  35701. private _lastFrameTime;
  35702. private _lastInteractionTime;
  35703. private _cameraRotationSpeed;
  35704. /**
  35705. * Initializes the behavior.
  35706. */
  35707. init(): void;
  35708. /**
  35709. * Attaches the behavior to its arc rotate camera.
  35710. * @param camera Defines the camera to attach the behavior to
  35711. */
  35712. attach(camera: ArcRotateCamera): void;
  35713. /**
  35714. * Detaches the behavior from its current arc rotate camera.
  35715. */
  35716. detach(): void;
  35717. /**
  35718. * Returns true if user is scrolling.
  35719. * @return true if user is scrolling.
  35720. */
  35721. private _userIsZooming;
  35722. private _lastFrameRadius;
  35723. private _shouldAnimationStopForInteraction;
  35724. /**
  35725. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35726. */
  35727. private _applyUserInteraction;
  35728. private _userIsMoving;
  35729. }
  35730. }
  35731. declare module BABYLON {
  35732. /**
  35733. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35734. */
  35735. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35736. private ui;
  35737. /**
  35738. * The name of the behavior
  35739. */
  35740. name: string;
  35741. /**
  35742. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35743. */
  35744. distanceAwayFromFace: number;
  35745. /**
  35746. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35747. */
  35748. distanceAwayFromBottomOfFace: number;
  35749. private _faceVectors;
  35750. private _target;
  35751. private _scene;
  35752. private _onRenderObserver;
  35753. private _tmpMatrix;
  35754. private _tmpVector;
  35755. /**
  35756. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35757. * @param ui The transform node that should be attched to the mesh
  35758. */
  35759. constructor(ui: TransformNode);
  35760. /**
  35761. * Initializes the behavior
  35762. */
  35763. init(): void;
  35764. private _closestFace;
  35765. private _zeroVector;
  35766. private _lookAtTmpMatrix;
  35767. private _lookAtToRef;
  35768. /**
  35769. * Attaches the AttachToBoxBehavior to the passed in mesh
  35770. * @param target The mesh that the specified node will be attached to
  35771. */
  35772. attach(target: Mesh): void;
  35773. /**
  35774. * Detaches the behavior from the mesh
  35775. */
  35776. detach(): void;
  35777. }
  35778. }
  35779. declare module BABYLON {
  35780. /**
  35781. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35782. */
  35783. export class FadeInOutBehavior implements Behavior<Mesh> {
  35784. /**
  35785. * Time in milliseconds to delay before fading in (Default: 0)
  35786. */
  35787. delay: number;
  35788. /**
  35789. * Time in milliseconds for the mesh to fade in (Default: 300)
  35790. */
  35791. fadeInTime: number;
  35792. private _millisecondsPerFrame;
  35793. private _hovered;
  35794. private _hoverValue;
  35795. private _ownerNode;
  35796. /**
  35797. * Instatiates the FadeInOutBehavior
  35798. */
  35799. constructor();
  35800. /**
  35801. * The name of the behavior
  35802. */
  35803. readonly name: string;
  35804. /**
  35805. * Initializes the behavior
  35806. */
  35807. init(): void;
  35808. /**
  35809. * Attaches the fade behavior on the passed in mesh
  35810. * @param ownerNode The mesh that will be faded in/out once attached
  35811. */
  35812. attach(ownerNode: Mesh): void;
  35813. /**
  35814. * Detaches the behavior from the mesh
  35815. */
  35816. detach(): void;
  35817. /**
  35818. * Triggers the mesh to begin fading in or out
  35819. * @param value if the object should fade in or out (true to fade in)
  35820. */
  35821. fadeIn(value: boolean): void;
  35822. private _update;
  35823. private _setAllVisibility;
  35824. }
  35825. }
  35826. declare module BABYLON {
  35827. /**
  35828. * Class containing a set of static utilities functions for managing Pivots
  35829. * @hidden
  35830. */
  35831. export class PivotTools {
  35832. private static _PivotCached;
  35833. private static _OldPivotPoint;
  35834. private static _PivotTranslation;
  35835. private static _PivotTmpVector;
  35836. /** @hidden */ private static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35837. /** @hidden */ private static _RestorePivotPoint(mesh: AbstractMesh): void;
  35838. }
  35839. }
  35840. declare module BABYLON {
  35841. /**
  35842. * Class containing static functions to help procedurally build meshes
  35843. */
  35844. export class PlaneBuilder {
  35845. /**
  35846. * Creates a plane mesh
  35847. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35848. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35849. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35850. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35851. * * 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
  35852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35853. * @param name defines the name of the mesh
  35854. * @param options defines the options used to create the mesh
  35855. * @param scene defines the hosting scene
  35856. * @returns the plane mesh
  35857. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35858. */
  35859. static CreatePlane(name: string, options: {
  35860. size?: number;
  35861. width?: number;
  35862. height?: number;
  35863. sideOrientation?: number;
  35864. frontUVs?: Vector4;
  35865. backUVs?: Vector4;
  35866. updatable?: boolean;
  35867. sourcePlane?: Plane;
  35868. }, scene?: Nullable<Scene>): Mesh;
  35869. }
  35870. }
  35871. declare module BABYLON {
  35872. /**
  35873. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35874. */
  35875. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35876. private static _AnyMouseID;
  35877. /**
  35878. * Abstract mesh the behavior is set on
  35879. */
  35880. attachedNode: AbstractMesh;
  35881. private _dragPlane;
  35882. private _scene;
  35883. private _pointerObserver;
  35884. private _beforeRenderObserver;
  35885. private static _planeScene;
  35886. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35887. /**
  35888. * 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)
  35889. */
  35890. maxDragAngle: number;
  35891. /**
  35892. * @hidden
  35893. */ private _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35894. /**
  35895. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35896. */
  35897. currentDraggingPointerID: number;
  35898. /**
  35899. * The last position where the pointer hit the drag plane in world space
  35900. */
  35901. lastDragPosition: Vector3;
  35902. /**
  35903. * If the behavior is currently in a dragging state
  35904. */
  35905. dragging: boolean;
  35906. /**
  35907. * 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)
  35908. */
  35909. dragDeltaRatio: number;
  35910. /**
  35911. * If the drag plane orientation should be updated during the dragging (Default: true)
  35912. */
  35913. updateDragPlane: boolean;
  35914. private _debugMode;
  35915. private _moving;
  35916. /**
  35917. * Fires each time the attached mesh is dragged with the pointer
  35918. * * delta between last drag position and current drag position in world space
  35919. * * dragDistance along the drag axis
  35920. * * dragPlaneNormal normal of the current drag plane used during the drag
  35921. * * dragPlanePoint in world space where the drag intersects the drag plane
  35922. */
  35923. onDragObservable: Observable<{
  35924. delta: Vector3;
  35925. dragPlanePoint: Vector3;
  35926. dragPlaneNormal: Vector3;
  35927. dragDistance: number;
  35928. pointerId: number;
  35929. }>;
  35930. /**
  35931. * Fires each time a drag begins (eg. mouse down on mesh)
  35932. */
  35933. onDragStartObservable: Observable<{
  35934. dragPlanePoint: Vector3;
  35935. pointerId: number;
  35936. }>;
  35937. /**
  35938. * Fires each time a drag ends (eg. mouse release after drag)
  35939. */
  35940. onDragEndObservable: Observable<{
  35941. dragPlanePoint: Vector3;
  35942. pointerId: number;
  35943. }>;
  35944. /**
  35945. * If the attached mesh should be moved when dragged
  35946. */
  35947. moveAttached: boolean;
  35948. /**
  35949. * If the drag behavior will react to drag events (Default: true)
  35950. */
  35951. enabled: boolean;
  35952. /**
  35953. * If pointer events should start and release the drag (Default: true)
  35954. */
  35955. startAndReleaseDragOnPointerEvents: boolean;
  35956. /**
  35957. * If camera controls should be detached during the drag
  35958. */
  35959. detachCameraControls: boolean;
  35960. /**
  35961. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35962. */
  35963. useObjectOrienationForDragging: boolean;
  35964. private _options;
  35965. /**
  35966. * Creates a pointer drag behavior that can be attached to a mesh
  35967. * @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)
  35968. */
  35969. constructor(options?: {
  35970. dragAxis?: Vector3;
  35971. dragPlaneNormal?: Vector3;
  35972. });
  35973. /**
  35974. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35975. */
  35976. validateDrag: (targetPosition: Vector3) => boolean;
  35977. /**
  35978. * The name of the behavior
  35979. */
  35980. readonly name: string;
  35981. /**
  35982. * Initializes the behavior
  35983. */
  35984. init(): void;
  35985. private _tmpVector;
  35986. private _alternatePickedPoint;
  35987. private _worldDragAxis;
  35988. private _targetPosition;
  35989. private _attachedElement;
  35990. /**
  35991. * Attaches the drag behavior the passed in mesh
  35992. * @param ownerNode The mesh that will be dragged around once attached
  35993. */
  35994. attach(ownerNode: AbstractMesh): void;
  35995. /**
  35996. * Force relase the drag action by code.
  35997. */
  35998. releaseDrag(): void;
  35999. private _startDragRay;
  36000. private _lastPointerRay;
  36001. /**
  36002. * Simulates the start of a pointer drag event on the behavior
  36003. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36004. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36005. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36006. */
  36007. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36008. private _startDrag;
  36009. private _dragDelta;
  36010. private _moveDrag;
  36011. private _pickWithRayOnDragPlane;
  36012. private _pointA;
  36013. private _pointB;
  36014. private _pointC;
  36015. private _lineA;
  36016. private _lineB;
  36017. private _localAxis;
  36018. private _lookAt;
  36019. private _updateDragPlanePosition;
  36020. /**
  36021. * Detaches the behavior from the mesh
  36022. */
  36023. detach(): void;
  36024. }
  36025. }
  36026. declare module BABYLON {
  36027. /**
  36028. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36029. */
  36030. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36031. private _dragBehaviorA;
  36032. private _dragBehaviorB;
  36033. private _startDistance;
  36034. private _initialScale;
  36035. private _targetScale;
  36036. private _ownerNode;
  36037. private _sceneRenderObserver;
  36038. /**
  36039. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36040. */
  36041. constructor();
  36042. /**
  36043. * The name of the behavior
  36044. */
  36045. readonly name: string;
  36046. /**
  36047. * Initializes the behavior
  36048. */
  36049. init(): void;
  36050. private _getCurrentDistance;
  36051. /**
  36052. * Attaches the scale behavior the passed in mesh
  36053. * @param ownerNode The mesh that will be scaled around once attached
  36054. */
  36055. attach(ownerNode: Mesh): void;
  36056. /**
  36057. * Detaches the behavior from the mesh
  36058. */
  36059. detach(): void;
  36060. }
  36061. }
  36062. declare module BABYLON {
  36063. /**
  36064. * 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
  36065. */
  36066. export class SixDofDragBehavior implements Behavior<Mesh> {
  36067. private static _virtualScene;
  36068. private _ownerNode;
  36069. private _sceneRenderObserver;
  36070. private _scene;
  36071. private _targetPosition;
  36072. private _virtualOriginMesh;
  36073. private _virtualDragMesh;
  36074. private _pointerObserver;
  36075. private _moving;
  36076. private _startingOrientation;
  36077. /**
  36078. * 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)
  36079. */
  36080. private zDragFactor;
  36081. /**
  36082. * If the object should rotate to face the drag origin
  36083. */
  36084. rotateDraggedObject: boolean;
  36085. /**
  36086. * If the behavior is currently in a dragging state
  36087. */
  36088. dragging: boolean;
  36089. /**
  36090. * 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)
  36091. */
  36092. dragDeltaRatio: number;
  36093. /**
  36094. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36095. */
  36096. currentDraggingPointerID: number;
  36097. /**
  36098. * If camera controls should be detached during the drag
  36099. */
  36100. detachCameraControls: boolean;
  36101. /**
  36102. * Fires each time a drag starts
  36103. */
  36104. onDragStartObservable: Observable<{}>;
  36105. /**
  36106. * Fires each time a drag ends (eg. mouse release after drag)
  36107. */
  36108. onDragEndObservable: Observable<{}>;
  36109. /**
  36110. * 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
  36111. */
  36112. constructor();
  36113. /**
  36114. * The name of the behavior
  36115. */
  36116. readonly name: string;
  36117. /**
  36118. * Initializes the behavior
  36119. */
  36120. init(): void;
  36121. /**
  36122. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36123. */
  36124. private readonly _pointerCamera;
  36125. /**
  36126. * Attaches the scale behavior the passed in mesh
  36127. * @param ownerNode The mesh that will be scaled around once attached
  36128. */
  36129. attach(ownerNode: Mesh): void;
  36130. /**
  36131. * Detaches the behavior from the mesh
  36132. */
  36133. detach(): void;
  36134. }
  36135. }
  36136. declare module BABYLON {
  36137. /**
  36138. * Class used to apply inverse kinematics to bones
  36139. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36140. */
  36141. export class BoneIKController {
  36142. private static _tmpVecs;
  36143. private static _tmpQuat;
  36144. private static _tmpMats;
  36145. /**
  36146. * Gets or sets the target mesh
  36147. */
  36148. targetMesh: AbstractMesh;
  36149. /** Gets or sets the mesh used as pole */
  36150. poleTargetMesh: AbstractMesh;
  36151. /**
  36152. * Gets or sets the bone used as pole
  36153. */
  36154. poleTargetBone: Nullable<Bone>;
  36155. /**
  36156. * Gets or sets the target position
  36157. */
  36158. targetPosition: Vector3;
  36159. /**
  36160. * Gets or sets the pole target position
  36161. */
  36162. poleTargetPosition: Vector3;
  36163. /**
  36164. * Gets or sets the pole target local offset
  36165. */
  36166. poleTargetLocalOffset: Vector3;
  36167. /**
  36168. * Gets or sets the pole angle
  36169. */
  36170. poleAngle: number;
  36171. /**
  36172. * Gets or sets the mesh associated with the controller
  36173. */
  36174. mesh: AbstractMesh;
  36175. /**
  36176. * 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)
  36177. */
  36178. slerpAmount: number;
  36179. private _bone1Quat;
  36180. private _bone1Mat;
  36181. private _bone2Ang;
  36182. private _bone1;
  36183. private _bone2;
  36184. private _bone1Length;
  36185. private _bone2Length;
  36186. private _maxAngle;
  36187. private _maxReach;
  36188. private _rightHandedSystem;
  36189. private _bendAxis;
  36190. private _slerping;
  36191. private _adjustRoll;
  36192. /**
  36193. * Gets or sets maximum allowed angle
  36194. */
  36195. maxAngle: number;
  36196. /**
  36197. * Creates a new BoneIKController
  36198. * @param mesh defines the mesh to control
  36199. * @param bone defines the bone to control
  36200. * @param options defines options to set up the controller
  36201. */
  36202. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36203. targetMesh?: AbstractMesh;
  36204. poleTargetMesh?: AbstractMesh;
  36205. poleTargetBone?: Bone;
  36206. poleTargetLocalOffset?: Vector3;
  36207. poleAngle?: number;
  36208. bendAxis?: Vector3;
  36209. maxAngle?: number;
  36210. slerpAmount?: number;
  36211. });
  36212. private _setMaxAngle;
  36213. /**
  36214. * Force the controller to update the bones
  36215. */
  36216. update(): void;
  36217. }
  36218. }
  36219. declare module BABYLON {
  36220. /**
  36221. * Class used to make a bone look toward a point in space
  36222. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36223. */
  36224. export class BoneLookController {
  36225. private static _tmpVecs;
  36226. private static _tmpQuat;
  36227. private static _tmpMats;
  36228. /**
  36229. * The target Vector3 that the bone will look at
  36230. */
  36231. target: Vector3;
  36232. /**
  36233. * The mesh that the bone is attached to
  36234. */
  36235. mesh: AbstractMesh;
  36236. /**
  36237. * The bone that will be looking to the target
  36238. */
  36239. bone: Bone;
  36240. /**
  36241. * The up axis of the coordinate system that is used when the bone is rotated
  36242. */
  36243. upAxis: Vector3;
  36244. /**
  36245. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36246. */
  36247. upAxisSpace: Space;
  36248. /**
  36249. * Used to make an adjustment to the yaw of the bone
  36250. */
  36251. adjustYaw: number;
  36252. /**
  36253. * Used to make an adjustment to the pitch of the bone
  36254. */
  36255. adjustPitch: number;
  36256. /**
  36257. * Used to make an adjustment to the roll of the bone
  36258. */
  36259. adjustRoll: number;
  36260. /**
  36261. * 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)
  36262. */
  36263. slerpAmount: number;
  36264. private _minYaw;
  36265. private _maxYaw;
  36266. private _minPitch;
  36267. private _maxPitch;
  36268. private _minYawSin;
  36269. private _minYawCos;
  36270. private _maxYawSin;
  36271. private _maxYawCos;
  36272. private _midYawConstraint;
  36273. private _minPitchTan;
  36274. private _maxPitchTan;
  36275. private _boneQuat;
  36276. private _slerping;
  36277. private _transformYawPitch;
  36278. private _transformYawPitchInv;
  36279. private _firstFrameSkipped;
  36280. private _yawRange;
  36281. private _fowardAxis;
  36282. /**
  36283. * Gets or sets the minimum yaw angle that the bone can look to
  36284. */
  36285. minYaw: number;
  36286. /**
  36287. * Gets or sets the maximum yaw angle that the bone can look to
  36288. */
  36289. maxYaw: number;
  36290. /**
  36291. * Gets or sets the minimum pitch angle that the bone can look to
  36292. */
  36293. minPitch: number;
  36294. /**
  36295. * Gets or sets the maximum pitch angle that the bone can look to
  36296. */
  36297. maxPitch: number;
  36298. /**
  36299. * Create a BoneLookController
  36300. * @param mesh the mesh that the bone belongs to
  36301. * @param bone the bone that will be looking to the target
  36302. * @param target the target Vector3 to look at
  36303. * @param options optional settings:
  36304. * * maxYaw: the maximum angle the bone will yaw to
  36305. * * minYaw: the minimum angle the bone will yaw to
  36306. * * maxPitch: the maximum angle the bone will pitch to
  36307. * * minPitch: the minimum angle the bone will yaw to
  36308. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36309. * * upAxis: the up axis of the coordinate system
  36310. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36311. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36312. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36313. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36314. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36315. * * adjustRoll: used to make an adjustment to the roll of the bone
  36316. **/
  36317. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36318. maxYaw?: number;
  36319. minYaw?: number;
  36320. maxPitch?: number;
  36321. minPitch?: number;
  36322. slerpAmount?: number;
  36323. upAxis?: Vector3;
  36324. upAxisSpace?: Space;
  36325. yawAxis?: Vector3;
  36326. pitchAxis?: Vector3;
  36327. adjustYaw?: number;
  36328. adjustPitch?: number;
  36329. adjustRoll?: number;
  36330. });
  36331. /**
  36332. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36333. */
  36334. update(): void;
  36335. private _getAngleDiff;
  36336. private _getAngleBetween;
  36337. private _isAngleBetween;
  36338. }
  36339. }
  36340. declare module BABYLON {
  36341. /**
  36342. * Manage the gamepad inputs to control an arc rotate camera.
  36343. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36344. */
  36345. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36346. /**
  36347. * Defines the camera the input is attached to.
  36348. */
  36349. camera: ArcRotateCamera;
  36350. /**
  36351. * Defines the gamepad the input is gathering event from.
  36352. */
  36353. gamepad: Nullable<Gamepad>;
  36354. /**
  36355. * Defines the gamepad rotation sensiblity.
  36356. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36357. */
  36358. gamepadRotationSensibility: number;
  36359. /**
  36360. * Defines the gamepad move sensiblity.
  36361. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36362. */
  36363. gamepadMoveSensibility: number;
  36364. private _onGamepadConnectedObserver;
  36365. private _onGamepadDisconnectedObserver;
  36366. /**
  36367. * Attach the input controls to a specific dom element to get the input from.
  36368. * @param element Defines the element the controls should be listened from
  36369. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36370. */
  36371. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36372. /**
  36373. * Detach the current controls from the specified dom element.
  36374. * @param element Defines the element to stop listening the inputs from
  36375. */
  36376. detachControl(element: Nullable<HTMLElement>): void;
  36377. /**
  36378. * Update the current camera state depending on the inputs that have been used this frame.
  36379. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36380. */
  36381. checkInputs(): void;
  36382. /**
  36383. * Gets the class name of the current intput.
  36384. * @returns the class name
  36385. */
  36386. getClassName(): string;
  36387. /**
  36388. * Get the friendly name associated with the input class.
  36389. * @returns the input friendly name
  36390. */
  36391. getSimpleName(): string;
  36392. }
  36393. }
  36394. declare module BABYLON {
  36395. interface ArcRotateCameraInputsManager {
  36396. /**
  36397. * Add orientation input support to the input manager.
  36398. * @returns the current input manager
  36399. */
  36400. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36401. }
  36402. /**
  36403. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36404. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36405. */
  36406. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36407. /**
  36408. * Defines the camera the input is attached to.
  36409. */
  36410. camera: ArcRotateCamera;
  36411. /**
  36412. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36413. */
  36414. alphaCorrection: number;
  36415. /**
  36416. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36417. */
  36418. gammaCorrection: number;
  36419. private _alpha;
  36420. private _gamma;
  36421. private _dirty;
  36422. private _deviceOrientationHandler;
  36423. /**
  36424. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36425. */
  36426. constructor();
  36427. /**
  36428. * Attach the input controls to a specific dom element to get the input from.
  36429. * @param element Defines the element the controls should be listened from
  36430. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36431. */
  36432. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36433. /** @hidden */ private _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36434. /**
  36435. * Update the current camera state depending on the inputs that have been used this frame.
  36436. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36437. */
  36438. checkInputs(): void;
  36439. /**
  36440. * Detach the current controls from the specified dom element.
  36441. * @param element Defines the element to stop listening the inputs from
  36442. */
  36443. detachControl(element: Nullable<HTMLElement>): void;
  36444. /**
  36445. * Gets the class name of the current intput.
  36446. * @returns the class name
  36447. */
  36448. getClassName(): string;
  36449. /**
  36450. * Get the friendly name associated with the input class.
  36451. * @returns the input friendly name
  36452. */
  36453. getSimpleName(): string;
  36454. }
  36455. }
  36456. declare module BABYLON {
  36457. /**
  36458. * Listen to mouse events to control the camera.
  36459. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36460. */
  36461. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36462. /**
  36463. * Defines the camera the input is attached to.
  36464. */
  36465. camera: FlyCamera;
  36466. /**
  36467. * Defines if touch is enabled. (Default is true.)
  36468. */
  36469. touchEnabled: boolean;
  36470. /**
  36471. * Defines the buttons associated with the input to handle camera rotation.
  36472. */
  36473. buttons: number[];
  36474. /**
  36475. * Assign buttons for Yaw control.
  36476. */
  36477. buttonsYaw: number[];
  36478. /**
  36479. * Assign buttons for Pitch control.
  36480. */
  36481. buttonsPitch: number[];
  36482. /**
  36483. * Assign buttons for Roll control.
  36484. */
  36485. buttonsRoll: number[];
  36486. /**
  36487. * Detect if any button is being pressed while mouse is moved.
  36488. * -1 = Mouse locked.
  36489. * 0 = Left button.
  36490. * 1 = Middle Button.
  36491. * 2 = Right Button.
  36492. */
  36493. activeButton: number;
  36494. /**
  36495. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36496. * Higher values reduce its sensitivity.
  36497. */
  36498. angularSensibility: number;
  36499. private _mousemoveCallback;
  36500. private _observer;
  36501. private _rollObserver;
  36502. private previousPosition;
  36503. private noPreventDefault;
  36504. private element;
  36505. /**
  36506. * Listen to mouse events to control the camera.
  36507. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36508. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36509. */
  36510. constructor(touchEnabled?: boolean);
  36511. /**
  36512. * Attach the mouse control to the HTML DOM element.
  36513. * @param element Defines the element that listens to the input events.
  36514. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36515. */
  36516. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36517. /**
  36518. * Detach the current controls from the specified dom element.
  36519. * @param element Defines the element to stop listening the inputs from
  36520. */
  36521. detachControl(element: Nullable<HTMLElement>): void;
  36522. /**
  36523. * Gets the class name of the current input.
  36524. * @returns the class name.
  36525. */
  36526. getClassName(): string;
  36527. /**
  36528. * Get the friendly name associated with the input class.
  36529. * @returns the input's friendly name.
  36530. */
  36531. getSimpleName(): string;
  36532. private _pointerInput;
  36533. private _onMouseMove;
  36534. /**
  36535. * Rotate camera by mouse offset.
  36536. */
  36537. private rotateCamera;
  36538. }
  36539. }
  36540. declare module BABYLON {
  36541. /**
  36542. * Default Inputs manager for the FlyCamera.
  36543. * It groups all the default supported inputs for ease of use.
  36544. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36545. */
  36546. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36547. /**
  36548. * Instantiates a new FlyCameraInputsManager.
  36549. * @param camera Defines the camera the inputs belong to.
  36550. */
  36551. constructor(camera: FlyCamera);
  36552. /**
  36553. * Add keyboard input support to the input manager.
  36554. * @returns the new FlyCameraKeyboardMoveInput().
  36555. */
  36556. addKeyboard(): FlyCameraInputsManager;
  36557. /**
  36558. * Add mouse input support to the input manager.
  36559. * @param touchEnabled Enable touch screen support.
  36560. * @returns the new FlyCameraMouseInput().
  36561. */
  36562. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36563. }
  36564. }
  36565. declare module BABYLON {
  36566. /**
  36567. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36568. * such as in a 3D Space Shooter or a Flight Simulator.
  36569. */
  36570. export class FlyCamera extends TargetCamera {
  36571. /**
  36572. * Define the collision ellipsoid of the camera.
  36573. * This is helpful for simulating a camera body, like a player's body.
  36574. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36575. */
  36576. ellipsoid: Vector3;
  36577. /**
  36578. * Define an offset for the position of the ellipsoid around the camera.
  36579. * This can be helpful if the camera is attached away from the player's body center,
  36580. * such as at its head.
  36581. */
  36582. ellipsoidOffset: Vector3;
  36583. /**
  36584. * Enable or disable collisions of the camera with the rest of the scene objects.
  36585. */
  36586. checkCollisions: boolean;
  36587. /**
  36588. * Enable or disable gravity on the camera.
  36589. */
  36590. applyGravity: boolean;
  36591. /**
  36592. * Define the current direction the camera is moving to.
  36593. */
  36594. cameraDirection: Vector3;
  36595. /**
  36596. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36597. * This overrides and empties cameraRotation.
  36598. */
  36599. rotationQuaternion: Quaternion;
  36600. /**
  36601. * Track Roll to maintain the wanted Rolling when looking around.
  36602. */ private _trackRoll: number;
  36603. /**
  36604. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36605. */
  36606. rollCorrect: number;
  36607. /**
  36608. * Mimic a banked turn, Rolling the camera when Yawing.
  36609. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36610. */
  36611. bankedTurn: boolean;
  36612. /**
  36613. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36614. */
  36615. bankedTurnLimit: number;
  36616. /**
  36617. * Value of 0 disables the banked Roll.
  36618. * Value of 1 is equal to the Yaw angle in radians.
  36619. */
  36620. bankedTurnMultiplier: number;
  36621. /**
  36622. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36623. */
  36624. inputs: FlyCameraInputsManager;
  36625. /**
  36626. * Gets the input sensibility for mouse input.
  36627. * Higher values reduce sensitivity.
  36628. */
  36629. /**
  36630. * Sets the input sensibility for a mouse input.
  36631. * Higher values reduce sensitivity.
  36632. */
  36633. angularSensibility: number;
  36634. /**
  36635. * Get the keys for camera movement forward.
  36636. */
  36637. /**
  36638. * Set the keys for camera movement forward.
  36639. */
  36640. keysForward: number[];
  36641. /**
  36642. * Get the keys for camera movement backward.
  36643. */
  36644. keysBackward: number[];
  36645. /**
  36646. * Get the keys for camera movement up.
  36647. */
  36648. /**
  36649. * Set the keys for camera movement up.
  36650. */
  36651. keysUp: number[];
  36652. /**
  36653. * Get the keys for camera movement down.
  36654. */
  36655. /**
  36656. * Set the keys for camera movement down.
  36657. */
  36658. keysDown: number[];
  36659. /**
  36660. * Get the keys for camera movement left.
  36661. */
  36662. /**
  36663. * Set the keys for camera movement left.
  36664. */
  36665. keysLeft: number[];
  36666. /**
  36667. * Set the keys for camera movement right.
  36668. */
  36669. /**
  36670. * Set the keys for camera movement right.
  36671. */
  36672. keysRight: number[];
  36673. /**
  36674. * Event raised when the camera collides with a mesh in the scene.
  36675. */
  36676. onCollide: (collidedMesh: AbstractMesh) => void;
  36677. private _collider;
  36678. private _needMoveForGravity;
  36679. private _oldPosition;
  36680. private _diffPosition;
  36681. private _newPosition;
  36682. /** @hidden */ private _localDirection: Vector3;
  36683. /** @hidden */ private _transformedDirection: Vector3;
  36684. /**
  36685. * Instantiates a FlyCamera.
  36686. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36687. * such as in a 3D Space Shooter or a Flight Simulator.
  36688. * @param name Define the name of the camera in the scene.
  36689. * @param position Define the starting position of the camera in the scene.
  36690. * @param scene Define the scene the camera belongs to.
  36691. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36692. */
  36693. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36694. /**
  36695. * Attach a control to the HTML DOM element.
  36696. * @param element Defines the element that listens to the input events.
  36697. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36698. */
  36699. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36700. /**
  36701. * Detach a control from the HTML DOM element.
  36702. * The camera will stop reacting to that input.
  36703. * @param element Defines the element that listens to the input events.
  36704. */
  36705. detachControl(element: HTMLElement): void;
  36706. private _collisionMask;
  36707. /**
  36708. * Get the mask that the camera ignores in collision events.
  36709. */
  36710. /**
  36711. * Set the mask that the camera ignores in collision events.
  36712. */
  36713. collisionMask: number;
  36714. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  36715. /** @hidden */
  36716. private _onCollisionPositionChange;
  36717. /** @hidden */ private _checkInputs(): void;
  36718. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  36719. /** @hidden */ private _updatePosition(): void;
  36720. /**
  36721. * Restore the Roll to its target value at the rate specified.
  36722. * @param rate - Higher means slower restoring.
  36723. * @hidden
  36724. */
  36725. restoreRoll(rate: number): void;
  36726. /**
  36727. * Destroy the camera and release the current resources held by it.
  36728. */
  36729. dispose(): void;
  36730. /**
  36731. * Get the current object class name.
  36732. * @returns the class name.
  36733. */
  36734. getClassName(): string;
  36735. }
  36736. }
  36737. declare module BABYLON {
  36738. /**
  36739. * Listen to keyboard events to control the camera.
  36740. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36741. */
  36742. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36743. /**
  36744. * Defines the camera the input is attached to.
  36745. */
  36746. camera: FlyCamera;
  36747. /**
  36748. * The list of keyboard keys used to control the forward move of the camera.
  36749. */
  36750. keysForward: number[];
  36751. /**
  36752. * The list of keyboard keys used to control the backward move of the camera.
  36753. */
  36754. keysBackward: number[];
  36755. /**
  36756. * The list of keyboard keys used to control the forward move of the camera.
  36757. */
  36758. keysUp: number[];
  36759. /**
  36760. * The list of keyboard keys used to control the backward move of the camera.
  36761. */
  36762. keysDown: number[];
  36763. /**
  36764. * The list of keyboard keys used to control the right strafe move of the camera.
  36765. */
  36766. keysRight: number[];
  36767. /**
  36768. * The list of keyboard keys used to control the left strafe move of the camera.
  36769. */
  36770. keysLeft: number[];
  36771. private _keys;
  36772. private _onCanvasBlurObserver;
  36773. private _onKeyboardObserver;
  36774. private _engine;
  36775. private _scene;
  36776. /**
  36777. * Attach the input controls to a specific dom element to get the input from.
  36778. * @param element Defines the element the controls should be listened from
  36779. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36780. */
  36781. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36782. /**
  36783. * Detach the current controls from the specified dom element.
  36784. * @param element Defines the element to stop listening the inputs from
  36785. */
  36786. detachControl(element: Nullable<HTMLElement>): void;
  36787. /**
  36788. * Gets the class name of the current intput.
  36789. * @returns the class name
  36790. */
  36791. getClassName(): string;
  36792. /** @hidden */ private _onLostFocus(e: FocusEvent): void;
  36793. /**
  36794. * Get the friendly name associated with the input class.
  36795. * @returns the input friendly name
  36796. */
  36797. getSimpleName(): string;
  36798. /**
  36799. * Update the current camera state depending on the inputs that have been used this frame.
  36800. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36801. */
  36802. checkInputs(): void;
  36803. }
  36804. }
  36805. declare module BABYLON {
  36806. /**
  36807. * Manage the mouse wheel inputs to control a follow camera.
  36808. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36809. */
  36810. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36811. /**
  36812. * Defines the camera the input is attached to.
  36813. */
  36814. camera: FollowCamera;
  36815. /**
  36816. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36817. */
  36818. axisControlRadius: boolean;
  36819. /**
  36820. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36821. */
  36822. axisControlHeight: boolean;
  36823. /**
  36824. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36825. */
  36826. axisControlRotation: boolean;
  36827. /**
  36828. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36829. * relation to mouseWheel events.
  36830. */
  36831. wheelPrecision: number;
  36832. /**
  36833. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36834. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36835. */
  36836. wheelDeltaPercentage: number;
  36837. private _wheel;
  36838. private _observer;
  36839. /**
  36840. * Attach the input controls to a specific dom element to get the input from.
  36841. * @param element Defines the element the controls should be listened from
  36842. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36843. */
  36844. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36845. /**
  36846. * Detach the current controls from the specified dom element.
  36847. * @param element Defines the element to stop listening the inputs from
  36848. */
  36849. detachControl(element: Nullable<HTMLElement>): void;
  36850. /**
  36851. * Gets the class name of the current intput.
  36852. * @returns the class name
  36853. */
  36854. getClassName(): string;
  36855. /**
  36856. * Get the friendly name associated with the input class.
  36857. * @returns the input friendly name
  36858. */
  36859. getSimpleName(): string;
  36860. }
  36861. }
  36862. declare module BABYLON {
  36863. /**
  36864. * Manage the pointers inputs to control an follow camera.
  36865. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36866. */
  36867. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36868. /**
  36869. * Defines the camera the input is attached to.
  36870. */
  36871. camera: FollowCamera;
  36872. /**
  36873. * Gets the class name of the current input.
  36874. * @returns the class name
  36875. */
  36876. getClassName(): string;
  36877. /**
  36878. * Defines the pointer angular sensibility along the X axis or how fast is
  36879. * the camera rotating.
  36880. * A negative number will reverse the axis direction.
  36881. */
  36882. angularSensibilityX: number;
  36883. /**
  36884. * Defines the pointer angular sensibility along the Y axis or how fast is
  36885. * the camera rotating.
  36886. * A negative number will reverse the axis direction.
  36887. */
  36888. angularSensibilityY: number;
  36889. /**
  36890. * Defines the pointer pinch precision or how fast is the camera zooming.
  36891. * A negative number will reverse the axis direction.
  36892. */
  36893. pinchPrecision: number;
  36894. /**
  36895. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36896. * from 0.
  36897. * It defines the percentage of current camera.radius to use as delta when
  36898. * pinch zoom is used.
  36899. */
  36900. pinchDeltaPercentage: number;
  36901. /**
  36902. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36903. */
  36904. axisXControlRadius: boolean;
  36905. /**
  36906. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36907. */
  36908. axisXControlHeight: boolean;
  36909. /**
  36910. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36911. */
  36912. axisXControlRotation: boolean;
  36913. /**
  36914. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36915. */
  36916. axisYControlRadius: boolean;
  36917. /**
  36918. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36919. */
  36920. axisYControlHeight: boolean;
  36921. /**
  36922. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36923. */
  36924. axisYControlRotation: boolean;
  36925. /**
  36926. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36927. */
  36928. axisPinchControlRadius: boolean;
  36929. /**
  36930. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36931. */
  36932. axisPinchControlHeight: boolean;
  36933. /**
  36934. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36935. */
  36936. axisPinchControlRotation: boolean;
  36937. /**
  36938. * Log error messages if basic misconfiguration has occurred.
  36939. */
  36940. warningEnable: boolean;
  36941. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36942. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36943. private _warningCounter;
  36944. private _warning;
  36945. }
  36946. }
  36947. declare module BABYLON {
  36948. /**
  36949. * Default Inputs manager for the FollowCamera.
  36950. * It groups all the default supported inputs for ease of use.
  36951. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36952. */
  36953. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36954. /**
  36955. * Instantiates a new FollowCameraInputsManager.
  36956. * @param camera Defines the camera the inputs belong to
  36957. */
  36958. constructor(camera: FollowCamera);
  36959. /**
  36960. * Add keyboard input support to the input manager.
  36961. * @returns the current input manager
  36962. */
  36963. addKeyboard(): FollowCameraInputsManager;
  36964. /**
  36965. * Add mouse wheel input support to the input manager.
  36966. * @returns the current input manager
  36967. */
  36968. addMouseWheel(): FollowCameraInputsManager;
  36969. /**
  36970. * Add pointers input support to the input manager.
  36971. * @returns the current input manager
  36972. */
  36973. addPointers(): FollowCameraInputsManager;
  36974. /**
  36975. * Add orientation input support to the input manager.
  36976. * @returns the current input manager
  36977. */
  36978. addVRDeviceOrientation(): FollowCameraInputsManager;
  36979. }
  36980. }
  36981. declare module BABYLON {
  36982. /**
  36983. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36984. * an arc rotate version arcFollowCamera are available.
  36985. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36986. */
  36987. export class FollowCamera extends TargetCamera {
  36988. /**
  36989. * Distance the follow camera should follow an object at
  36990. */
  36991. radius: number;
  36992. /**
  36993. * Minimum allowed distance of the camera to the axis of rotation
  36994. * (The camera can not get closer).
  36995. * This can help limiting how the Camera is able to move in the scene.
  36996. */
  36997. lowerRadiusLimit: Nullable<number>;
  36998. /**
  36999. * Maximum allowed distance of the camera to the axis of rotation
  37000. * (The camera can not get further).
  37001. * This can help limiting how the Camera is able to move in the scene.
  37002. */
  37003. upperRadiusLimit: Nullable<number>;
  37004. /**
  37005. * Define a rotation offset between the camera and the object it follows
  37006. */
  37007. rotationOffset: number;
  37008. /**
  37009. * Minimum allowed angle to camera position relative to target object.
  37010. * This can help limiting how the Camera is able to move in the scene.
  37011. */
  37012. lowerRotationOffsetLimit: Nullable<number>;
  37013. /**
  37014. * Maximum allowed angle to camera position relative to target object.
  37015. * This can help limiting how the Camera is able to move in the scene.
  37016. */
  37017. upperRotationOffsetLimit: Nullable<number>;
  37018. /**
  37019. * Define a height offset between the camera and the object it follows.
  37020. * It can help following an object from the top (like a car chaing a plane)
  37021. */
  37022. heightOffset: number;
  37023. /**
  37024. * Minimum allowed height of camera position relative to target object.
  37025. * This can help limiting how the Camera is able to move in the scene.
  37026. */
  37027. lowerHeightOffsetLimit: Nullable<number>;
  37028. /**
  37029. * Maximum allowed height of camera position relative to target object.
  37030. * This can help limiting how the Camera is able to move in the scene.
  37031. */
  37032. upperHeightOffsetLimit: Nullable<number>;
  37033. /**
  37034. * Define how fast the camera can accelerate to follow it s target.
  37035. */
  37036. cameraAcceleration: number;
  37037. /**
  37038. * Define the speed limit of the camera following an object.
  37039. */
  37040. maxCameraSpeed: number;
  37041. /**
  37042. * Define the target of the camera.
  37043. */
  37044. lockedTarget: Nullable<AbstractMesh>;
  37045. /**
  37046. * Defines the input associated with the camera.
  37047. */
  37048. inputs: FollowCameraInputsManager;
  37049. /**
  37050. * Instantiates the follow camera.
  37051. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37052. * @param name Define the name of the camera in the scene
  37053. * @param position Define the position of the camera
  37054. * @param scene Define the scene the camera belong to
  37055. * @param lockedTarget Define the target of the camera
  37056. */
  37057. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37058. private _follow;
  37059. /**
  37060. * Attached controls to the current camera.
  37061. * @param element Defines the element the controls should be listened from
  37062. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37063. */
  37064. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37065. /**
  37066. * Detach the current controls from the camera.
  37067. * The camera will stop reacting to inputs.
  37068. * @param element Defines the element to stop listening the inputs from
  37069. */
  37070. detachControl(element: HTMLElement): void;
  37071. /** @hidden */ private _checkInputs(): void;
  37072. private _checkLimits;
  37073. /**
  37074. * Gets the camera class name.
  37075. * @returns the class name
  37076. */
  37077. getClassName(): string;
  37078. }
  37079. /**
  37080. * Arc Rotate version of the follow camera.
  37081. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37082. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37083. */
  37084. export class ArcFollowCamera extends TargetCamera {
  37085. /** The longitudinal angle of the camera */
  37086. alpha: number;
  37087. /** The latitudinal angle of the camera */
  37088. beta: number;
  37089. /** The radius of the camera from its target */
  37090. radius: number;
  37091. /** Define the camera target (the messh it should follow) */
  37092. target: Nullable<AbstractMesh>;
  37093. private _cartesianCoordinates;
  37094. /**
  37095. * Instantiates a new ArcFollowCamera
  37096. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37097. * @param name Define the name of the camera
  37098. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37099. * @param beta Define the rotation angle of the camera around the elevation axis
  37100. * @param radius Define the radius of the camera from its target point
  37101. * @param target Define the target of the camera
  37102. * @param scene Define the scene the camera belongs to
  37103. */
  37104. constructor(name: string,
  37105. /** The longitudinal angle of the camera */
  37106. alpha: number,
  37107. /** The latitudinal angle of the camera */
  37108. beta: number,
  37109. /** The radius of the camera from its target */
  37110. radius: number,
  37111. /** Define the camera target (the messh it should follow) */
  37112. target: Nullable<AbstractMesh>, scene: Scene);
  37113. private _follow;
  37114. /** @hidden */ private _checkInputs(): void;
  37115. /**
  37116. * Returns the class name of the object.
  37117. * It is mostly used internally for serialization purposes.
  37118. */
  37119. getClassName(): string;
  37120. }
  37121. }
  37122. declare module BABYLON {
  37123. /**
  37124. * Manage the keyboard inputs to control the movement of a follow camera.
  37125. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37126. */
  37127. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37128. /**
  37129. * Defines the camera the input is attached to.
  37130. */
  37131. camera: FollowCamera;
  37132. /**
  37133. * Defines the list of key codes associated with the up action (increase heightOffset)
  37134. */
  37135. keysHeightOffsetIncr: number[];
  37136. /**
  37137. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37138. */
  37139. keysHeightOffsetDecr: number[];
  37140. /**
  37141. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37142. */
  37143. keysHeightOffsetModifierAlt: boolean;
  37144. /**
  37145. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37146. */
  37147. keysHeightOffsetModifierCtrl: boolean;
  37148. /**
  37149. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37150. */
  37151. keysHeightOffsetModifierShift: boolean;
  37152. /**
  37153. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37154. */
  37155. keysRotationOffsetIncr: number[];
  37156. /**
  37157. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37158. */
  37159. keysRotationOffsetDecr: number[];
  37160. /**
  37161. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37162. */
  37163. keysRotationOffsetModifierAlt: boolean;
  37164. /**
  37165. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37166. */
  37167. keysRotationOffsetModifierCtrl: boolean;
  37168. /**
  37169. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37170. */
  37171. keysRotationOffsetModifierShift: boolean;
  37172. /**
  37173. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37174. */
  37175. keysRadiusIncr: number[];
  37176. /**
  37177. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37178. */
  37179. keysRadiusDecr: number[];
  37180. /**
  37181. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37182. */
  37183. keysRadiusModifierAlt: boolean;
  37184. /**
  37185. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37186. */
  37187. keysRadiusModifierCtrl: boolean;
  37188. /**
  37189. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37190. */
  37191. keysRadiusModifierShift: boolean;
  37192. /**
  37193. * Defines the rate of change of heightOffset.
  37194. */
  37195. heightSensibility: number;
  37196. /**
  37197. * Defines the rate of change of rotationOffset.
  37198. */
  37199. rotationSensibility: number;
  37200. /**
  37201. * Defines the rate of change of radius.
  37202. */
  37203. radiusSensibility: number;
  37204. private _keys;
  37205. private _ctrlPressed;
  37206. private _altPressed;
  37207. private _shiftPressed;
  37208. private _onCanvasBlurObserver;
  37209. private _onKeyboardObserver;
  37210. private _engine;
  37211. private _scene;
  37212. /**
  37213. * Attach the input controls to a specific dom element to get the input from.
  37214. * @param element Defines the element the controls should be listened from
  37215. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37216. */
  37217. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37218. /**
  37219. * Detach the current controls from the specified dom element.
  37220. * @param element Defines the element to stop listening the inputs from
  37221. */
  37222. detachControl(element: Nullable<HTMLElement>): void;
  37223. /**
  37224. * Update the current camera state depending on the inputs that have been used this frame.
  37225. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37226. */
  37227. checkInputs(): void;
  37228. /**
  37229. * Gets the class name of the current input.
  37230. * @returns the class name
  37231. */
  37232. getClassName(): string;
  37233. /**
  37234. * Get the friendly name associated with the input class.
  37235. * @returns the input friendly name
  37236. */
  37237. getSimpleName(): string;
  37238. /**
  37239. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37240. * allow modification of the heightOffset value.
  37241. */
  37242. private _modifierHeightOffset;
  37243. /**
  37244. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37245. * allow modification of the rotationOffset value.
  37246. */
  37247. private _modifierRotationOffset;
  37248. /**
  37249. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37250. * allow modification of the radius value.
  37251. */
  37252. private _modifierRadius;
  37253. }
  37254. }
  37255. declare module BABYLON {
  37256. interface FreeCameraInputsManager {
  37257. /**
  37258. * @hidden
  37259. */ private _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37260. /**
  37261. * Add orientation input support to the input manager.
  37262. * @returns the current input manager
  37263. */
  37264. addDeviceOrientation(): FreeCameraInputsManager;
  37265. }
  37266. /**
  37267. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37268. * Screen rotation is taken into account.
  37269. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37270. */
  37271. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37272. private _camera;
  37273. private _screenOrientationAngle;
  37274. private _constantTranform;
  37275. private _screenQuaternion;
  37276. private _alpha;
  37277. private _beta;
  37278. private _gamma;
  37279. /**
  37280. * Can be used to detect if a device orientation sensor is availible on a device
  37281. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  37282. * @returns a promise that will resolve on orientation change
  37283. */
  37284. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  37285. /**
  37286. * @hidden
  37287. */ private _onDeviceOrientationChangedObservable: Observable<void>;
  37288. /**
  37289. * Instantiates a new input
  37290. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37291. */
  37292. constructor();
  37293. /**
  37294. * Define the camera controlled by the input.
  37295. */
  37296. camera: FreeCamera;
  37297. /**
  37298. * Attach the input controls to a specific dom element to get the input from.
  37299. * @param element Defines the element the controls should be listened from
  37300. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37301. */
  37302. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37303. private _orientationChanged;
  37304. private _deviceOrientation;
  37305. /**
  37306. * Detach the current controls from the specified dom element.
  37307. * @param element Defines the element to stop listening the inputs from
  37308. */
  37309. detachControl(element: Nullable<HTMLElement>): void;
  37310. /**
  37311. * Update the current camera state depending on the inputs that have been used this frame.
  37312. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37313. */
  37314. checkInputs(): void;
  37315. /**
  37316. * Gets the class name of the current intput.
  37317. * @returns the class name
  37318. */
  37319. getClassName(): string;
  37320. /**
  37321. * Get the friendly name associated with the input class.
  37322. * @returns the input friendly name
  37323. */
  37324. getSimpleName(): string;
  37325. }
  37326. }
  37327. declare module BABYLON {
  37328. /**
  37329. * Manage the gamepad inputs to control a free camera.
  37330. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37331. */
  37332. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37333. /**
  37334. * Define the camera the input is attached to.
  37335. */
  37336. camera: FreeCamera;
  37337. /**
  37338. * Define the Gamepad controlling the input
  37339. */
  37340. gamepad: Nullable<Gamepad>;
  37341. /**
  37342. * Defines the gamepad rotation sensiblity.
  37343. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37344. */
  37345. gamepadAngularSensibility: number;
  37346. /**
  37347. * Defines the gamepad move sensiblity.
  37348. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37349. */
  37350. gamepadMoveSensibility: number;
  37351. private _onGamepadConnectedObserver;
  37352. private _onGamepadDisconnectedObserver;
  37353. private _cameraTransform;
  37354. private _deltaTransform;
  37355. private _vector3;
  37356. private _vector2;
  37357. /**
  37358. * Attach the input controls to a specific dom element to get the input from.
  37359. * @param element Defines the element the controls should be listened from
  37360. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37361. */
  37362. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37363. /**
  37364. * Detach the current controls from the specified dom element.
  37365. * @param element Defines the element to stop listening the inputs from
  37366. */
  37367. detachControl(element: Nullable<HTMLElement>): void;
  37368. /**
  37369. * Update the current camera state depending on the inputs that have been used this frame.
  37370. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37371. */
  37372. checkInputs(): void;
  37373. /**
  37374. * Gets the class name of the current intput.
  37375. * @returns the class name
  37376. */
  37377. getClassName(): string;
  37378. /**
  37379. * Get the friendly name associated with the input class.
  37380. * @returns the input friendly name
  37381. */
  37382. getSimpleName(): string;
  37383. }
  37384. }
  37385. declare module BABYLON {
  37386. /**
  37387. * Defines the potential axis of a Joystick
  37388. */
  37389. export enum JoystickAxis {
  37390. /** X axis */
  37391. X = 0,
  37392. /** Y axis */
  37393. Y = 1,
  37394. /** Z axis */
  37395. Z = 2
  37396. }
  37397. /**
  37398. * Class used to define virtual joystick (used in touch mode)
  37399. */
  37400. export class VirtualJoystick {
  37401. /**
  37402. * Gets or sets a boolean indicating that left and right values must be inverted
  37403. */
  37404. reverseLeftRight: boolean;
  37405. /**
  37406. * Gets or sets a boolean indicating that up and down values must be inverted
  37407. */
  37408. reverseUpDown: boolean;
  37409. /**
  37410. * Gets the offset value for the position (ie. the change of the position value)
  37411. */
  37412. deltaPosition: Vector3;
  37413. /**
  37414. * Gets a boolean indicating if the virtual joystick was pressed
  37415. */
  37416. pressed: boolean;
  37417. /**
  37418. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37419. */
  37420. static Canvas: Nullable<HTMLCanvasElement>;
  37421. private static _globalJoystickIndex;
  37422. private static vjCanvasContext;
  37423. private static vjCanvasWidth;
  37424. private static vjCanvasHeight;
  37425. private static halfWidth;
  37426. private _action;
  37427. private _axisTargetedByLeftAndRight;
  37428. private _axisTargetedByUpAndDown;
  37429. private _joystickSensibility;
  37430. private _inversedSensibility;
  37431. private _joystickPointerID;
  37432. private _joystickColor;
  37433. private _joystickPointerPos;
  37434. private _joystickPreviousPointerPos;
  37435. private _joystickPointerStartPos;
  37436. private _deltaJoystickVector;
  37437. private _leftJoystick;
  37438. private _touches;
  37439. private _onPointerDownHandlerRef;
  37440. private _onPointerMoveHandlerRef;
  37441. private _onPointerUpHandlerRef;
  37442. private _onResize;
  37443. /**
  37444. * Creates a new virtual joystick
  37445. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37446. */
  37447. constructor(leftJoystick?: boolean);
  37448. /**
  37449. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37450. * @param newJoystickSensibility defines the new sensibility
  37451. */
  37452. setJoystickSensibility(newJoystickSensibility: number): void;
  37453. private _onPointerDown;
  37454. private _onPointerMove;
  37455. private _onPointerUp;
  37456. /**
  37457. * Change the color of the virtual joystick
  37458. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37459. */
  37460. setJoystickColor(newColor: string): void;
  37461. /**
  37462. * Defines a callback to call when the joystick is touched
  37463. * @param action defines the callback
  37464. */
  37465. setActionOnTouch(action: () => any): void;
  37466. /**
  37467. * Defines which axis you'd like to control for left & right
  37468. * @param axis defines the axis to use
  37469. */
  37470. setAxisForLeftRight(axis: JoystickAxis): void;
  37471. /**
  37472. * Defines which axis you'd like to control for up & down
  37473. * @param axis defines the axis to use
  37474. */
  37475. setAxisForUpDown(axis: JoystickAxis): void;
  37476. private _drawVirtualJoystick;
  37477. /**
  37478. * Release internal HTML canvas
  37479. */
  37480. releaseCanvas(): void;
  37481. }
  37482. }
  37483. declare module BABYLON {
  37484. interface FreeCameraInputsManager {
  37485. /**
  37486. * Add virtual joystick input support to the input manager.
  37487. * @returns the current input manager
  37488. */
  37489. addVirtualJoystick(): FreeCameraInputsManager;
  37490. }
  37491. /**
  37492. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37493. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37494. */
  37495. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37496. /**
  37497. * Defines the camera the input is attached to.
  37498. */
  37499. camera: FreeCamera;
  37500. private _leftjoystick;
  37501. private _rightjoystick;
  37502. /**
  37503. * Gets the left stick of the virtual joystick.
  37504. * @returns The virtual Joystick
  37505. */
  37506. getLeftJoystick(): VirtualJoystick;
  37507. /**
  37508. * Gets the right stick of the virtual joystick.
  37509. * @returns The virtual Joystick
  37510. */
  37511. getRightJoystick(): VirtualJoystick;
  37512. /**
  37513. * Update the current camera state depending on the inputs that have been used this frame.
  37514. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37515. */
  37516. checkInputs(): void;
  37517. /**
  37518. * Attach the input controls to a specific dom element to get the input from.
  37519. * @param element Defines the element the controls should be listened from
  37520. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37521. */
  37522. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37523. /**
  37524. * Detach the current controls from the specified dom element.
  37525. * @param element Defines the element to stop listening the inputs from
  37526. */
  37527. detachControl(element: Nullable<HTMLElement>): void;
  37528. /**
  37529. * Gets the class name of the current intput.
  37530. * @returns the class name
  37531. */
  37532. getClassName(): string;
  37533. /**
  37534. * Get the friendly name associated with the input class.
  37535. * @returns the input friendly name
  37536. */
  37537. getSimpleName(): string;
  37538. }
  37539. }
  37540. declare module BABYLON {
  37541. /**
  37542. * This represents a FPS type of camera controlled by touch.
  37543. * This is like a universal camera minus the Gamepad controls.
  37544. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37545. */
  37546. export class TouchCamera extends FreeCamera {
  37547. /**
  37548. * Defines the touch sensibility for rotation.
  37549. * The higher the faster.
  37550. */
  37551. touchAngularSensibility: number;
  37552. /**
  37553. * Defines the touch sensibility for move.
  37554. * The higher the faster.
  37555. */
  37556. touchMoveSensibility: number;
  37557. /**
  37558. * Instantiates a new touch camera.
  37559. * This represents a FPS type of camera controlled by touch.
  37560. * This is like a universal camera minus the Gamepad controls.
  37561. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37562. * @param name Define the name of the camera in the scene
  37563. * @param position Define the start position of the camera in the scene
  37564. * @param scene Define the scene the camera belongs to
  37565. */
  37566. constructor(name: string, position: Vector3, scene: Scene);
  37567. /**
  37568. * Gets the current object class name.
  37569. * @return the class name
  37570. */
  37571. getClassName(): string;
  37572. /** @hidden */ private _setupInputs(): void;
  37573. }
  37574. }
  37575. declare module BABYLON {
  37576. /**
  37577. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37578. * being tilted forward or back and left or right.
  37579. */
  37580. export class DeviceOrientationCamera extends FreeCamera {
  37581. private _initialQuaternion;
  37582. private _quaternionCache;
  37583. private _tmpDragQuaternion;
  37584. private _disablePointerInputWhenUsingDeviceOrientation;
  37585. /**
  37586. * Creates a new device orientation camera
  37587. * @param name The name of the camera
  37588. * @param position The start position camera
  37589. * @param scene The scene the camera belongs to
  37590. */
  37591. constructor(name: string, position: Vector3, scene: Scene);
  37592. /**
  37593. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  37594. */
  37595. disablePointerInputWhenUsingDeviceOrientation: boolean;
  37596. private _dragFactor;
  37597. /**
  37598. * Enabled turning on the y axis when the orientation sensor is active
  37599. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37600. */
  37601. enableHorizontalDragging(dragFactor?: number): void;
  37602. /**
  37603. * Gets the current instance class name ("DeviceOrientationCamera").
  37604. * This helps avoiding instanceof at run time.
  37605. * @returns the class name
  37606. */
  37607. getClassName(): string;
  37608. /**
  37609. * @hidden
  37610. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37611. */ private _checkInputs(): void;
  37612. /**
  37613. * Reset the camera to its default orientation on the specified axis only.
  37614. * @param axis The axis to reset
  37615. */
  37616. resetToCurrentRotation(axis?: Axis): void;
  37617. }
  37618. }
  37619. declare module BABYLON {
  37620. /**
  37621. * Defines supported buttons for XBox360 compatible gamepads
  37622. */
  37623. export enum Xbox360Button {
  37624. /** A */
  37625. A = 0,
  37626. /** B */
  37627. B = 1,
  37628. /** X */
  37629. X = 2,
  37630. /** Y */
  37631. Y = 3,
  37632. /** Start */
  37633. Start = 4,
  37634. /** Back */
  37635. Back = 5,
  37636. /** Left button */
  37637. LB = 6,
  37638. /** Right button */
  37639. RB = 7,
  37640. /** Left stick */
  37641. LeftStick = 8,
  37642. /** Right stick */
  37643. RightStick = 9
  37644. }
  37645. /** Defines values for XBox360 DPad */
  37646. export enum Xbox360Dpad {
  37647. /** Up */
  37648. Up = 0,
  37649. /** Down */
  37650. Down = 1,
  37651. /** Left */
  37652. Left = 2,
  37653. /** Right */
  37654. Right = 3
  37655. }
  37656. /**
  37657. * Defines a XBox360 gamepad
  37658. */
  37659. export class Xbox360Pad extends Gamepad {
  37660. private _leftTrigger;
  37661. private _rightTrigger;
  37662. private _onlefttriggerchanged;
  37663. private _onrighttriggerchanged;
  37664. private _onbuttondown;
  37665. private _onbuttonup;
  37666. private _ondpaddown;
  37667. private _ondpadup;
  37668. /** Observable raised when a button is pressed */
  37669. onButtonDownObservable: Observable<Xbox360Button>;
  37670. /** Observable raised when a button is released */
  37671. onButtonUpObservable: Observable<Xbox360Button>;
  37672. /** Observable raised when a pad is pressed */
  37673. onPadDownObservable: Observable<Xbox360Dpad>;
  37674. /** Observable raised when a pad is released */
  37675. onPadUpObservable: Observable<Xbox360Dpad>;
  37676. private _buttonA;
  37677. private _buttonB;
  37678. private _buttonX;
  37679. private _buttonY;
  37680. private _buttonBack;
  37681. private _buttonStart;
  37682. private _buttonLB;
  37683. private _buttonRB;
  37684. private _buttonLeftStick;
  37685. private _buttonRightStick;
  37686. private _dPadUp;
  37687. private _dPadDown;
  37688. private _dPadLeft;
  37689. private _dPadRight;
  37690. private _isXboxOnePad;
  37691. /**
  37692. * Creates a new XBox360 gamepad object
  37693. * @param id defines the id of this gamepad
  37694. * @param index defines its index
  37695. * @param gamepad defines the internal HTML gamepad object
  37696. * @param xboxOne defines if it is a XBox One gamepad
  37697. */
  37698. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37699. /**
  37700. * Defines the callback to call when left trigger is pressed
  37701. * @param callback defines the callback to use
  37702. */
  37703. onlefttriggerchanged(callback: (value: number) => void): void;
  37704. /**
  37705. * Defines the callback to call when right trigger is pressed
  37706. * @param callback defines the callback to use
  37707. */
  37708. onrighttriggerchanged(callback: (value: number) => void): void;
  37709. /**
  37710. * Gets the left trigger value
  37711. */
  37712. /**
  37713. * Sets the left trigger value
  37714. */
  37715. leftTrigger: number;
  37716. /**
  37717. * Gets the right trigger value
  37718. */
  37719. /**
  37720. * Sets the right trigger value
  37721. */
  37722. rightTrigger: number;
  37723. /**
  37724. * Defines the callback to call when a button is pressed
  37725. * @param callback defines the callback to use
  37726. */
  37727. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37728. /**
  37729. * Defines the callback to call when a button is released
  37730. * @param callback defines the callback to use
  37731. */
  37732. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37733. /**
  37734. * Defines the callback to call when a pad is pressed
  37735. * @param callback defines the callback to use
  37736. */
  37737. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37738. /**
  37739. * Defines the callback to call when a pad is released
  37740. * @param callback defines the callback to use
  37741. */
  37742. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37743. private _setButtonValue;
  37744. private _setDPadValue;
  37745. /**
  37746. * Gets the value of the `A` button
  37747. */
  37748. /**
  37749. * Sets the value of the `A` button
  37750. */
  37751. buttonA: number;
  37752. /**
  37753. * Gets the value of the `B` button
  37754. */
  37755. /**
  37756. * Sets the value of the `B` button
  37757. */
  37758. buttonB: number;
  37759. /**
  37760. * Gets the value of the `X` button
  37761. */
  37762. /**
  37763. * Sets the value of the `X` button
  37764. */
  37765. buttonX: number;
  37766. /**
  37767. * Gets the value of the `Y` button
  37768. */
  37769. /**
  37770. * Sets the value of the `Y` button
  37771. */
  37772. buttonY: number;
  37773. /**
  37774. * Gets the value of the `Start` button
  37775. */
  37776. /**
  37777. * Sets the value of the `Start` button
  37778. */
  37779. buttonStart: number;
  37780. /**
  37781. * Gets the value of the `Back` button
  37782. */
  37783. /**
  37784. * Sets the value of the `Back` button
  37785. */
  37786. buttonBack: number;
  37787. /**
  37788. * Gets the value of the `Left` button
  37789. */
  37790. /**
  37791. * Sets the value of the `Left` button
  37792. */
  37793. buttonLB: number;
  37794. /**
  37795. * Gets the value of the `Right` button
  37796. */
  37797. /**
  37798. * Sets the value of the `Right` button
  37799. */
  37800. buttonRB: number;
  37801. /**
  37802. * Gets the value of the Left joystick
  37803. */
  37804. /**
  37805. * Sets the value of the Left joystick
  37806. */
  37807. buttonLeftStick: number;
  37808. /**
  37809. * Gets the value of the Right joystick
  37810. */
  37811. /**
  37812. * Sets the value of the Right joystick
  37813. */
  37814. buttonRightStick: number;
  37815. /**
  37816. * Gets the value of D-pad up
  37817. */
  37818. /**
  37819. * Sets the value of D-pad up
  37820. */
  37821. dPadUp: number;
  37822. /**
  37823. * Gets the value of D-pad down
  37824. */
  37825. /**
  37826. * Sets the value of D-pad down
  37827. */
  37828. dPadDown: number;
  37829. /**
  37830. * Gets the value of D-pad left
  37831. */
  37832. /**
  37833. * Sets the value of D-pad left
  37834. */
  37835. dPadLeft: number;
  37836. /**
  37837. * Gets the value of D-pad right
  37838. */
  37839. /**
  37840. * Sets the value of D-pad right
  37841. */
  37842. dPadRight: number;
  37843. /**
  37844. * Force the gamepad to synchronize with device values
  37845. */
  37846. update(): void;
  37847. /**
  37848. * Disposes the gamepad
  37849. */
  37850. dispose(): void;
  37851. }
  37852. }
  37853. declare module BABYLON {
  37854. /**
  37855. * Defines supported buttons for DualShock compatible gamepads
  37856. */
  37857. export enum DualShockButton {
  37858. /** Cross */
  37859. Cross = 0,
  37860. /** Circle */
  37861. Circle = 1,
  37862. /** Square */
  37863. Square = 2,
  37864. /** Triangle */
  37865. Triangle = 3,
  37866. /** Options */
  37867. Options = 4,
  37868. /** Share */
  37869. Share = 5,
  37870. /** L1 */
  37871. L1 = 6,
  37872. /** R1 */
  37873. R1 = 7,
  37874. /** Left stick */
  37875. LeftStick = 8,
  37876. /** Right stick */
  37877. RightStick = 9
  37878. }
  37879. /** Defines values for DualShock DPad */
  37880. export enum DualShockDpad {
  37881. /** Up */
  37882. Up = 0,
  37883. /** Down */
  37884. Down = 1,
  37885. /** Left */
  37886. Left = 2,
  37887. /** Right */
  37888. Right = 3
  37889. }
  37890. /**
  37891. * Defines a DualShock gamepad
  37892. */
  37893. export class DualShockPad extends Gamepad {
  37894. private _leftTrigger;
  37895. private _rightTrigger;
  37896. private _onlefttriggerchanged;
  37897. private _onrighttriggerchanged;
  37898. private _onbuttondown;
  37899. private _onbuttonup;
  37900. private _ondpaddown;
  37901. private _ondpadup;
  37902. /** Observable raised when a button is pressed */
  37903. onButtonDownObservable: Observable<DualShockButton>;
  37904. /** Observable raised when a button is released */
  37905. onButtonUpObservable: Observable<DualShockButton>;
  37906. /** Observable raised when a pad is pressed */
  37907. onPadDownObservable: Observable<DualShockDpad>;
  37908. /** Observable raised when a pad is released */
  37909. onPadUpObservable: Observable<DualShockDpad>;
  37910. private _buttonCross;
  37911. private _buttonCircle;
  37912. private _buttonSquare;
  37913. private _buttonTriangle;
  37914. private _buttonShare;
  37915. private _buttonOptions;
  37916. private _buttonL1;
  37917. private _buttonR1;
  37918. private _buttonLeftStick;
  37919. private _buttonRightStick;
  37920. private _dPadUp;
  37921. private _dPadDown;
  37922. private _dPadLeft;
  37923. private _dPadRight;
  37924. /**
  37925. * Creates a new DualShock gamepad object
  37926. * @param id defines the id of this gamepad
  37927. * @param index defines its index
  37928. * @param gamepad defines the internal HTML gamepad object
  37929. */
  37930. constructor(id: string, index: number, gamepad: any);
  37931. /**
  37932. * Defines the callback to call when left trigger is pressed
  37933. * @param callback defines the callback to use
  37934. */
  37935. onlefttriggerchanged(callback: (value: number) => void): void;
  37936. /**
  37937. * Defines the callback to call when right trigger is pressed
  37938. * @param callback defines the callback to use
  37939. */
  37940. onrighttriggerchanged(callback: (value: number) => void): void;
  37941. /**
  37942. * Gets the left trigger value
  37943. */
  37944. /**
  37945. * Sets the left trigger value
  37946. */
  37947. leftTrigger: number;
  37948. /**
  37949. * Gets the right trigger value
  37950. */
  37951. /**
  37952. * Sets the right trigger value
  37953. */
  37954. rightTrigger: number;
  37955. /**
  37956. * Defines the callback to call when a button is pressed
  37957. * @param callback defines the callback to use
  37958. */
  37959. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  37960. /**
  37961. * Defines the callback to call when a button is released
  37962. * @param callback defines the callback to use
  37963. */
  37964. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  37965. /**
  37966. * Defines the callback to call when a pad is pressed
  37967. * @param callback defines the callback to use
  37968. */
  37969. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  37970. /**
  37971. * Defines the callback to call when a pad is released
  37972. * @param callback defines the callback to use
  37973. */
  37974. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  37975. private _setButtonValue;
  37976. private _setDPadValue;
  37977. /**
  37978. * Gets the value of the `Cross` button
  37979. */
  37980. /**
  37981. * Sets the value of the `Cross` button
  37982. */
  37983. buttonCross: number;
  37984. /**
  37985. * Gets the value of the `Circle` button
  37986. */
  37987. /**
  37988. * Sets the value of the `Circle` button
  37989. */
  37990. buttonCircle: number;
  37991. /**
  37992. * Gets the value of the `Square` button
  37993. */
  37994. /**
  37995. * Sets the value of the `Square` button
  37996. */
  37997. buttonSquare: number;
  37998. /**
  37999. * Gets the value of the `Triangle` button
  38000. */
  38001. /**
  38002. * Sets the value of the `Triangle` button
  38003. */
  38004. buttonTriangle: number;
  38005. /**
  38006. * Gets the value of the `Options` button
  38007. */
  38008. /**
  38009. * Sets the value of the `Options` button
  38010. */
  38011. buttonOptions: number;
  38012. /**
  38013. * Gets the value of the `Share` button
  38014. */
  38015. /**
  38016. * Sets the value of the `Share` button
  38017. */
  38018. buttonShare: number;
  38019. /**
  38020. * Gets the value of the `L1` button
  38021. */
  38022. /**
  38023. * Sets the value of the `L1` button
  38024. */
  38025. buttonL1: number;
  38026. /**
  38027. * Gets the value of the `R1` button
  38028. */
  38029. /**
  38030. * Sets the value of the `R1` button
  38031. */
  38032. buttonR1: number;
  38033. /**
  38034. * Gets the value of the Left joystick
  38035. */
  38036. /**
  38037. * Sets the value of the Left joystick
  38038. */
  38039. buttonLeftStick: number;
  38040. /**
  38041. * Gets the value of the Right joystick
  38042. */
  38043. /**
  38044. * Sets the value of the Right joystick
  38045. */
  38046. buttonRightStick: number;
  38047. /**
  38048. * Gets the value of D-pad up
  38049. */
  38050. /**
  38051. * Sets the value of D-pad up
  38052. */
  38053. dPadUp: number;
  38054. /**
  38055. * Gets the value of D-pad down
  38056. */
  38057. /**
  38058. * Sets the value of D-pad down
  38059. */
  38060. dPadDown: number;
  38061. /**
  38062. * Gets the value of D-pad left
  38063. */
  38064. /**
  38065. * Sets the value of D-pad left
  38066. */
  38067. dPadLeft: number;
  38068. /**
  38069. * Gets the value of D-pad right
  38070. */
  38071. /**
  38072. * Sets the value of D-pad right
  38073. */
  38074. dPadRight: number;
  38075. /**
  38076. * Force the gamepad to synchronize with device values
  38077. */
  38078. update(): void;
  38079. /**
  38080. * Disposes the gamepad
  38081. */
  38082. dispose(): void;
  38083. }
  38084. }
  38085. declare module BABYLON {
  38086. /**
  38087. * Manager for handling gamepads
  38088. */
  38089. export class GamepadManager {
  38090. private _scene?;
  38091. private _babylonGamepads;
  38092. private _oneGamepadConnected;
  38093. /** @hidden */ private _isMonitoring: boolean;
  38094. private _gamepadEventSupported;
  38095. private _gamepadSupport;
  38096. /**
  38097. * observable to be triggered when the gamepad controller has been connected
  38098. */
  38099. onGamepadConnectedObservable: Observable<Gamepad>;
  38100. /**
  38101. * observable to be triggered when the gamepad controller has been disconnected
  38102. */
  38103. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38104. private _onGamepadConnectedEvent;
  38105. private _onGamepadDisconnectedEvent;
  38106. /**
  38107. * Initializes the gamepad manager
  38108. * @param _scene BabylonJS scene
  38109. */
  38110. constructor(_scene?: Scene | undefined);
  38111. /**
  38112. * The gamepads in the game pad manager
  38113. */
  38114. readonly gamepads: Gamepad[];
  38115. /**
  38116. * Get the gamepad controllers based on type
  38117. * @param type The type of gamepad controller
  38118. * @returns Nullable gamepad
  38119. */
  38120. getGamepadByType(type?: number): Nullable<Gamepad>;
  38121. /**
  38122. * Disposes the gamepad manager
  38123. */
  38124. dispose(): void;
  38125. private _addNewGamepad;
  38126. private _startMonitoringGamepads;
  38127. private _stopMonitoringGamepads;
  38128. /** @hidden */ private _checkGamepadsStatus(): void;
  38129. private _updateGamepadObjects;
  38130. }
  38131. }
  38132. declare module BABYLON {
  38133. interface Scene {
  38134. /** @hidden */ private _gamepadManager: Nullable<GamepadManager>;
  38135. /**
  38136. * Gets the gamepad manager associated with the scene
  38137. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38138. */
  38139. gamepadManager: GamepadManager;
  38140. }
  38141. /**
  38142. * Interface representing a free camera inputs manager
  38143. */
  38144. interface FreeCameraInputsManager {
  38145. /**
  38146. * Adds gamepad input support to the FreeCameraInputsManager.
  38147. * @returns the FreeCameraInputsManager
  38148. */
  38149. addGamepad(): FreeCameraInputsManager;
  38150. }
  38151. /**
  38152. * Interface representing an arc rotate camera inputs manager
  38153. */
  38154. interface ArcRotateCameraInputsManager {
  38155. /**
  38156. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38157. * @returns the camera inputs manager
  38158. */
  38159. addGamepad(): ArcRotateCameraInputsManager;
  38160. }
  38161. /**
  38162. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38163. */
  38164. export class GamepadSystemSceneComponent implements ISceneComponent {
  38165. /**
  38166. * The component name helpfull to identify the component in the list of scene components.
  38167. */
  38168. readonly name: string;
  38169. /**
  38170. * The scene the component belongs to.
  38171. */
  38172. scene: Scene;
  38173. /**
  38174. * Creates a new instance of the component for the given scene
  38175. * @param scene Defines the scene to register the component in
  38176. */
  38177. constructor(scene: Scene);
  38178. /**
  38179. * Registers the component in a given scene
  38180. */
  38181. register(): void;
  38182. /**
  38183. * Rebuilds the elements related to this component in case of
  38184. * context lost for instance.
  38185. */
  38186. rebuild(): void;
  38187. /**
  38188. * Disposes the component and the associated ressources
  38189. */
  38190. dispose(): void;
  38191. private _beforeCameraUpdate;
  38192. }
  38193. }
  38194. declare module BABYLON {
  38195. /**
  38196. * 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,
  38197. * which still works and will still be found in many Playgrounds.
  38198. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38199. */
  38200. export class UniversalCamera extends TouchCamera {
  38201. /**
  38202. * Defines the gamepad rotation sensiblity.
  38203. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38204. */
  38205. gamepadAngularSensibility: number;
  38206. /**
  38207. * Defines the gamepad move sensiblity.
  38208. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38209. */
  38210. gamepadMoveSensibility: number;
  38211. /**
  38212. * 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,
  38213. * which still works and will still be found in many Playgrounds.
  38214. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38215. * @param name Define the name of the camera in the scene
  38216. * @param position Define the start position of the camera in the scene
  38217. * @param scene Define the scene the camera belongs to
  38218. */
  38219. constructor(name: string, position: Vector3, scene: Scene);
  38220. /**
  38221. * Gets the current object class name.
  38222. * @return the class name
  38223. */
  38224. getClassName(): string;
  38225. }
  38226. }
  38227. declare module BABYLON {
  38228. /**
  38229. * This represents a FPS type of camera. This is only here for back compat purpose.
  38230. * Please use the UniversalCamera instead as both are identical.
  38231. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38232. */
  38233. export class GamepadCamera extends UniversalCamera {
  38234. /**
  38235. * Instantiates a new Gamepad Camera
  38236. * This represents a FPS type of camera. This is only here for back compat purpose.
  38237. * Please use the UniversalCamera instead as both are identical.
  38238. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38239. * @param name Define the name of the camera in the scene
  38240. * @param position Define the start position of the camera in the scene
  38241. * @param scene Define the scene the camera belongs to
  38242. */
  38243. constructor(name: string, position: Vector3, scene: Scene);
  38244. /**
  38245. * Gets the current object class name.
  38246. * @return the class name
  38247. */
  38248. getClassName(): string;
  38249. }
  38250. }
  38251. declare module BABYLON {
  38252. /** @hidden */
  38253. export var passPixelShader: {
  38254. name: string;
  38255. shader: string;
  38256. };
  38257. }
  38258. declare module BABYLON {
  38259. /** @hidden */
  38260. export var passCubePixelShader: {
  38261. name: string;
  38262. shader: string;
  38263. };
  38264. }
  38265. declare module BABYLON {
  38266. /**
  38267. * PassPostProcess which produces an output the same as it's input
  38268. */
  38269. export class PassPostProcess extends PostProcess {
  38270. /**
  38271. * Creates the PassPostProcess
  38272. * @param name The name of the effect.
  38273. * @param options The required width/height ratio to downsize to before computing the render pass.
  38274. * @param camera The camera to apply the render pass to.
  38275. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38276. * @param engine The engine which the post process will be applied. (default: current engine)
  38277. * @param reusable If the post process can be reused on the same frame. (default: false)
  38278. * @param textureType The type of texture to be used when performing the post processing.
  38279. * @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)
  38280. */
  38281. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38282. }
  38283. /**
  38284. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38285. */
  38286. export class PassCubePostProcess extends PostProcess {
  38287. private _face;
  38288. /**
  38289. * Gets or sets the cube face to display.
  38290. * * 0 is +X
  38291. * * 1 is -X
  38292. * * 2 is +Y
  38293. * * 3 is -Y
  38294. * * 4 is +Z
  38295. * * 5 is -Z
  38296. */
  38297. face: number;
  38298. /**
  38299. * Creates the PassCubePostProcess
  38300. * @param name The name of the effect.
  38301. * @param options The required width/height ratio to downsize to before computing the render pass.
  38302. * @param camera The camera to apply the render pass to.
  38303. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38304. * @param engine The engine which the post process will be applied. (default: current engine)
  38305. * @param reusable If the post process can be reused on the same frame. (default: false)
  38306. * @param textureType The type of texture to be used when performing the post processing.
  38307. * @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)
  38308. */
  38309. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38310. }
  38311. }
  38312. declare module BABYLON {
  38313. /** @hidden */
  38314. export var anaglyphPixelShader: {
  38315. name: string;
  38316. shader: string;
  38317. };
  38318. }
  38319. declare module BABYLON {
  38320. /**
  38321. * Postprocess used to generate anaglyphic rendering
  38322. */
  38323. export class AnaglyphPostProcess extends PostProcess {
  38324. private _passedProcess;
  38325. /**
  38326. * Creates a new AnaglyphPostProcess
  38327. * @param name defines postprocess name
  38328. * @param options defines creation options or target ratio scale
  38329. * @param rigCameras defines cameras using this postprocess
  38330. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38331. * @param engine defines hosting engine
  38332. * @param reusable defines if the postprocess will be reused multiple times per frame
  38333. */
  38334. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38335. }
  38336. }
  38337. declare module BABYLON {
  38338. /**
  38339. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38340. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38341. */
  38342. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38343. /**
  38344. * Creates a new AnaglyphArcRotateCamera
  38345. * @param name defines camera name
  38346. * @param alpha defines alpha angle (in radians)
  38347. * @param beta defines beta angle (in radians)
  38348. * @param radius defines radius
  38349. * @param target defines camera target
  38350. * @param interaxialDistance defines distance between each color axis
  38351. * @param scene defines the hosting scene
  38352. */
  38353. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38354. /**
  38355. * Gets camera class name
  38356. * @returns AnaglyphArcRotateCamera
  38357. */
  38358. getClassName(): string;
  38359. }
  38360. }
  38361. declare module BABYLON {
  38362. /**
  38363. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38364. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38365. */
  38366. export class AnaglyphFreeCamera extends FreeCamera {
  38367. /**
  38368. * Creates a new AnaglyphFreeCamera
  38369. * @param name defines camera name
  38370. * @param position defines initial position
  38371. * @param interaxialDistance defines distance between each color axis
  38372. * @param scene defines the hosting scene
  38373. */
  38374. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38375. /**
  38376. * Gets camera class name
  38377. * @returns AnaglyphFreeCamera
  38378. */
  38379. getClassName(): string;
  38380. }
  38381. }
  38382. declare module BABYLON {
  38383. /**
  38384. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38385. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38386. */
  38387. export class AnaglyphGamepadCamera extends GamepadCamera {
  38388. /**
  38389. * Creates a new AnaglyphGamepadCamera
  38390. * @param name defines camera name
  38391. * @param position defines initial position
  38392. * @param interaxialDistance defines distance between each color axis
  38393. * @param scene defines the hosting scene
  38394. */
  38395. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38396. /**
  38397. * Gets camera class name
  38398. * @returns AnaglyphGamepadCamera
  38399. */
  38400. getClassName(): string;
  38401. }
  38402. }
  38403. declare module BABYLON {
  38404. /**
  38405. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38406. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38407. */
  38408. export class AnaglyphUniversalCamera extends UniversalCamera {
  38409. /**
  38410. * Creates a new AnaglyphUniversalCamera
  38411. * @param name defines camera name
  38412. * @param position defines initial position
  38413. * @param interaxialDistance defines distance between each color axis
  38414. * @param scene defines the hosting scene
  38415. */
  38416. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38417. /**
  38418. * Gets camera class name
  38419. * @returns AnaglyphUniversalCamera
  38420. */
  38421. getClassName(): string;
  38422. }
  38423. }
  38424. declare module BABYLON {
  38425. /** @hidden */
  38426. export var stereoscopicInterlacePixelShader: {
  38427. name: string;
  38428. shader: string;
  38429. };
  38430. }
  38431. declare module BABYLON {
  38432. /**
  38433. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38434. */
  38435. export class StereoscopicInterlacePostProcess extends PostProcess {
  38436. private _stepSize;
  38437. private _passedProcess;
  38438. /**
  38439. * Initializes a StereoscopicInterlacePostProcess
  38440. * @param name The name of the effect.
  38441. * @param rigCameras The rig cameras to be appled to the post process
  38442. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38443. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38444. * @param engine The engine which the post process will be applied. (default: current engine)
  38445. * @param reusable If the post process can be reused on the same frame. (default: false)
  38446. */
  38447. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38448. }
  38449. }
  38450. declare module BABYLON {
  38451. /**
  38452. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38453. * @see http://doc.babylonjs.com/features/cameras
  38454. */
  38455. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38456. /**
  38457. * Creates a new StereoscopicArcRotateCamera
  38458. * @param name defines camera name
  38459. * @param alpha defines alpha angle (in radians)
  38460. * @param beta defines beta angle (in radians)
  38461. * @param radius defines radius
  38462. * @param target defines camera target
  38463. * @param interaxialDistance defines distance between each color axis
  38464. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38465. * @param scene defines the hosting scene
  38466. */
  38467. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38468. /**
  38469. * Gets camera class name
  38470. * @returns StereoscopicArcRotateCamera
  38471. */
  38472. getClassName(): string;
  38473. }
  38474. }
  38475. declare module BABYLON {
  38476. /**
  38477. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38478. * @see http://doc.babylonjs.com/features/cameras
  38479. */
  38480. export class StereoscopicFreeCamera extends FreeCamera {
  38481. /**
  38482. * Creates a new StereoscopicFreeCamera
  38483. * @param name defines camera name
  38484. * @param position defines initial position
  38485. * @param interaxialDistance defines distance between each color axis
  38486. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38487. * @param scene defines the hosting scene
  38488. */
  38489. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38490. /**
  38491. * Gets camera class name
  38492. * @returns StereoscopicFreeCamera
  38493. */
  38494. getClassName(): string;
  38495. }
  38496. }
  38497. declare module BABYLON {
  38498. /**
  38499. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38500. * @see http://doc.babylonjs.com/features/cameras
  38501. */
  38502. export class StereoscopicGamepadCamera extends GamepadCamera {
  38503. /**
  38504. * Creates a new StereoscopicGamepadCamera
  38505. * @param name defines camera name
  38506. * @param position defines initial position
  38507. * @param interaxialDistance defines distance between each color axis
  38508. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38509. * @param scene defines the hosting scene
  38510. */
  38511. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38512. /**
  38513. * Gets camera class name
  38514. * @returns StereoscopicGamepadCamera
  38515. */
  38516. getClassName(): string;
  38517. }
  38518. }
  38519. declare module BABYLON {
  38520. /**
  38521. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38522. * @see http://doc.babylonjs.com/features/cameras
  38523. */
  38524. export class StereoscopicUniversalCamera extends UniversalCamera {
  38525. /**
  38526. * Creates a new StereoscopicUniversalCamera
  38527. * @param name defines camera name
  38528. * @param position defines initial position
  38529. * @param interaxialDistance defines distance between each color axis
  38530. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38531. * @param scene defines the hosting scene
  38532. */
  38533. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38534. /**
  38535. * Gets camera class name
  38536. * @returns StereoscopicUniversalCamera
  38537. */
  38538. getClassName(): string;
  38539. }
  38540. }
  38541. declare module BABYLON {
  38542. /**
  38543. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38544. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38545. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38546. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38547. */
  38548. export class VirtualJoysticksCamera extends FreeCamera {
  38549. /**
  38550. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38551. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38552. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38553. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38554. * @param name Define the name of the camera in the scene
  38555. * @param position Define the start position of the camera in the scene
  38556. * @param scene Define the scene the camera belongs to
  38557. */
  38558. constructor(name: string, position: Vector3, scene: Scene);
  38559. /**
  38560. * Gets the current object class name.
  38561. * @return the class name
  38562. */
  38563. getClassName(): string;
  38564. }
  38565. }
  38566. declare module BABYLON {
  38567. /**
  38568. * This represents all the required metrics to create a VR camera.
  38569. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38570. */
  38571. export class VRCameraMetrics {
  38572. /**
  38573. * Define the horizontal resolution off the screen.
  38574. */
  38575. hResolution: number;
  38576. /**
  38577. * Define the vertical resolution off the screen.
  38578. */
  38579. vResolution: number;
  38580. /**
  38581. * Define the horizontal screen size.
  38582. */
  38583. hScreenSize: number;
  38584. /**
  38585. * Define the vertical screen size.
  38586. */
  38587. vScreenSize: number;
  38588. /**
  38589. * Define the vertical screen center position.
  38590. */
  38591. vScreenCenter: number;
  38592. /**
  38593. * Define the distance of the eyes to the screen.
  38594. */
  38595. eyeToScreenDistance: number;
  38596. /**
  38597. * Define the distance between both lenses
  38598. */
  38599. lensSeparationDistance: number;
  38600. /**
  38601. * Define the distance between both viewer's eyes.
  38602. */
  38603. interpupillaryDistance: number;
  38604. /**
  38605. * Define the distortion factor of the VR postprocess.
  38606. * Please, touch with care.
  38607. */
  38608. distortionK: number[];
  38609. /**
  38610. * Define the chromatic aberration correction factors for the VR post process.
  38611. */
  38612. chromaAbCorrection: number[];
  38613. /**
  38614. * Define the scale factor of the post process.
  38615. * The smaller the better but the slower.
  38616. */
  38617. postProcessScaleFactor: number;
  38618. /**
  38619. * Define an offset for the lens center.
  38620. */
  38621. lensCenterOffset: number;
  38622. /**
  38623. * Define if the current vr camera should compensate the distortion of the lense or not.
  38624. */
  38625. compensateDistortion: boolean;
  38626. /**
  38627. * Defines if multiview should be enabled when rendering (Default: false)
  38628. */
  38629. multiviewEnabled: boolean;
  38630. /**
  38631. * Gets the rendering aspect ratio based on the provided resolutions.
  38632. */
  38633. readonly aspectRatio: number;
  38634. /**
  38635. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38636. */
  38637. readonly aspectRatioFov: number;
  38638. /**
  38639. * @hidden
  38640. */
  38641. readonly leftHMatrix: Matrix;
  38642. /**
  38643. * @hidden
  38644. */
  38645. readonly rightHMatrix: Matrix;
  38646. /**
  38647. * @hidden
  38648. */
  38649. readonly leftPreViewMatrix: Matrix;
  38650. /**
  38651. * @hidden
  38652. */
  38653. readonly rightPreViewMatrix: Matrix;
  38654. /**
  38655. * Get the default VRMetrics based on the most generic setup.
  38656. * @returns the default vr metrics
  38657. */
  38658. static GetDefault(): VRCameraMetrics;
  38659. }
  38660. }
  38661. declare module BABYLON {
  38662. /** @hidden */
  38663. export var vrDistortionCorrectionPixelShader: {
  38664. name: string;
  38665. shader: string;
  38666. };
  38667. }
  38668. declare module BABYLON {
  38669. /**
  38670. * VRDistortionCorrectionPostProcess used for mobile VR
  38671. */
  38672. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38673. private _isRightEye;
  38674. private _distortionFactors;
  38675. private _postProcessScaleFactor;
  38676. private _lensCenterOffset;
  38677. private _scaleIn;
  38678. private _scaleFactor;
  38679. private _lensCenter;
  38680. /**
  38681. * Initializes the VRDistortionCorrectionPostProcess
  38682. * @param name The name of the effect.
  38683. * @param camera The camera to apply the render pass to.
  38684. * @param isRightEye If this is for the right eye distortion
  38685. * @param vrMetrics All the required metrics for the VR camera
  38686. */
  38687. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38688. }
  38689. }
  38690. declare module BABYLON {
  38691. /**
  38692. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38693. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38694. */
  38695. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38696. /**
  38697. * Creates a new VRDeviceOrientationArcRotateCamera
  38698. * @param name defines camera name
  38699. * @param alpha defines the camera rotation along the logitudinal axis
  38700. * @param beta defines the camera rotation along the latitudinal axis
  38701. * @param radius defines the camera distance from its target
  38702. * @param target defines the camera target
  38703. * @param scene defines the scene the camera belongs to
  38704. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38705. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38706. */
  38707. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38708. /**
  38709. * Gets camera class name
  38710. * @returns VRDeviceOrientationArcRotateCamera
  38711. */
  38712. getClassName(): string;
  38713. }
  38714. }
  38715. declare module BABYLON {
  38716. /**
  38717. * Camera used to simulate VR rendering (based on FreeCamera)
  38718. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38719. */
  38720. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38721. /**
  38722. * Creates a new VRDeviceOrientationFreeCamera
  38723. * @param name defines camera name
  38724. * @param position defines the start position of the camera
  38725. * @param scene defines the scene the camera belongs to
  38726. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38727. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38728. */
  38729. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38730. /**
  38731. * Gets camera class name
  38732. * @returns VRDeviceOrientationFreeCamera
  38733. */
  38734. getClassName(): string;
  38735. }
  38736. }
  38737. declare module BABYLON {
  38738. /**
  38739. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38740. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38741. */
  38742. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38743. /**
  38744. * Creates a new VRDeviceOrientationGamepadCamera
  38745. * @param name defines camera name
  38746. * @param position defines the start position of the camera
  38747. * @param scene defines the scene the camera belongs to
  38748. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38749. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38750. */
  38751. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38752. /**
  38753. * Gets camera class name
  38754. * @returns VRDeviceOrientationGamepadCamera
  38755. */
  38756. getClassName(): string;
  38757. }
  38758. }
  38759. declare module BABYLON {
  38760. /**
  38761. * Base class of materials working in push mode in babylon JS
  38762. * @hidden
  38763. */
  38764. export class PushMaterial extends Material {
  38765. protected _activeEffect: Effect;
  38766. protected _normalMatrix: Matrix;
  38767. /**
  38768. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38769. * This means that the material can keep using a previous shader while a new one is being compiled.
  38770. * This is mostly used when shader parallel compilation is supported (true by default)
  38771. */
  38772. allowShaderHotSwapping: boolean;
  38773. constructor(name: string, scene: Scene);
  38774. getEffect(): Effect;
  38775. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38776. /**
  38777. * Binds the given world matrix to the active effect
  38778. *
  38779. * @param world the matrix to bind
  38780. */
  38781. bindOnlyWorldMatrix(world: Matrix): void;
  38782. /**
  38783. * Binds the given normal matrix to the active effect
  38784. *
  38785. * @param normalMatrix the matrix to bind
  38786. */
  38787. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38788. bind(world: Matrix, mesh?: Mesh): void;
  38789. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38790. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38791. }
  38792. }
  38793. declare module BABYLON {
  38794. /**
  38795. * This groups all the flags used to control the materials channel.
  38796. */
  38797. export class MaterialFlags {
  38798. private static _DiffuseTextureEnabled;
  38799. /**
  38800. * Are diffuse textures enabled in the application.
  38801. */
  38802. static DiffuseTextureEnabled: boolean;
  38803. private static _AmbientTextureEnabled;
  38804. /**
  38805. * Are ambient textures enabled in the application.
  38806. */
  38807. static AmbientTextureEnabled: boolean;
  38808. private static _OpacityTextureEnabled;
  38809. /**
  38810. * Are opacity textures enabled in the application.
  38811. */
  38812. static OpacityTextureEnabled: boolean;
  38813. private static _ReflectionTextureEnabled;
  38814. /**
  38815. * Are reflection textures enabled in the application.
  38816. */
  38817. static ReflectionTextureEnabled: boolean;
  38818. private static _EmissiveTextureEnabled;
  38819. /**
  38820. * Are emissive textures enabled in the application.
  38821. */
  38822. static EmissiveTextureEnabled: boolean;
  38823. private static _SpecularTextureEnabled;
  38824. /**
  38825. * Are specular textures enabled in the application.
  38826. */
  38827. static SpecularTextureEnabled: boolean;
  38828. private static _BumpTextureEnabled;
  38829. /**
  38830. * Are bump textures enabled in the application.
  38831. */
  38832. static BumpTextureEnabled: boolean;
  38833. private static _LightmapTextureEnabled;
  38834. /**
  38835. * Are lightmap textures enabled in the application.
  38836. */
  38837. static LightmapTextureEnabled: boolean;
  38838. private static _RefractionTextureEnabled;
  38839. /**
  38840. * Are refraction textures enabled in the application.
  38841. */
  38842. static RefractionTextureEnabled: boolean;
  38843. private static _ColorGradingTextureEnabled;
  38844. /**
  38845. * Are color grading textures enabled in the application.
  38846. */
  38847. static ColorGradingTextureEnabled: boolean;
  38848. private static _FresnelEnabled;
  38849. /**
  38850. * Are fresnels enabled in the application.
  38851. */
  38852. static FresnelEnabled: boolean;
  38853. private static _ClearCoatTextureEnabled;
  38854. /**
  38855. * Are clear coat textures enabled in the application.
  38856. */
  38857. static ClearCoatTextureEnabled: boolean;
  38858. private static _ClearCoatBumpTextureEnabled;
  38859. /**
  38860. * Are clear coat bump textures enabled in the application.
  38861. */
  38862. static ClearCoatBumpTextureEnabled: boolean;
  38863. private static _ClearCoatTintTextureEnabled;
  38864. /**
  38865. * Are clear coat tint textures enabled in the application.
  38866. */
  38867. static ClearCoatTintTextureEnabled: boolean;
  38868. private static _SheenTextureEnabled;
  38869. /**
  38870. * Are sheen textures enabled in the application.
  38871. */
  38872. static SheenTextureEnabled: boolean;
  38873. private static _AnisotropicTextureEnabled;
  38874. /**
  38875. * Are anisotropic textures enabled in the application.
  38876. */
  38877. static AnisotropicTextureEnabled: boolean;
  38878. private static _ThicknessTextureEnabled;
  38879. /**
  38880. * Are thickness textures enabled in the application.
  38881. */
  38882. static ThicknessTextureEnabled: boolean;
  38883. }
  38884. }
  38885. declare module BABYLON {
  38886. /** @hidden */
  38887. export var defaultFragmentDeclaration: {
  38888. name: string;
  38889. shader: string;
  38890. };
  38891. }
  38892. declare module BABYLON {
  38893. /** @hidden */
  38894. export var defaultUboDeclaration: {
  38895. name: string;
  38896. shader: string;
  38897. };
  38898. }
  38899. declare module BABYLON {
  38900. /** @hidden */
  38901. export var lightFragmentDeclaration: {
  38902. name: string;
  38903. shader: string;
  38904. };
  38905. }
  38906. declare module BABYLON {
  38907. /** @hidden */
  38908. export var lightUboDeclaration: {
  38909. name: string;
  38910. shader: string;
  38911. };
  38912. }
  38913. declare module BABYLON {
  38914. /** @hidden */
  38915. export var lightsFragmentFunctions: {
  38916. name: string;
  38917. shader: string;
  38918. };
  38919. }
  38920. declare module BABYLON {
  38921. /** @hidden */
  38922. export var shadowsFragmentFunctions: {
  38923. name: string;
  38924. shader: string;
  38925. };
  38926. }
  38927. declare module BABYLON {
  38928. /** @hidden */
  38929. export var fresnelFunction: {
  38930. name: string;
  38931. shader: string;
  38932. };
  38933. }
  38934. declare module BABYLON {
  38935. /** @hidden */
  38936. export var reflectionFunction: {
  38937. name: string;
  38938. shader: string;
  38939. };
  38940. }
  38941. declare module BABYLON {
  38942. /** @hidden */
  38943. export var bumpFragmentFunctions: {
  38944. name: string;
  38945. shader: string;
  38946. };
  38947. }
  38948. declare module BABYLON {
  38949. /** @hidden */
  38950. export var logDepthDeclaration: {
  38951. name: string;
  38952. shader: string;
  38953. };
  38954. }
  38955. declare module BABYLON {
  38956. /** @hidden */
  38957. export var bumpFragment: {
  38958. name: string;
  38959. shader: string;
  38960. };
  38961. }
  38962. declare module BABYLON {
  38963. /** @hidden */
  38964. export var depthPrePass: {
  38965. name: string;
  38966. shader: string;
  38967. };
  38968. }
  38969. declare module BABYLON {
  38970. /** @hidden */
  38971. export var lightFragment: {
  38972. name: string;
  38973. shader: string;
  38974. };
  38975. }
  38976. declare module BABYLON {
  38977. /** @hidden */
  38978. export var logDepthFragment: {
  38979. name: string;
  38980. shader: string;
  38981. };
  38982. }
  38983. declare module BABYLON {
  38984. /** @hidden */
  38985. export var defaultPixelShader: {
  38986. name: string;
  38987. shader: string;
  38988. };
  38989. }
  38990. declare module BABYLON {
  38991. /** @hidden */
  38992. export var defaultVertexDeclaration: {
  38993. name: string;
  38994. shader: string;
  38995. };
  38996. }
  38997. declare module BABYLON {
  38998. /** @hidden */
  38999. export var bumpVertexDeclaration: {
  39000. name: string;
  39001. shader: string;
  39002. };
  39003. }
  39004. declare module BABYLON {
  39005. /** @hidden */
  39006. export var bumpVertex: {
  39007. name: string;
  39008. shader: string;
  39009. };
  39010. }
  39011. declare module BABYLON {
  39012. /** @hidden */
  39013. export var fogVertex: {
  39014. name: string;
  39015. shader: string;
  39016. };
  39017. }
  39018. declare module BABYLON {
  39019. /** @hidden */
  39020. export var shadowsVertex: {
  39021. name: string;
  39022. shader: string;
  39023. };
  39024. }
  39025. declare module BABYLON {
  39026. /** @hidden */
  39027. export var pointCloudVertex: {
  39028. name: string;
  39029. shader: string;
  39030. };
  39031. }
  39032. declare module BABYLON {
  39033. /** @hidden */
  39034. export var logDepthVertex: {
  39035. name: string;
  39036. shader: string;
  39037. };
  39038. }
  39039. declare module BABYLON {
  39040. /** @hidden */
  39041. export var defaultVertexShader: {
  39042. name: string;
  39043. shader: string;
  39044. };
  39045. }
  39046. declare module BABYLON {
  39047. /** @hidden */
  39048. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39049. MAINUV1: boolean;
  39050. MAINUV2: boolean;
  39051. DIFFUSE: boolean;
  39052. DIFFUSEDIRECTUV: number;
  39053. AMBIENT: boolean;
  39054. AMBIENTDIRECTUV: number;
  39055. OPACITY: boolean;
  39056. OPACITYDIRECTUV: number;
  39057. OPACITYRGB: boolean;
  39058. REFLECTION: boolean;
  39059. EMISSIVE: boolean;
  39060. EMISSIVEDIRECTUV: number;
  39061. SPECULAR: boolean;
  39062. SPECULARDIRECTUV: number;
  39063. BUMP: boolean;
  39064. BUMPDIRECTUV: number;
  39065. PARALLAX: boolean;
  39066. PARALLAXOCCLUSION: boolean;
  39067. SPECULAROVERALPHA: boolean;
  39068. CLIPPLANE: boolean;
  39069. CLIPPLANE2: boolean;
  39070. CLIPPLANE3: boolean;
  39071. CLIPPLANE4: boolean;
  39072. ALPHATEST: boolean;
  39073. DEPTHPREPASS: boolean;
  39074. ALPHAFROMDIFFUSE: boolean;
  39075. POINTSIZE: boolean;
  39076. FOG: boolean;
  39077. SPECULARTERM: boolean;
  39078. DIFFUSEFRESNEL: boolean;
  39079. OPACITYFRESNEL: boolean;
  39080. REFLECTIONFRESNEL: boolean;
  39081. REFRACTIONFRESNEL: boolean;
  39082. EMISSIVEFRESNEL: boolean;
  39083. FRESNEL: boolean;
  39084. NORMAL: boolean;
  39085. UV1: boolean;
  39086. UV2: boolean;
  39087. VERTEXCOLOR: boolean;
  39088. VERTEXALPHA: boolean;
  39089. NUM_BONE_INFLUENCERS: number;
  39090. BonesPerMesh: number;
  39091. BONETEXTURE: boolean;
  39092. INSTANCES: boolean;
  39093. GLOSSINESS: boolean;
  39094. ROUGHNESS: boolean;
  39095. EMISSIVEASILLUMINATION: boolean;
  39096. LINKEMISSIVEWITHDIFFUSE: boolean;
  39097. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39098. LIGHTMAP: boolean;
  39099. LIGHTMAPDIRECTUV: number;
  39100. OBJECTSPACE_NORMALMAP: boolean;
  39101. USELIGHTMAPASSHADOWMAP: boolean;
  39102. REFLECTIONMAP_3D: boolean;
  39103. REFLECTIONMAP_SPHERICAL: boolean;
  39104. REFLECTIONMAP_PLANAR: boolean;
  39105. REFLECTIONMAP_CUBIC: boolean;
  39106. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39107. REFLECTIONMAP_PROJECTION: boolean;
  39108. REFLECTIONMAP_SKYBOX: boolean;
  39109. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39110. REFLECTIONMAP_EXPLICIT: boolean;
  39111. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39112. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39113. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39114. INVERTCUBICMAP: boolean;
  39115. LOGARITHMICDEPTH: boolean;
  39116. REFRACTION: boolean;
  39117. REFRACTIONMAP_3D: boolean;
  39118. REFLECTIONOVERALPHA: boolean;
  39119. TWOSIDEDLIGHTING: boolean;
  39120. SHADOWFLOAT: boolean;
  39121. MORPHTARGETS: boolean;
  39122. MORPHTARGETS_NORMAL: boolean;
  39123. MORPHTARGETS_TANGENT: boolean;
  39124. MORPHTARGETS_UV: boolean;
  39125. NUM_MORPH_INFLUENCERS: number;
  39126. NONUNIFORMSCALING: boolean;
  39127. PREMULTIPLYALPHA: boolean;
  39128. IMAGEPROCESSING: boolean;
  39129. VIGNETTE: boolean;
  39130. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39131. VIGNETTEBLENDMODEOPAQUE: boolean;
  39132. TONEMAPPING: boolean;
  39133. TONEMAPPING_ACES: boolean;
  39134. CONTRAST: boolean;
  39135. COLORCURVES: boolean;
  39136. COLORGRADING: boolean;
  39137. COLORGRADING3D: boolean;
  39138. SAMPLER3DGREENDEPTH: boolean;
  39139. SAMPLER3DBGRMAP: boolean;
  39140. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39141. MULTIVIEW: boolean;
  39142. /**
  39143. * If the reflection texture on this material is in linear color space
  39144. * @hidden
  39145. */
  39146. IS_REFLECTION_LINEAR: boolean;
  39147. /**
  39148. * If the refraction texture on this material is in linear color space
  39149. * @hidden
  39150. */
  39151. IS_REFRACTION_LINEAR: boolean;
  39152. EXPOSURE: boolean;
  39153. constructor();
  39154. setReflectionMode(modeToEnable: string): void;
  39155. }
  39156. /**
  39157. * This is the default material used in Babylon. It is the best trade off between quality
  39158. * and performances.
  39159. * @see http://doc.babylonjs.com/babylon101/materials
  39160. */
  39161. export class StandardMaterial extends PushMaterial {
  39162. private _diffuseTexture;
  39163. /**
  39164. * The basic texture of the material as viewed under a light.
  39165. */
  39166. diffuseTexture: Nullable<BaseTexture>;
  39167. private _ambientTexture;
  39168. /**
  39169. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39170. */
  39171. ambientTexture: Nullable<BaseTexture>;
  39172. private _opacityTexture;
  39173. /**
  39174. * Define the transparency of the material from a texture.
  39175. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39176. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39177. */
  39178. opacityTexture: Nullable<BaseTexture>;
  39179. private _reflectionTexture;
  39180. /**
  39181. * Define the texture used to display the reflection.
  39182. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39183. */
  39184. reflectionTexture: Nullable<BaseTexture>;
  39185. private _emissiveTexture;
  39186. /**
  39187. * Define texture of the material as if self lit.
  39188. * This will be mixed in the final result even in the absence of light.
  39189. */
  39190. emissiveTexture: Nullable<BaseTexture>;
  39191. private _specularTexture;
  39192. /**
  39193. * Define how the color and intensity of the highlight given by the light in the material.
  39194. */
  39195. specularTexture: Nullable<BaseTexture>;
  39196. private _bumpTexture;
  39197. /**
  39198. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39199. * 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.
  39200. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39201. */
  39202. bumpTexture: Nullable<BaseTexture>;
  39203. private _lightmapTexture;
  39204. /**
  39205. * Complex lighting can be computationally expensive to compute at runtime.
  39206. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39207. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39208. */
  39209. lightmapTexture: Nullable<BaseTexture>;
  39210. private _refractionTexture;
  39211. /**
  39212. * Define the texture used to display the refraction.
  39213. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39214. */
  39215. refractionTexture: Nullable<BaseTexture>;
  39216. /**
  39217. * The color of the material lit by the environmental background lighting.
  39218. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39219. */
  39220. ambientColor: Color3;
  39221. /**
  39222. * The basic color of the material as viewed under a light.
  39223. */
  39224. diffuseColor: Color3;
  39225. /**
  39226. * Define how the color and intensity of the highlight given by the light in the material.
  39227. */
  39228. specularColor: Color3;
  39229. /**
  39230. * Define the color of the material as if self lit.
  39231. * This will be mixed in the final result even in the absence of light.
  39232. */
  39233. emissiveColor: Color3;
  39234. /**
  39235. * Defines how sharp are the highlights in the material.
  39236. * The bigger the value the sharper giving a more glossy feeling to the result.
  39237. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39238. */
  39239. specularPower: number;
  39240. private _useAlphaFromDiffuseTexture;
  39241. /**
  39242. * Does the transparency come from the diffuse texture alpha channel.
  39243. */
  39244. useAlphaFromDiffuseTexture: boolean;
  39245. private _useEmissiveAsIllumination;
  39246. /**
  39247. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39248. */
  39249. useEmissiveAsIllumination: boolean;
  39250. private _linkEmissiveWithDiffuse;
  39251. /**
  39252. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39253. * the emissive level when the final color is close to one.
  39254. */
  39255. linkEmissiveWithDiffuse: boolean;
  39256. private _useSpecularOverAlpha;
  39257. /**
  39258. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39259. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39260. */
  39261. useSpecularOverAlpha: boolean;
  39262. private _useReflectionOverAlpha;
  39263. /**
  39264. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39265. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39266. */
  39267. useReflectionOverAlpha: boolean;
  39268. private _disableLighting;
  39269. /**
  39270. * Does lights from the scene impacts this material.
  39271. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39272. */
  39273. disableLighting: boolean;
  39274. private _useObjectSpaceNormalMap;
  39275. /**
  39276. * Allows using an object space normal map (instead of tangent space).
  39277. */
  39278. useObjectSpaceNormalMap: boolean;
  39279. private _useParallax;
  39280. /**
  39281. * Is parallax enabled or not.
  39282. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39283. */
  39284. useParallax: boolean;
  39285. private _useParallaxOcclusion;
  39286. /**
  39287. * Is parallax occlusion enabled or not.
  39288. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39289. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39290. */
  39291. useParallaxOcclusion: boolean;
  39292. /**
  39293. * 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.
  39294. */
  39295. parallaxScaleBias: number;
  39296. private _roughness;
  39297. /**
  39298. * Helps to define how blurry the reflections should appears in the material.
  39299. */
  39300. roughness: number;
  39301. /**
  39302. * In case of refraction, define the value of the index of refraction.
  39303. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39304. */
  39305. indexOfRefraction: number;
  39306. /**
  39307. * Invert the refraction texture alongside the y axis.
  39308. * It can be useful with procedural textures or probe for instance.
  39309. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39310. */
  39311. invertRefractionY: boolean;
  39312. /**
  39313. * Defines the alpha limits in alpha test mode.
  39314. */
  39315. alphaCutOff: number;
  39316. private _useLightmapAsShadowmap;
  39317. /**
  39318. * In case of light mapping, define whether the map contains light or shadow informations.
  39319. */
  39320. useLightmapAsShadowmap: boolean;
  39321. private _diffuseFresnelParameters;
  39322. /**
  39323. * Define the diffuse fresnel parameters of the material.
  39324. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39325. */
  39326. diffuseFresnelParameters: FresnelParameters;
  39327. private _opacityFresnelParameters;
  39328. /**
  39329. * Define the opacity fresnel parameters of the material.
  39330. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39331. */
  39332. opacityFresnelParameters: FresnelParameters;
  39333. private _reflectionFresnelParameters;
  39334. /**
  39335. * Define the reflection fresnel parameters of the material.
  39336. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39337. */
  39338. reflectionFresnelParameters: FresnelParameters;
  39339. private _refractionFresnelParameters;
  39340. /**
  39341. * Define the refraction fresnel parameters of the material.
  39342. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39343. */
  39344. refractionFresnelParameters: FresnelParameters;
  39345. private _emissiveFresnelParameters;
  39346. /**
  39347. * Define the emissive fresnel parameters of the material.
  39348. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39349. */
  39350. emissiveFresnelParameters: FresnelParameters;
  39351. private _useReflectionFresnelFromSpecular;
  39352. /**
  39353. * If true automatically deducts the fresnels values from the material specularity.
  39354. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39355. */
  39356. useReflectionFresnelFromSpecular: boolean;
  39357. private _useGlossinessFromSpecularMapAlpha;
  39358. /**
  39359. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39360. */
  39361. useGlossinessFromSpecularMapAlpha: boolean;
  39362. private _maxSimultaneousLights;
  39363. /**
  39364. * Defines the maximum number of lights that can be used in the material
  39365. */
  39366. maxSimultaneousLights: number;
  39367. private _invertNormalMapX;
  39368. /**
  39369. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39370. */
  39371. invertNormalMapX: boolean;
  39372. private _invertNormalMapY;
  39373. /**
  39374. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39375. */
  39376. invertNormalMapY: boolean;
  39377. private _twoSidedLighting;
  39378. /**
  39379. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39380. */
  39381. twoSidedLighting: boolean;
  39382. /**
  39383. * Default configuration related to image processing available in the standard Material.
  39384. */
  39385. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39386. /**
  39387. * Gets the image processing configuration used either in this material.
  39388. */
  39389. /**
  39390. * Sets the Default image processing configuration used either in the this material.
  39391. *
  39392. * If sets to null, the scene one is in use.
  39393. */
  39394. imageProcessingConfiguration: ImageProcessingConfiguration;
  39395. /**
  39396. * Keep track of the image processing observer to allow dispose and replace.
  39397. */
  39398. private _imageProcessingObserver;
  39399. /**
  39400. * Attaches a new image processing configuration to the Standard Material.
  39401. * @param configuration
  39402. */
  39403. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39404. /**
  39405. * Gets wether the color curves effect is enabled.
  39406. */
  39407. /**
  39408. * Sets wether the color curves effect is enabled.
  39409. */
  39410. cameraColorCurvesEnabled: boolean;
  39411. /**
  39412. * Gets wether the color grading effect is enabled.
  39413. */
  39414. /**
  39415. * Gets wether the color grading effect is enabled.
  39416. */
  39417. cameraColorGradingEnabled: boolean;
  39418. /**
  39419. * Gets wether tonemapping is enabled or not.
  39420. */
  39421. /**
  39422. * Sets wether tonemapping is enabled or not
  39423. */
  39424. cameraToneMappingEnabled: boolean;
  39425. /**
  39426. * The camera exposure used on this material.
  39427. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39428. * This corresponds to a photographic exposure.
  39429. */
  39430. /**
  39431. * The camera exposure used on this material.
  39432. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39433. * This corresponds to a photographic exposure.
  39434. */
  39435. cameraExposure: number;
  39436. /**
  39437. * Gets The camera contrast used on this material.
  39438. */
  39439. /**
  39440. * Sets The camera contrast used on this material.
  39441. */
  39442. cameraContrast: number;
  39443. /**
  39444. * Gets the Color Grading 2D Lookup Texture.
  39445. */
  39446. /**
  39447. * Sets the Color Grading 2D Lookup Texture.
  39448. */
  39449. cameraColorGradingTexture: Nullable<BaseTexture>;
  39450. /**
  39451. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39452. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39453. * 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;
  39454. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39455. */
  39456. /**
  39457. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39458. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39459. * 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;
  39460. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39461. */
  39462. cameraColorCurves: Nullable<ColorCurves>;
  39463. /**
  39464. * Custom callback helping to override the default shader used in the material.
  39465. */
  39466. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39467. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39468. protected _worldViewProjectionMatrix: Matrix;
  39469. protected _globalAmbientColor: Color3;
  39470. protected _useLogarithmicDepth: boolean;
  39471. /**
  39472. * Instantiates a new standard material.
  39473. * This is the default material used in Babylon. It is the best trade off between quality
  39474. * and performances.
  39475. * @see http://doc.babylonjs.com/babylon101/materials
  39476. * @param name Define the name of the material in the scene
  39477. * @param scene Define the scene the material belong to
  39478. */
  39479. constructor(name: string, scene: Scene);
  39480. /**
  39481. * Gets a boolean indicating that current material needs to register RTT
  39482. */
  39483. readonly hasRenderTargetTextures: boolean;
  39484. /**
  39485. * Gets the current class name of the material e.g. "StandardMaterial"
  39486. * Mainly use in serialization.
  39487. * @returns the class name
  39488. */
  39489. getClassName(): string;
  39490. /**
  39491. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39492. * You can try switching to logarithmic depth.
  39493. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39494. */
  39495. useLogarithmicDepth: boolean;
  39496. /**
  39497. * Specifies if the material will require alpha blending
  39498. * @returns a boolean specifying if alpha blending is needed
  39499. */
  39500. needAlphaBlending(): boolean;
  39501. /**
  39502. * Specifies if this material should be rendered in alpha test mode
  39503. * @returns a boolean specifying if an alpha test is needed.
  39504. */
  39505. needAlphaTesting(): boolean;
  39506. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39507. /**
  39508. * Get the texture used for alpha test purpose.
  39509. * @returns the diffuse texture in case of the standard material.
  39510. */
  39511. getAlphaTestTexture(): Nullable<BaseTexture>;
  39512. /**
  39513. * Get if the submesh is ready to be used and all its information available.
  39514. * Child classes can use it to update shaders
  39515. * @param mesh defines the mesh to check
  39516. * @param subMesh defines which submesh to check
  39517. * @param useInstances specifies that instances should be used
  39518. * @returns a boolean indicating that the submesh is ready or not
  39519. */
  39520. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39521. /**
  39522. * Builds the material UBO layouts.
  39523. * Used internally during the effect preparation.
  39524. */
  39525. buildUniformLayout(): void;
  39526. /**
  39527. * Unbinds the material from the mesh
  39528. */
  39529. unbind(): void;
  39530. /**
  39531. * Binds the submesh to this material by preparing the effect and shader to draw
  39532. * @param world defines the world transformation matrix
  39533. * @param mesh defines the mesh containing the submesh
  39534. * @param subMesh defines the submesh to bind the material to
  39535. */
  39536. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39537. /**
  39538. * Get the list of animatables in the material.
  39539. * @returns the list of animatables object used in the material
  39540. */
  39541. getAnimatables(): IAnimatable[];
  39542. /**
  39543. * Gets the active textures from the material
  39544. * @returns an array of textures
  39545. */
  39546. getActiveTextures(): BaseTexture[];
  39547. /**
  39548. * Specifies if the material uses a texture
  39549. * @param texture defines the texture to check against the material
  39550. * @returns a boolean specifying if the material uses the texture
  39551. */
  39552. hasTexture(texture: BaseTexture): boolean;
  39553. /**
  39554. * Disposes the material
  39555. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39556. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39557. */
  39558. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39559. /**
  39560. * Makes a duplicate of the material, and gives it a new name
  39561. * @param name defines the new name for the duplicated material
  39562. * @returns the cloned material
  39563. */
  39564. clone(name: string): StandardMaterial;
  39565. /**
  39566. * Serializes this material in a JSON representation
  39567. * @returns the serialized material object
  39568. */
  39569. serialize(): any;
  39570. /**
  39571. * Creates a standard material from parsed material data
  39572. * @param source defines the JSON representation of the material
  39573. * @param scene defines the hosting scene
  39574. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39575. * @returns a new standard material
  39576. */
  39577. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39578. /**
  39579. * Are diffuse textures enabled in the application.
  39580. */
  39581. static DiffuseTextureEnabled: boolean;
  39582. /**
  39583. * Are ambient textures enabled in the application.
  39584. */
  39585. static AmbientTextureEnabled: boolean;
  39586. /**
  39587. * Are opacity textures enabled in the application.
  39588. */
  39589. static OpacityTextureEnabled: boolean;
  39590. /**
  39591. * Are reflection textures enabled in the application.
  39592. */
  39593. static ReflectionTextureEnabled: boolean;
  39594. /**
  39595. * Are emissive textures enabled in the application.
  39596. */
  39597. static EmissiveTextureEnabled: boolean;
  39598. /**
  39599. * Are specular textures enabled in the application.
  39600. */
  39601. static SpecularTextureEnabled: boolean;
  39602. /**
  39603. * Are bump textures enabled in the application.
  39604. */
  39605. static BumpTextureEnabled: boolean;
  39606. /**
  39607. * Are lightmap textures enabled in the application.
  39608. */
  39609. static LightmapTextureEnabled: boolean;
  39610. /**
  39611. * Are refraction textures enabled in the application.
  39612. */
  39613. static RefractionTextureEnabled: boolean;
  39614. /**
  39615. * Are color grading textures enabled in the application.
  39616. */
  39617. static ColorGradingTextureEnabled: boolean;
  39618. /**
  39619. * Are fresnels enabled in the application.
  39620. */
  39621. static FresnelEnabled: boolean;
  39622. }
  39623. }
  39624. declare module BABYLON {
  39625. /**
  39626. * A class extending Texture allowing drawing on a texture
  39627. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39628. */
  39629. export class DynamicTexture extends Texture {
  39630. private _generateMipMaps;
  39631. private _canvas;
  39632. private _context;
  39633. private _engine;
  39634. /**
  39635. * Creates a DynamicTexture
  39636. * @param name defines the name of the texture
  39637. * @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
  39638. * @param scene defines the scene where you want the texture
  39639. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39640. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39641. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39642. */
  39643. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39644. /**
  39645. * Get the current class name of the texture useful for serialization or dynamic coding.
  39646. * @returns "DynamicTexture"
  39647. */
  39648. getClassName(): string;
  39649. /**
  39650. * Gets the current state of canRescale
  39651. */
  39652. readonly canRescale: boolean;
  39653. private _recreate;
  39654. /**
  39655. * Scales the texture
  39656. * @param ratio the scale factor to apply to both width and height
  39657. */
  39658. scale(ratio: number): void;
  39659. /**
  39660. * Resizes the texture
  39661. * @param width the new width
  39662. * @param height the new height
  39663. */
  39664. scaleTo(width: number, height: number): void;
  39665. /**
  39666. * Gets the context of the canvas used by the texture
  39667. * @returns the canvas context of the dynamic texture
  39668. */
  39669. getContext(): CanvasRenderingContext2D;
  39670. /**
  39671. * Clears the texture
  39672. */
  39673. clear(): void;
  39674. /**
  39675. * Updates the texture
  39676. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39677. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39678. */
  39679. update(invertY?: boolean, premulAlpha?: boolean): void;
  39680. /**
  39681. * Draws text onto the texture
  39682. * @param text defines the text to be drawn
  39683. * @param x defines the placement of the text from the left
  39684. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39685. * @param font defines the font to be used with font-style, font-size, font-name
  39686. * @param color defines the color used for the text
  39687. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39688. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39689. * @param update defines whether texture is immediately update (default is true)
  39690. */
  39691. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39692. /**
  39693. * Clones the texture
  39694. * @returns the clone of the texture.
  39695. */
  39696. clone(): DynamicTexture;
  39697. /**
  39698. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39699. * @returns a serialized dynamic texture object
  39700. */
  39701. serialize(): any;
  39702. /** @hidden */ private _rebuild(): void;
  39703. }
  39704. }
  39705. declare module BABYLON {
  39706. /** @hidden */
  39707. export var imageProcessingPixelShader: {
  39708. name: string;
  39709. shader: string;
  39710. };
  39711. }
  39712. declare module BABYLON {
  39713. /**
  39714. * ImageProcessingPostProcess
  39715. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39716. */
  39717. export class ImageProcessingPostProcess extends PostProcess {
  39718. /**
  39719. * Default configuration related to image processing available in the PBR Material.
  39720. */
  39721. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39722. /**
  39723. * Gets the image processing configuration used either in this material.
  39724. */
  39725. /**
  39726. * Sets the Default image processing configuration used either in the this material.
  39727. *
  39728. * If sets to null, the scene one is in use.
  39729. */
  39730. imageProcessingConfiguration: ImageProcessingConfiguration;
  39731. /**
  39732. * Keep track of the image processing observer to allow dispose and replace.
  39733. */
  39734. private _imageProcessingObserver;
  39735. /**
  39736. * Attaches a new image processing configuration to the PBR Material.
  39737. * @param configuration
  39738. */
  39739. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39740. /**
  39741. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39742. */
  39743. /**
  39744. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39745. */
  39746. colorCurves: Nullable<ColorCurves>;
  39747. /**
  39748. * Gets wether the color curves effect is enabled.
  39749. */
  39750. /**
  39751. * Sets wether the color curves effect is enabled.
  39752. */
  39753. colorCurvesEnabled: boolean;
  39754. /**
  39755. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39756. */
  39757. /**
  39758. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39759. */
  39760. colorGradingTexture: Nullable<BaseTexture>;
  39761. /**
  39762. * Gets wether the color grading effect is enabled.
  39763. */
  39764. /**
  39765. * Gets wether the color grading effect is enabled.
  39766. */
  39767. colorGradingEnabled: boolean;
  39768. /**
  39769. * Gets exposure used in the effect.
  39770. */
  39771. /**
  39772. * Sets exposure used in the effect.
  39773. */
  39774. exposure: number;
  39775. /**
  39776. * Gets wether tonemapping is enabled or not.
  39777. */
  39778. /**
  39779. * Sets wether tonemapping is enabled or not
  39780. */
  39781. toneMappingEnabled: boolean;
  39782. /**
  39783. * Gets the type of tone mapping effect.
  39784. */
  39785. /**
  39786. * Sets the type of tone mapping effect.
  39787. */
  39788. toneMappingType: number;
  39789. /**
  39790. * Gets contrast used in the effect.
  39791. */
  39792. /**
  39793. * Sets contrast used in the effect.
  39794. */
  39795. contrast: number;
  39796. /**
  39797. * Gets Vignette stretch size.
  39798. */
  39799. /**
  39800. * Sets Vignette stretch size.
  39801. */
  39802. vignetteStretch: number;
  39803. /**
  39804. * Gets Vignette centre X Offset.
  39805. */
  39806. /**
  39807. * Sets Vignette centre X Offset.
  39808. */
  39809. vignetteCentreX: number;
  39810. /**
  39811. * Gets Vignette centre Y Offset.
  39812. */
  39813. /**
  39814. * Sets Vignette centre Y Offset.
  39815. */
  39816. vignetteCentreY: number;
  39817. /**
  39818. * Gets Vignette weight or intensity of the vignette effect.
  39819. */
  39820. /**
  39821. * Sets Vignette weight or intensity of the vignette effect.
  39822. */
  39823. vignetteWeight: number;
  39824. /**
  39825. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39826. * if vignetteEnabled is set to true.
  39827. */
  39828. /**
  39829. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39830. * if vignetteEnabled is set to true.
  39831. */
  39832. vignetteColor: Color4;
  39833. /**
  39834. * Gets Camera field of view used by the Vignette effect.
  39835. */
  39836. /**
  39837. * Sets Camera field of view used by the Vignette effect.
  39838. */
  39839. vignetteCameraFov: number;
  39840. /**
  39841. * Gets the vignette blend mode allowing different kind of effect.
  39842. */
  39843. /**
  39844. * Sets the vignette blend mode allowing different kind of effect.
  39845. */
  39846. vignetteBlendMode: number;
  39847. /**
  39848. * Gets wether the vignette effect is enabled.
  39849. */
  39850. /**
  39851. * Sets wether the vignette effect is enabled.
  39852. */
  39853. vignetteEnabled: boolean;
  39854. private _fromLinearSpace;
  39855. /**
  39856. * Gets wether the input of the processing is in Gamma or Linear Space.
  39857. */
  39858. /**
  39859. * Sets wether the input of the processing is in Gamma or Linear Space.
  39860. */
  39861. fromLinearSpace: boolean;
  39862. /**
  39863. * Defines cache preventing GC.
  39864. */
  39865. private _defines;
  39866. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39867. /**
  39868. * "ImageProcessingPostProcess"
  39869. * @returns "ImageProcessingPostProcess"
  39870. */
  39871. getClassName(): string;
  39872. protected _updateParameters(): void;
  39873. dispose(camera?: Camera): void;
  39874. }
  39875. }
  39876. declare module BABYLON {
  39877. /**
  39878. * Class containing static functions to help procedurally build meshes
  39879. */
  39880. export class GroundBuilder {
  39881. /**
  39882. * Creates a ground mesh
  39883. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39884. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39885. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39886. * @param name defines the name of the mesh
  39887. * @param options defines the options used to create the mesh
  39888. * @param scene defines the hosting scene
  39889. * @returns the ground mesh
  39890. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39891. */
  39892. static CreateGround(name: string, options: {
  39893. width?: number;
  39894. height?: number;
  39895. subdivisions?: number;
  39896. subdivisionsX?: number;
  39897. subdivisionsY?: number;
  39898. updatable?: boolean;
  39899. }, scene: any): Mesh;
  39900. /**
  39901. * Creates a tiled ground mesh
  39902. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39903. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39904. * * 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
  39905. * * 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
  39906. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39907. * @param name defines the name of the mesh
  39908. * @param options defines the options used to create the mesh
  39909. * @param scene defines the hosting scene
  39910. * @returns the tiled ground mesh
  39911. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39912. */
  39913. static CreateTiledGround(name: string, options: {
  39914. xmin: number;
  39915. zmin: number;
  39916. xmax: number;
  39917. zmax: number;
  39918. subdivisions?: {
  39919. w: number;
  39920. h: number;
  39921. };
  39922. precision?: {
  39923. w: number;
  39924. h: number;
  39925. };
  39926. updatable?: boolean;
  39927. }, scene?: Nullable<Scene>): Mesh;
  39928. /**
  39929. * Creates a ground mesh from a height map
  39930. * * The parameter `url` sets the URL of the height map image resource.
  39931. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39932. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39933. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39934. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39935. * * 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.
  39936. * * 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).
  39937. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39939. * @param name defines the name of the mesh
  39940. * @param url defines the url to the height map
  39941. * @param options defines the options used to create the mesh
  39942. * @param scene defines the hosting scene
  39943. * @returns the ground mesh
  39944. * @see https://doc.babylonjs.com/babylon101/height_map
  39945. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39946. */
  39947. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39948. width?: number;
  39949. height?: number;
  39950. subdivisions?: number;
  39951. minHeight?: number;
  39952. maxHeight?: number;
  39953. colorFilter?: Color3;
  39954. alphaFilter?: number;
  39955. updatable?: boolean;
  39956. onReady?: (mesh: GroundMesh) => void;
  39957. }, scene?: Nullable<Scene>): GroundMesh;
  39958. }
  39959. }
  39960. declare module BABYLON {
  39961. /**
  39962. * Class containing static functions to help procedurally build meshes
  39963. */
  39964. export class TorusBuilder {
  39965. /**
  39966. * Creates a torus mesh
  39967. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39968. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39969. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39970. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39971. * * 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
  39972. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39973. * @param name defines the name of the mesh
  39974. * @param options defines the options used to create the mesh
  39975. * @param scene defines the hosting scene
  39976. * @returns the torus mesh
  39977. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39978. */
  39979. static CreateTorus(name: string, options: {
  39980. diameter?: number;
  39981. thickness?: number;
  39982. tessellation?: number;
  39983. updatable?: boolean;
  39984. sideOrientation?: number;
  39985. frontUVs?: Vector4;
  39986. backUVs?: Vector4;
  39987. }, scene: any): Mesh;
  39988. }
  39989. }
  39990. declare module BABYLON {
  39991. /**
  39992. * Class containing static functions to help procedurally build meshes
  39993. */
  39994. export class CylinderBuilder {
  39995. /**
  39996. * Creates a cylinder or a cone mesh
  39997. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39998. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39999. * * 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.
  40000. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40001. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40002. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40003. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40004. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  40005. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40006. * * 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).
  40007. * * 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
  40008. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40009. * * 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
  40010. * * 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.
  40011. * * If `enclose` is false, a ring surface is one element.
  40012. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40013. * * 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
  40014. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40015. * * 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
  40016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40017. * @param name defines the name of the mesh
  40018. * @param options defines the options used to create the mesh
  40019. * @param scene defines the hosting scene
  40020. * @returns the cylinder mesh
  40021. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40022. */
  40023. static CreateCylinder(name: string, options: {
  40024. height?: number;
  40025. diameterTop?: number;
  40026. diameterBottom?: number;
  40027. diameter?: number;
  40028. tessellation?: number;
  40029. subdivisions?: number;
  40030. arc?: number;
  40031. faceColors?: Color4[];
  40032. faceUV?: Vector4[];
  40033. updatable?: boolean;
  40034. hasRings?: boolean;
  40035. enclose?: boolean;
  40036. cap?: number;
  40037. sideOrientation?: number;
  40038. frontUVs?: Vector4;
  40039. backUVs?: Vector4;
  40040. }, scene: any): Mesh;
  40041. }
  40042. }
  40043. declare module BABYLON {
  40044. /**
  40045. * Options to modify the vr teleportation behavior.
  40046. */
  40047. export interface VRTeleportationOptions {
  40048. /**
  40049. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40050. */
  40051. floorMeshName?: string;
  40052. /**
  40053. * A list of meshes to be used as the teleportation floor. (default: empty)
  40054. */
  40055. floorMeshes?: Mesh[];
  40056. }
  40057. /**
  40058. * Options to modify the vr experience helper's behavior.
  40059. */
  40060. export interface VRExperienceHelperOptions extends WebVROptions {
  40061. /**
  40062. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40063. */
  40064. createDeviceOrientationCamera?: boolean;
  40065. /**
  40066. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40067. */
  40068. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40069. /**
  40070. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40071. */
  40072. laserToggle?: boolean;
  40073. /**
  40074. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40075. */
  40076. floorMeshes?: Mesh[];
  40077. /**
  40078. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40079. */
  40080. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40081. }
  40082. /**
  40083. * Event containing information after VR has been entered
  40084. */
  40085. export class OnAfterEnteringVRObservableEvent {
  40086. /**
  40087. * If entering vr was successful
  40088. */
  40089. success: boolean;
  40090. }
  40091. /**
  40092. * Helps to quickly add VR support to an existing scene.
  40093. * See http://doc.babylonjs.com/how_to/webvr_helper
  40094. */
  40095. export class VRExperienceHelper {
  40096. /** Options to modify the vr experience helper's behavior. */
  40097. webVROptions: VRExperienceHelperOptions;
  40098. private _scene;
  40099. private _position;
  40100. private _btnVR;
  40101. private _btnVRDisplayed;
  40102. private _webVRsupported;
  40103. private _webVRready;
  40104. private _webVRrequesting;
  40105. private _webVRpresenting;
  40106. private _hasEnteredVR;
  40107. private _fullscreenVRpresenting;
  40108. private _canvas;
  40109. private _webVRCamera;
  40110. private _vrDeviceOrientationCamera;
  40111. private _deviceOrientationCamera;
  40112. private _existingCamera;
  40113. private _onKeyDown;
  40114. private _onVrDisplayPresentChange;
  40115. private _onVRDisplayChanged;
  40116. private _onVRRequestPresentStart;
  40117. private _onVRRequestPresentComplete;
  40118. /**
  40119. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  40120. */
  40121. enableGazeEvenWhenNoPointerLock: boolean;
  40122. /**
  40123. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  40124. */
  40125. exitVROnDoubleTap: boolean;
  40126. /**
  40127. * Observable raised right before entering VR.
  40128. */
  40129. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40130. /**
  40131. * Observable raised when entering VR has completed.
  40132. */
  40133. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40134. /**
  40135. * Observable raised when exiting VR.
  40136. */
  40137. onExitingVRObservable: Observable<VRExperienceHelper>;
  40138. /**
  40139. * Observable raised when controller mesh is loaded.
  40140. */
  40141. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40142. /** Return this.onEnteringVRObservable
  40143. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40144. */
  40145. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40146. /** Return this.onExitingVRObservable
  40147. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40148. */
  40149. readonly onExitingVR: Observable<VRExperienceHelper>;
  40150. /** Return this.onControllerMeshLoadedObservable
  40151. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40152. */
  40153. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40154. private _rayLength;
  40155. private _useCustomVRButton;
  40156. private _teleportationRequested;
  40157. private _teleportActive;
  40158. private _floorMeshName;
  40159. private _floorMeshesCollection;
  40160. private _rotationAllowed;
  40161. private _teleportBackwardsVector;
  40162. private _teleportationTarget;
  40163. private _isDefaultTeleportationTarget;
  40164. private _postProcessMove;
  40165. private _teleportationFillColor;
  40166. private _teleportationBorderColor;
  40167. private _rotationAngle;
  40168. private _haloCenter;
  40169. private _cameraGazer;
  40170. private _padSensibilityUp;
  40171. private _padSensibilityDown;
  40172. private _leftController;
  40173. private _rightController;
  40174. /**
  40175. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40176. */
  40177. onNewMeshSelected: Observable<AbstractMesh>;
  40178. /**
  40179. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  40180. * This observable will provide the mesh and the controller used to select the mesh
  40181. */
  40182. onMeshSelectedWithController: Observable<{
  40183. mesh: AbstractMesh;
  40184. controller: WebVRController;
  40185. }>;
  40186. /**
  40187. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40188. */
  40189. onNewMeshPicked: Observable<PickingInfo>;
  40190. private _circleEase;
  40191. /**
  40192. * Observable raised before camera teleportation
  40193. */
  40194. onBeforeCameraTeleport: Observable<Vector3>;
  40195. /**
  40196. * Observable raised after camera teleportation
  40197. */
  40198. onAfterCameraTeleport: Observable<Vector3>;
  40199. /**
  40200. * Observable raised when current selected mesh gets unselected
  40201. */
  40202. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40203. private _raySelectionPredicate;
  40204. /**
  40205. * To be optionaly changed by user to define custom ray selection
  40206. */
  40207. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40208. /**
  40209. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40210. */
  40211. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40212. /**
  40213. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40214. */
  40215. teleportationEnabled: boolean;
  40216. private _defaultHeight;
  40217. private _teleportationInitialized;
  40218. private _interactionsEnabled;
  40219. private _interactionsRequested;
  40220. private _displayGaze;
  40221. private _displayLaserPointer;
  40222. /**
  40223. * The mesh used to display where the user is going to teleport.
  40224. */
  40225. /**
  40226. * Sets the mesh to be used to display where the user is going to teleport.
  40227. */
  40228. teleportationTarget: Mesh;
  40229. /**
  40230. * 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
  40231. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40232. * See http://doc.babylonjs.com/resources/baking_transformations
  40233. */
  40234. gazeTrackerMesh: Mesh;
  40235. /**
  40236. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40237. */
  40238. updateGazeTrackerScale: boolean;
  40239. /**
  40240. * If the gaze trackers color should be updated when selecting meshes
  40241. */
  40242. updateGazeTrackerColor: boolean;
  40243. /**
  40244. * The gaze tracking mesh corresponding to the left controller
  40245. */
  40246. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40247. /**
  40248. * The gaze tracking mesh corresponding to the right controller
  40249. */
  40250. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40251. /**
  40252. * If the ray of the gaze should be displayed.
  40253. */
  40254. /**
  40255. * Sets if the ray of the gaze should be displayed.
  40256. */
  40257. displayGaze: boolean;
  40258. /**
  40259. * If the ray of the LaserPointer should be displayed.
  40260. */
  40261. /**
  40262. * Sets if the ray of the LaserPointer should be displayed.
  40263. */
  40264. displayLaserPointer: boolean;
  40265. /**
  40266. * The deviceOrientationCamera used as the camera when not in VR.
  40267. */
  40268. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40269. /**
  40270. * Based on the current WebVR support, returns the current VR camera used.
  40271. */
  40272. readonly currentVRCamera: Nullable<Camera>;
  40273. /**
  40274. * The webVRCamera which is used when in VR.
  40275. */
  40276. readonly webVRCamera: WebVRFreeCamera;
  40277. /**
  40278. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40279. */
  40280. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40281. /**
  40282. * The html button that is used to trigger entering into VR.
  40283. */
  40284. readonly vrButton: Nullable<HTMLButtonElement>;
  40285. private readonly _teleportationRequestInitiated;
  40286. /**
  40287. * Defines wether or not Pointer lock should be requested when switching to
  40288. * full screen.
  40289. */
  40290. requestPointerLockOnFullScreen: boolean;
  40291. /**
  40292. * Instantiates a VRExperienceHelper.
  40293. * Helps to quickly add VR support to an existing scene.
  40294. * @param scene The scene the VRExperienceHelper belongs to.
  40295. * @param webVROptions Options to modify the vr experience helper's behavior.
  40296. */
  40297. constructor(scene: Scene,
  40298. /** Options to modify the vr experience helper's behavior. */
  40299. webVROptions?: VRExperienceHelperOptions);
  40300. private _onDefaultMeshLoaded;
  40301. private _onResize;
  40302. private _onFullscreenChange;
  40303. /**
  40304. * Gets a value indicating if we are currently in VR mode.
  40305. */
  40306. readonly isInVRMode: boolean;
  40307. private onVrDisplayPresentChange;
  40308. private onVRDisplayChanged;
  40309. private moveButtonToBottomRight;
  40310. private displayVRButton;
  40311. private updateButtonVisibility;
  40312. private _cachedAngularSensibility;
  40313. /**
  40314. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40315. * Otherwise, will use the fullscreen API.
  40316. */
  40317. enterVR(): void;
  40318. /**
  40319. * Attempt to exit VR, or fullscreen.
  40320. */
  40321. exitVR(): void;
  40322. /**
  40323. * The position of the vr experience helper.
  40324. */
  40325. /**
  40326. * Sets the position of the vr experience helper.
  40327. */
  40328. position: Vector3;
  40329. /**
  40330. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40331. */
  40332. enableInteractions(): void;
  40333. private readonly _noControllerIsActive;
  40334. private beforeRender;
  40335. private _isTeleportationFloor;
  40336. /**
  40337. * Adds a floor mesh to be used for teleportation.
  40338. * @param floorMesh the mesh to be used for teleportation.
  40339. */
  40340. addFloorMesh(floorMesh: Mesh): void;
  40341. /**
  40342. * Removes a floor mesh from being used for teleportation.
  40343. * @param floorMesh the mesh to be removed.
  40344. */
  40345. removeFloorMesh(floorMesh: Mesh): void;
  40346. /**
  40347. * Enables interactions and teleportation using the VR controllers and gaze.
  40348. * @param vrTeleportationOptions options to modify teleportation behavior.
  40349. */
  40350. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40351. private _onNewGamepadConnected;
  40352. private _tryEnableInteractionOnController;
  40353. private _onNewGamepadDisconnected;
  40354. private _enableInteractionOnController;
  40355. private _checkTeleportWithRay;
  40356. private _checkRotate;
  40357. private _checkTeleportBackwards;
  40358. private _enableTeleportationOnController;
  40359. private _createTeleportationCircles;
  40360. private _displayTeleportationTarget;
  40361. private _hideTeleportationTarget;
  40362. private _rotateCamera;
  40363. private _moveTeleportationSelectorTo;
  40364. private _workingVector;
  40365. private _workingQuaternion;
  40366. private _workingMatrix;
  40367. /**
  40368. * Teleports the users feet to the desired location
  40369. * @param location The location where the user's feet should be placed
  40370. */
  40371. teleportCamera(location: Vector3): void;
  40372. private _convertNormalToDirectionOfRay;
  40373. private _castRayAndSelectObject;
  40374. private _notifySelectedMeshUnselected;
  40375. /**
  40376. * Sets the color of the laser ray from the vr controllers.
  40377. * @param color new color for the ray.
  40378. */
  40379. changeLaserColor(color: Color3): void;
  40380. /**
  40381. * Sets the color of the ray from the vr headsets gaze.
  40382. * @param color new color for the ray.
  40383. */
  40384. changeGazeColor(color: Color3): void;
  40385. /**
  40386. * Exits VR and disposes of the vr experience helper
  40387. */
  40388. dispose(): void;
  40389. /**
  40390. * Gets the name of the VRExperienceHelper class
  40391. * @returns "VRExperienceHelper"
  40392. */
  40393. getClassName(): string;
  40394. }
  40395. }
  40396. declare module BABYLON {
  40397. /**
  40398. * Manages an XRSession to work with Babylon's engine
  40399. * @see https://doc.babylonjs.com/how_to/webxr
  40400. */
  40401. export class WebXRSessionManager implements IDisposable {
  40402. private scene;
  40403. /**
  40404. * Fires every time a new xrFrame arrives which can be used to update the camera
  40405. */
  40406. onXRFrameObservable: Observable<any>;
  40407. /**
  40408. * Fires when the xr session is ended either by the device or manually done
  40409. */
  40410. onXRSessionEnded: Observable<any>;
  40411. /**
  40412. * Underlying xr session
  40413. */
  40414. session: XRSession;
  40415. /**
  40416. * Type of reference space used when creating the session
  40417. */
  40418. referenceSpace: XRReferenceSpace;
  40419. /** @hidden */ private _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40420. /**
  40421. * Current XR frame
  40422. */
  40423. currentFrame: Nullable<XRFrame>;
  40424. private _xrNavigator;
  40425. private baseLayer;
  40426. /**
  40427. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40428. * @param scene The scene which the session should be created for
  40429. */
  40430. constructor(scene: Scene);
  40431. /**
  40432. * Initializes the manager
  40433. * After initialization enterXR can be called to start an XR session
  40434. * @returns Promise which resolves after it is initialized
  40435. */
  40436. initializeAsync(): Promise<void>;
  40437. /**
  40438. * Initializes an xr session
  40439. * @param xrSessionMode mode to initialize
  40440. * @returns a promise which will resolve once the session has been initialized
  40441. */
  40442. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  40443. /**
  40444. * Sets the reference space on the xr session
  40445. * @param referenceSpace space to set
  40446. * @returns a promise that will resolve once the reference space has been set
  40447. */
  40448. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  40449. /**
  40450. * Updates the render state of the session
  40451. * @param state state to set
  40452. * @returns a promise that resolves once the render state has been updated
  40453. */
  40454. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  40455. /**
  40456. * Starts rendering to the xr layer
  40457. * @returns a promise that will resolve once rendering has started
  40458. */
  40459. startRenderingToXRAsync(): Promise<void>;
  40460. /**
  40461. * Stops the xrSession and restores the renderloop
  40462. * @returns Promise which resolves after it exits XR
  40463. */
  40464. exitXRAsync(): Promise<unknown>;
  40465. /**
  40466. * Checks if a session would be supported for the creation options specified
  40467. * @param sessionMode session mode to check if supported eg. immersive-vr
  40468. * @returns true if supported
  40469. */
  40470. supportsSessionAsync(sessionMode: XRSessionMode): any;
  40471. /**
  40472. * @hidden
  40473. * Converts the render layer of xrSession to a render target
  40474. * @param session session to create render target for
  40475. * @param scene scene the new render target should be created for
  40476. */ private static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  40477. /**
  40478. * Disposes of the session manager
  40479. */
  40480. dispose(): void;
  40481. }
  40482. }
  40483. declare module BABYLON {
  40484. /**
  40485. * WebXR Camera which holds the views for the xrSession
  40486. * @see https://doc.babylonjs.com/how_to/webxr
  40487. */
  40488. export class WebXRCamera extends FreeCamera {
  40489. private static _TmpMatrix;
  40490. /**
  40491. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40492. * @param name the name of the camera
  40493. * @param scene the scene to add the camera to
  40494. */
  40495. constructor(name: string, scene: Scene);
  40496. private _updateNumberOfRigCameras;
  40497. /** @hidden */ private _updateForDualEyeDebugging(pupilDistance?: number): void;
  40498. /**
  40499. * Updates the cameras position from the current pose information of the XR session
  40500. * @param xrSessionManager the session containing pose information
  40501. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40502. */
  40503. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40504. }
  40505. }
  40506. declare module BABYLON {
  40507. /**
  40508. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40509. */
  40510. export class WebXRManagedOutputCanvas implements IDisposable {
  40511. private helper;
  40512. private _canvas;
  40513. /**
  40514. * xrpresent context of the canvas which can be used to display/mirror xr content
  40515. */
  40516. canvasContext: WebGLRenderingContext;
  40517. /**
  40518. * xr layer for the canvas
  40519. */
  40520. xrLayer: Nullable<XRWebGLLayer>;
  40521. /**
  40522. * Initializes the xr layer for the session
  40523. * @param xrSession xr session
  40524. * @returns a promise that will resolve once the XR Layer has been created
  40525. */
  40526. initializeXRLayerAsync(xrSession: any): any;
  40527. /**
  40528. * Initializes the canvas to be added/removed upon entering/exiting xr
  40529. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40530. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40531. */
  40532. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40533. /**
  40534. * Disposes of the object
  40535. */
  40536. dispose(): void;
  40537. private _setManagedOutputCanvas;
  40538. private _addCanvas;
  40539. private _removeCanvas;
  40540. }
  40541. }
  40542. declare module BABYLON {
  40543. /**
  40544. * States of the webXR experience
  40545. */
  40546. export enum WebXRState {
  40547. /**
  40548. * Transitioning to being in XR mode
  40549. */
  40550. ENTERING_XR = 0,
  40551. /**
  40552. * Transitioning to non XR mode
  40553. */
  40554. EXITING_XR = 1,
  40555. /**
  40556. * In XR mode and presenting
  40557. */
  40558. IN_XR = 2,
  40559. /**
  40560. * Not entered XR mode
  40561. */
  40562. NOT_IN_XR = 3
  40563. }
  40564. /**
  40565. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  40566. * @see https://doc.babylonjs.com/how_to/webxr
  40567. */
  40568. export class WebXRExperienceHelper implements IDisposable {
  40569. private scene;
  40570. /**
  40571. * 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
  40572. */
  40573. container: AbstractMesh;
  40574. /**
  40575. * Camera used to render xr content
  40576. */
  40577. camera: WebXRCamera;
  40578. /**
  40579. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40580. */
  40581. state: WebXRState;
  40582. private _setState;
  40583. private static _TmpVector;
  40584. /**
  40585. * Fires when the state of the experience helper has changed
  40586. */
  40587. onStateChangedObservable: Observable<WebXRState>;
  40588. /** Session manager used to keep track of xr session */
  40589. sessionManager: WebXRSessionManager;
  40590. private _nonVRCamera;
  40591. private _originalSceneAutoClear;
  40592. private _supported;
  40593. /**
  40594. * Creates the experience helper
  40595. * @param scene the scene to attach the experience helper to
  40596. * @returns a promise for the experience helper
  40597. */
  40598. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40599. /**
  40600. * Creates a WebXRExperienceHelper
  40601. * @param scene The scene the helper should be created in
  40602. */
  40603. private constructor();
  40604. /**
  40605. * Exits XR mode and returns the scene to its original state
  40606. * @returns promise that resolves after xr mode has exited
  40607. */
  40608. exitXRAsync(): Promise<unknown>;
  40609. /**
  40610. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40611. * @param sessionCreationOptions options for the XR session
  40612. * @param referenceSpaceType frame of reference of the XR session
  40613. * @param outputCanvas the output canvas that will be used to enter XR mode
  40614. * @returns promise that resolves after xr mode has entered
  40615. */
  40616. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  40617. /**
  40618. * Updates the global position of the camera by moving the camera's container
  40619. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40620. * @param position The desired global position of the camera
  40621. */
  40622. setPositionOfCameraUsingContainer(position: Vector3): void;
  40623. /**
  40624. * Rotates the xr camera by rotating the camera's container around the camera's position
  40625. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40626. * @param rotation the desired quaternion rotation to apply to the camera
  40627. */
  40628. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40629. /**
  40630. * Disposes of the experience helper
  40631. */
  40632. dispose(): void;
  40633. }
  40634. }
  40635. declare module BABYLON {
  40636. /**
  40637. * Button which can be used to enter a different mode of XR
  40638. */
  40639. export class WebXREnterExitUIButton {
  40640. /** button element */
  40641. element: HTMLElement;
  40642. /** XR initialization options for the button */
  40643. sessionMode: XRSessionMode;
  40644. /** Reference space type */
  40645. referenceSpaceType: XRReferenceSpaceType;
  40646. /**
  40647. * Creates a WebXREnterExitUIButton
  40648. * @param element button element
  40649. * @param sessionMode XR initialization session mode
  40650. * @param referenceSpaceType the type of reference space to be used
  40651. */
  40652. constructor(
  40653. /** button element */
  40654. element: HTMLElement,
  40655. /** XR initialization options for the button */
  40656. sessionMode: XRSessionMode,
  40657. /** Reference space type */
  40658. referenceSpaceType: XRReferenceSpaceType);
  40659. /**
  40660. * Overwritable function which can be used to update the button's visuals when the state changes
  40661. * @param activeButton the current active button in the UI
  40662. */
  40663. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40664. }
  40665. /**
  40666. * Options to create the webXR UI
  40667. */
  40668. export class WebXREnterExitUIOptions {
  40669. /**
  40670. * Context to enter xr with
  40671. */
  40672. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  40673. /**
  40674. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40675. */
  40676. customButtons?: Array<WebXREnterExitUIButton>;
  40677. }
  40678. /**
  40679. * UI to allow the user to enter/exit XR mode
  40680. */
  40681. export class WebXREnterExitUI implements IDisposable {
  40682. private scene;
  40683. private _overlay;
  40684. private _buttons;
  40685. private _activeButton;
  40686. /**
  40687. * Fired every time the active button is changed.
  40688. *
  40689. * When xr is entered via a button that launches xr that button will be the callback parameter
  40690. *
  40691. * When exiting xr the callback parameter will be null)
  40692. */
  40693. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40694. /**
  40695. * Creates UI to allow the user to enter/exit XR mode
  40696. * @param scene the scene to add the ui to
  40697. * @param helper the xr experience helper to enter/exit xr with
  40698. * @param options options to configure the UI
  40699. * @returns the created ui
  40700. */
  40701. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40702. private constructor();
  40703. private _updateButtons;
  40704. /**
  40705. * Disposes of the object
  40706. */
  40707. dispose(): void;
  40708. }
  40709. }
  40710. declare module BABYLON {
  40711. /**
  40712. * Represents an XR input
  40713. */
  40714. export class WebXRController {
  40715. private scene;
  40716. /** The underlying input source for the controller */
  40717. inputSource: XRInputSource;
  40718. private parentContainer;
  40719. /**
  40720. * 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
  40721. */
  40722. grip?: AbstractMesh;
  40723. /**
  40724. * Pointer which can be used to select objects or attach a visible laser to
  40725. */
  40726. pointer: AbstractMesh;
  40727. /**
  40728. * Event that fires when the controller is removed/disposed
  40729. */
  40730. onDisposeObservable: Observable<{}>;
  40731. private _tmpMatrix;
  40732. private _tmpQuaternion;
  40733. private _tmpVector;
  40734. /**
  40735. * Creates the controller
  40736. * @see https://doc.babylonjs.com/how_to/webxr
  40737. * @param scene the scene which the controller should be associated to
  40738. * @param inputSource the underlying input source for the controller
  40739. * @param parentContainer parent that the controller meshes should be children of
  40740. */
  40741. constructor(scene: Scene,
  40742. /** The underlying input source for the controller */
  40743. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  40744. /**
  40745. * Updates the controller pose based on the given XRFrame
  40746. * @param xrFrame xr frame to update the pose with
  40747. * @param referenceSpace reference space to use
  40748. */
  40749. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  40750. /**
  40751. * Gets a world space ray coming from the controller
  40752. * @param result the resulting ray
  40753. */
  40754. getWorldPointerRayToRef(result: Ray): void;
  40755. /**
  40756. * Disposes of the object
  40757. */
  40758. dispose(): void;
  40759. }
  40760. }
  40761. declare module BABYLON {
  40762. /**
  40763. * XR input used to track XR inputs such as controllers/rays
  40764. */
  40765. export class WebXRInput implements IDisposable {
  40766. /**
  40767. * Base experience the input listens to
  40768. */
  40769. baseExperience: WebXRExperienceHelper;
  40770. /**
  40771. * XR controllers being tracked
  40772. */
  40773. controllers: Array<WebXRController>;
  40774. private _frameObserver;
  40775. private _stateObserver;
  40776. /**
  40777. * Event when a controller has been connected/added
  40778. */
  40779. onControllerAddedObservable: Observable<WebXRController>;
  40780. /**
  40781. * Event when a controller has been removed/disconnected
  40782. */
  40783. onControllerRemovedObservable: Observable<WebXRController>;
  40784. /**
  40785. * Initializes the WebXRInput
  40786. * @param baseExperience experience helper which the input should be created for
  40787. */
  40788. constructor(
  40789. /**
  40790. * Base experience the input listens to
  40791. */
  40792. baseExperience: WebXRExperienceHelper);
  40793. private _onInputSourcesChange;
  40794. private _addAndRemoveControllers;
  40795. /**
  40796. * Disposes of the object
  40797. */
  40798. dispose(): void;
  40799. }
  40800. }
  40801. declare module BABYLON {
  40802. /**
  40803. * Enables teleportation
  40804. */
  40805. export class WebXRControllerTeleportation {
  40806. private _teleportationFillColor;
  40807. private _teleportationBorderColor;
  40808. private _tmpRay;
  40809. private _tmpVector;
  40810. /**
  40811. * Creates a WebXRControllerTeleportation
  40812. * @param input input manager to add teleportation to
  40813. * @param floorMeshes floormeshes which can be teleported to
  40814. */
  40815. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  40816. }
  40817. }
  40818. declare module BABYLON {
  40819. /**
  40820. * Handles pointer input automatically for the pointer of XR controllers
  40821. */
  40822. export class WebXRControllerPointerSelection {
  40823. private static _idCounter;
  40824. private _tmpRay;
  40825. /**
  40826. * Creates a WebXRControllerPointerSelection
  40827. * @param input input manager to setup pointer selection
  40828. */
  40829. constructor(input: WebXRInput);
  40830. private _convertNormalToDirectionOfRay;
  40831. private _updatePointerDistance;
  40832. }
  40833. }
  40834. declare module BABYLON {
  40835. /**
  40836. * Class used to represent data loading progression
  40837. */
  40838. export class SceneLoaderProgressEvent {
  40839. /** defines if data length to load can be evaluated */
  40840. readonly lengthComputable: boolean;
  40841. /** defines the loaded data length */
  40842. readonly loaded: number;
  40843. /** defines the data length to load */
  40844. readonly total: number;
  40845. /**
  40846. * Create a new progress event
  40847. * @param lengthComputable defines if data length to load can be evaluated
  40848. * @param loaded defines the loaded data length
  40849. * @param total defines the data length to load
  40850. */
  40851. constructor(
  40852. /** defines if data length to load can be evaluated */
  40853. lengthComputable: boolean,
  40854. /** defines the loaded data length */
  40855. loaded: number,
  40856. /** defines the data length to load */
  40857. total: number);
  40858. /**
  40859. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  40860. * @param event defines the source event
  40861. * @returns a new SceneLoaderProgressEvent
  40862. */
  40863. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  40864. }
  40865. /**
  40866. * Interface used by SceneLoader plugins to define supported file extensions
  40867. */
  40868. export interface ISceneLoaderPluginExtensions {
  40869. /**
  40870. * Defines the list of supported extensions
  40871. */
  40872. [extension: string]: {
  40873. isBinary: boolean;
  40874. };
  40875. }
  40876. /**
  40877. * Interface used by SceneLoader plugin factory
  40878. */
  40879. export interface ISceneLoaderPluginFactory {
  40880. /**
  40881. * Defines the name of the factory
  40882. */
  40883. name: string;
  40884. /**
  40885. * Function called to create a new plugin
  40886. * @return the new plugin
  40887. */
  40888. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  40889. /**
  40890. * Boolean indicating if the plugin can direct load specific data
  40891. */
  40892. canDirectLoad?: (data: string) => boolean;
  40893. }
  40894. /**
  40895. * Interface used to define a SceneLoader plugin
  40896. */
  40897. export interface ISceneLoaderPlugin {
  40898. /**
  40899. * The friendly name of this plugin.
  40900. */
  40901. name: string;
  40902. /**
  40903. * The file extensions supported by this plugin.
  40904. */
  40905. extensions: string | ISceneLoaderPluginExtensions;
  40906. /**
  40907. * Import meshes into a scene.
  40908. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40909. * @param scene The scene to import into
  40910. * @param data The data to import
  40911. * @param rootUrl The root url for scene and resources
  40912. * @param meshes The meshes array to import into
  40913. * @param particleSystems The particle systems array to import into
  40914. * @param skeletons The skeletons array to import into
  40915. * @param onError The callback when import fails
  40916. * @returns True if successful or false otherwise
  40917. */
  40918. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  40919. /**
  40920. * Load into a scene.
  40921. * @param scene The scene to load into
  40922. * @param data The data to import
  40923. * @param rootUrl The root url for scene and resources
  40924. * @param onError The callback when import fails
  40925. * @returns true if successful or false otherwise
  40926. */
  40927. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  40928. /**
  40929. * The callback that returns true if the data can be directly loaded.
  40930. */
  40931. canDirectLoad?: (data: string) => boolean;
  40932. /**
  40933. * The callback that allows custom handling of the root url based on the response url.
  40934. */
  40935. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  40936. /**
  40937. * Load into an asset container.
  40938. * @param scene The scene to load into
  40939. * @param data The data to import
  40940. * @param rootUrl The root url for scene and resources
  40941. * @param onError The callback when import fails
  40942. * @returns The loaded asset container
  40943. */
  40944. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  40945. }
  40946. /**
  40947. * Interface used to define an async SceneLoader plugin
  40948. */
  40949. export interface ISceneLoaderPluginAsync {
  40950. /**
  40951. * The friendly name of this plugin.
  40952. */
  40953. name: string;
  40954. /**
  40955. * The file extensions supported by this plugin.
  40956. */
  40957. extensions: string | ISceneLoaderPluginExtensions;
  40958. /**
  40959. * Import meshes into a scene.
  40960. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40961. * @param scene The scene to import into
  40962. * @param data The data to import
  40963. * @param rootUrl The root url for scene and resources
  40964. * @param onProgress The callback when the load progresses
  40965. * @param fileName Defines the name of the file to load
  40966. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  40967. */
  40968. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  40969. meshes: AbstractMesh[];
  40970. particleSystems: IParticleSystem[];
  40971. skeletons: Skeleton[];
  40972. animationGroups: AnimationGroup[];
  40973. }>;
  40974. /**
  40975. * Load into a scene.
  40976. * @param scene The scene to load into
  40977. * @param data The data to import
  40978. * @param rootUrl The root url for scene and resources
  40979. * @param onProgress The callback when the load progresses
  40980. * @param fileName Defines the name of the file to load
  40981. * @returns Nothing
  40982. */
  40983. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  40984. /**
  40985. * The callback that returns true if the data can be directly loaded.
  40986. */
  40987. canDirectLoad?: (data: string) => boolean;
  40988. /**
  40989. * The callback that allows custom handling of the root url based on the response url.
  40990. */
  40991. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  40992. /**
  40993. * Load into an asset container.
  40994. * @param scene The scene to load into
  40995. * @param data The data to import
  40996. * @param rootUrl The root url for scene and resources
  40997. * @param onProgress The callback when the load progresses
  40998. * @param fileName Defines the name of the file to load
  40999. * @returns The loaded asset container
  41000. */
  41001. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41002. }
  41003. /**
  41004. * Class used to load scene from various file formats using registered plugins
  41005. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41006. */
  41007. export class SceneLoader {
  41008. /**
  41009. * No logging while loading
  41010. */
  41011. static readonly NO_LOGGING: number;
  41012. /**
  41013. * Minimal logging while loading
  41014. */
  41015. static readonly MINIMAL_LOGGING: number;
  41016. /**
  41017. * Summary logging while loading
  41018. */
  41019. static readonly SUMMARY_LOGGING: number;
  41020. /**
  41021. * Detailled logging while loading
  41022. */
  41023. static readonly DETAILED_LOGGING: number;
  41024. /**
  41025. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41026. */
  41027. static ForceFullSceneLoadingForIncremental: boolean;
  41028. /**
  41029. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41030. */
  41031. static ShowLoadingScreen: boolean;
  41032. /**
  41033. * Defines the current logging level (while loading the scene)
  41034. * @ignorenaming
  41035. */
  41036. static loggingLevel: number;
  41037. /**
  41038. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41039. */
  41040. static CleanBoneMatrixWeights: boolean;
  41041. /**
  41042. * Event raised when a plugin is used to load a scene
  41043. */
  41044. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41045. private static _registeredPlugins;
  41046. private static _getDefaultPlugin;
  41047. private static _getPluginForExtension;
  41048. private static _getPluginForDirectLoad;
  41049. private static _getPluginForFilename;
  41050. private static _getDirectLoad;
  41051. private static _loadData;
  41052. private static _getFileInfo;
  41053. /**
  41054. * Gets a plugin that can load the given extension
  41055. * @param extension defines the extension to load
  41056. * @returns a plugin or null if none works
  41057. */
  41058. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41059. /**
  41060. * Gets a boolean indicating that the given extension can be loaded
  41061. * @param extension defines the extension to load
  41062. * @returns true if the extension is supported
  41063. */
  41064. static IsPluginForExtensionAvailable(extension: string): boolean;
  41065. /**
  41066. * Adds a new plugin to the list of registered plugins
  41067. * @param plugin defines the plugin to add
  41068. */
  41069. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41070. /**
  41071. * Import meshes into a scene
  41072. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41073. * @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)
  41074. * @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)
  41075. * @param scene the instance of BABYLON.Scene to append to
  41076. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41077. * @param onProgress a callback with a progress event for each file being loaded
  41078. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41079. * @param pluginExtension the extension used to determine the plugin
  41080. * @returns The loaded plugin
  41081. */
  41082. 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>;
  41083. /**
  41084. * Import meshes into a scene
  41085. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41086. * @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)
  41087. * @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)
  41088. * @param scene the instance of BABYLON.Scene to append to
  41089. * @param onProgress a callback with a progress event for each file being loaded
  41090. * @param pluginExtension the extension used to determine the plugin
  41091. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41092. */
  41093. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41094. meshes: AbstractMesh[];
  41095. particleSystems: IParticleSystem[];
  41096. skeletons: Skeleton[];
  41097. animationGroups: AnimationGroup[];
  41098. }>;
  41099. /**
  41100. * Load a scene
  41101. * @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)
  41102. * @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)
  41103. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41104. * @param onSuccess a callback with the scene when import succeeds
  41105. * @param onProgress a callback with a progress event for each file being loaded
  41106. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41107. * @param pluginExtension the extension used to determine the plugin
  41108. * @returns The loaded plugin
  41109. */
  41110. 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>;
  41111. /**
  41112. * Load a scene
  41113. * @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)
  41114. * @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)
  41115. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41116. * @param onProgress a callback with a progress event for each file being loaded
  41117. * @param pluginExtension the extension used to determine the plugin
  41118. * @returns The loaded scene
  41119. */
  41120. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41121. /**
  41122. * Append a scene
  41123. * @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)
  41124. * @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)
  41125. * @param scene is the instance of BABYLON.Scene to append to
  41126. * @param onSuccess a callback with the scene when import succeeds
  41127. * @param onProgress a callback with a progress event for each file being loaded
  41128. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41129. * @param pluginExtension the extension used to determine the plugin
  41130. * @returns The loaded plugin
  41131. */
  41132. 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>;
  41133. /**
  41134. * Append a scene
  41135. * @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)
  41136. * @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)
  41137. * @param scene is the instance of BABYLON.Scene to append to
  41138. * @param onProgress a callback with a progress event for each file being loaded
  41139. * @param pluginExtension the extension used to determine the plugin
  41140. * @returns The given scene
  41141. */
  41142. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41143. /**
  41144. * Load a scene into an asset container
  41145. * @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)
  41146. * @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)
  41147. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41148. * @param onSuccess a callback with the scene when import succeeds
  41149. * @param onProgress a callback with a progress event for each file being loaded
  41150. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41151. * @param pluginExtension the extension used to determine the plugin
  41152. * @returns The loaded plugin
  41153. */
  41154. 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>;
  41155. /**
  41156. * Load a scene into an asset container
  41157. * @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)
  41158. * @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)
  41159. * @param scene is the instance of Scene to append to
  41160. * @param onProgress a callback with a progress event for each file being loaded
  41161. * @param pluginExtension the extension used to determine the plugin
  41162. * @returns The loaded asset container
  41163. */
  41164. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41165. }
  41166. }
  41167. declare module BABYLON {
  41168. /**
  41169. * Generic Controller
  41170. */
  41171. export class GenericController extends WebVRController {
  41172. /**
  41173. * Base Url for the controller model.
  41174. */
  41175. static readonly MODEL_BASE_URL: string;
  41176. /**
  41177. * File name for the controller model.
  41178. */
  41179. static readonly MODEL_FILENAME: string;
  41180. /**
  41181. * Creates a new GenericController from a gamepad
  41182. * @param vrGamepad the gamepad that the controller should be created from
  41183. */
  41184. constructor(vrGamepad: any);
  41185. /**
  41186. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41187. * @param scene scene in which to add meshes
  41188. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41189. */
  41190. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41191. /**
  41192. * Called once for each button that changed state since the last frame
  41193. * @param buttonIdx Which button index changed
  41194. * @param state New state of the button
  41195. * @param changes Which properties on the state changed since last frame
  41196. */
  41197. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41198. }
  41199. }
  41200. declare module BABYLON {
  41201. /**
  41202. * Defines the WindowsMotionController object that the state of the windows motion controller
  41203. */
  41204. export class WindowsMotionController extends WebVRController {
  41205. /**
  41206. * The base url used to load the left and right controller models
  41207. */
  41208. static MODEL_BASE_URL: string;
  41209. /**
  41210. * The name of the left controller model file
  41211. */
  41212. static MODEL_LEFT_FILENAME: string;
  41213. /**
  41214. * The name of the right controller model file
  41215. */
  41216. static MODEL_RIGHT_FILENAME: string;
  41217. /**
  41218. * The controller name prefix for this controller type
  41219. */
  41220. static readonly GAMEPAD_ID_PREFIX: string;
  41221. /**
  41222. * The controller id pattern for this controller type
  41223. */
  41224. private static readonly GAMEPAD_ID_PATTERN;
  41225. private _loadedMeshInfo;
  41226. private readonly _mapping;
  41227. /**
  41228. * Fired when the trackpad on this controller is clicked
  41229. */
  41230. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41231. /**
  41232. * Fired when the trackpad on this controller is modified
  41233. */
  41234. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41235. /**
  41236. * The current x and y values of this controller's trackpad
  41237. */
  41238. trackpad: StickValues;
  41239. /**
  41240. * Creates a new WindowsMotionController from a gamepad
  41241. * @param vrGamepad the gamepad that the controller should be created from
  41242. */
  41243. constructor(vrGamepad: any);
  41244. /**
  41245. * Fired when the trigger on this controller is modified
  41246. */
  41247. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41248. /**
  41249. * Fired when the menu button on this controller is modified
  41250. */
  41251. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41252. /**
  41253. * Fired when the grip button on this controller is modified
  41254. */
  41255. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41256. /**
  41257. * Fired when the thumbstick button on this controller is modified
  41258. */
  41259. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41260. /**
  41261. * Fired when the touchpad button on this controller is modified
  41262. */
  41263. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41264. /**
  41265. * Fired when the touchpad values on this controller are modified
  41266. */
  41267. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41268. private _updateTrackpad;
  41269. /**
  41270. * Called once per frame by the engine.
  41271. */
  41272. update(): void;
  41273. /**
  41274. * Called once for each button that changed state since the last frame
  41275. * @param buttonIdx Which button index changed
  41276. * @param state New state of the button
  41277. * @param changes Which properties on the state changed since last frame
  41278. */
  41279. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41280. /**
  41281. * Moves the buttons on the controller mesh based on their current state
  41282. * @param buttonName the name of the button to move
  41283. * @param buttonValue the value of the button which determines the buttons new position
  41284. */
  41285. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41286. /**
  41287. * Moves the axis on the controller mesh based on its current state
  41288. * @param axis the index of the axis
  41289. * @param axisValue the value of the axis which determines the meshes new position
  41290. * @hidden
  41291. */
  41292. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41293. /**
  41294. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41295. * @param scene scene in which to add meshes
  41296. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41297. */
  41298. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41299. /**
  41300. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41301. * can be transformed by button presses and axes values, based on this._mapping.
  41302. *
  41303. * @param scene scene in which the meshes exist
  41304. * @param meshes list of meshes that make up the controller model to process
  41305. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41306. */
  41307. private processModel;
  41308. private createMeshInfo;
  41309. /**
  41310. * Gets the ray of the controller in the direction the controller is pointing
  41311. * @param length the length the resulting ray should be
  41312. * @returns a ray in the direction the controller is pointing
  41313. */
  41314. getForwardRay(length?: number): Ray;
  41315. /**
  41316. * Disposes of the controller
  41317. */
  41318. dispose(): void;
  41319. }
  41320. }
  41321. declare module BABYLON {
  41322. /**
  41323. * Oculus Touch Controller
  41324. */
  41325. export class OculusTouchController extends WebVRController {
  41326. /**
  41327. * Base Url for the controller model.
  41328. */
  41329. static MODEL_BASE_URL: string;
  41330. /**
  41331. * File name for the left controller model.
  41332. */
  41333. static MODEL_LEFT_FILENAME: string;
  41334. /**
  41335. * File name for the right controller model.
  41336. */
  41337. static MODEL_RIGHT_FILENAME: string;
  41338. /**
  41339. * Base Url for the Quest controller model.
  41340. */
  41341. static QUEST_MODEL_BASE_URL: string;
  41342. /**
  41343. * @hidden
  41344. * If the controllers are running on a device that needs the updated Quest controller models
  41345. */ private static _IsQuest: boolean;
  41346. /**
  41347. * Fired when the secondary trigger on this controller is modified
  41348. */
  41349. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41350. /**
  41351. * Fired when the thumb rest on this controller is modified
  41352. */
  41353. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41354. /**
  41355. * Creates a new OculusTouchController from a gamepad
  41356. * @param vrGamepad the gamepad that the controller should be created from
  41357. */
  41358. constructor(vrGamepad: any);
  41359. /**
  41360. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41361. * @param scene scene in which to add meshes
  41362. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41363. */
  41364. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41365. /**
  41366. * Fired when the A button on this controller is modified
  41367. */
  41368. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41369. /**
  41370. * Fired when the B button on this controller is modified
  41371. */
  41372. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41373. /**
  41374. * Fired when the X button on this controller is modified
  41375. */
  41376. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41377. /**
  41378. * Fired when the Y button on this controller is modified
  41379. */
  41380. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41381. /**
  41382. * Called once for each button that changed state since the last frame
  41383. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41384. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41385. * 2) secondary trigger (same)
  41386. * 3) A (right) X (left), touch, pressed = value
  41387. * 4) B / Y
  41388. * 5) thumb rest
  41389. * @param buttonIdx Which button index changed
  41390. * @param state New state of the button
  41391. * @param changes Which properties on the state changed since last frame
  41392. */
  41393. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41394. }
  41395. }
  41396. declare module BABYLON {
  41397. /**
  41398. * Vive Controller
  41399. */
  41400. export class ViveController extends WebVRController {
  41401. /**
  41402. * Base Url for the controller model.
  41403. */
  41404. static MODEL_BASE_URL: string;
  41405. /**
  41406. * File name for the controller model.
  41407. */
  41408. static MODEL_FILENAME: string;
  41409. /**
  41410. * Creates a new ViveController from a gamepad
  41411. * @param vrGamepad the gamepad that the controller should be created from
  41412. */
  41413. constructor(vrGamepad: any);
  41414. /**
  41415. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41416. * @param scene scene in which to add meshes
  41417. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41418. */
  41419. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41420. /**
  41421. * Fired when the left button on this controller is modified
  41422. */
  41423. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41424. /**
  41425. * Fired when the right button on this controller is modified
  41426. */
  41427. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41428. /**
  41429. * Fired when the menu button on this controller is modified
  41430. */
  41431. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41432. /**
  41433. * Called once for each button that changed state since the last frame
  41434. * Vive mapping:
  41435. * 0: touchpad
  41436. * 1: trigger
  41437. * 2: left AND right buttons
  41438. * 3: menu button
  41439. * @param buttonIdx Which button index changed
  41440. * @param state New state of the button
  41441. * @param changes Which properties on the state changed since last frame
  41442. */
  41443. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41444. }
  41445. }
  41446. declare module BABYLON {
  41447. /**
  41448. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  41449. */
  41450. export class WebXRControllerModelLoader {
  41451. /**
  41452. * Creates the WebXRControllerModelLoader
  41453. * @param input xr input that creates the controllers
  41454. */
  41455. constructor(input: WebXRInput);
  41456. }
  41457. }
  41458. declare module BABYLON {
  41459. /**
  41460. * Contains an array of blocks representing the octree
  41461. */
  41462. export interface IOctreeContainer<T> {
  41463. /**
  41464. * Blocks within the octree
  41465. */
  41466. blocks: Array<OctreeBlock<T>>;
  41467. }
  41468. /**
  41469. * Class used to store a cell in an octree
  41470. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41471. */
  41472. export class OctreeBlock<T> {
  41473. /**
  41474. * Gets the content of the current block
  41475. */
  41476. entries: T[];
  41477. /**
  41478. * Gets the list of block children
  41479. */
  41480. blocks: Array<OctreeBlock<T>>;
  41481. private _depth;
  41482. private _maxDepth;
  41483. private _capacity;
  41484. private _minPoint;
  41485. private _maxPoint;
  41486. private _boundingVectors;
  41487. private _creationFunc;
  41488. /**
  41489. * Creates a new block
  41490. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41491. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41492. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41493. * @param depth defines the current depth of this block in the octree
  41494. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41495. * @param creationFunc defines a callback to call when an element is added to the block
  41496. */
  41497. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41498. /**
  41499. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41500. */
  41501. readonly capacity: number;
  41502. /**
  41503. * Gets the minimum vector (in world space) of the block's bounding box
  41504. */
  41505. readonly minPoint: Vector3;
  41506. /**
  41507. * Gets the maximum vector (in world space) of the block's bounding box
  41508. */
  41509. readonly maxPoint: Vector3;
  41510. /**
  41511. * Add a new element to this block
  41512. * @param entry defines the element to add
  41513. */
  41514. addEntry(entry: T): void;
  41515. /**
  41516. * Remove an element from this block
  41517. * @param entry defines the element to remove
  41518. */
  41519. removeEntry(entry: T): void;
  41520. /**
  41521. * Add an array of elements to this block
  41522. * @param entries defines the array of elements to add
  41523. */
  41524. addEntries(entries: T[]): void;
  41525. /**
  41526. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41527. * @param frustumPlanes defines the frustum planes to test
  41528. * @param selection defines the array to store current content if selection is positive
  41529. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41530. */
  41531. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41532. /**
  41533. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41534. * @param sphereCenter defines the bounding sphere center
  41535. * @param sphereRadius defines the bounding sphere radius
  41536. * @param selection defines the array to store current content if selection is positive
  41537. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41538. */
  41539. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41540. /**
  41541. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41542. * @param ray defines the ray to test with
  41543. * @param selection defines the array to store current content if selection is positive
  41544. */
  41545. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41546. /**
  41547. * Subdivide the content into child blocks (this block will then be empty)
  41548. */
  41549. createInnerBlocks(): void;
  41550. /**
  41551. * @hidden
  41552. */ 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;
  41553. }
  41554. }
  41555. declare module BABYLON {
  41556. /**
  41557. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41558. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41559. */
  41560. export class Octree<T> {
  41561. /** 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.) */
  41562. maxDepth: number;
  41563. /**
  41564. * Blocks within the octree containing objects
  41565. */
  41566. blocks: Array<OctreeBlock<T>>;
  41567. /**
  41568. * Content stored in the octree
  41569. */
  41570. dynamicContent: T[];
  41571. private _maxBlockCapacity;
  41572. private _selectionContent;
  41573. private _creationFunc;
  41574. /**
  41575. * Creates a octree
  41576. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41577. * @param creationFunc function to be used to instatiate the octree
  41578. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41579. * @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.)
  41580. */
  41581. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41582. /** 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.) */
  41583. maxDepth?: number);
  41584. /**
  41585. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41586. * @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);
  41587. * @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);
  41588. * @param entries meshes to be added to the octree blocks
  41589. */
  41590. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41591. /**
  41592. * Adds a mesh to the octree
  41593. * @param entry Mesh to add to the octree
  41594. */
  41595. addMesh(entry: T): void;
  41596. /**
  41597. * Remove an element from the octree
  41598. * @param entry defines the element to remove
  41599. */
  41600. removeMesh(entry: T): void;
  41601. /**
  41602. * Selects an array of meshes within the frustum
  41603. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41604. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41605. * @returns array of meshes within the frustum
  41606. */
  41607. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41608. /**
  41609. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41610. * @param sphereCenter defines the bounding sphere center
  41611. * @param sphereRadius defines the bounding sphere radius
  41612. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41613. * @returns an array of objects that intersect the sphere
  41614. */
  41615. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41616. /**
  41617. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41618. * @param ray defines the ray to test with
  41619. * @returns array of intersected objects
  41620. */
  41621. intersectsRay(ray: Ray): SmartArray<T>;
  41622. /**
  41623. * Adds a mesh into the octree block if it intersects the block
  41624. */
  41625. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41626. /**
  41627. * Adds a submesh into the octree block if it intersects the block
  41628. */
  41629. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41630. }
  41631. }
  41632. declare module BABYLON {
  41633. interface Scene {
  41634. /**
  41635. * @hidden
  41636. * Backing Filed
  41637. */ private _selectionOctree: Octree<AbstractMesh>;
  41638. /**
  41639. * Gets the octree used to boost mesh selection (picking)
  41640. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41641. */
  41642. selectionOctree: Octree<AbstractMesh>;
  41643. /**
  41644. * Creates or updates the octree used to boost selection (picking)
  41645. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41646. * @param maxCapacity defines the maximum capacity per leaf
  41647. * @param maxDepth defines the maximum depth of the octree
  41648. * @returns an octree of AbstractMesh
  41649. */
  41650. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41651. }
  41652. interface AbstractMesh {
  41653. /**
  41654. * @hidden
  41655. * Backing Field
  41656. */ private _submeshesOctree: Octree<SubMesh>;
  41657. /**
  41658. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41659. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41660. * @param maxCapacity defines the maximum size of each block (64 by default)
  41661. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41662. * @returns the new octree
  41663. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41664. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41665. */
  41666. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41667. }
  41668. /**
  41669. * Defines the octree scene component responsible to manage any octrees
  41670. * in a given scene.
  41671. */
  41672. export class OctreeSceneComponent {
  41673. /**
  41674. * The component name help to identify the component in the list of scene components.
  41675. */
  41676. readonly name: string;
  41677. /**
  41678. * The scene the component belongs to.
  41679. */
  41680. scene: Scene;
  41681. /**
  41682. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41683. */
  41684. readonly checksIsEnabled: boolean;
  41685. /**
  41686. * Creates a new instance of the component for the given scene
  41687. * @param scene Defines the scene to register the component in
  41688. */
  41689. constructor(scene: Scene);
  41690. /**
  41691. * Registers the component in a given scene
  41692. */
  41693. register(): void;
  41694. /**
  41695. * Return the list of active meshes
  41696. * @returns the list of active meshes
  41697. */
  41698. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41699. /**
  41700. * Return the list of active sub meshes
  41701. * @param mesh The mesh to get the candidates sub meshes from
  41702. * @returns the list of active sub meshes
  41703. */
  41704. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41705. private _tempRay;
  41706. /**
  41707. * Return the list of sub meshes intersecting with a given local ray
  41708. * @param mesh defines the mesh to find the submesh for
  41709. * @param localRay defines the ray in local space
  41710. * @returns the list of intersecting sub meshes
  41711. */
  41712. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41713. /**
  41714. * Return the list of sub meshes colliding with a collider
  41715. * @param mesh defines the mesh to find the submesh for
  41716. * @param collider defines the collider to evaluate the collision against
  41717. * @returns the list of colliding sub meshes
  41718. */
  41719. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41720. /**
  41721. * Rebuilds the elements related to this component in case of
  41722. * context lost for instance.
  41723. */
  41724. rebuild(): void;
  41725. /**
  41726. * Disposes the component and the associated ressources.
  41727. */
  41728. dispose(): void;
  41729. }
  41730. }
  41731. declare module BABYLON {
  41732. /**
  41733. * Renders a layer on top of an existing scene
  41734. */
  41735. export class UtilityLayerRenderer implements IDisposable {
  41736. /** the original scene that will be rendered on top of */
  41737. originalScene: Scene;
  41738. private _pointerCaptures;
  41739. private _lastPointerEvents;
  41740. private static _DefaultUtilityLayer;
  41741. private static _DefaultKeepDepthUtilityLayer;
  41742. private _sharedGizmoLight;
  41743. private _renderCamera;
  41744. /**
  41745. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  41746. * @returns the camera that is used when rendering the utility layer
  41747. */
  41748. getRenderCamera(): Nullable<Camera>;
  41749. /**
  41750. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  41751. * @param cam the camera that should be used when rendering the utility layer
  41752. */
  41753. setRenderCamera(cam: Nullable<Camera>): void;
  41754. /**
  41755. * @hidden
  41756. * Light which used by gizmos to get light shading
  41757. */ private _getSharedGizmoLight(): HemisphericLight;
  41758. /**
  41759. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41760. */
  41761. pickUtilitySceneFirst: boolean;
  41762. /**
  41763. * 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)
  41764. */
  41765. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41766. /**
  41767. * 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)
  41768. */
  41769. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41770. /**
  41771. * The scene that is rendered on top of the original scene
  41772. */
  41773. utilityLayerScene: Scene;
  41774. /**
  41775. * If the utility layer should automatically be rendered on top of existing scene
  41776. */
  41777. shouldRender: boolean;
  41778. /**
  41779. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41780. */
  41781. onlyCheckPointerDownEvents: boolean;
  41782. /**
  41783. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41784. */
  41785. processAllEvents: boolean;
  41786. /**
  41787. * Observable raised when the pointer move from the utility layer scene to the main scene
  41788. */
  41789. onPointerOutObservable: Observable<number>;
  41790. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41791. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41792. private _afterRenderObserver;
  41793. private _sceneDisposeObserver;
  41794. private _originalPointerObserver;
  41795. /**
  41796. * Instantiates a UtilityLayerRenderer
  41797. * @param originalScene the original scene that will be rendered on top of
  41798. * @param handleEvents boolean indicating if the utility layer should handle events
  41799. */
  41800. constructor(
  41801. /** the original scene that will be rendered on top of */
  41802. originalScene: Scene, handleEvents?: boolean);
  41803. private _notifyObservers;
  41804. /**
  41805. * Renders the utility layers scene on top of the original scene
  41806. */
  41807. render(): void;
  41808. /**
  41809. * Disposes of the renderer
  41810. */
  41811. dispose(): void;
  41812. private _updateCamera;
  41813. }
  41814. }
  41815. declare module BABYLON {
  41816. /**
  41817. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41818. */
  41819. export class Gizmo implements IDisposable {
  41820. /** The utility layer the gizmo will be added to */
  41821. gizmoLayer: UtilityLayerRenderer;
  41822. /**
  41823. * The root mesh of the gizmo
  41824. */ private _rootMesh: Mesh;
  41825. private _attachedMesh;
  41826. /**
  41827. * Ratio for the scale of the gizmo (Default: 1)
  41828. */
  41829. scaleRatio: number;
  41830. /**
  41831. * If a custom mesh has been set (Default: false)
  41832. */
  41833. protected _customMeshSet: boolean;
  41834. /**
  41835. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41836. * * When set, interactions will be enabled
  41837. */
  41838. attachedMesh: Nullable<AbstractMesh>;
  41839. /**
  41840. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41841. * @param mesh The mesh to replace the default mesh of the gizmo
  41842. */
  41843. setCustomMesh(mesh: Mesh): void;
  41844. /**
  41845. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41846. */
  41847. updateGizmoRotationToMatchAttachedMesh: boolean;
  41848. /**
  41849. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41850. */
  41851. updateGizmoPositionToMatchAttachedMesh: boolean;
  41852. /**
  41853. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  41854. */
  41855. updateScale: boolean;
  41856. protected _interactionsEnabled: boolean;
  41857. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41858. private _beforeRenderObserver;
  41859. private _tempVector;
  41860. /**
  41861. * Creates a gizmo
  41862. * @param gizmoLayer The utility layer the gizmo will be added to
  41863. */
  41864. constructor(
  41865. /** The utility layer the gizmo will be added to */
  41866. gizmoLayer?: UtilityLayerRenderer);
  41867. /**
  41868. * Updates the gizmo to match the attached mesh's position/rotation
  41869. */
  41870. protected _update(): void;
  41871. /**
  41872. * Disposes of the gizmo
  41873. */
  41874. dispose(): void;
  41875. }
  41876. }
  41877. declare module BABYLON {
  41878. /**
  41879. * Single plane drag gizmo
  41880. */
  41881. export class PlaneDragGizmo extends Gizmo {
  41882. /**
  41883. * Drag behavior responsible for the gizmos dragging interactions
  41884. */
  41885. dragBehavior: PointerDragBehavior;
  41886. private _pointerObserver;
  41887. /**
  41888. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41889. */
  41890. snapDistance: number;
  41891. /**
  41892. * Event that fires each time the gizmo snaps to a new location.
  41893. * * snapDistance is the the change in distance
  41894. */
  41895. onSnapObservable: Observable<{
  41896. snapDistance: number;
  41897. }>;
  41898. private _plane;
  41899. private _coloredMaterial;
  41900. private _hoverMaterial;
  41901. private _isEnabled;
  41902. private _parent;
  41903. /** @hidden */ private static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  41904. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41905. /**
  41906. * Creates a PlaneDragGizmo
  41907. * @param gizmoLayer The utility layer the gizmo will be added to
  41908. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  41909. * @param color The color of the gizmo
  41910. */
  41911. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  41912. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41913. /**
  41914. * If the gizmo is enabled
  41915. */
  41916. isEnabled: boolean;
  41917. /**
  41918. * Disposes of the gizmo
  41919. */
  41920. dispose(): void;
  41921. }
  41922. }
  41923. declare module BABYLON {
  41924. /**
  41925. * Gizmo that enables dragging a mesh along 3 axis
  41926. */
  41927. export class PositionGizmo extends Gizmo {
  41928. /**
  41929. * Internal gizmo used for interactions on the x axis
  41930. */
  41931. xGizmo: AxisDragGizmo;
  41932. /**
  41933. * Internal gizmo used for interactions on the y axis
  41934. */
  41935. yGizmo: AxisDragGizmo;
  41936. /**
  41937. * Internal gizmo used for interactions on the z axis
  41938. */
  41939. zGizmo: AxisDragGizmo;
  41940. /**
  41941. * Internal gizmo used for interactions on the yz plane
  41942. */
  41943. xPlaneGizmo: PlaneDragGizmo;
  41944. /**
  41945. * Internal gizmo used for interactions on the xz plane
  41946. */
  41947. yPlaneGizmo: PlaneDragGizmo;
  41948. /**
  41949. * Internal gizmo used for interactions on the xy plane
  41950. */
  41951. zPlaneGizmo: PlaneDragGizmo;
  41952. /**
  41953. * private variables
  41954. */
  41955. private _meshAttached;
  41956. private _updateGizmoRotationToMatchAttachedMesh;
  41957. private _snapDistance;
  41958. private _scaleRatio;
  41959. /** Fires an event when any of it's sub gizmos are dragged */
  41960. onDragStartObservable: Observable<unknown>;
  41961. /** Fires an event when any of it's sub gizmos are released from dragging */
  41962. onDragEndObservable: Observable<unknown>;
  41963. /**
  41964. * If set to true, planar drag is enabled
  41965. */
  41966. private _planarGizmoEnabled;
  41967. attachedMesh: Nullable<AbstractMesh>;
  41968. /**
  41969. * Creates a PositionGizmo
  41970. * @param gizmoLayer The utility layer the gizmo will be added to
  41971. */
  41972. constructor(gizmoLayer?: UtilityLayerRenderer);
  41973. /**
  41974. * If the planar drag gizmo is enabled
  41975. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  41976. */
  41977. planarGizmoEnabled: boolean;
  41978. updateGizmoRotationToMatchAttachedMesh: boolean;
  41979. /**
  41980. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41981. */
  41982. snapDistance: number;
  41983. /**
  41984. * Ratio for the scale of the gizmo (Default: 1)
  41985. */
  41986. scaleRatio: number;
  41987. /**
  41988. * Disposes of the gizmo
  41989. */
  41990. dispose(): void;
  41991. /**
  41992. * CustomMeshes are not supported by this gizmo
  41993. * @param mesh The mesh to replace the default mesh of the gizmo
  41994. */
  41995. setCustomMesh(mesh: Mesh): void;
  41996. }
  41997. }
  41998. declare module BABYLON {
  41999. /**
  42000. * Single axis drag gizmo
  42001. */
  42002. export class AxisDragGizmo extends Gizmo {
  42003. /**
  42004. * Drag behavior responsible for the gizmos dragging interactions
  42005. */
  42006. dragBehavior: PointerDragBehavior;
  42007. private _pointerObserver;
  42008. /**
  42009. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42010. */
  42011. snapDistance: number;
  42012. /**
  42013. * Event that fires each time the gizmo snaps to a new location.
  42014. * * snapDistance is the the change in distance
  42015. */
  42016. onSnapObservable: Observable<{
  42017. snapDistance: number;
  42018. }>;
  42019. private _isEnabled;
  42020. private _parent;
  42021. private _arrow;
  42022. private _coloredMaterial;
  42023. private _hoverMaterial;
  42024. /** @hidden */ private static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42025. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42026. /**
  42027. * Creates an AxisDragGizmo
  42028. * @param gizmoLayer The utility layer the gizmo will be added to
  42029. * @param dragAxis The axis which the gizmo will be able to drag on
  42030. * @param color The color of the gizmo
  42031. */
  42032. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42033. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42034. /**
  42035. * If the gizmo is enabled
  42036. */
  42037. isEnabled: boolean;
  42038. /**
  42039. * Disposes of the gizmo
  42040. */
  42041. dispose(): void;
  42042. }
  42043. }
  42044. declare module BABYLON.Debug {
  42045. /**
  42046. * The Axes viewer will show 3 axes in a specific point in space
  42047. */
  42048. export class AxesViewer {
  42049. private _xAxis;
  42050. private _yAxis;
  42051. private _zAxis;
  42052. private _scaleLinesFactor;
  42053. private _instanced;
  42054. /**
  42055. * Gets the hosting scene
  42056. */
  42057. scene: Scene;
  42058. /**
  42059. * Gets or sets a number used to scale line length
  42060. */
  42061. scaleLines: number;
  42062. /** Gets the node hierarchy used to render x-axis */
  42063. readonly xAxis: TransformNode;
  42064. /** Gets the node hierarchy used to render y-axis */
  42065. readonly yAxis: TransformNode;
  42066. /** Gets the node hierarchy used to render z-axis */
  42067. readonly zAxis: TransformNode;
  42068. /**
  42069. * Creates a new AxesViewer
  42070. * @param scene defines the hosting scene
  42071. * @param scaleLines defines a number used to scale line length (1 by default)
  42072. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42073. * @param xAxis defines the node hierarchy used to render the x-axis
  42074. * @param yAxis defines the node hierarchy used to render the y-axis
  42075. * @param zAxis defines the node hierarchy used to render the z-axis
  42076. */
  42077. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42078. /**
  42079. * Force the viewer to update
  42080. * @param position defines the position of the viewer
  42081. * @param xaxis defines the x axis of the viewer
  42082. * @param yaxis defines the y axis of the viewer
  42083. * @param zaxis defines the z axis of the viewer
  42084. */
  42085. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42086. /**
  42087. * Creates an instance of this axes viewer.
  42088. * @returns a new axes viewer with instanced meshes
  42089. */
  42090. createInstance(): AxesViewer;
  42091. /** Releases resources */
  42092. dispose(): void;
  42093. private static _SetRenderingGroupId;
  42094. }
  42095. }
  42096. declare module BABYLON.Debug {
  42097. /**
  42098. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42099. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42100. */
  42101. export class BoneAxesViewer extends AxesViewer {
  42102. /**
  42103. * Gets or sets the target mesh where to display the axes viewer
  42104. */
  42105. mesh: Nullable<Mesh>;
  42106. /**
  42107. * Gets or sets the target bone where to display the axes viewer
  42108. */
  42109. bone: Nullable<Bone>;
  42110. /** Gets current position */
  42111. pos: Vector3;
  42112. /** Gets direction of X axis */
  42113. xaxis: Vector3;
  42114. /** Gets direction of Y axis */
  42115. yaxis: Vector3;
  42116. /** Gets direction of Z axis */
  42117. zaxis: Vector3;
  42118. /**
  42119. * Creates a new BoneAxesViewer
  42120. * @param scene defines the hosting scene
  42121. * @param bone defines the target bone
  42122. * @param mesh defines the target mesh
  42123. * @param scaleLines defines a scaling factor for line length (1 by default)
  42124. */
  42125. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42126. /**
  42127. * Force the viewer to update
  42128. */
  42129. update(): void;
  42130. /** Releases resources */
  42131. dispose(): void;
  42132. }
  42133. }
  42134. declare module BABYLON {
  42135. /**
  42136. * Interface used to define scene explorer extensibility option
  42137. */
  42138. export interface IExplorerExtensibilityOption {
  42139. /**
  42140. * Define the option label
  42141. */
  42142. label: string;
  42143. /**
  42144. * Defines the action to execute on click
  42145. */
  42146. action: (entity: any) => void;
  42147. }
  42148. /**
  42149. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42150. */
  42151. export interface IExplorerExtensibilityGroup {
  42152. /**
  42153. * Defines a predicate to test if a given type mut be extended
  42154. */
  42155. predicate: (entity: any) => boolean;
  42156. /**
  42157. * Gets the list of options added to a type
  42158. */
  42159. entries: IExplorerExtensibilityOption[];
  42160. }
  42161. /**
  42162. * Interface used to define the options to use to create the Inspector
  42163. */
  42164. export interface IInspectorOptions {
  42165. /**
  42166. * Display in overlay mode (default: false)
  42167. */
  42168. overlay?: boolean;
  42169. /**
  42170. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42171. */
  42172. globalRoot?: HTMLElement;
  42173. /**
  42174. * Display the Scene explorer
  42175. */
  42176. showExplorer?: boolean;
  42177. /**
  42178. * Display the property inspector
  42179. */
  42180. showInspector?: boolean;
  42181. /**
  42182. * Display in embed mode (both panes on the right)
  42183. */
  42184. embedMode?: boolean;
  42185. /**
  42186. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42187. */
  42188. handleResize?: boolean;
  42189. /**
  42190. * Allow the panes to popup (default: true)
  42191. */
  42192. enablePopup?: boolean;
  42193. /**
  42194. * Allow the panes to be closed by users (default: true)
  42195. */
  42196. enableClose?: boolean;
  42197. /**
  42198. * Optional list of extensibility entries
  42199. */
  42200. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42201. /**
  42202. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42203. */
  42204. inspectorURL?: string;
  42205. }
  42206. interface Scene {
  42207. /**
  42208. * @hidden
  42209. * Backing field
  42210. */ private _debugLayer: DebugLayer;
  42211. /**
  42212. * Gets the debug layer (aka Inspector) associated with the scene
  42213. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42214. */
  42215. debugLayer: DebugLayer;
  42216. }
  42217. /**
  42218. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42219. * what is happening in your scene
  42220. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42221. */
  42222. export class DebugLayer {
  42223. /**
  42224. * Define the url to get the inspector script from.
  42225. * By default it uses the babylonjs CDN.
  42226. * @ignoreNaming
  42227. */
  42228. static InspectorURL: string;
  42229. private _scene;
  42230. private BJSINSPECTOR;
  42231. private _onPropertyChangedObservable?;
  42232. /**
  42233. * Observable triggered when a property is changed through the inspector.
  42234. */
  42235. readonly onPropertyChangedObservable: any;
  42236. /**
  42237. * Instantiates a new debug layer.
  42238. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42239. * what is happening in your scene
  42240. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42241. * @param scene Defines the scene to inspect
  42242. */
  42243. constructor(scene: Scene);
  42244. /** Creates the inspector window. */
  42245. private _createInspector;
  42246. /**
  42247. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42248. * @param entity defines the entity to select
  42249. * @param lineContainerTitle defines the specific block to highlight
  42250. */
  42251. select(entity: any, lineContainerTitle?: string): void;
  42252. /** Get the inspector from bundle or global */
  42253. private _getGlobalInspector;
  42254. /**
  42255. * Get if the inspector is visible or not.
  42256. * @returns true if visible otherwise, false
  42257. */
  42258. isVisible(): boolean;
  42259. /**
  42260. * Hide the inspector and close its window.
  42261. */
  42262. hide(): void;
  42263. /**
  42264. * Launch the debugLayer.
  42265. * @param config Define the configuration of the inspector
  42266. * @return a promise fulfilled when the debug layer is visible
  42267. */
  42268. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42269. }
  42270. }
  42271. declare module BABYLON {
  42272. /**
  42273. * Class containing static functions to help procedurally build meshes
  42274. */
  42275. export class BoxBuilder {
  42276. /**
  42277. * Creates a box mesh
  42278. * * The parameter `size` sets the size (float) of each box side (default 1)
  42279. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42280. * * 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)
  42281. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42282. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42283. * * 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
  42284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42285. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42286. * @param name defines the name of the mesh
  42287. * @param options defines the options used to create the mesh
  42288. * @param scene defines the hosting scene
  42289. * @returns the box mesh
  42290. */
  42291. static CreateBox(name: string, options: {
  42292. size?: number;
  42293. width?: number;
  42294. height?: number;
  42295. depth?: number;
  42296. faceUV?: Vector4[];
  42297. faceColors?: Color4[];
  42298. sideOrientation?: number;
  42299. frontUVs?: Vector4;
  42300. backUVs?: Vector4;
  42301. wrap?: boolean;
  42302. topBaseAt?: number;
  42303. bottomBaseAt?: number;
  42304. updatable?: boolean;
  42305. }, scene?: Nullable<Scene>): Mesh;
  42306. }
  42307. }
  42308. declare module BABYLON {
  42309. /**
  42310. * Class containing static functions to help procedurally build meshes
  42311. */
  42312. export class SphereBuilder {
  42313. /**
  42314. * Creates a sphere mesh
  42315. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42316. * * 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`)
  42317. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42318. * * 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
  42319. * * 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)
  42320. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42321. * * 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
  42322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42323. * @param name defines the name of the mesh
  42324. * @param options defines the options used to create the mesh
  42325. * @param scene defines the hosting scene
  42326. * @returns the sphere mesh
  42327. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42328. */
  42329. static CreateSphere(name: string, options: {
  42330. segments?: number;
  42331. diameter?: number;
  42332. diameterX?: number;
  42333. diameterY?: number;
  42334. diameterZ?: number;
  42335. arc?: number;
  42336. slice?: number;
  42337. sideOrientation?: number;
  42338. frontUVs?: Vector4;
  42339. backUVs?: Vector4;
  42340. updatable?: boolean;
  42341. }, scene: any): Mesh;
  42342. }
  42343. }
  42344. declare module BABYLON.Debug {
  42345. /**
  42346. * Used to show the physics impostor around the specific mesh
  42347. */
  42348. export class PhysicsViewer {
  42349. /** @hidden */
  42350. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42351. /** @hidden */
  42352. protected _meshes: Array<Nullable<AbstractMesh>>;
  42353. /** @hidden */
  42354. protected _scene: Nullable<Scene>;
  42355. /** @hidden */
  42356. protected _numMeshes: number;
  42357. /** @hidden */
  42358. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42359. private _renderFunction;
  42360. private _utilityLayer;
  42361. private _debugBoxMesh;
  42362. private _debugSphereMesh;
  42363. private _debugCylinderMesh;
  42364. private _debugMaterial;
  42365. private _debugMeshMeshes;
  42366. /**
  42367. * Creates a new PhysicsViewer
  42368. * @param scene defines the hosting scene
  42369. */
  42370. constructor(scene: Scene);
  42371. /** @hidden */
  42372. protected _updateDebugMeshes(): void;
  42373. /**
  42374. * Renders a specified physic impostor
  42375. * @param impostor defines the impostor to render
  42376. * @param targetMesh defines the mesh represented by the impostor
  42377. * @returns the new debug mesh used to render the impostor
  42378. */
  42379. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42380. /**
  42381. * Hides a specified physic impostor
  42382. * @param impostor defines the impostor to hide
  42383. */
  42384. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42385. private _getDebugMaterial;
  42386. private _getDebugBoxMesh;
  42387. private _getDebugSphereMesh;
  42388. private _getDebugCylinderMesh;
  42389. private _getDebugMeshMesh;
  42390. private _getDebugMesh;
  42391. /** Releases all resources */
  42392. dispose(): void;
  42393. }
  42394. }
  42395. declare module BABYLON {
  42396. /**
  42397. * Class containing static functions to help procedurally build meshes
  42398. */
  42399. export class LinesBuilder {
  42400. /**
  42401. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42402. * * 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
  42403. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42404. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42405. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42406. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42407. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42408. * * 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
  42409. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42411. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42412. * @param name defines the name of the new line system
  42413. * @param options defines the options used to create the line system
  42414. * @param scene defines the hosting scene
  42415. * @returns a new line system mesh
  42416. */
  42417. static CreateLineSystem(name: string, options: {
  42418. lines: Vector3[][];
  42419. updatable?: boolean;
  42420. instance?: Nullable<LinesMesh>;
  42421. colors?: Nullable<Color4[][]>;
  42422. useVertexAlpha?: boolean;
  42423. }, scene: Nullable<Scene>): LinesMesh;
  42424. /**
  42425. * Creates a line mesh
  42426. * 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
  42427. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42428. * * The parameter `points` is an array successive Vector3
  42429. * * 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
  42430. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42431. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42432. * * When updating an instance, remember that only point positions can change, not the number of points
  42433. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42434. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42435. * @param name defines the name of the new line system
  42436. * @param options defines the options used to create the line system
  42437. * @param scene defines the hosting scene
  42438. * @returns a new line mesh
  42439. */
  42440. static CreateLines(name: string, options: {
  42441. points: Vector3[];
  42442. updatable?: boolean;
  42443. instance?: Nullable<LinesMesh>;
  42444. colors?: Color4[];
  42445. useVertexAlpha?: boolean;
  42446. }, scene?: Nullable<Scene>): LinesMesh;
  42447. /**
  42448. * Creates a dashed line mesh
  42449. * * 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
  42450. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42451. * * The parameter `points` is an array successive Vector3
  42452. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42453. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42454. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42455. * * 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
  42456. * * When updating an instance, remember that only point positions can change, not the number of points
  42457. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42458. * @param name defines the name of the mesh
  42459. * @param options defines the options used to create the mesh
  42460. * @param scene defines the hosting scene
  42461. * @returns the dashed line mesh
  42462. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42463. */
  42464. static CreateDashedLines(name: string, options: {
  42465. points: Vector3[];
  42466. dashSize?: number;
  42467. gapSize?: number;
  42468. dashNb?: number;
  42469. updatable?: boolean;
  42470. instance?: LinesMesh;
  42471. }, scene?: Nullable<Scene>): LinesMesh;
  42472. }
  42473. }
  42474. declare module BABYLON {
  42475. /**
  42476. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42477. * in order to better appreciate the issue one might have.
  42478. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42479. */
  42480. export class RayHelper {
  42481. /**
  42482. * Defines the ray we are currently tryin to visualize.
  42483. */
  42484. ray: Nullable<Ray>;
  42485. private _renderPoints;
  42486. private _renderLine;
  42487. private _renderFunction;
  42488. private _scene;
  42489. private _updateToMeshFunction;
  42490. private _attachedToMesh;
  42491. private _meshSpaceDirection;
  42492. private _meshSpaceOrigin;
  42493. /**
  42494. * Helper function to create a colored helper in a scene in one line.
  42495. * @param ray Defines the ray we are currently tryin to visualize
  42496. * @param scene Defines the scene the ray is used in
  42497. * @param color Defines the color we want to see the ray in
  42498. * @returns The newly created ray helper.
  42499. */
  42500. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42501. /**
  42502. * Instantiate a new ray helper.
  42503. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42504. * in order to better appreciate the issue one might have.
  42505. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42506. * @param ray Defines the ray we are currently tryin to visualize
  42507. */
  42508. constructor(ray: Ray);
  42509. /**
  42510. * Shows the ray we are willing to debug.
  42511. * @param scene Defines the scene the ray needs to be rendered in
  42512. * @param color Defines the color the ray needs to be rendered in
  42513. */
  42514. show(scene: Scene, color?: Color3): void;
  42515. /**
  42516. * Hides the ray we are debugging.
  42517. */
  42518. hide(): void;
  42519. private _render;
  42520. /**
  42521. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42522. * @param mesh Defines the mesh we want the helper attached to
  42523. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42524. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42525. * @param length Defines the length of the ray
  42526. */
  42527. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42528. /**
  42529. * Detach the ray helper from the mesh it has previously been attached to.
  42530. */
  42531. detachFromMesh(): void;
  42532. private _updateToMesh;
  42533. /**
  42534. * Dispose the helper and release its associated resources.
  42535. */
  42536. dispose(): void;
  42537. }
  42538. }
  42539. declare module BABYLON.Debug {
  42540. /**
  42541. * Class used to render a debug view of a given skeleton
  42542. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42543. */
  42544. export class SkeletonViewer {
  42545. /** defines the skeleton to render */
  42546. skeleton: Skeleton;
  42547. /** defines the mesh attached to the skeleton */
  42548. mesh: AbstractMesh;
  42549. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42550. autoUpdateBonesMatrices: boolean;
  42551. /** defines the rendering group id to use with the viewer */
  42552. renderingGroupId: number;
  42553. /** Gets or sets the color used to render the skeleton */
  42554. color: Color3;
  42555. private _scene;
  42556. private _debugLines;
  42557. private _debugMesh;
  42558. private _isEnabled;
  42559. private _renderFunction;
  42560. private _utilityLayer;
  42561. /**
  42562. * Returns the mesh used to render the bones
  42563. */
  42564. readonly debugMesh: Nullable<LinesMesh>;
  42565. /**
  42566. * Creates a new SkeletonViewer
  42567. * @param skeleton defines the skeleton to render
  42568. * @param mesh defines the mesh attached to the skeleton
  42569. * @param scene defines the hosting scene
  42570. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42571. * @param renderingGroupId defines the rendering group id to use with the viewer
  42572. */
  42573. constructor(
  42574. /** defines the skeleton to render */
  42575. skeleton: Skeleton,
  42576. /** defines the mesh attached to the skeleton */
  42577. mesh: AbstractMesh, scene: Scene,
  42578. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42579. autoUpdateBonesMatrices?: boolean,
  42580. /** defines the rendering group id to use with the viewer */
  42581. renderingGroupId?: number);
  42582. /** Gets or sets a boolean indicating if the viewer is enabled */
  42583. isEnabled: boolean;
  42584. private _getBonePosition;
  42585. private _getLinesForBonesWithLength;
  42586. private _getLinesForBonesNoLength;
  42587. /** Update the viewer to sync with current skeleton state */
  42588. update(): void;
  42589. /** Release associated resources */
  42590. dispose(): void;
  42591. }
  42592. }
  42593. declare module BABYLON {
  42594. /**
  42595. * Options to create the null engine
  42596. */
  42597. export class NullEngineOptions {
  42598. /**
  42599. * Render width (Default: 512)
  42600. */
  42601. renderWidth: number;
  42602. /**
  42603. * Render height (Default: 256)
  42604. */
  42605. renderHeight: number;
  42606. /**
  42607. * Texture size (Default: 512)
  42608. */
  42609. textureSize: number;
  42610. /**
  42611. * If delta time between frames should be constant
  42612. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42613. */
  42614. deterministicLockstep: boolean;
  42615. /**
  42616. * Maximum about of steps between frames (Default: 4)
  42617. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42618. */
  42619. lockstepMaxSteps: number;
  42620. }
  42621. /**
  42622. * The null engine class provides support for headless version of babylon.js.
  42623. * This can be used in server side scenario or for testing purposes
  42624. */
  42625. export class NullEngine extends Engine {
  42626. private _options;
  42627. /**
  42628. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42629. */
  42630. isDeterministicLockStep(): boolean;
  42631. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42632. getLockstepMaxSteps(): number;
  42633. /**
  42634. * Sets hardware scaling, used to save performance if needed
  42635. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42636. */
  42637. getHardwareScalingLevel(): number;
  42638. constructor(options?: NullEngineOptions);
  42639. createVertexBuffer(vertices: FloatArray): DataBuffer;
  42640. createIndexBuffer(indices: IndicesArray): DataBuffer;
  42641. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42642. getRenderWidth(useScreen?: boolean): number;
  42643. getRenderHeight(useScreen?: boolean): number;
  42644. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  42645. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42646. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  42647. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  42648. bindSamplers(effect: Effect): void;
  42649. enableEffect(effect: Effect): void;
  42650. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42651. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42652. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42653. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42654. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42655. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42656. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42657. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42658. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42659. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42660. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42661. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42662. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42663. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42664. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42665. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42666. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42667. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42668. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42669. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42670. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42671. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42672. bindBuffers(vertexBuffers: {
  42673. [key: string]: VertexBuffer;
  42674. }, indexBuffer: DataBuffer, effect: Effect): void;
  42675. wipeCaches(bruteForce?: boolean): void;
  42676. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42677. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42678. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42679. /** @hidden */ private _createTexture(): WebGLTexture;
  42680. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  42681. 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;
  42682. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42683. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42684. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42685. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42686. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  42687. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42688. areAllEffectsReady(): boolean;
  42689. /**
  42690. * @hidden
  42691. * Get the current error code of the webGL context
  42692. * @returns the error code
  42693. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42694. */
  42695. getError(): number;
  42696. /** @hidden */ private _getUnpackAlignement(): number;
  42697. /** @hidden */ private _unpackFlipY(value: boolean): void;
  42698. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42699. /**
  42700. * Updates a dynamic vertex buffer.
  42701. * @param vertexBuffer the vertex buffer to update
  42702. * @param data the data used to update the vertex buffer
  42703. * @param byteOffset the byte offset of the data (optional)
  42704. * @param byteLength the byte length of the data (optional)
  42705. */
  42706. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void; private _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42707. /** @hidden */ private _bindTexture(channel: number, texture: InternalTexture): void;
  42708. /** @hidden */ private _releaseBuffer(buffer: DataBuffer): boolean;
  42709. releaseEffects(): void;
  42710. displayLoadingUI(): void;
  42711. hideLoadingUI(): void;
  42712. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42713. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42714. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42715. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42716. }
  42717. }
  42718. declare module BABYLON {
  42719. /** @hidden */
  42720. export class _OcclusionDataStorage {
  42721. /** @hidden */
  42722. occlusionInternalRetryCounter: number;
  42723. /** @hidden */
  42724. isOcclusionQueryInProgress: boolean;
  42725. /** @hidden */
  42726. isOccluded: boolean;
  42727. /** @hidden */
  42728. occlusionRetryCount: number;
  42729. /** @hidden */
  42730. occlusionType: number;
  42731. /** @hidden */
  42732. occlusionQueryAlgorithmType: number;
  42733. }
  42734. interface Engine {
  42735. /**
  42736. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42737. * @return the new query
  42738. */
  42739. createQuery(): WebGLQuery;
  42740. /**
  42741. * Delete and release a webGL query
  42742. * @param query defines the query to delete
  42743. * @return the current engine
  42744. */
  42745. deleteQuery(query: WebGLQuery): Engine;
  42746. /**
  42747. * Check if a given query has resolved and got its value
  42748. * @param query defines the query to check
  42749. * @returns true if the query got its value
  42750. */
  42751. isQueryResultAvailable(query: WebGLQuery): boolean;
  42752. /**
  42753. * Gets the value of a given query
  42754. * @param query defines the query to check
  42755. * @returns the value of the query
  42756. */
  42757. getQueryResult(query: WebGLQuery): number;
  42758. /**
  42759. * Initiates an occlusion query
  42760. * @param algorithmType defines the algorithm to use
  42761. * @param query defines the query to use
  42762. * @returns the current engine
  42763. * @see http://doc.babylonjs.com/features/occlusionquery
  42764. */
  42765. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42766. /**
  42767. * Ends an occlusion query
  42768. * @see http://doc.babylonjs.com/features/occlusionquery
  42769. * @param algorithmType defines the algorithm to use
  42770. * @returns the current engine
  42771. */
  42772. endOcclusionQuery(algorithmType: number): Engine;
  42773. /**
  42774. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42775. * Please note that only one query can be issued at a time
  42776. * @returns a time token used to track the time span
  42777. */
  42778. startTimeQuery(): Nullable<_TimeToken>;
  42779. /**
  42780. * Ends a time query
  42781. * @param token defines the token used to measure the time span
  42782. * @returns the time spent (in ns)
  42783. */
  42784. endTimeQuery(token: _TimeToken): int;
  42785. /** @hidden */ private _currentNonTimestampToken: Nullable<_TimeToken>;
  42786. /** @hidden */ private _createTimeQuery(): WebGLQuery;
  42787. /** @hidden */ private _deleteTimeQuery(query: WebGLQuery): void;
  42788. /** @hidden */ private _getGlAlgorithmType(algorithmType: number): number;
  42789. /** @hidden */ private _getTimeQueryResult(query: WebGLQuery): any;
  42790. /** @hidden */ private _getTimeQueryAvailability(query: WebGLQuery): any;
  42791. }
  42792. interface AbstractMesh {
  42793. /**
  42794. * Backing filed
  42795. * @hidden
  42796. */ private __occlusionDataStorage: _OcclusionDataStorage;
  42797. /**
  42798. * Access property
  42799. * @hidden
  42800. */ private _occlusionDataStorage: _OcclusionDataStorage;
  42801. /**
  42802. * 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.
  42803. * The default value is -1 which means don't break the query and wait till the result
  42804. * @see http://doc.babylonjs.com/features/occlusionquery
  42805. */
  42806. occlusionRetryCount: number;
  42807. /**
  42808. * 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:
  42809. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42810. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42811. * * 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.
  42812. * @see http://doc.babylonjs.com/features/occlusionquery
  42813. */
  42814. occlusionType: number;
  42815. /**
  42816. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42817. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42818. * * 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.
  42819. * @see http://doc.babylonjs.com/features/occlusionquery
  42820. */
  42821. occlusionQueryAlgorithmType: number;
  42822. /**
  42823. * 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
  42824. * @see http://doc.babylonjs.com/features/occlusionquery
  42825. */
  42826. isOccluded: boolean;
  42827. /**
  42828. * Flag to check the progress status of the query
  42829. * @see http://doc.babylonjs.com/features/occlusionquery
  42830. */
  42831. isOcclusionQueryInProgress: boolean;
  42832. }
  42833. }
  42834. declare module BABYLON {
  42835. /** @hidden */
  42836. export var _forceTransformFeedbackToBundle: boolean;
  42837. interface Engine {
  42838. /**
  42839. * Creates a webGL transform feedback object
  42840. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42841. * @returns the webGL transform feedback object
  42842. */
  42843. createTransformFeedback(): WebGLTransformFeedback;
  42844. /**
  42845. * Delete a webGL transform feedback object
  42846. * @param value defines the webGL transform feedback object to delete
  42847. */
  42848. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42849. /**
  42850. * Bind a webGL transform feedback object to the webgl context
  42851. * @param value defines the webGL transform feedback object to bind
  42852. */
  42853. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42854. /**
  42855. * Begins a transform feedback operation
  42856. * @param usePoints defines if points or triangles must be used
  42857. */
  42858. beginTransformFeedback(usePoints: boolean): void;
  42859. /**
  42860. * Ends a transform feedback operation
  42861. */
  42862. endTransformFeedback(): void;
  42863. /**
  42864. * Specify the varyings to use with transform feedback
  42865. * @param program defines the associated webGL program
  42866. * @param value defines the list of strings representing the varying names
  42867. */
  42868. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42869. /**
  42870. * Bind a webGL buffer for a transform feedback operation
  42871. * @param value defines the webGL buffer to bind
  42872. */
  42873. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  42874. }
  42875. }
  42876. declare module BABYLON {
  42877. /**
  42878. * Creation options of the multi render target texture.
  42879. */
  42880. export interface IMultiRenderTargetOptions {
  42881. /**
  42882. * Define if the texture needs to create mip maps after render.
  42883. */
  42884. generateMipMaps?: boolean;
  42885. /**
  42886. * Define the types of all the draw buffers we want to create
  42887. */
  42888. types?: number[];
  42889. /**
  42890. * Define the sampling modes of all the draw buffers we want to create
  42891. */
  42892. samplingModes?: number[];
  42893. /**
  42894. * Define if a depth buffer is required
  42895. */
  42896. generateDepthBuffer?: boolean;
  42897. /**
  42898. * Define if a stencil buffer is required
  42899. */
  42900. generateStencilBuffer?: boolean;
  42901. /**
  42902. * Define if a depth texture is required instead of a depth buffer
  42903. */
  42904. generateDepthTexture?: boolean;
  42905. /**
  42906. * Define the number of desired draw buffers
  42907. */
  42908. textureCount?: number;
  42909. /**
  42910. * Define if aspect ratio should be adapted to the texture or stay the scene one
  42911. */
  42912. doNotChangeAspectRatio?: boolean;
  42913. /**
  42914. * Define the default type of the buffers we are creating
  42915. */
  42916. defaultType?: number;
  42917. }
  42918. /**
  42919. * A multi render target, like a render target provides the ability to render to a texture.
  42920. * Unlike the render target, it can render to several draw buffers in one draw.
  42921. * This is specially interesting in deferred rendering or for any effects requiring more than
  42922. * just one color from a single pass.
  42923. */
  42924. export class MultiRenderTarget extends RenderTargetTexture {
  42925. private _internalTextures;
  42926. private _textures;
  42927. private _multiRenderTargetOptions;
  42928. /**
  42929. * Get if draw buffers are currently supported by the used hardware and browser.
  42930. */
  42931. readonly isSupported: boolean;
  42932. /**
  42933. * Get the list of textures generated by the multi render target.
  42934. */
  42935. readonly textures: Texture[];
  42936. /**
  42937. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  42938. */
  42939. readonly depthTexture: Texture;
  42940. /**
  42941. * Set the wrapping mode on U of all the textures we are rendering to.
  42942. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  42943. */
  42944. wrapU: number;
  42945. /**
  42946. * Set the wrapping mode on V of all the textures we are rendering to.
  42947. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  42948. */
  42949. wrapV: number;
  42950. /**
  42951. * Instantiate a new multi render target texture.
  42952. * A multi render target, like a render target provides the ability to render to a texture.
  42953. * Unlike the render target, it can render to several draw buffers in one draw.
  42954. * This is specially interesting in deferred rendering or for any effects requiring more than
  42955. * just one color from a single pass.
  42956. * @param name Define the name of the texture
  42957. * @param size Define the size of the buffers to render to
  42958. * @param count Define the number of target we are rendering into
  42959. * @param scene Define the scene the texture belongs to
  42960. * @param options Define the options used to create the multi render target
  42961. */
  42962. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  42963. /** @hidden */ private _rebuild(): void;
  42964. private _createInternalTextures;
  42965. private _createTextures;
  42966. /**
  42967. * Define the number of samples used if MSAA is enabled.
  42968. */
  42969. samples: number;
  42970. /**
  42971. * Resize all the textures in the multi render target.
  42972. * Be carrefull as it will recreate all the data in the new texture.
  42973. * @param size Define the new size
  42974. */
  42975. resize(size: any): void;
  42976. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  42977. /**
  42978. * Dispose the render targets and their associated resources
  42979. */
  42980. dispose(): void;
  42981. /**
  42982. * Release all the underlying texture used as draw buffers.
  42983. */
  42984. releaseInternalTextures(): void;
  42985. }
  42986. }
  42987. declare module BABYLON {
  42988. interface Engine {
  42989. /**
  42990. * Unbind a list of render target textures from the webGL context
  42991. * This is used only when drawBuffer extension or webGL2 are active
  42992. * @param textures defines the render target textures to unbind
  42993. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  42994. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  42995. */
  42996. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  42997. /**
  42998. * Create a multi render target texture
  42999. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43000. * @param size defines the size of the texture
  43001. * @param options defines the creation options
  43002. * @returns the cube texture as an InternalTexture
  43003. */
  43004. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43005. /**
  43006. * Update the sample count for a given multiple render target texture
  43007. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43008. * @param textures defines the textures to update
  43009. * @param samples defines the sample count to set
  43010. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43011. */
  43012. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43013. }
  43014. }
  43015. declare module BABYLON {
  43016. /**
  43017. * Gather the list of clipboard event types as constants.
  43018. */
  43019. export class ClipboardEventTypes {
  43020. /**
  43021. * The clipboard event is fired when a copy command is active (pressed).
  43022. */
  43023. static readonly COPY: number;
  43024. /**
  43025. * The clipboard event is fired when a cut command is active (pressed).
  43026. */
  43027. static readonly CUT: number;
  43028. /**
  43029. * The clipboard event is fired when a paste command is active (pressed).
  43030. */
  43031. static readonly PASTE: number;
  43032. }
  43033. /**
  43034. * This class is used to store clipboard related info for the onClipboardObservable event.
  43035. */
  43036. export class ClipboardInfo {
  43037. /**
  43038. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43039. */
  43040. type: number;
  43041. /**
  43042. * Defines the related dom event
  43043. */
  43044. event: ClipboardEvent;
  43045. /**
  43046. *Creates an instance of ClipboardInfo.
  43047. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43048. * @param event Defines the related dom event
  43049. */
  43050. constructor(
  43051. /**
  43052. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43053. */
  43054. type: number,
  43055. /**
  43056. * Defines the related dom event
  43057. */
  43058. event: ClipboardEvent);
  43059. /**
  43060. * Get the clipboard event's type from the keycode.
  43061. * @param keyCode Defines the keyCode for the current keyboard event.
  43062. * @return {number}
  43063. */
  43064. static GetTypeFromCharacter(keyCode: number): number;
  43065. }
  43066. }
  43067. declare module BABYLON {
  43068. /**
  43069. * Google Daydream controller
  43070. */
  43071. export class DaydreamController extends WebVRController {
  43072. /**
  43073. * Base Url for the controller model.
  43074. */
  43075. static MODEL_BASE_URL: string;
  43076. /**
  43077. * File name for the controller model.
  43078. */
  43079. static MODEL_FILENAME: string;
  43080. /**
  43081. * Gamepad Id prefix used to identify Daydream Controller.
  43082. */
  43083. static readonly GAMEPAD_ID_PREFIX: string;
  43084. /**
  43085. * Creates a new DaydreamController from a gamepad
  43086. * @param vrGamepad the gamepad that the controller should be created from
  43087. */
  43088. constructor(vrGamepad: any);
  43089. /**
  43090. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43091. * @param scene scene in which to add meshes
  43092. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43093. */
  43094. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43095. /**
  43096. * Called once for each button that changed state since the last frame
  43097. * @param buttonIdx Which button index changed
  43098. * @param state New state of the button
  43099. * @param changes Which properties on the state changed since last frame
  43100. */
  43101. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43102. }
  43103. }
  43104. declare module BABYLON {
  43105. /**
  43106. * Gear VR Controller
  43107. */
  43108. export class GearVRController extends WebVRController {
  43109. /**
  43110. * Base Url for the controller model.
  43111. */
  43112. static MODEL_BASE_URL: string;
  43113. /**
  43114. * File name for the controller model.
  43115. */
  43116. static MODEL_FILENAME: string;
  43117. /**
  43118. * Gamepad Id prefix used to identify this controller.
  43119. */
  43120. static readonly GAMEPAD_ID_PREFIX: string;
  43121. private readonly _buttonIndexToObservableNameMap;
  43122. /**
  43123. * Creates a new GearVRController from a gamepad
  43124. * @param vrGamepad the gamepad that the controller should be created from
  43125. */
  43126. constructor(vrGamepad: any);
  43127. /**
  43128. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43129. * @param scene scene in which to add meshes
  43130. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43131. */
  43132. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43133. /**
  43134. * Called once for each button that changed state since the last frame
  43135. * @param buttonIdx Which button index changed
  43136. * @param state New state of the button
  43137. * @param changes Which properties on the state changed since last frame
  43138. */
  43139. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43140. }
  43141. }
  43142. declare module BABYLON {
  43143. /**
  43144. * Class containing static functions to help procedurally build meshes
  43145. */
  43146. export class PolyhedronBuilder {
  43147. /**
  43148. * Creates a polyhedron mesh
  43149. * * 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
  43150. * * The parameter `size` (positive float, default 1) sets the polygon size
  43151. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43152. * * 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`
  43153. * * 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
  43154. * * 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)`)
  43155. * * 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
  43156. * * 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
  43157. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43158. * * 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
  43159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43160. * @param name defines the name of the mesh
  43161. * @param options defines the options used to create the mesh
  43162. * @param scene defines the hosting scene
  43163. * @returns the polyhedron mesh
  43164. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43165. */
  43166. static CreatePolyhedron(name: string, options: {
  43167. type?: number;
  43168. size?: number;
  43169. sizeX?: number;
  43170. sizeY?: number;
  43171. sizeZ?: number;
  43172. custom?: any;
  43173. faceUV?: Vector4[];
  43174. faceColors?: Color4[];
  43175. flat?: boolean;
  43176. updatable?: boolean;
  43177. sideOrientation?: number;
  43178. frontUVs?: Vector4;
  43179. backUVs?: Vector4;
  43180. }, scene?: Nullable<Scene>): Mesh;
  43181. }
  43182. }
  43183. declare module BABYLON {
  43184. /**
  43185. * Gizmo that enables scaling a mesh along 3 axis
  43186. */
  43187. export class ScaleGizmo extends Gizmo {
  43188. /**
  43189. * Internal gizmo used for interactions on the x axis
  43190. */
  43191. xGizmo: AxisScaleGizmo;
  43192. /**
  43193. * Internal gizmo used for interactions on the y axis
  43194. */
  43195. yGizmo: AxisScaleGizmo;
  43196. /**
  43197. * Internal gizmo used for interactions on the z axis
  43198. */
  43199. zGizmo: AxisScaleGizmo;
  43200. /**
  43201. * Internal gizmo used to scale all axis equally
  43202. */
  43203. uniformScaleGizmo: AxisScaleGizmo;
  43204. private _meshAttached;
  43205. private _updateGizmoRotationToMatchAttachedMesh;
  43206. private _snapDistance;
  43207. private _scaleRatio;
  43208. private _uniformScalingMesh;
  43209. private _octahedron;
  43210. /** Fires an event when any of it's sub gizmos are dragged */
  43211. onDragStartObservable: Observable<unknown>;
  43212. /** Fires an event when any of it's sub gizmos are released from dragging */
  43213. onDragEndObservable: Observable<unknown>;
  43214. attachedMesh: Nullable<AbstractMesh>;
  43215. /**
  43216. * Creates a ScaleGizmo
  43217. * @param gizmoLayer The utility layer the gizmo will be added to
  43218. */
  43219. constructor(gizmoLayer?: UtilityLayerRenderer);
  43220. updateGizmoRotationToMatchAttachedMesh: boolean;
  43221. /**
  43222. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43223. */
  43224. snapDistance: number;
  43225. /**
  43226. * Ratio for the scale of the gizmo (Default: 1)
  43227. */
  43228. scaleRatio: number;
  43229. /**
  43230. * Disposes of the gizmo
  43231. */
  43232. dispose(): void;
  43233. }
  43234. }
  43235. declare module BABYLON {
  43236. /**
  43237. * Single axis scale gizmo
  43238. */
  43239. export class AxisScaleGizmo extends Gizmo {
  43240. /**
  43241. * Drag behavior responsible for the gizmos dragging interactions
  43242. */
  43243. dragBehavior: PointerDragBehavior;
  43244. private _pointerObserver;
  43245. /**
  43246. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43247. */
  43248. snapDistance: number;
  43249. /**
  43250. * Event that fires each time the gizmo snaps to a new location.
  43251. * * snapDistance is the the change in distance
  43252. */
  43253. onSnapObservable: Observable<{
  43254. snapDistance: number;
  43255. }>;
  43256. /**
  43257. * If the scaling operation should be done on all axis (default: false)
  43258. */
  43259. uniformScaling: boolean;
  43260. private _isEnabled;
  43261. private _parent;
  43262. private _arrow;
  43263. private _coloredMaterial;
  43264. private _hoverMaterial;
  43265. /**
  43266. * Creates an AxisScaleGizmo
  43267. * @param gizmoLayer The utility layer the gizmo will be added to
  43268. * @param dragAxis The axis which the gizmo will be able to scale on
  43269. * @param color The color of the gizmo
  43270. */
  43271. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  43272. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43273. /**
  43274. * If the gizmo is enabled
  43275. */
  43276. isEnabled: boolean;
  43277. /**
  43278. * Disposes of the gizmo
  43279. */
  43280. dispose(): void;
  43281. /**
  43282. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43283. * @param mesh The mesh to replace the default mesh of the gizmo
  43284. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43285. */
  43286. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43287. }
  43288. }
  43289. declare module BABYLON {
  43290. /**
  43291. * Bounding box gizmo
  43292. */
  43293. export class BoundingBoxGizmo extends Gizmo {
  43294. private _lineBoundingBox;
  43295. private _rotateSpheresParent;
  43296. private _scaleBoxesParent;
  43297. private _boundingDimensions;
  43298. private _renderObserver;
  43299. private _pointerObserver;
  43300. private _scaleDragSpeed;
  43301. private _tmpQuaternion;
  43302. private _tmpVector;
  43303. private _tmpRotationMatrix;
  43304. /**
  43305. * 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)
  43306. */
  43307. ignoreChildren: boolean;
  43308. /**
  43309. * 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)
  43310. */
  43311. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43312. /**
  43313. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43314. */
  43315. rotationSphereSize: number;
  43316. /**
  43317. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43318. */
  43319. scaleBoxSize: number;
  43320. /**
  43321. * 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)
  43322. */
  43323. fixedDragMeshScreenSize: boolean;
  43324. /**
  43325. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43326. */
  43327. fixedDragMeshScreenSizeDistanceFactor: number;
  43328. /**
  43329. * Fired when a rotation sphere or scale box is dragged
  43330. */
  43331. onDragStartObservable: Observable<{}>;
  43332. /**
  43333. * Fired when a scale box is dragged
  43334. */
  43335. onScaleBoxDragObservable: Observable<{}>;
  43336. /**
  43337. * Fired when a scale box drag is ended
  43338. */
  43339. onScaleBoxDragEndObservable: Observable<{}>;
  43340. /**
  43341. * Fired when a rotation sphere is dragged
  43342. */
  43343. onRotationSphereDragObservable: Observable<{}>;
  43344. /**
  43345. * Fired when a rotation sphere drag is ended
  43346. */
  43347. onRotationSphereDragEndObservable: Observable<{}>;
  43348. /**
  43349. * 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)
  43350. */
  43351. scalePivot: Nullable<Vector3>;
  43352. /**
  43353. * Mesh used as a pivot to rotate the attached mesh
  43354. */
  43355. private _anchorMesh;
  43356. private _existingMeshScale;
  43357. private _dragMesh;
  43358. private pointerDragBehavior;
  43359. private coloredMaterial;
  43360. private hoverColoredMaterial;
  43361. /**
  43362. * Sets the color of the bounding box gizmo
  43363. * @param color the color to set
  43364. */
  43365. setColor(color: Color3): void;
  43366. /**
  43367. * Creates an BoundingBoxGizmo
  43368. * @param gizmoLayer The utility layer the gizmo will be added to
  43369. * @param color The color of the gizmo
  43370. */
  43371. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43372. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43373. private _selectNode;
  43374. /**
  43375. * Updates the bounding box information for the Gizmo
  43376. */
  43377. updateBoundingBox(): void;
  43378. private _updateRotationSpheres;
  43379. private _updateScaleBoxes;
  43380. /**
  43381. * Enables rotation on the specified axis and disables rotation on the others
  43382. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43383. */
  43384. setEnabledRotationAxis(axis: string): void;
  43385. /**
  43386. * Enables/disables scaling
  43387. * @param enable if scaling should be enabled
  43388. */
  43389. setEnabledScaling(enable: boolean): void;
  43390. private _updateDummy;
  43391. /**
  43392. * Enables a pointer drag behavior on the bounding box of the gizmo
  43393. */
  43394. enableDragBehavior(): void;
  43395. /**
  43396. * Disposes of the gizmo
  43397. */
  43398. dispose(): void;
  43399. /**
  43400. * 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)
  43401. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43402. * @returns the bounding box mesh with the passed in mesh as a child
  43403. */
  43404. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43405. /**
  43406. * CustomMeshes are not supported by this gizmo
  43407. * @param mesh The mesh to replace the default mesh of the gizmo
  43408. */
  43409. setCustomMesh(mesh: Mesh): void;
  43410. }
  43411. }
  43412. declare module BABYLON {
  43413. /**
  43414. * Single plane rotation gizmo
  43415. */
  43416. export class PlaneRotationGizmo extends Gizmo {
  43417. /**
  43418. * Drag behavior responsible for the gizmos dragging interactions
  43419. */
  43420. dragBehavior: PointerDragBehavior;
  43421. private _pointerObserver;
  43422. /**
  43423. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43424. */
  43425. snapDistance: number;
  43426. /**
  43427. * Event that fires each time the gizmo snaps to a new location.
  43428. * * snapDistance is the the change in distance
  43429. */
  43430. onSnapObservable: Observable<{
  43431. snapDistance: number;
  43432. }>;
  43433. private _isEnabled;
  43434. private _parent;
  43435. /**
  43436. * Creates a PlaneRotationGizmo
  43437. * @param gizmoLayer The utility layer the gizmo will be added to
  43438. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43439. * @param color The color of the gizmo
  43440. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43441. * @param useEulerRotation Use and update Euler angle instead of quaternion
  43442. */
  43443. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  43444. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43445. /**
  43446. * If the gizmo is enabled
  43447. */
  43448. isEnabled: boolean;
  43449. /**
  43450. * Disposes of the gizmo
  43451. */
  43452. dispose(): void;
  43453. }
  43454. }
  43455. declare module BABYLON {
  43456. /**
  43457. * Gizmo that enables rotating a mesh along 3 axis
  43458. */
  43459. export class RotationGizmo extends Gizmo {
  43460. /**
  43461. * Internal gizmo used for interactions on the x axis
  43462. */
  43463. xGizmo: PlaneRotationGizmo;
  43464. /**
  43465. * Internal gizmo used for interactions on the y axis
  43466. */
  43467. yGizmo: PlaneRotationGizmo;
  43468. /**
  43469. * Internal gizmo used for interactions on the z axis
  43470. */
  43471. zGizmo: PlaneRotationGizmo;
  43472. /** Fires an event when any of it's sub gizmos are dragged */
  43473. onDragStartObservable: Observable<unknown>;
  43474. /** Fires an event when any of it's sub gizmos are released from dragging */
  43475. onDragEndObservable: Observable<unknown>;
  43476. private _meshAttached;
  43477. attachedMesh: Nullable<AbstractMesh>;
  43478. /**
  43479. * Creates a RotationGizmo
  43480. * @param gizmoLayer The utility layer the gizmo will be added to
  43481. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43482. * @param useEulerRotation Use and update Euler angle instead of quaternion
  43483. */
  43484. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  43485. updateGizmoRotationToMatchAttachedMesh: boolean;
  43486. /**
  43487. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43488. */
  43489. snapDistance: number;
  43490. /**
  43491. * Ratio for the scale of the gizmo (Default: 1)
  43492. */
  43493. scaleRatio: number;
  43494. /**
  43495. * Disposes of the gizmo
  43496. */
  43497. dispose(): void;
  43498. /**
  43499. * CustomMeshes are not supported by this gizmo
  43500. * @param mesh The mesh to replace the default mesh of the gizmo
  43501. */
  43502. setCustomMesh(mesh: Mesh): void;
  43503. }
  43504. }
  43505. declare module BABYLON {
  43506. /**
  43507. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43508. */
  43509. export class GizmoManager implements IDisposable {
  43510. private scene;
  43511. /**
  43512. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43513. */
  43514. gizmos: {
  43515. positionGizmo: Nullable<PositionGizmo>;
  43516. rotationGizmo: Nullable<RotationGizmo>;
  43517. scaleGizmo: Nullable<ScaleGizmo>;
  43518. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43519. };
  43520. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43521. clearGizmoOnEmptyPointerEvent: boolean;
  43522. /** Fires an event when the manager is attached to a mesh */
  43523. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43524. private _gizmosEnabled;
  43525. private _pointerObserver;
  43526. private _attachedMesh;
  43527. private _boundingBoxColor;
  43528. private _defaultUtilityLayer;
  43529. private _defaultKeepDepthUtilityLayer;
  43530. /**
  43531. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43532. */
  43533. boundingBoxDragBehavior: SixDofDragBehavior;
  43534. /**
  43535. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43536. */
  43537. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43538. /**
  43539. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43540. */
  43541. usePointerToAttachGizmos: boolean;
  43542. /**
  43543. * Utility layer that the bounding box gizmo belongs to
  43544. */
  43545. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  43546. /**
  43547. * Utility layer that all gizmos besides bounding box belong to
  43548. */
  43549. readonly utilityLayer: UtilityLayerRenderer;
  43550. /**
  43551. * Instatiates a gizmo manager
  43552. * @param scene the scene to overlay the gizmos on top of
  43553. */
  43554. constructor(scene: Scene);
  43555. /**
  43556. * Attaches a set of gizmos to the specified mesh
  43557. * @param mesh The mesh the gizmo's should be attached to
  43558. */
  43559. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43560. /**
  43561. * If the position gizmo is enabled
  43562. */
  43563. positionGizmoEnabled: boolean;
  43564. /**
  43565. * If the rotation gizmo is enabled
  43566. */
  43567. rotationGizmoEnabled: boolean;
  43568. /**
  43569. * If the scale gizmo is enabled
  43570. */
  43571. scaleGizmoEnabled: boolean;
  43572. /**
  43573. * If the boundingBox gizmo is enabled
  43574. */
  43575. boundingBoxGizmoEnabled: boolean;
  43576. /**
  43577. * Disposes of the gizmo manager
  43578. */
  43579. dispose(): void;
  43580. }
  43581. }
  43582. declare module BABYLON {
  43583. /**
  43584. * A directional light is defined by a direction (what a surprise!).
  43585. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  43586. * 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.
  43587. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43588. */
  43589. export class DirectionalLight extends ShadowLight {
  43590. private _shadowFrustumSize;
  43591. /**
  43592. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  43593. */
  43594. /**
  43595. * Specifies a fix frustum size for the shadow generation.
  43596. */
  43597. shadowFrustumSize: number;
  43598. private _shadowOrthoScale;
  43599. /**
  43600. * Gets the shadow projection scale against the optimal computed one.
  43601. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43602. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43603. */
  43604. /**
  43605. * Sets the shadow projection scale against the optimal computed one.
  43606. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43607. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43608. */
  43609. shadowOrthoScale: number;
  43610. /**
  43611. * Automatically compute the projection matrix to best fit (including all the casters)
  43612. * on each frame.
  43613. */
  43614. autoUpdateExtends: boolean;
  43615. private _orthoLeft;
  43616. private _orthoRight;
  43617. private _orthoTop;
  43618. private _orthoBottom;
  43619. /**
  43620. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  43621. * The directional light is emitted from everywhere in the given direction.
  43622. * It can cast shadows.
  43623. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43624. * @param name The friendly name of the light
  43625. * @param direction The direction of the light
  43626. * @param scene The scene the light belongs to
  43627. */
  43628. constructor(name: string, direction: Vector3, scene: Scene);
  43629. /**
  43630. * Returns the string "DirectionalLight".
  43631. * @return The class name
  43632. */
  43633. getClassName(): string;
  43634. /**
  43635. * Returns the integer 1.
  43636. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43637. */
  43638. getTypeID(): number;
  43639. /**
  43640. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  43641. * Returns the DirectionalLight Shadow projection matrix.
  43642. */
  43643. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43644. /**
  43645. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  43646. * Returns the DirectionalLight Shadow projection matrix.
  43647. */
  43648. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  43649. /**
  43650. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  43651. * Returns the DirectionalLight Shadow projection matrix.
  43652. */
  43653. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43654. protected _buildUniformLayout(): void;
  43655. /**
  43656. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  43657. * @param effect The effect to update
  43658. * @param lightIndex The index of the light in the effect to update
  43659. * @returns The directional light
  43660. */
  43661. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  43662. /**
  43663. * Gets the minZ used for shadow according to both the scene and the light.
  43664. *
  43665. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43666. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43667. * @param activeCamera The camera we are returning the min for
  43668. * @returns the depth min z
  43669. */
  43670. getDepthMinZ(activeCamera: Camera): number;
  43671. /**
  43672. * Gets the maxZ used for shadow according to both the scene and the light.
  43673. *
  43674. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43675. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43676. * @param activeCamera The camera we are returning the max for
  43677. * @returns the depth max z
  43678. */
  43679. getDepthMaxZ(activeCamera: Camera): number;
  43680. /**
  43681. * Prepares the list of defines specific to the light type.
  43682. * @param defines the list of defines
  43683. * @param lightIndex defines the index of the light for the effect
  43684. */
  43685. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43686. }
  43687. }
  43688. declare module BABYLON {
  43689. /**
  43690. * Class containing static functions to help procedurally build meshes
  43691. */
  43692. export class HemisphereBuilder {
  43693. /**
  43694. * Creates a hemisphere mesh
  43695. * @param name defines the name of the mesh
  43696. * @param options defines the options used to create the mesh
  43697. * @param scene defines the hosting scene
  43698. * @returns the hemisphere mesh
  43699. */
  43700. static CreateHemisphere(name: string, options: {
  43701. segments?: number;
  43702. diameter?: number;
  43703. sideOrientation?: number;
  43704. }, scene: any): Mesh;
  43705. }
  43706. }
  43707. declare module BABYLON {
  43708. /**
  43709. * A spot light is defined by a position, a direction, an angle, and an exponent.
  43710. * These values define a cone of light starting from the position, emitting toward the direction.
  43711. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  43712. * and the exponent defines the speed of the decay of the light with distance (reach).
  43713. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43714. */
  43715. export class SpotLight extends ShadowLight {
  43716. private _angle;
  43717. private _innerAngle;
  43718. private _cosHalfAngle;
  43719. private _lightAngleScale;
  43720. private _lightAngleOffset;
  43721. /**
  43722. * Gets the cone angle of the spot light in Radians.
  43723. */
  43724. /**
  43725. * Sets the cone angle of the spot light in Radians.
  43726. */
  43727. angle: number;
  43728. /**
  43729. * Only used in gltf falloff mode, this defines the angle where
  43730. * the directional falloff will start before cutting at angle which could be seen
  43731. * as outer angle.
  43732. */
  43733. /**
  43734. * Only used in gltf falloff mode, this defines the angle where
  43735. * the directional falloff will start before cutting at angle which could be seen
  43736. * as outer angle.
  43737. */
  43738. innerAngle: number;
  43739. private _shadowAngleScale;
  43740. /**
  43741. * Allows scaling the angle of the light for shadow generation only.
  43742. */
  43743. /**
  43744. * Allows scaling the angle of the light for shadow generation only.
  43745. */
  43746. shadowAngleScale: number;
  43747. /**
  43748. * The light decay speed with the distance from the emission spot.
  43749. */
  43750. exponent: number;
  43751. private _projectionTextureMatrix;
  43752. /**
  43753. * Allows reading the projecton texture
  43754. */
  43755. readonly projectionTextureMatrix: Matrix;
  43756. protected _projectionTextureLightNear: number;
  43757. /**
  43758. * Gets the near clip of the Spotlight for texture projection.
  43759. */
  43760. /**
  43761. * Sets the near clip of the Spotlight for texture projection.
  43762. */
  43763. projectionTextureLightNear: number;
  43764. protected _projectionTextureLightFar: number;
  43765. /**
  43766. * Gets the far clip of the Spotlight for texture projection.
  43767. */
  43768. /**
  43769. * Sets the far clip of the Spotlight for texture projection.
  43770. */
  43771. projectionTextureLightFar: number;
  43772. protected _projectionTextureUpDirection: Vector3;
  43773. /**
  43774. * Gets the Up vector of the Spotlight for texture projection.
  43775. */
  43776. /**
  43777. * Sets the Up vector of the Spotlight for texture projection.
  43778. */
  43779. projectionTextureUpDirection: Vector3;
  43780. private _projectionTexture;
  43781. /**
  43782. * Gets the projection texture of the light.
  43783. */
  43784. /**
  43785. * Sets the projection texture of the light.
  43786. */
  43787. projectionTexture: Nullable<BaseTexture>;
  43788. private _projectionTextureViewLightDirty;
  43789. private _projectionTextureProjectionLightDirty;
  43790. private _projectionTextureDirty;
  43791. private _projectionTextureViewTargetVector;
  43792. private _projectionTextureViewLightMatrix;
  43793. private _projectionTextureProjectionLightMatrix;
  43794. private _projectionTextureScalingMatrix;
  43795. /**
  43796. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  43797. * It can cast shadows.
  43798. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43799. * @param name The light friendly name
  43800. * @param position The position of the spot light in the scene
  43801. * @param direction The direction of the light in the scene
  43802. * @param angle The cone angle of the light in Radians
  43803. * @param exponent The light decay speed with the distance from the emission spot
  43804. * @param scene The scene the lights belongs to
  43805. */
  43806. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  43807. /**
  43808. * Returns the string "SpotLight".
  43809. * @returns the class name
  43810. */
  43811. getClassName(): string;
  43812. /**
  43813. * Returns the integer 2.
  43814. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43815. */
  43816. getTypeID(): number;
  43817. /**
  43818. * Overrides the direction setter to recompute the projection texture view light Matrix.
  43819. */
  43820. protected _setDirection(value: Vector3): void;
  43821. /**
  43822. * Overrides the position setter to recompute the projection texture view light Matrix.
  43823. */
  43824. protected _setPosition(value: Vector3): void;
  43825. /**
  43826. * 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.
  43827. * Returns the SpotLight.
  43828. */
  43829. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43830. protected _computeProjectionTextureViewLightMatrix(): void;
  43831. protected _computeProjectionTextureProjectionLightMatrix(): void;
  43832. /**
  43833. * Main function for light texture projection matrix computing.
  43834. */
  43835. protected _computeProjectionTextureMatrix(): void;
  43836. protected _buildUniformLayout(): void;
  43837. private _computeAngleValues;
  43838. /**
  43839. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  43840. * @param effect The effect to update
  43841. * @param lightIndex The index of the light in the effect to update
  43842. * @returns The spot light
  43843. */
  43844. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  43845. /**
  43846. * Disposes the light and the associated resources.
  43847. */
  43848. dispose(): void;
  43849. /**
  43850. * Prepares the list of defines specific to the light type.
  43851. * @param defines the list of defines
  43852. * @param lightIndex defines the index of the light for the effect
  43853. */
  43854. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43855. }
  43856. }
  43857. declare module BABYLON {
  43858. /**
  43859. * Gizmo that enables viewing a light
  43860. */
  43861. export class LightGizmo extends Gizmo {
  43862. private _lightMesh;
  43863. private _material;
  43864. private cachedPosition;
  43865. private cachedForward;
  43866. /**
  43867. * Creates a LightGizmo
  43868. * @param gizmoLayer The utility layer the gizmo will be added to
  43869. */
  43870. constructor(gizmoLayer?: UtilityLayerRenderer);
  43871. private _light;
  43872. /**
  43873. * The light that the gizmo is attached to
  43874. */
  43875. light: Nullable<Light>;
  43876. /**
  43877. * Gets the material used to render the light gizmo
  43878. */
  43879. readonly material: StandardMaterial;
  43880. /**
  43881. * @hidden
  43882. * Updates the gizmo to match the attached mesh's position/rotation
  43883. */
  43884. protected _update(): void;
  43885. private static _Scale;
  43886. /**
  43887. * Creates the lines for a light mesh
  43888. */
  43889. private static _createLightLines;
  43890. /**
  43891. * Disposes of the light gizmo
  43892. */
  43893. dispose(): void;
  43894. private static _CreateHemisphericLightMesh;
  43895. private static _CreatePointLightMesh;
  43896. private static _CreateSpotLightMesh;
  43897. private static _CreateDirectionalLightMesh;
  43898. }
  43899. }
  43900. declare module BABYLON {
  43901. /** @hidden */
  43902. export var backgroundFragmentDeclaration: {
  43903. name: string;
  43904. shader: string;
  43905. };
  43906. }
  43907. declare module BABYLON {
  43908. /** @hidden */
  43909. export var backgroundUboDeclaration: {
  43910. name: string;
  43911. shader: string;
  43912. };
  43913. }
  43914. declare module BABYLON {
  43915. /** @hidden */
  43916. export var backgroundPixelShader: {
  43917. name: string;
  43918. shader: string;
  43919. };
  43920. }
  43921. declare module BABYLON {
  43922. /** @hidden */
  43923. export var backgroundVertexDeclaration: {
  43924. name: string;
  43925. shader: string;
  43926. };
  43927. }
  43928. declare module BABYLON {
  43929. /** @hidden */
  43930. export var backgroundVertexShader: {
  43931. name: string;
  43932. shader: string;
  43933. };
  43934. }
  43935. declare module BABYLON {
  43936. /**
  43937. * Background material used to create an efficient environement around your scene.
  43938. */
  43939. export class BackgroundMaterial extends PushMaterial {
  43940. /**
  43941. * Standard reflectance value at parallel view angle.
  43942. */
  43943. static StandardReflectance0: number;
  43944. /**
  43945. * Standard reflectance value at grazing angle.
  43946. */
  43947. static StandardReflectance90: number;
  43948. protected _primaryColor: Color3;
  43949. /**
  43950. * Key light Color (multiply against the environement texture)
  43951. */
  43952. primaryColor: Color3;
  43953. protected __perceptualColor: Nullable<Color3>;
  43954. /**
  43955. * Experimental Internal Use Only.
  43956. *
  43957. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43958. * This acts as a helper to set the primary color to a more "human friendly" value.
  43959. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43960. * output color as close as possible from the chosen value.
  43961. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43962. * part of lighting setup.)
  43963. */ private _perceptualColor: Nullable<Color3>;
  43964. protected _primaryColorShadowLevel: float;
  43965. /**
  43966. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43967. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43968. */
  43969. primaryColorShadowLevel: float;
  43970. protected _primaryColorHighlightLevel: float;
  43971. /**
  43972. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43973. * The primary color is used at the level chosen to define what the white area would look.
  43974. */
  43975. primaryColorHighlightLevel: float;
  43976. protected _reflectionTexture: Nullable<BaseTexture>;
  43977. /**
  43978. * Reflection Texture used in the material.
  43979. * Should be author in a specific way for the best result (refer to the documentation).
  43980. */
  43981. reflectionTexture: Nullable<BaseTexture>;
  43982. protected _reflectionBlur: float;
  43983. /**
  43984. * Reflection Texture level of blur.
  43985. *
  43986. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43987. * texture twice.
  43988. */
  43989. reflectionBlur: float;
  43990. protected _diffuseTexture: Nullable<BaseTexture>;
  43991. /**
  43992. * Diffuse Texture used in the material.
  43993. * Should be author in a specific way for the best result (refer to the documentation).
  43994. */
  43995. diffuseTexture: Nullable<BaseTexture>;
  43996. protected _shadowLights: Nullable<IShadowLight[]>;
  43997. /**
  43998. * Specify the list of lights casting shadow on the material.
  43999. * All scene shadow lights will be included if null.
  44000. */
  44001. shadowLights: Nullable<IShadowLight[]>;
  44002. protected _shadowLevel: float;
  44003. /**
  44004. * Helps adjusting the shadow to a softer level if required.
  44005. * 0 means black shadows and 1 means no shadows.
  44006. */
  44007. shadowLevel: float;
  44008. protected _sceneCenter: Vector3;
  44009. /**
  44010. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44011. * It is usually zero but might be interesting to modify according to your setup.
  44012. */
  44013. sceneCenter: Vector3;
  44014. protected _opacityFresnel: boolean;
  44015. /**
  44016. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44017. * This helps ensuring a nice transition when the camera goes under the ground.
  44018. */
  44019. opacityFresnel: boolean;
  44020. protected _reflectionFresnel: boolean;
  44021. /**
  44022. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44023. * This helps adding a mirror texture on the ground.
  44024. */
  44025. reflectionFresnel: boolean;
  44026. protected _reflectionFalloffDistance: number;
  44027. /**
  44028. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44029. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44030. */
  44031. reflectionFalloffDistance: number;
  44032. protected _reflectionAmount: number;
  44033. /**
  44034. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44035. */
  44036. reflectionAmount: number;
  44037. protected _reflectionReflectance0: number;
  44038. /**
  44039. * This specifies the weight of the reflection at grazing angle.
  44040. */
  44041. reflectionReflectance0: number;
  44042. protected _reflectionReflectance90: number;
  44043. /**
  44044. * This specifies the weight of the reflection at a perpendicular point of view.
  44045. */
  44046. reflectionReflectance90: number;
  44047. /**
  44048. * Sets the reflection reflectance fresnel values according to the default standard
  44049. * empirically know to work well :-)
  44050. */
  44051. reflectionStandardFresnelWeight: number;
  44052. protected _useRGBColor: boolean;
  44053. /**
  44054. * Helps to directly use the maps channels instead of their level.
  44055. */
  44056. useRGBColor: boolean;
  44057. protected _enableNoise: boolean;
  44058. /**
  44059. * This helps reducing the banding effect that could occur on the background.
  44060. */
  44061. enableNoise: boolean;
  44062. /**
  44063. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44064. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44065. * Recommended to be keep at 1.0 except for special cases.
  44066. */
  44067. fovMultiplier: number;
  44068. private _fovMultiplier;
  44069. /**
  44070. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44071. */
  44072. useEquirectangularFOV: boolean;
  44073. private _maxSimultaneousLights;
  44074. /**
  44075. * Number of Simultaneous lights allowed on the material.
  44076. */
  44077. maxSimultaneousLights: int;
  44078. /**
  44079. * Default configuration related to image processing available in the Background Material.
  44080. */
  44081. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44082. /**
  44083. * Keep track of the image processing observer to allow dispose and replace.
  44084. */
  44085. private _imageProcessingObserver;
  44086. /**
  44087. * Attaches a new image processing configuration to the PBR Material.
  44088. * @param configuration (if null the scene configuration will be use)
  44089. */
  44090. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44091. /**
  44092. * Gets the image processing configuration used either in this material.
  44093. */
  44094. /**
  44095. * Sets the Default image processing configuration used either in the this material.
  44096. *
  44097. * If sets to null, the scene one is in use.
  44098. */
  44099. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44100. /**
  44101. * Gets wether the color curves effect is enabled.
  44102. */
  44103. /**
  44104. * Sets wether the color curves effect is enabled.
  44105. */
  44106. cameraColorCurvesEnabled: boolean;
  44107. /**
  44108. * Gets wether the color grading effect is enabled.
  44109. */
  44110. /**
  44111. * Gets wether the color grading effect is enabled.
  44112. */
  44113. cameraColorGradingEnabled: boolean;
  44114. /**
  44115. * Gets wether tonemapping is enabled or not.
  44116. */
  44117. /**
  44118. * Sets wether tonemapping is enabled or not
  44119. */
  44120. cameraToneMappingEnabled: boolean;
  44121. /**
  44122. * The camera exposure used on this material.
  44123. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44124. * This corresponds to a photographic exposure.
  44125. */
  44126. /**
  44127. * The camera exposure used on this material.
  44128. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44129. * This corresponds to a photographic exposure.
  44130. */
  44131. cameraExposure: float;
  44132. /**
  44133. * Gets The camera contrast used on this material.
  44134. */
  44135. /**
  44136. * Sets The camera contrast used on this material.
  44137. */
  44138. cameraContrast: float;
  44139. /**
  44140. * Gets the Color Grading 2D Lookup Texture.
  44141. */
  44142. /**
  44143. * Sets the Color Grading 2D Lookup Texture.
  44144. */
  44145. cameraColorGradingTexture: Nullable<BaseTexture>;
  44146. /**
  44147. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44148. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44149. * 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;
  44150. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44151. */
  44152. /**
  44153. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44154. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44155. * 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;
  44156. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44157. */
  44158. cameraColorCurves: Nullable<ColorCurves>;
  44159. /**
  44160. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44161. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44162. */
  44163. switchToBGR: boolean;
  44164. private _renderTargets;
  44165. private _reflectionControls;
  44166. private _white;
  44167. private _primaryShadowColor;
  44168. private _primaryHighlightColor;
  44169. /**
  44170. * Instantiates a Background Material in the given scene
  44171. * @param name The friendly name of the material
  44172. * @param scene The scene to add the material to
  44173. */
  44174. constructor(name: string, scene: Scene);
  44175. /**
  44176. * Gets a boolean indicating that current material needs to register RTT
  44177. */
  44178. readonly hasRenderTargetTextures: boolean;
  44179. /**
  44180. * The entire material has been created in order to prevent overdraw.
  44181. * @returns false
  44182. */
  44183. needAlphaTesting(): boolean;
  44184. /**
  44185. * The entire material has been created in order to prevent overdraw.
  44186. * @returns true if blending is enable
  44187. */
  44188. needAlphaBlending(): boolean;
  44189. /**
  44190. * Checks wether the material is ready to be rendered for a given mesh.
  44191. * @param mesh The mesh to render
  44192. * @param subMesh The submesh to check against
  44193. * @param useInstances Specify wether or not the material is used with instances
  44194. * @returns true if all the dependencies are ready (Textures, Effects...)
  44195. */
  44196. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44197. /**
  44198. * Compute the primary color according to the chosen perceptual color.
  44199. */
  44200. private _computePrimaryColorFromPerceptualColor;
  44201. /**
  44202. * Compute the highlights and shadow colors according to their chosen levels.
  44203. */
  44204. private _computePrimaryColors;
  44205. /**
  44206. * Build the uniform buffer used in the material.
  44207. */
  44208. buildUniformLayout(): void;
  44209. /**
  44210. * Unbind the material.
  44211. */
  44212. unbind(): void;
  44213. /**
  44214. * Bind only the world matrix to the material.
  44215. * @param world The world matrix to bind.
  44216. */
  44217. bindOnlyWorldMatrix(world: Matrix): void;
  44218. /**
  44219. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44220. * @param world The world matrix to bind.
  44221. * @param subMesh The submesh to bind for.
  44222. */
  44223. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44224. /**
  44225. * Dispose the material.
  44226. * @param forceDisposeEffect Force disposal of the associated effect.
  44227. * @param forceDisposeTextures Force disposal of the associated textures.
  44228. */
  44229. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44230. /**
  44231. * Clones the material.
  44232. * @param name The cloned name.
  44233. * @returns The cloned material.
  44234. */
  44235. clone(name: string): BackgroundMaterial;
  44236. /**
  44237. * Serializes the current material to its JSON representation.
  44238. * @returns The JSON representation.
  44239. */
  44240. serialize(): any;
  44241. /**
  44242. * Gets the class name of the material
  44243. * @returns "BackgroundMaterial"
  44244. */
  44245. getClassName(): string;
  44246. /**
  44247. * Parse a JSON input to create back a background material.
  44248. * @param source The JSON data to parse
  44249. * @param scene The scene to create the parsed material in
  44250. * @param rootUrl The root url of the assets the material depends upon
  44251. * @returns the instantiated BackgroundMaterial.
  44252. */
  44253. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44254. }
  44255. }
  44256. declare module BABYLON {
  44257. /**
  44258. * Represents the different options available during the creation of
  44259. * a Environment helper.
  44260. *
  44261. * This can control the default ground, skybox and image processing setup of your scene.
  44262. */
  44263. export interface IEnvironmentHelperOptions {
  44264. /**
  44265. * Specifies wether or not to create a ground.
  44266. * True by default.
  44267. */
  44268. createGround: boolean;
  44269. /**
  44270. * Specifies the ground size.
  44271. * 15 by default.
  44272. */
  44273. groundSize: number;
  44274. /**
  44275. * The texture used on the ground for the main color.
  44276. * Comes from the BabylonJS CDN by default.
  44277. *
  44278. * Remarks: Can be either a texture or a url.
  44279. */
  44280. groundTexture: string | BaseTexture;
  44281. /**
  44282. * The color mixed in the ground texture by default.
  44283. * BabylonJS clearColor by default.
  44284. */
  44285. groundColor: Color3;
  44286. /**
  44287. * Specifies the ground opacity.
  44288. * 1 by default.
  44289. */
  44290. groundOpacity: number;
  44291. /**
  44292. * Enables the ground to receive shadows.
  44293. * True by default.
  44294. */
  44295. enableGroundShadow: boolean;
  44296. /**
  44297. * Helps preventing the shadow to be fully black on the ground.
  44298. * 0.5 by default.
  44299. */
  44300. groundShadowLevel: number;
  44301. /**
  44302. * Creates a mirror texture attach to the ground.
  44303. * false by default.
  44304. */
  44305. enableGroundMirror: boolean;
  44306. /**
  44307. * Specifies the ground mirror size ratio.
  44308. * 0.3 by default as the default kernel is 64.
  44309. */
  44310. groundMirrorSizeRatio: number;
  44311. /**
  44312. * Specifies the ground mirror blur kernel size.
  44313. * 64 by default.
  44314. */
  44315. groundMirrorBlurKernel: number;
  44316. /**
  44317. * Specifies the ground mirror visibility amount.
  44318. * 1 by default
  44319. */
  44320. groundMirrorAmount: number;
  44321. /**
  44322. * Specifies the ground mirror reflectance weight.
  44323. * This uses the standard weight of the background material to setup the fresnel effect
  44324. * of the mirror.
  44325. * 1 by default.
  44326. */
  44327. groundMirrorFresnelWeight: number;
  44328. /**
  44329. * Specifies the ground mirror Falloff distance.
  44330. * This can helps reducing the size of the reflection.
  44331. * 0 by Default.
  44332. */
  44333. groundMirrorFallOffDistance: number;
  44334. /**
  44335. * Specifies the ground mirror texture type.
  44336. * Unsigned Int by Default.
  44337. */
  44338. groundMirrorTextureType: number;
  44339. /**
  44340. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44341. * the shown objects.
  44342. */
  44343. groundYBias: number;
  44344. /**
  44345. * Specifies wether or not to create a skybox.
  44346. * True by default.
  44347. */
  44348. createSkybox: boolean;
  44349. /**
  44350. * Specifies the skybox size.
  44351. * 20 by default.
  44352. */
  44353. skyboxSize: number;
  44354. /**
  44355. * The texture used on the skybox for the main color.
  44356. * Comes from the BabylonJS CDN by default.
  44357. *
  44358. * Remarks: Can be either a texture or a url.
  44359. */
  44360. skyboxTexture: string | BaseTexture;
  44361. /**
  44362. * The color mixed in the skybox texture by default.
  44363. * BabylonJS clearColor by default.
  44364. */
  44365. skyboxColor: Color3;
  44366. /**
  44367. * The background rotation around the Y axis of the scene.
  44368. * This helps aligning the key lights of your scene with the background.
  44369. * 0 by default.
  44370. */
  44371. backgroundYRotation: number;
  44372. /**
  44373. * Compute automatically the size of the elements to best fit with the scene.
  44374. */
  44375. sizeAuto: boolean;
  44376. /**
  44377. * Default position of the rootMesh if autoSize is not true.
  44378. */
  44379. rootPosition: Vector3;
  44380. /**
  44381. * Sets up the image processing in the scene.
  44382. * true by default.
  44383. */
  44384. setupImageProcessing: boolean;
  44385. /**
  44386. * The texture used as your environment texture in the scene.
  44387. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44388. *
  44389. * Remarks: Can be either a texture or a url.
  44390. */
  44391. environmentTexture: string | BaseTexture;
  44392. /**
  44393. * The value of the exposure to apply to the scene.
  44394. * 0.6 by default if setupImageProcessing is true.
  44395. */
  44396. cameraExposure: number;
  44397. /**
  44398. * The value of the contrast to apply to the scene.
  44399. * 1.6 by default if setupImageProcessing is true.
  44400. */
  44401. cameraContrast: number;
  44402. /**
  44403. * Specifies wether or not tonemapping should be enabled in the scene.
  44404. * true by default if setupImageProcessing is true.
  44405. */
  44406. toneMappingEnabled: boolean;
  44407. }
  44408. /**
  44409. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44410. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44411. * It also helps with the default setup of your imageProcessing configuration.
  44412. */
  44413. export class EnvironmentHelper {
  44414. /**
  44415. * Default ground texture URL.
  44416. */
  44417. private static _groundTextureCDNUrl;
  44418. /**
  44419. * Default skybox texture URL.
  44420. */
  44421. private static _skyboxTextureCDNUrl;
  44422. /**
  44423. * Default environment texture URL.
  44424. */
  44425. private static _environmentTextureCDNUrl;
  44426. /**
  44427. * Creates the default options for the helper.
  44428. */
  44429. private static _getDefaultOptions;
  44430. private _rootMesh;
  44431. /**
  44432. * Gets the root mesh created by the helper.
  44433. */
  44434. readonly rootMesh: Mesh;
  44435. private _skybox;
  44436. /**
  44437. * Gets the skybox created by the helper.
  44438. */
  44439. readonly skybox: Nullable<Mesh>;
  44440. private _skyboxTexture;
  44441. /**
  44442. * Gets the skybox texture created by the helper.
  44443. */
  44444. readonly skyboxTexture: Nullable<BaseTexture>;
  44445. private _skyboxMaterial;
  44446. /**
  44447. * Gets the skybox material created by the helper.
  44448. */
  44449. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44450. private _ground;
  44451. /**
  44452. * Gets the ground mesh created by the helper.
  44453. */
  44454. readonly ground: Nullable<Mesh>;
  44455. private _groundTexture;
  44456. /**
  44457. * Gets the ground texture created by the helper.
  44458. */
  44459. readonly groundTexture: Nullable<BaseTexture>;
  44460. private _groundMirror;
  44461. /**
  44462. * Gets the ground mirror created by the helper.
  44463. */
  44464. readonly groundMirror: Nullable<MirrorTexture>;
  44465. /**
  44466. * Gets the ground mirror render list to helps pushing the meshes
  44467. * you wish in the ground reflection.
  44468. */
  44469. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44470. private _groundMaterial;
  44471. /**
  44472. * Gets the ground material created by the helper.
  44473. */
  44474. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44475. /**
  44476. * Stores the creation options.
  44477. */
  44478. private readonly _scene;
  44479. private _options;
  44480. /**
  44481. * This observable will be notified with any error during the creation of the environment,
  44482. * mainly texture creation errors.
  44483. */
  44484. onErrorObservable: Observable<{
  44485. message?: string;
  44486. exception?: any;
  44487. }>;
  44488. /**
  44489. * constructor
  44490. * @param options Defines the options we want to customize the helper
  44491. * @param scene The scene to add the material to
  44492. */
  44493. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44494. /**
  44495. * Updates the background according to the new options
  44496. * @param options
  44497. */
  44498. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44499. /**
  44500. * Sets the primary color of all the available elements.
  44501. * @param color the main color to affect to the ground and the background
  44502. */
  44503. setMainColor(color: Color3): void;
  44504. /**
  44505. * Setup the image processing according to the specified options.
  44506. */
  44507. private _setupImageProcessing;
  44508. /**
  44509. * Setup the environment texture according to the specified options.
  44510. */
  44511. private _setupEnvironmentTexture;
  44512. /**
  44513. * Setup the background according to the specified options.
  44514. */
  44515. private _setupBackground;
  44516. /**
  44517. * Get the scene sizes according to the setup.
  44518. */
  44519. private _getSceneSize;
  44520. /**
  44521. * Setup the ground according to the specified options.
  44522. */
  44523. private _setupGround;
  44524. /**
  44525. * Setup the ground material according to the specified options.
  44526. */
  44527. private _setupGroundMaterial;
  44528. /**
  44529. * Setup the ground diffuse texture according to the specified options.
  44530. */
  44531. private _setupGroundDiffuseTexture;
  44532. /**
  44533. * Setup the ground mirror texture according to the specified options.
  44534. */
  44535. private _setupGroundMirrorTexture;
  44536. /**
  44537. * Setup the ground to receive the mirror texture.
  44538. */
  44539. private _setupMirrorInGroundMaterial;
  44540. /**
  44541. * Setup the skybox according to the specified options.
  44542. */
  44543. private _setupSkybox;
  44544. /**
  44545. * Setup the skybox material according to the specified options.
  44546. */
  44547. private _setupSkyboxMaterial;
  44548. /**
  44549. * Setup the skybox reflection texture according to the specified options.
  44550. */
  44551. private _setupSkyboxReflectionTexture;
  44552. private _errorHandler;
  44553. /**
  44554. * Dispose all the elements created by the Helper.
  44555. */
  44556. dispose(): void;
  44557. }
  44558. }
  44559. declare module BABYLON {
  44560. /**
  44561. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44562. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44563. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44564. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44565. */
  44566. export class PhotoDome extends TransformNode {
  44567. /**
  44568. * Define the image as a Monoscopic panoramic 360 image.
  44569. */
  44570. static readonly MODE_MONOSCOPIC: number;
  44571. /**
  44572. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  44573. */
  44574. static readonly MODE_TOPBOTTOM: number;
  44575. /**
  44576. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  44577. */
  44578. static readonly MODE_SIDEBYSIDE: number;
  44579. private _useDirectMapping;
  44580. /**
  44581. * The texture being displayed on the sphere
  44582. */
  44583. protected _photoTexture: Texture;
  44584. /**
  44585. * Gets or sets the texture being displayed on the sphere
  44586. */
  44587. photoTexture: Texture;
  44588. /**
  44589. * Observable raised when an error occured while loading the 360 image
  44590. */
  44591. onLoadErrorObservable: Observable<string>;
  44592. /**
  44593. * The skybox material
  44594. */
  44595. protected _material: BackgroundMaterial;
  44596. /**
  44597. * The surface used for the skybox
  44598. */
  44599. protected _mesh: Mesh;
  44600. /**
  44601. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44602. * Also see the options.resolution property.
  44603. */
  44604. fovMultiplier: number;
  44605. private _imageMode;
  44606. /**
  44607. * Gets or set the current video mode for the video. It can be:
  44608. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  44609. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  44610. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  44611. */
  44612. imageMode: number;
  44613. /**
  44614. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44615. * @param name Element's name, child elements will append suffixes for their own names.
  44616. * @param urlsOfPhoto defines the url of the photo to display
  44617. * @param options defines an object containing optional or exposed sub element properties
  44618. * @param onError defines a callback called when an error occured while loading the texture
  44619. */
  44620. constructor(name: string, urlOfPhoto: string, options: {
  44621. resolution?: number;
  44622. size?: number;
  44623. useDirectMapping?: boolean;
  44624. faceForward?: boolean;
  44625. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44626. private _onBeforeCameraRenderObserver;
  44627. private _changeImageMode;
  44628. /**
  44629. * Releases resources associated with this node.
  44630. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44631. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44632. */
  44633. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44634. }
  44635. }
  44636. declare module BABYLON {
  44637. /** @hidden */
  44638. export var rgbdDecodePixelShader: {
  44639. name: string;
  44640. shader: string;
  44641. };
  44642. }
  44643. declare module BABYLON {
  44644. /**
  44645. * Class used to host texture specific utilities
  44646. */
  44647. export class BRDFTextureTools {
  44648. /**
  44649. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  44650. * @param texture the texture to expand.
  44651. */
  44652. private static _ExpandDefaultBRDFTexture;
  44653. /**
  44654. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44655. * @param scene defines the hosting scene
  44656. * @returns the environment BRDF texture
  44657. */
  44658. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44659. private static _environmentBRDFBase64Texture;
  44660. }
  44661. }
  44662. declare module BABYLON {
  44663. /**
  44664. * @hidden
  44665. */
  44666. export interface IMaterialClearCoatDefines {
  44667. CLEARCOAT: boolean;
  44668. CLEARCOAT_DEFAULTIOR: boolean;
  44669. CLEARCOAT_TEXTURE: boolean;
  44670. CLEARCOAT_TEXTUREDIRECTUV: number;
  44671. CLEARCOAT_BUMP: boolean;
  44672. CLEARCOAT_BUMPDIRECTUV: number;
  44673. CLEARCOAT_TINT: boolean;
  44674. CLEARCOAT_TINT_TEXTURE: boolean;
  44675. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44676. /** @hidden */ private _areTexturesDirty: boolean;
  44677. }
  44678. /**
  44679. * Define the code related to the clear coat parameters of the pbr material.
  44680. */
  44681. export class PBRClearCoatConfiguration {
  44682. /**
  44683. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44684. * The default fits with a polyurethane material.
  44685. */
  44686. private static readonly _DefaultIndexOfRefraction;
  44687. private _isEnabled;
  44688. /**
  44689. * Defines if the clear coat is enabled in the material.
  44690. */
  44691. isEnabled: boolean;
  44692. /**
  44693. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44694. */
  44695. intensity: number;
  44696. /**
  44697. * Defines the clear coat layer roughness.
  44698. */
  44699. roughness: number;
  44700. private _indexOfRefraction;
  44701. /**
  44702. * Defines the index of refraction of the clear coat.
  44703. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44704. * The default fits with a polyurethane material.
  44705. * Changing the default value is more performance intensive.
  44706. */
  44707. indexOfRefraction: number;
  44708. private _texture;
  44709. /**
  44710. * Stores the clear coat values in a texture.
  44711. */
  44712. texture: Nullable<BaseTexture>;
  44713. private _bumpTexture;
  44714. /**
  44715. * Define the clear coat specific bump texture.
  44716. */
  44717. bumpTexture: Nullable<BaseTexture>;
  44718. private _isTintEnabled;
  44719. /**
  44720. * Defines if the clear coat tint is enabled in the material.
  44721. */
  44722. isTintEnabled: boolean;
  44723. /**
  44724. * Defines the clear coat tint of the material.
  44725. * This is only use if tint is enabled
  44726. */
  44727. tintColor: Color3;
  44728. /**
  44729. * Defines the distance at which the tint color should be found in the
  44730. * clear coat media.
  44731. * This is only use if tint is enabled
  44732. */
  44733. tintColorAtDistance: number;
  44734. /**
  44735. * Defines the clear coat layer thickness.
  44736. * This is only use if tint is enabled
  44737. */
  44738. tintThickness: number;
  44739. private _tintTexture;
  44740. /**
  44741. * Stores the clear tint values in a texture.
  44742. * rgb is tint
  44743. * a is a thickness factor
  44744. */
  44745. tintTexture: Nullable<BaseTexture>;
  44746. /** @hidden */
  44747. private _internalMarkAllSubMeshesAsTexturesDirty;
  44748. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  44749. /**
  44750. * Instantiate a new istance of clear coat configuration.
  44751. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44752. */
  44753. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44754. /**
  44755. * Gets wehter the submesh is ready to be used or not.
  44756. * @param defines the list of "defines" to update.
  44757. * @param scene defines the scene the material belongs to.
  44758. * @param engine defines the engine the material belongs to.
  44759. * @param disableBumpMap defines wether the material disables bump or not.
  44760. * @returns - boolean indicating that the submesh is ready or not.
  44761. */
  44762. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44763. /**
  44764. * Checks to see if a texture is used in the material.
  44765. * @param defines the list of "defines" to update.
  44766. * @param scene defines the scene to the material belongs to.
  44767. */
  44768. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44769. /**
  44770. * Binds the material data.
  44771. * @param uniformBuffer defines the Uniform buffer to fill in.
  44772. * @param scene defines the scene the material belongs to.
  44773. * @param engine defines the engine the material belongs to.
  44774. * @param disableBumpMap defines wether the material disables bump or not.
  44775. * @param isFrozen defines wether the material is frozen or not.
  44776. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44777. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44778. */
  44779. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44780. /**
  44781. * Checks to see if a texture is used in the material.
  44782. * @param texture - Base texture to use.
  44783. * @returns - Boolean specifying if a texture is used in the material.
  44784. */
  44785. hasTexture(texture: BaseTexture): boolean;
  44786. /**
  44787. * Returns an array of the actively used textures.
  44788. * @param activeTextures Array of BaseTextures
  44789. */
  44790. getActiveTextures(activeTextures: BaseTexture[]): void;
  44791. /**
  44792. * Returns the animatable textures.
  44793. * @param animatables Array of animatable textures.
  44794. */
  44795. getAnimatables(animatables: IAnimatable[]): void;
  44796. /**
  44797. * Disposes the resources of the material.
  44798. * @param forceDisposeTextures - Forces the disposal of all textures.
  44799. */
  44800. dispose(forceDisposeTextures?: boolean): void;
  44801. /**
  44802. * Get the current class name of the texture useful for serialization or dynamic coding.
  44803. * @returns "PBRClearCoatConfiguration"
  44804. */
  44805. getClassName(): string;
  44806. /**
  44807. * Add fallbacks to the effect fallbacks list.
  44808. * @param defines defines the Base texture to use.
  44809. * @param fallbacks defines the current fallback list.
  44810. * @param currentRank defines the current fallback rank.
  44811. * @returns the new fallback rank.
  44812. */
  44813. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44814. /**
  44815. * Add the required uniforms to the current list.
  44816. * @param uniforms defines the current uniform list.
  44817. */
  44818. static AddUniforms(uniforms: string[]): void;
  44819. /**
  44820. * Add the required samplers to the current list.
  44821. * @param samplers defines the current sampler list.
  44822. */
  44823. static AddSamplers(samplers: string[]): void;
  44824. /**
  44825. * Add the required uniforms to the current buffer.
  44826. * @param uniformBuffer defines the current uniform buffer.
  44827. */
  44828. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44829. /**
  44830. * Makes a duplicate of the current configuration into another one.
  44831. * @param clearCoatConfiguration define the config where to copy the info
  44832. */
  44833. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44834. /**
  44835. * Serializes this clear coat configuration.
  44836. * @returns - An object with the serialized config.
  44837. */
  44838. serialize(): any;
  44839. /**
  44840. * Parses a anisotropy Configuration from a serialized object.
  44841. * @param source - Serialized object.
  44842. * @param scene Defines the scene we are parsing for
  44843. * @param rootUrl Defines the rootUrl to load from
  44844. */
  44845. parse(source: any, scene: Scene, rootUrl: string): void;
  44846. }
  44847. }
  44848. declare module BABYLON {
  44849. /**
  44850. * @hidden
  44851. */
  44852. export interface IMaterialAnisotropicDefines {
  44853. ANISOTROPIC: boolean;
  44854. ANISOTROPIC_TEXTURE: boolean;
  44855. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44856. MAINUV1: boolean; private _areTexturesDirty: boolean; private _needUVs: boolean;
  44857. }
  44858. /**
  44859. * Define the code related to the anisotropic parameters of the pbr material.
  44860. */
  44861. export class PBRAnisotropicConfiguration {
  44862. private _isEnabled;
  44863. /**
  44864. * Defines if the anisotropy is enabled in the material.
  44865. */
  44866. isEnabled: boolean;
  44867. /**
  44868. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44869. */
  44870. intensity: number;
  44871. /**
  44872. * Defines if the effect is along the tangents, bitangents or in between.
  44873. * By default, the effect is "strectching" the highlights along the tangents.
  44874. */
  44875. direction: Vector2;
  44876. private _texture;
  44877. /**
  44878. * Stores the anisotropy values in a texture.
  44879. * rg is direction (like normal from -1 to 1)
  44880. * b is a intensity
  44881. */
  44882. texture: Nullable<BaseTexture>;
  44883. /** @hidden */
  44884. private _internalMarkAllSubMeshesAsTexturesDirty;
  44885. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  44886. /**
  44887. * Instantiate a new istance of anisotropy configuration.
  44888. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44889. */
  44890. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44891. /**
  44892. * Specifies that the submesh is ready to be used.
  44893. * @param defines the list of "defines" to update.
  44894. * @param scene defines the scene the material belongs to.
  44895. * @returns - boolean indicating that the submesh is ready or not.
  44896. */
  44897. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44898. /**
  44899. * Checks to see if a texture is used in the material.
  44900. * @param defines the list of "defines" to update.
  44901. * @param mesh the mesh we are preparing the defines for.
  44902. * @param scene defines the scene the material belongs to.
  44903. */
  44904. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44905. /**
  44906. * Binds the material data.
  44907. * @param uniformBuffer defines the Uniform buffer to fill in.
  44908. * @param scene defines the scene the material belongs to.
  44909. * @param isFrozen defines wether the material is frozen or not.
  44910. */
  44911. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44912. /**
  44913. * Checks to see if a texture is used in the material.
  44914. * @param texture - Base texture to use.
  44915. * @returns - Boolean specifying if a texture is used in the material.
  44916. */
  44917. hasTexture(texture: BaseTexture): boolean;
  44918. /**
  44919. * Returns an array of the actively used textures.
  44920. * @param activeTextures Array of BaseTextures
  44921. */
  44922. getActiveTextures(activeTextures: BaseTexture[]): void;
  44923. /**
  44924. * Returns the animatable textures.
  44925. * @param animatables Array of animatable textures.
  44926. */
  44927. getAnimatables(animatables: IAnimatable[]): void;
  44928. /**
  44929. * Disposes the resources of the material.
  44930. * @param forceDisposeTextures - Forces the disposal of all textures.
  44931. */
  44932. dispose(forceDisposeTextures?: boolean): void;
  44933. /**
  44934. * Get the current class name of the texture useful for serialization or dynamic coding.
  44935. * @returns "PBRAnisotropicConfiguration"
  44936. */
  44937. getClassName(): string;
  44938. /**
  44939. * Add fallbacks to the effect fallbacks list.
  44940. * @param defines defines the Base texture to use.
  44941. * @param fallbacks defines the current fallback list.
  44942. * @param currentRank defines the current fallback rank.
  44943. * @returns the new fallback rank.
  44944. */
  44945. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44946. /**
  44947. * Add the required uniforms to the current list.
  44948. * @param uniforms defines the current uniform list.
  44949. */
  44950. static AddUniforms(uniforms: string[]): void;
  44951. /**
  44952. * Add the required uniforms to the current buffer.
  44953. * @param uniformBuffer defines the current uniform buffer.
  44954. */
  44955. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44956. /**
  44957. * Add the required samplers to the current list.
  44958. * @param samplers defines the current sampler list.
  44959. */
  44960. static AddSamplers(samplers: string[]): void;
  44961. /**
  44962. * Makes a duplicate of the current configuration into another one.
  44963. * @param anisotropicConfiguration define the config where to copy the info
  44964. */
  44965. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44966. /**
  44967. * Serializes this anisotropy configuration.
  44968. * @returns - An object with the serialized config.
  44969. */
  44970. serialize(): any;
  44971. /**
  44972. * Parses a anisotropy Configuration from a serialized object.
  44973. * @param source - Serialized object.
  44974. * @param scene Defines the scene we are parsing for
  44975. * @param rootUrl Defines the rootUrl to load from
  44976. */
  44977. parse(source: any, scene: Scene, rootUrl: string): void;
  44978. }
  44979. }
  44980. declare module BABYLON {
  44981. /**
  44982. * @hidden
  44983. */
  44984. export interface IMaterialBRDFDefines {
  44985. BRDF_V_HEIGHT_CORRELATED: boolean;
  44986. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44987. SPHERICAL_HARMONICS: boolean;
  44988. /** @hidden */ private _areMiscDirty: boolean;
  44989. }
  44990. /**
  44991. * Define the code related to the BRDF parameters of the pbr material.
  44992. */
  44993. export class PBRBRDFConfiguration {
  44994. /**
  44995. * Default value used for the energy conservation.
  44996. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44997. */
  44998. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  44999. /**
  45000. * Default value used for the Smith Visibility Height Correlated mode.
  45001. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45002. */
  45003. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  45004. /**
  45005. * Default value used for the IBL diffuse part.
  45006. * This can help switching back to the polynomials mode globally which is a tiny bit
  45007. * less GPU intensive at the drawback of a lower quality.
  45008. */
  45009. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  45010. private _useEnergyConservation;
  45011. /**
  45012. * Defines if the material uses energy conservation.
  45013. */
  45014. useEnergyConservation: boolean;
  45015. private _useSmithVisibilityHeightCorrelated;
  45016. /**
  45017. * LEGACY Mode set to false
  45018. * Defines if the material uses height smith correlated visibility term.
  45019. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45020. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45021. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45022. * Not relying on height correlated will also disable energy conservation.
  45023. */
  45024. useSmithVisibilityHeightCorrelated: boolean;
  45025. private _useSphericalHarmonics;
  45026. /**
  45027. * LEGACY Mode set to false
  45028. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  45029. * diffuse part of the IBL.
  45030. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  45031. * to the ground truth.
  45032. */
  45033. useSphericalHarmonics: boolean;
  45034. /** @hidden */
  45035. private _internalMarkAllSubMeshesAsMiscDirty;
  45036. /** @hidden */ private _markAllSubMeshesAsMiscDirty(): void;
  45037. /**
  45038. * Instantiate a new istance of clear coat configuration.
  45039. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45040. */
  45041. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45042. /**
  45043. * Checks to see if a texture is used in the material.
  45044. * @param defines the list of "defines" to update.
  45045. */
  45046. prepareDefines(defines: IMaterialBRDFDefines): void;
  45047. /**
  45048. * Get the current class name of the texture useful for serialization or dynamic coding.
  45049. * @returns "PBRClearCoatConfiguration"
  45050. */
  45051. getClassName(): string;
  45052. /**
  45053. * Makes a duplicate of the current configuration into another one.
  45054. * @param brdfConfiguration define the config where to copy the info
  45055. */
  45056. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45057. /**
  45058. * Serializes this BRDF configuration.
  45059. * @returns - An object with the serialized config.
  45060. */
  45061. serialize(): any;
  45062. /**
  45063. * Parses a anisotropy Configuration from a serialized object.
  45064. * @param source - Serialized object.
  45065. * @param scene Defines the scene we are parsing for
  45066. * @param rootUrl Defines the rootUrl to load from
  45067. */
  45068. parse(source: any, scene: Scene, rootUrl: string): void;
  45069. }
  45070. }
  45071. declare module BABYLON {
  45072. /**
  45073. * @hidden
  45074. */
  45075. export interface IMaterialSheenDefines {
  45076. SHEEN: boolean;
  45077. SHEEN_TEXTURE: boolean;
  45078. SHEEN_TEXTUREDIRECTUV: number;
  45079. SHEEN_LINKWITHALBEDO: boolean;
  45080. /** @hidden */ private _areTexturesDirty: boolean;
  45081. }
  45082. /**
  45083. * Define the code related to the Sheen parameters of the pbr material.
  45084. */
  45085. export class PBRSheenConfiguration {
  45086. private _isEnabled;
  45087. /**
  45088. * Defines if the material uses sheen.
  45089. */
  45090. isEnabled: boolean;
  45091. private _linkSheenWithAlbedo;
  45092. /**
  45093. * Defines if the sheen is linked to the sheen color.
  45094. */
  45095. linkSheenWithAlbedo: boolean;
  45096. /**
  45097. * Defines the sheen intensity.
  45098. */
  45099. intensity: number;
  45100. /**
  45101. * Defines the sheen color.
  45102. */
  45103. color: Color3;
  45104. private _texture;
  45105. /**
  45106. * Stores the sheen tint values in a texture.
  45107. * rgb is tint
  45108. * a is a intensity
  45109. */
  45110. texture: Nullable<BaseTexture>;
  45111. /** @hidden */
  45112. private _internalMarkAllSubMeshesAsTexturesDirty;
  45113. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  45114. /**
  45115. * Instantiate a new istance of clear coat configuration.
  45116. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45117. */
  45118. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45119. /**
  45120. * Specifies that the submesh is ready to be used.
  45121. * @param defines the list of "defines" to update.
  45122. * @param scene defines the scene the material belongs to.
  45123. * @returns - boolean indicating that the submesh is ready or not.
  45124. */
  45125. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45126. /**
  45127. * Checks to see if a texture is used in the material.
  45128. * @param defines the list of "defines" to update.
  45129. * @param scene defines the scene the material belongs to.
  45130. */
  45131. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45132. /**
  45133. * Binds the material data.
  45134. * @param uniformBuffer defines the Uniform buffer to fill in.
  45135. * @param scene defines the scene the material belongs to.
  45136. * @param isFrozen defines wether the material is frozen or not.
  45137. */
  45138. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45139. /**
  45140. * Checks to see if a texture is used in the material.
  45141. * @param texture - Base texture to use.
  45142. * @returns - Boolean specifying if a texture is used in the material.
  45143. */
  45144. hasTexture(texture: BaseTexture): boolean;
  45145. /**
  45146. * Returns an array of the actively used textures.
  45147. * @param activeTextures Array of BaseTextures
  45148. */
  45149. getActiveTextures(activeTextures: BaseTexture[]): void;
  45150. /**
  45151. * Returns the animatable textures.
  45152. * @param animatables Array of animatable textures.
  45153. */
  45154. getAnimatables(animatables: IAnimatable[]): void;
  45155. /**
  45156. * Disposes the resources of the material.
  45157. * @param forceDisposeTextures - Forces the disposal of all textures.
  45158. */
  45159. dispose(forceDisposeTextures?: boolean): void;
  45160. /**
  45161. * Get the current class name of the texture useful for serialization or dynamic coding.
  45162. * @returns "PBRSheenConfiguration"
  45163. */
  45164. getClassName(): string;
  45165. /**
  45166. * Add fallbacks to the effect fallbacks list.
  45167. * @param defines defines the Base texture to use.
  45168. * @param fallbacks defines the current fallback list.
  45169. * @param currentRank defines the current fallback rank.
  45170. * @returns the new fallback rank.
  45171. */
  45172. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45173. /**
  45174. * Add the required uniforms to the current list.
  45175. * @param uniforms defines the current uniform list.
  45176. */
  45177. static AddUniforms(uniforms: string[]): void;
  45178. /**
  45179. * Add the required uniforms to the current buffer.
  45180. * @param uniformBuffer defines the current uniform buffer.
  45181. */
  45182. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45183. /**
  45184. * Add the required samplers to the current list.
  45185. * @param samplers defines the current sampler list.
  45186. */
  45187. static AddSamplers(samplers: string[]): void;
  45188. /**
  45189. * Makes a duplicate of the current configuration into another one.
  45190. * @param sheenConfiguration define the config where to copy the info
  45191. */
  45192. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45193. /**
  45194. * Serializes this BRDF configuration.
  45195. * @returns - An object with the serialized config.
  45196. */
  45197. serialize(): any;
  45198. /**
  45199. * Parses a anisotropy Configuration from a serialized object.
  45200. * @param source - Serialized object.
  45201. * @param scene Defines the scene we are parsing for
  45202. * @param rootUrl Defines the rootUrl to load from
  45203. */
  45204. parse(source: any, scene: Scene, rootUrl: string): void;
  45205. }
  45206. }
  45207. declare module BABYLON {
  45208. /**
  45209. * @hidden
  45210. */
  45211. export interface IMaterialSubSurfaceDefines {
  45212. SUBSURFACE: boolean;
  45213. SS_REFRACTION: boolean;
  45214. SS_TRANSLUCENCY: boolean;
  45215. SS_SCATERRING: boolean;
  45216. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45217. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45218. SS_REFRACTIONMAP_3D: boolean;
  45219. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45220. SS_LODINREFRACTIONALPHA: boolean;
  45221. SS_GAMMAREFRACTION: boolean;
  45222. SS_RGBDREFRACTION: boolean;
  45223. SS_LINEARSPECULARREFRACTION: boolean;
  45224. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45225. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45226. /** @hidden */ private _areTexturesDirty: boolean;
  45227. }
  45228. /**
  45229. * Define the code related to the sub surface parameters of the pbr material.
  45230. */
  45231. export class PBRSubSurfaceConfiguration {
  45232. private _isRefractionEnabled;
  45233. /**
  45234. * Defines if the refraction is enabled in the material.
  45235. */
  45236. isRefractionEnabled: boolean;
  45237. private _isTranslucencyEnabled;
  45238. /**
  45239. * Defines if the translucency is enabled in the material.
  45240. */
  45241. isTranslucencyEnabled: boolean;
  45242. private _isScatteringEnabled;
  45243. /**
  45244. * Defines the refraction intensity of the material.
  45245. * The refraction when enabled replaces the Diffuse part of the material.
  45246. * The intensity helps transitionning between diffuse and refraction.
  45247. */
  45248. refractionIntensity: number;
  45249. /**
  45250. * Defines the translucency intensity of the material.
  45251. * When translucency has been enabled, this defines how much of the "translucency"
  45252. * is addded to the diffuse part of the material.
  45253. */
  45254. translucencyIntensity: number;
  45255. /**
  45256. * Defines the scattering intensity of the material.
  45257. * When scattering has been enabled, this defines how much of the "scattered light"
  45258. * is addded to the diffuse part of the material.
  45259. */
  45260. scatteringIntensity: number;
  45261. private _thicknessTexture;
  45262. /**
  45263. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  45264. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  45265. * 0 would mean minimumThickness
  45266. * 1 would mean maximumThickness
  45267. * The other channels might be use as a mask to vary the different effects intensity.
  45268. */
  45269. thicknessTexture: Nullable<BaseTexture>;
  45270. private _refractionTexture;
  45271. /**
  45272. * Defines the texture to use for refraction.
  45273. */
  45274. refractionTexture: Nullable<BaseTexture>;
  45275. private _indexOfRefraction;
  45276. /**
  45277. * Defines the index of refraction used in the material.
  45278. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  45279. */
  45280. indexOfRefraction: number;
  45281. private _invertRefractionY;
  45282. /**
  45283. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45284. */
  45285. invertRefractionY: boolean;
  45286. private _linkRefractionWithTransparency;
  45287. /**
  45288. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45289. * Materials half opaque for instance using refraction could benefit from this control.
  45290. */
  45291. linkRefractionWithTransparency: boolean;
  45292. /**
  45293. * Defines the minimum thickness stored in the thickness map.
  45294. * If no thickness map is defined, this value will be used to simulate thickness.
  45295. */
  45296. minimumThickness: number;
  45297. /**
  45298. * Defines the maximum thickness stored in the thickness map.
  45299. */
  45300. maximumThickness: number;
  45301. /**
  45302. * Defines the volume tint of the material.
  45303. * This is used for both translucency and scattering.
  45304. */
  45305. tintColor: Color3;
  45306. /**
  45307. * Defines the distance at which the tint color should be found in the media.
  45308. * This is used for refraction only.
  45309. */
  45310. tintColorAtDistance: number;
  45311. /**
  45312. * Defines how far each channel transmit through the media.
  45313. * It is defined as a color to simplify it selection.
  45314. */
  45315. diffusionDistance: Color3;
  45316. private _useMaskFromThicknessTexture;
  45317. /**
  45318. * Stores the intensity of the different subsurface effects in the thickness texture.
  45319. * * the green channel is the translucency intensity.
  45320. * * the blue channel is the scattering intensity.
  45321. * * the alpha channel is the refraction intensity.
  45322. */
  45323. useMaskFromThicknessTexture: boolean;
  45324. /** @hidden */
  45325. private _internalMarkAllSubMeshesAsTexturesDirty;
  45326. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  45327. /**
  45328. * Instantiate a new istance of sub surface configuration.
  45329. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45330. */
  45331. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45332. /**
  45333. * Gets wehter the submesh is ready to be used or not.
  45334. * @param defines the list of "defines" to update.
  45335. * @param scene defines the scene the material belongs to.
  45336. * @returns - boolean indicating that the submesh is ready or not.
  45337. */
  45338. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  45339. /**
  45340. * Checks to see if a texture is used in the material.
  45341. * @param defines the list of "defines" to update.
  45342. * @param scene defines the scene to the material belongs to.
  45343. */
  45344. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  45345. /**
  45346. * Binds the material data.
  45347. * @param uniformBuffer defines the Uniform buffer to fill in.
  45348. * @param scene defines the scene the material belongs to.
  45349. * @param engine defines the engine the material belongs to.
  45350. * @param isFrozen defines wether the material is frozen or not.
  45351. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  45352. */
  45353. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  45354. /**
  45355. * Unbinds the material from the mesh.
  45356. * @param activeEffect defines the effect that should be unbound from.
  45357. * @returns true if unbound, otherwise false
  45358. */
  45359. unbind(activeEffect: Effect): boolean;
  45360. /**
  45361. * Returns the texture used for refraction or null if none is used.
  45362. * @param scene defines the scene the material belongs to.
  45363. * @returns - Refraction texture if present. If no refraction texture and refraction
  45364. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45365. */
  45366. private _getRefractionTexture;
  45367. /**
  45368. * Returns true if alpha blending should be disabled.
  45369. */
  45370. readonly disableAlphaBlending: boolean;
  45371. /**
  45372. * Fills the list of render target textures.
  45373. * @param renderTargets the list of render targets to update
  45374. */
  45375. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  45376. /**
  45377. * Checks to see if a texture is used in the material.
  45378. * @param texture - Base texture to use.
  45379. * @returns - Boolean specifying if a texture is used in the material.
  45380. */
  45381. hasTexture(texture: BaseTexture): boolean;
  45382. /**
  45383. * Gets a boolean indicating that current material needs to register RTT
  45384. * @returns true if this uses a render target otherwise false.
  45385. */
  45386. hasRenderTargetTextures(): boolean;
  45387. /**
  45388. * Returns an array of the actively used textures.
  45389. * @param activeTextures Array of BaseTextures
  45390. */
  45391. getActiveTextures(activeTextures: BaseTexture[]): void;
  45392. /**
  45393. * Returns the animatable textures.
  45394. * @param animatables Array of animatable textures.
  45395. */
  45396. getAnimatables(animatables: IAnimatable[]): void;
  45397. /**
  45398. * Disposes the resources of the material.
  45399. * @param forceDisposeTextures - Forces the disposal of all textures.
  45400. */
  45401. dispose(forceDisposeTextures?: boolean): void;
  45402. /**
  45403. * Get the current class name of the texture useful for serialization or dynamic coding.
  45404. * @returns "PBRSubSurfaceConfiguration"
  45405. */
  45406. getClassName(): string;
  45407. /**
  45408. * Add fallbacks to the effect fallbacks list.
  45409. * @param defines defines the Base texture to use.
  45410. * @param fallbacks defines the current fallback list.
  45411. * @param currentRank defines the current fallback rank.
  45412. * @returns the new fallback rank.
  45413. */
  45414. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45415. /**
  45416. * Add the required uniforms to the current list.
  45417. * @param uniforms defines the current uniform list.
  45418. */
  45419. static AddUniforms(uniforms: string[]): void;
  45420. /**
  45421. * Add the required samplers to the current list.
  45422. * @param samplers defines the current sampler list.
  45423. */
  45424. static AddSamplers(samplers: string[]): void;
  45425. /**
  45426. * Add the required uniforms to the current buffer.
  45427. * @param uniformBuffer defines the current uniform buffer.
  45428. */
  45429. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45430. /**
  45431. * Makes a duplicate of the current configuration into another one.
  45432. * @param configuration define the config where to copy the info
  45433. */
  45434. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  45435. /**
  45436. * Serializes this Sub Surface configuration.
  45437. * @returns - An object with the serialized config.
  45438. */
  45439. serialize(): any;
  45440. /**
  45441. * Parses a anisotropy Configuration from a serialized object.
  45442. * @param source - Serialized object.
  45443. * @param scene Defines the scene we are parsing for
  45444. * @param rootUrl Defines the rootUrl to load from
  45445. */
  45446. parse(source: any, scene: Scene, rootUrl: string): void;
  45447. }
  45448. }
  45449. declare module BABYLON {
  45450. /** @hidden */
  45451. export var pbrFragmentDeclaration: {
  45452. name: string;
  45453. shader: string;
  45454. };
  45455. }
  45456. declare module BABYLON {
  45457. /** @hidden */
  45458. export var pbrUboDeclaration: {
  45459. name: string;
  45460. shader: string;
  45461. };
  45462. }
  45463. declare module BABYLON {
  45464. /** @hidden */
  45465. export var pbrFragmentExtraDeclaration: {
  45466. name: string;
  45467. shader: string;
  45468. };
  45469. }
  45470. declare module BABYLON {
  45471. /** @hidden */
  45472. export var pbrFragmentSamplersDeclaration: {
  45473. name: string;
  45474. shader: string;
  45475. };
  45476. }
  45477. declare module BABYLON {
  45478. /** @hidden */
  45479. export var pbrHelperFunctions: {
  45480. name: string;
  45481. shader: string;
  45482. };
  45483. }
  45484. declare module BABYLON {
  45485. /** @hidden */
  45486. export var harmonicsFunctions: {
  45487. name: string;
  45488. shader: string;
  45489. };
  45490. }
  45491. declare module BABYLON {
  45492. /** @hidden */
  45493. export var pbrDirectLightingSetupFunctions: {
  45494. name: string;
  45495. shader: string;
  45496. };
  45497. }
  45498. declare module BABYLON {
  45499. /** @hidden */
  45500. export var pbrDirectLightingFalloffFunctions: {
  45501. name: string;
  45502. shader: string;
  45503. };
  45504. }
  45505. declare module BABYLON {
  45506. /** @hidden */
  45507. export var pbrBRDFFunctions: {
  45508. name: string;
  45509. shader: string;
  45510. };
  45511. }
  45512. declare module BABYLON {
  45513. /** @hidden */
  45514. export var pbrDirectLightingFunctions: {
  45515. name: string;
  45516. shader: string;
  45517. };
  45518. }
  45519. declare module BABYLON {
  45520. /** @hidden */
  45521. export var pbrIBLFunctions: {
  45522. name: string;
  45523. shader: string;
  45524. };
  45525. }
  45526. declare module BABYLON {
  45527. /** @hidden */
  45528. export var pbrDebug: {
  45529. name: string;
  45530. shader: string;
  45531. };
  45532. }
  45533. declare module BABYLON {
  45534. /** @hidden */
  45535. export var pbrPixelShader: {
  45536. name: string;
  45537. shader: string;
  45538. };
  45539. }
  45540. declare module BABYLON {
  45541. /** @hidden */
  45542. export var pbrVertexDeclaration: {
  45543. name: string;
  45544. shader: string;
  45545. };
  45546. }
  45547. declare module BABYLON {
  45548. /** @hidden */
  45549. export var pbrVertexShader: {
  45550. name: string;
  45551. shader: string;
  45552. };
  45553. }
  45554. declare module BABYLON {
  45555. /**
  45556. * Manages the defines for the PBR Material.
  45557. * @hidden
  45558. */
  45559. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  45560. PBR: boolean;
  45561. MAINUV1: boolean;
  45562. MAINUV2: boolean;
  45563. UV1: boolean;
  45564. UV2: boolean;
  45565. ALBEDO: boolean;
  45566. ALBEDODIRECTUV: number;
  45567. VERTEXCOLOR: boolean;
  45568. AMBIENT: boolean;
  45569. AMBIENTDIRECTUV: number;
  45570. AMBIENTINGRAYSCALE: boolean;
  45571. OPACITY: boolean;
  45572. VERTEXALPHA: boolean;
  45573. OPACITYDIRECTUV: number;
  45574. OPACITYRGB: boolean;
  45575. ALPHATEST: boolean;
  45576. DEPTHPREPASS: boolean;
  45577. ALPHABLEND: boolean;
  45578. ALPHAFROMALBEDO: boolean;
  45579. ALPHATESTVALUE: string;
  45580. SPECULAROVERALPHA: boolean;
  45581. RADIANCEOVERALPHA: boolean;
  45582. ALPHAFRESNEL: boolean;
  45583. LINEARALPHAFRESNEL: boolean;
  45584. PREMULTIPLYALPHA: boolean;
  45585. EMISSIVE: boolean;
  45586. EMISSIVEDIRECTUV: number;
  45587. REFLECTIVITY: boolean;
  45588. REFLECTIVITYDIRECTUV: number;
  45589. SPECULARTERM: boolean;
  45590. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  45591. MICROSURFACEAUTOMATIC: boolean;
  45592. LODBASEDMICROSFURACE: boolean;
  45593. MICROSURFACEMAP: boolean;
  45594. MICROSURFACEMAPDIRECTUV: number;
  45595. METALLICWORKFLOW: boolean;
  45596. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  45597. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  45598. METALLNESSSTOREINMETALMAPBLUE: boolean;
  45599. AOSTOREINMETALMAPRED: boolean;
  45600. ENVIRONMENTBRDF: boolean;
  45601. ENVIRONMENTBRDF_RGBD: boolean;
  45602. NORMAL: boolean;
  45603. TANGENT: boolean;
  45604. BUMP: boolean;
  45605. BUMPDIRECTUV: number;
  45606. OBJECTSPACE_NORMALMAP: boolean;
  45607. PARALLAX: boolean;
  45608. PARALLAXOCCLUSION: boolean;
  45609. NORMALXYSCALE: boolean;
  45610. LIGHTMAP: boolean;
  45611. LIGHTMAPDIRECTUV: number;
  45612. USELIGHTMAPASSHADOWMAP: boolean;
  45613. GAMMALIGHTMAP: boolean;
  45614. REFLECTION: boolean;
  45615. REFLECTIONMAP_3D: boolean;
  45616. REFLECTIONMAP_SPHERICAL: boolean;
  45617. REFLECTIONMAP_PLANAR: boolean;
  45618. REFLECTIONMAP_CUBIC: boolean;
  45619. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  45620. REFLECTIONMAP_PROJECTION: boolean;
  45621. REFLECTIONMAP_SKYBOX: boolean;
  45622. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  45623. REFLECTIONMAP_EXPLICIT: boolean;
  45624. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  45625. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  45626. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  45627. INVERTCUBICMAP: boolean;
  45628. USESPHERICALFROMREFLECTIONMAP: boolean;
  45629. USEIRRADIANCEMAP: boolean;
  45630. SPHERICAL_HARMONICS: boolean;
  45631. USESPHERICALINVERTEX: boolean;
  45632. REFLECTIONMAP_OPPOSITEZ: boolean;
  45633. LODINREFLECTIONALPHA: boolean;
  45634. GAMMAREFLECTION: boolean;
  45635. RGBDREFLECTION: boolean;
  45636. LINEARSPECULARREFLECTION: boolean;
  45637. RADIANCEOCCLUSION: boolean;
  45638. HORIZONOCCLUSION: boolean;
  45639. INSTANCES: boolean;
  45640. NUM_BONE_INFLUENCERS: number;
  45641. BonesPerMesh: number;
  45642. BONETEXTURE: boolean;
  45643. NONUNIFORMSCALING: boolean;
  45644. MORPHTARGETS: boolean;
  45645. MORPHTARGETS_NORMAL: boolean;
  45646. MORPHTARGETS_TANGENT: boolean;
  45647. MORPHTARGETS_UV: boolean;
  45648. NUM_MORPH_INFLUENCERS: number;
  45649. IMAGEPROCESSING: boolean;
  45650. VIGNETTE: boolean;
  45651. VIGNETTEBLENDMODEMULTIPLY: boolean;
  45652. VIGNETTEBLENDMODEOPAQUE: boolean;
  45653. TONEMAPPING: boolean;
  45654. TONEMAPPING_ACES: boolean;
  45655. CONTRAST: boolean;
  45656. COLORCURVES: boolean;
  45657. COLORGRADING: boolean;
  45658. COLORGRADING3D: boolean;
  45659. SAMPLER3DGREENDEPTH: boolean;
  45660. SAMPLER3DBGRMAP: boolean;
  45661. IMAGEPROCESSINGPOSTPROCESS: boolean;
  45662. EXPOSURE: boolean;
  45663. MULTIVIEW: boolean;
  45664. USEPHYSICALLIGHTFALLOFF: boolean;
  45665. USEGLTFLIGHTFALLOFF: boolean;
  45666. TWOSIDEDLIGHTING: boolean;
  45667. SHADOWFLOAT: boolean;
  45668. CLIPPLANE: boolean;
  45669. CLIPPLANE2: boolean;
  45670. CLIPPLANE3: boolean;
  45671. CLIPPLANE4: boolean;
  45672. POINTSIZE: boolean;
  45673. FOG: boolean;
  45674. LOGARITHMICDEPTH: boolean;
  45675. FORCENORMALFORWARD: boolean;
  45676. SPECULARAA: boolean;
  45677. CLEARCOAT: boolean;
  45678. CLEARCOAT_DEFAULTIOR: boolean;
  45679. CLEARCOAT_TEXTURE: boolean;
  45680. CLEARCOAT_TEXTUREDIRECTUV: number;
  45681. CLEARCOAT_BUMP: boolean;
  45682. CLEARCOAT_BUMPDIRECTUV: number;
  45683. CLEARCOAT_TINT: boolean;
  45684. CLEARCOAT_TINT_TEXTURE: boolean;
  45685. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45686. ANISOTROPIC: boolean;
  45687. ANISOTROPIC_TEXTURE: boolean;
  45688. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45689. BRDF_V_HEIGHT_CORRELATED: boolean;
  45690. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45691. SHEEN: boolean;
  45692. SHEEN_TEXTURE: boolean;
  45693. SHEEN_TEXTUREDIRECTUV: number;
  45694. SHEEN_LINKWITHALBEDO: boolean;
  45695. SUBSURFACE: boolean;
  45696. SS_REFRACTION: boolean;
  45697. SS_TRANSLUCENCY: boolean;
  45698. SS_SCATERRING: boolean;
  45699. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45700. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45701. SS_REFRACTIONMAP_3D: boolean;
  45702. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45703. SS_LODINREFRACTIONALPHA: boolean;
  45704. SS_GAMMAREFRACTION: boolean;
  45705. SS_RGBDREFRACTION: boolean;
  45706. SS_LINEARSPECULARREFRACTION: boolean;
  45707. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45708. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45709. UNLIT: boolean;
  45710. DEBUGMODE: number;
  45711. /**
  45712. * Initializes the PBR Material defines.
  45713. */
  45714. constructor();
  45715. /**
  45716. * Resets the PBR Material defines.
  45717. */
  45718. reset(): void;
  45719. }
  45720. /**
  45721. * The Physically based material base class of BJS.
  45722. *
  45723. * This offers the main features of a standard PBR material.
  45724. * For more information, please refer to the documentation :
  45725. * https://doc.babylonjs.com/how_to/physically_based_rendering
  45726. */
  45727. export abstract class PBRBaseMaterial extends PushMaterial {
  45728. /**
  45729. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45730. */
  45731. static readonly PBRMATERIAL_OPAQUE: number;
  45732. /**
  45733. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45734. */
  45735. static readonly PBRMATERIAL_ALPHATEST: number;
  45736. /**
  45737. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45738. */
  45739. static readonly PBRMATERIAL_ALPHABLEND: number;
  45740. /**
  45741. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45742. * They are also discarded below the alpha cutoff threshold to improve performances.
  45743. */
  45744. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45745. /**
  45746. * Defines the default value of how much AO map is occluding the analytical lights
  45747. * (point spot...).
  45748. */
  45749. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45750. /**
  45751. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45752. */
  45753. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45754. /**
  45755. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45756. * to enhance interoperability with other engines.
  45757. */
  45758. static readonly LIGHTFALLOFF_GLTF: number;
  45759. /**
  45760. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45761. * to enhance interoperability with other materials.
  45762. */
  45763. static readonly LIGHTFALLOFF_STANDARD: number;
  45764. /**
  45765. * Intensity of the direct lights e.g. the four lights available in your scene.
  45766. * This impacts both the direct diffuse and specular highlights.
  45767. */
  45768. protected _directIntensity: number;
  45769. /**
  45770. * Intensity of the emissive part of the material.
  45771. * This helps controlling the emissive effect without modifying the emissive color.
  45772. */
  45773. protected _emissiveIntensity: number;
  45774. /**
  45775. * Intensity of the environment e.g. how much the environment will light the object
  45776. * either through harmonics for rough material or through the refelction for shiny ones.
  45777. */
  45778. protected _environmentIntensity: number;
  45779. /**
  45780. * This is a special control allowing the reduction of the specular highlights coming from the
  45781. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45782. */
  45783. protected _specularIntensity: number;
  45784. /**
  45785. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45786. */
  45787. private _lightingInfos;
  45788. /**
  45789. * Debug Control allowing disabling the bump map on this material.
  45790. */
  45791. protected _disableBumpMap: boolean;
  45792. /**
  45793. * AKA Diffuse Texture in standard nomenclature.
  45794. */
  45795. protected _albedoTexture: Nullable<BaseTexture>;
  45796. /**
  45797. * AKA Occlusion Texture in other nomenclature.
  45798. */
  45799. protected _ambientTexture: Nullable<BaseTexture>;
  45800. /**
  45801. * AKA Occlusion Texture Intensity in other nomenclature.
  45802. */
  45803. protected _ambientTextureStrength: number;
  45804. /**
  45805. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45806. * 1 means it completely occludes it
  45807. * 0 mean it has no impact
  45808. */
  45809. protected _ambientTextureImpactOnAnalyticalLights: number;
  45810. /**
  45811. * Stores the alpha values in a texture.
  45812. */
  45813. protected _opacityTexture: Nullable<BaseTexture>;
  45814. /**
  45815. * Stores the reflection values in a texture.
  45816. */
  45817. protected _reflectionTexture: Nullable<BaseTexture>;
  45818. /**
  45819. * Stores the emissive values in a texture.
  45820. */
  45821. protected _emissiveTexture: Nullable<BaseTexture>;
  45822. /**
  45823. * AKA Specular texture in other nomenclature.
  45824. */
  45825. protected _reflectivityTexture: Nullable<BaseTexture>;
  45826. /**
  45827. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45828. */
  45829. protected _metallicTexture: Nullable<BaseTexture>;
  45830. /**
  45831. * Specifies the metallic scalar of the metallic/roughness workflow.
  45832. * Can also be used to scale the metalness values of the metallic texture.
  45833. */
  45834. protected _metallic: Nullable<number>;
  45835. /**
  45836. * Specifies the roughness scalar of the metallic/roughness workflow.
  45837. * Can also be used to scale the roughness values of the metallic texture.
  45838. */
  45839. protected _roughness: Nullable<number>;
  45840. /**
  45841. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45842. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45843. */
  45844. protected _microSurfaceTexture: Nullable<BaseTexture>;
  45845. /**
  45846. * Stores surface normal data used to displace a mesh in a texture.
  45847. */
  45848. protected _bumpTexture: Nullable<BaseTexture>;
  45849. /**
  45850. * Stores the pre-calculated light information of a mesh in a texture.
  45851. */
  45852. protected _lightmapTexture: Nullable<BaseTexture>;
  45853. /**
  45854. * The color of a material in ambient lighting.
  45855. */
  45856. protected _ambientColor: Color3;
  45857. /**
  45858. * AKA Diffuse Color in other nomenclature.
  45859. */
  45860. protected _albedoColor: Color3;
  45861. /**
  45862. * AKA Specular Color in other nomenclature.
  45863. */
  45864. protected _reflectivityColor: Color3;
  45865. /**
  45866. * The color applied when light is reflected from a material.
  45867. */
  45868. protected _reflectionColor: Color3;
  45869. /**
  45870. * The color applied when light is emitted from a material.
  45871. */
  45872. protected _emissiveColor: Color3;
  45873. /**
  45874. * AKA Glossiness in other nomenclature.
  45875. */
  45876. protected _microSurface: number;
  45877. /**
  45878. * Specifies that the material will use the light map as a show map.
  45879. */
  45880. protected _useLightmapAsShadowmap: boolean;
  45881. /**
  45882. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45883. * makes the reflect vector face the model (under horizon).
  45884. */
  45885. protected _useHorizonOcclusion: boolean;
  45886. /**
  45887. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45888. * too much the area relying on ambient texture to define their ambient occlusion.
  45889. */
  45890. protected _useRadianceOcclusion: boolean;
  45891. /**
  45892. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45893. */
  45894. protected _useAlphaFromAlbedoTexture: boolean;
  45895. /**
  45896. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45897. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45898. */
  45899. protected _useSpecularOverAlpha: boolean;
  45900. /**
  45901. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45902. */
  45903. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45904. /**
  45905. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45906. */
  45907. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45908. /**
  45909. * Specifies if the metallic texture contains the roughness information in its green channel.
  45910. */
  45911. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45912. /**
  45913. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45914. */
  45915. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45916. /**
  45917. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45918. */
  45919. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45920. /**
  45921. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45922. */
  45923. protected _useAmbientInGrayScale: boolean;
  45924. /**
  45925. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45926. * The material will try to infer what glossiness each pixel should be.
  45927. */
  45928. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45929. /**
  45930. * Defines the falloff type used in this material.
  45931. * It by default is Physical.
  45932. */
  45933. protected _lightFalloff: number;
  45934. /**
  45935. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45936. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45937. */
  45938. protected _useRadianceOverAlpha: boolean;
  45939. /**
  45940. * Allows using an object space normal map (instead of tangent space).
  45941. */
  45942. protected _useObjectSpaceNormalMap: boolean;
  45943. /**
  45944. * Allows using the bump map in parallax mode.
  45945. */
  45946. protected _useParallax: boolean;
  45947. /**
  45948. * Allows using the bump map in parallax occlusion mode.
  45949. */
  45950. protected _useParallaxOcclusion: boolean;
  45951. /**
  45952. * Controls the scale bias of the parallax mode.
  45953. */
  45954. protected _parallaxScaleBias: number;
  45955. /**
  45956. * If sets to true, disables all the lights affecting the material.
  45957. */
  45958. protected _disableLighting: boolean;
  45959. /**
  45960. * Number of Simultaneous lights allowed on the material.
  45961. */
  45962. protected _maxSimultaneousLights: number;
  45963. /**
  45964. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45965. */
  45966. protected _invertNormalMapX: boolean;
  45967. /**
  45968. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45969. */
  45970. protected _invertNormalMapY: boolean;
  45971. /**
  45972. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45973. */
  45974. protected _twoSidedLighting: boolean;
  45975. /**
  45976. * Defines the alpha limits in alpha test mode.
  45977. */
  45978. protected _alphaCutOff: number;
  45979. /**
  45980. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45981. */
  45982. protected _forceAlphaTest: boolean;
  45983. /**
  45984. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45985. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45986. */
  45987. protected _useAlphaFresnel: boolean;
  45988. /**
  45989. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45990. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45991. */
  45992. protected _useLinearAlphaFresnel: boolean;
  45993. /**
  45994. * The transparency mode of the material.
  45995. */
  45996. protected _transparencyMode: Nullable<number>;
  45997. /**
  45998. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45999. * from cos thetav and roughness:
  46000. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  46001. */
  46002. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  46003. /**
  46004. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46005. */
  46006. protected _forceIrradianceInFragment: boolean;
  46007. /**
  46008. * Force normal to face away from face.
  46009. */
  46010. protected _forceNormalForward: boolean;
  46011. /**
  46012. * Enables specular anti aliasing in the PBR shader.
  46013. * It will both interacts on the Geometry for analytical and IBL lighting.
  46014. * It also prefilter the roughness map based on the bump values.
  46015. */
  46016. protected _enableSpecularAntiAliasing: boolean;
  46017. /**
  46018. * Default configuration related to image processing available in the PBR Material.
  46019. */
  46020. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46021. /**
  46022. * Keep track of the image processing observer to allow dispose and replace.
  46023. */
  46024. private _imageProcessingObserver;
  46025. /**
  46026. * Attaches a new image processing configuration to the PBR Material.
  46027. * @param configuration
  46028. */
  46029. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46030. /**
  46031. * Stores the available render targets.
  46032. */
  46033. private _renderTargets;
  46034. /**
  46035. * Sets the global ambient color for the material used in lighting calculations.
  46036. */
  46037. private _globalAmbientColor;
  46038. /**
  46039. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  46040. */
  46041. private _useLogarithmicDepth;
  46042. /**
  46043. * If set to true, no lighting calculations will be applied.
  46044. */
  46045. private _unlit;
  46046. private _debugMode;
  46047. /**
  46048. * @hidden
  46049. * This is reserved for the inspector.
  46050. * Defines the material debug mode.
  46051. * It helps seeing only some components of the material while troubleshooting.
  46052. */
  46053. debugMode: number;
  46054. /**
  46055. * @hidden
  46056. * This is reserved for the inspector.
  46057. * Specify from where on screen the debug mode should start.
  46058. * The value goes from -1 (full screen) to 1 (not visible)
  46059. * It helps with side by side comparison against the final render
  46060. * This defaults to -1
  46061. */
  46062. private debugLimit;
  46063. /**
  46064. * @hidden
  46065. * This is reserved for the inspector.
  46066. * As the default viewing range might not be enough (if the ambient is really small for instance)
  46067. * You can use the factor to better multiply the final value.
  46068. */
  46069. private debugFactor;
  46070. /**
  46071. * Defines the clear coat layer parameters for the material.
  46072. */
  46073. readonly clearCoat: PBRClearCoatConfiguration;
  46074. /**
  46075. * Defines the anisotropic parameters for the material.
  46076. */
  46077. readonly anisotropy: PBRAnisotropicConfiguration;
  46078. /**
  46079. * Defines the BRDF parameters for the material.
  46080. */
  46081. readonly brdf: PBRBRDFConfiguration;
  46082. /**
  46083. * Defines the Sheen parameters for the material.
  46084. */
  46085. readonly sheen: PBRSheenConfiguration;
  46086. /**
  46087. * Defines the SubSurface parameters for the material.
  46088. */
  46089. readonly subSurface: PBRSubSurfaceConfiguration;
  46090. /**
  46091. * Custom callback helping to override the default shader used in the material.
  46092. */
  46093. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  46094. /**
  46095. * Instantiates a new PBRMaterial instance.
  46096. *
  46097. * @param name The material name
  46098. * @param scene The scene the material will be use in.
  46099. */
  46100. constructor(name: string, scene: Scene);
  46101. /**
  46102. * Gets a boolean indicating that current material needs to register RTT
  46103. */
  46104. readonly hasRenderTargetTextures: boolean;
  46105. /**
  46106. * Gets the name of the material class.
  46107. */
  46108. getClassName(): string;
  46109. /**
  46110. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46111. */
  46112. /**
  46113. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46114. */
  46115. useLogarithmicDepth: boolean;
  46116. /**
  46117. * Gets the current transparency mode.
  46118. */
  46119. /**
  46120. * Sets the transparency mode of the material.
  46121. *
  46122. * | Value | Type | Description |
  46123. * | ----- | ----------------------------------- | ----------- |
  46124. * | 0 | OPAQUE | |
  46125. * | 1 | ALPHATEST | |
  46126. * | 2 | ALPHABLEND | |
  46127. * | 3 | ALPHATESTANDBLEND | |
  46128. *
  46129. */
  46130. transparencyMode: Nullable<number>;
  46131. /**
  46132. * Returns true if alpha blending should be disabled.
  46133. */
  46134. private readonly _disableAlphaBlending;
  46135. /**
  46136. * Specifies whether or not this material should be rendered in alpha blend mode.
  46137. */
  46138. needAlphaBlending(): boolean;
  46139. /**
  46140. * Specifies if the mesh will require alpha blending.
  46141. * @param mesh - BJS mesh.
  46142. */
  46143. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  46144. /**
  46145. * Specifies whether or not this material should be rendered in alpha test mode.
  46146. */
  46147. needAlphaTesting(): boolean;
  46148. /**
  46149. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  46150. */
  46151. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  46152. /**
  46153. * Gets the texture used for the alpha test.
  46154. */
  46155. getAlphaTestTexture(): Nullable<BaseTexture>;
  46156. /**
  46157. * Specifies that the submesh is ready to be used.
  46158. * @param mesh - BJS mesh.
  46159. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  46160. * @param useInstances - Specifies that instances should be used.
  46161. * @returns - boolean indicating that the submesh is ready or not.
  46162. */
  46163. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46164. /**
  46165. * Specifies if the material uses metallic roughness workflow.
  46166. * @returns boolean specifiying if the material uses metallic roughness workflow.
  46167. */
  46168. isMetallicWorkflow(): boolean;
  46169. private _prepareEffect;
  46170. private _prepareDefines;
  46171. /**
  46172. * Force shader compilation
  46173. */
  46174. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  46175. clipPlane: boolean;
  46176. }>): void;
  46177. /**
  46178. * Initializes the uniform buffer layout for the shader.
  46179. */
  46180. buildUniformLayout(): void;
  46181. /**
  46182. * Unbinds the material from the mesh
  46183. */
  46184. unbind(): void;
  46185. /**
  46186. * Binds the submesh data.
  46187. * @param world - The world matrix.
  46188. * @param mesh - The BJS mesh.
  46189. * @param subMesh - A submesh of the BJS mesh.
  46190. */
  46191. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46192. /**
  46193. * Returns the animatable textures.
  46194. * @returns - Array of animatable textures.
  46195. */
  46196. getAnimatables(): IAnimatable[];
  46197. /**
  46198. * Returns the texture used for reflections.
  46199. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  46200. */
  46201. private _getReflectionTexture;
  46202. /**
  46203. * Returns an array of the actively used textures.
  46204. * @returns - Array of BaseTextures
  46205. */
  46206. getActiveTextures(): BaseTexture[];
  46207. /**
  46208. * Checks to see if a texture is used in the material.
  46209. * @param texture - Base texture to use.
  46210. * @returns - Boolean specifying if a texture is used in the material.
  46211. */
  46212. hasTexture(texture: BaseTexture): boolean;
  46213. /**
  46214. * Disposes the resources of the material.
  46215. * @param forceDisposeEffect - Forces the disposal of effects.
  46216. * @param forceDisposeTextures - Forces the disposal of all textures.
  46217. */
  46218. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46219. }
  46220. }
  46221. declare module BABYLON {
  46222. /**
  46223. * The Physically based material of BJS.
  46224. *
  46225. * This offers the main features of a standard PBR material.
  46226. * For more information, please refer to the documentation :
  46227. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46228. */
  46229. export class PBRMaterial extends PBRBaseMaterial {
  46230. /**
  46231. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46232. */
  46233. static readonly PBRMATERIAL_OPAQUE: number;
  46234. /**
  46235. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46236. */
  46237. static readonly PBRMATERIAL_ALPHATEST: number;
  46238. /**
  46239. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46240. */
  46241. static readonly PBRMATERIAL_ALPHABLEND: number;
  46242. /**
  46243. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46244. * They are also discarded below the alpha cutoff threshold to improve performances.
  46245. */
  46246. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46247. /**
  46248. * Defines the default value of how much AO map is occluding the analytical lights
  46249. * (point spot...).
  46250. */
  46251. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46252. /**
  46253. * Intensity of the direct lights e.g. the four lights available in your scene.
  46254. * This impacts both the direct diffuse and specular highlights.
  46255. */
  46256. directIntensity: number;
  46257. /**
  46258. * Intensity of the emissive part of the material.
  46259. * This helps controlling the emissive effect without modifying the emissive color.
  46260. */
  46261. emissiveIntensity: number;
  46262. /**
  46263. * Intensity of the environment e.g. how much the environment will light the object
  46264. * either through harmonics for rough material or through the refelction for shiny ones.
  46265. */
  46266. environmentIntensity: number;
  46267. /**
  46268. * This is a special control allowing the reduction of the specular highlights coming from the
  46269. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46270. */
  46271. specularIntensity: number;
  46272. /**
  46273. * Debug Control allowing disabling the bump map on this material.
  46274. */
  46275. disableBumpMap: boolean;
  46276. /**
  46277. * AKA Diffuse Texture in standard nomenclature.
  46278. */
  46279. albedoTexture: BaseTexture;
  46280. /**
  46281. * AKA Occlusion Texture in other nomenclature.
  46282. */
  46283. ambientTexture: BaseTexture;
  46284. /**
  46285. * AKA Occlusion Texture Intensity in other nomenclature.
  46286. */
  46287. ambientTextureStrength: number;
  46288. /**
  46289. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46290. * 1 means it completely occludes it
  46291. * 0 mean it has no impact
  46292. */
  46293. ambientTextureImpactOnAnalyticalLights: number;
  46294. /**
  46295. * Stores the alpha values in a texture.
  46296. */
  46297. opacityTexture: BaseTexture;
  46298. /**
  46299. * Stores the reflection values in a texture.
  46300. */
  46301. reflectionTexture: Nullable<BaseTexture>;
  46302. /**
  46303. * Stores the emissive values in a texture.
  46304. */
  46305. emissiveTexture: BaseTexture;
  46306. /**
  46307. * AKA Specular texture in other nomenclature.
  46308. */
  46309. reflectivityTexture: BaseTexture;
  46310. /**
  46311. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46312. */
  46313. metallicTexture: BaseTexture;
  46314. /**
  46315. * Specifies the metallic scalar of the metallic/roughness workflow.
  46316. * Can also be used to scale the metalness values of the metallic texture.
  46317. */
  46318. metallic: Nullable<number>;
  46319. /**
  46320. * Specifies the roughness scalar of the metallic/roughness workflow.
  46321. * Can also be used to scale the roughness values of the metallic texture.
  46322. */
  46323. roughness: Nullable<number>;
  46324. /**
  46325. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46326. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46327. */
  46328. microSurfaceTexture: BaseTexture;
  46329. /**
  46330. * Stores surface normal data used to displace a mesh in a texture.
  46331. */
  46332. bumpTexture: BaseTexture;
  46333. /**
  46334. * Stores the pre-calculated light information of a mesh in a texture.
  46335. */
  46336. lightmapTexture: BaseTexture;
  46337. /**
  46338. * Stores the refracted light information in a texture.
  46339. */
  46340. refractionTexture: Nullable<BaseTexture>;
  46341. /**
  46342. * The color of a material in ambient lighting.
  46343. */
  46344. ambientColor: Color3;
  46345. /**
  46346. * AKA Diffuse Color in other nomenclature.
  46347. */
  46348. albedoColor: Color3;
  46349. /**
  46350. * AKA Specular Color in other nomenclature.
  46351. */
  46352. reflectivityColor: Color3;
  46353. /**
  46354. * The color reflected from the material.
  46355. */
  46356. reflectionColor: Color3;
  46357. /**
  46358. * The color emitted from the material.
  46359. */
  46360. emissiveColor: Color3;
  46361. /**
  46362. * AKA Glossiness in other nomenclature.
  46363. */
  46364. microSurface: number;
  46365. /**
  46366. * source material index of refraction (IOR)' / 'destination material IOR.
  46367. */
  46368. indexOfRefraction: number;
  46369. /**
  46370. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46371. */
  46372. invertRefractionY: boolean;
  46373. /**
  46374. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46375. * Materials half opaque for instance using refraction could benefit from this control.
  46376. */
  46377. linkRefractionWithTransparency: boolean;
  46378. /**
  46379. * If true, the light map contains occlusion information instead of lighting info.
  46380. */
  46381. useLightmapAsShadowmap: boolean;
  46382. /**
  46383. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46384. */
  46385. useAlphaFromAlbedoTexture: boolean;
  46386. /**
  46387. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46388. */
  46389. forceAlphaTest: boolean;
  46390. /**
  46391. * Defines the alpha limits in alpha test mode.
  46392. */
  46393. alphaCutOff: number;
  46394. /**
  46395. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  46396. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46397. */
  46398. useSpecularOverAlpha: boolean;
  46399. /**
  46400. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46401. */
  46402. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46403. /**
  46404. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46405. */
  46406. useRoughnessFromMetallicTextureAlpha: boolean;
  46407. /**
  46408. * Specifies if the metallic texture contains the roughness information in its green channel.
  46409. */
  46410. useRoughnessFromMetallicTextureGreen: boolean;
  46411. /**
  46412. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46413. */
  46414. useMetallnessFromMetallicTextureBlue: boolean;
  46415. /**
  46416. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46417. */
  46418. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46419. /**
  46420. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46421. */
  46422. useAmbientInGrayScale: boolean;
  46423. /**
  46424. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46425. * The material will try to infer what glossiness each pixel should be.
  46426. */
  46427. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46428. /**
  46429. * BJS is using an harcoded light falloff based on a manually sets up range.
  46430. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46431. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46432. */
  46433. /**
  46434. * BJS is using an harcoded light falloff based on a manually sets up range.
  46435. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46436. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46437. */
  46438. usePhysicalLightFalloff: boolean;
  46439. /**
  46440. * In order to support the falloff compatibility with gltf, a special mode has been added
  46441. * to reproduce the gltf light falloff.
  46442. */
  46443. /**
  46444. * In order to support the falloff compatibility with gltf, a special mode has been added
  46445. * to reproduce the gltf light falloff.
  46446. */
  46447. useGLTFLightFalloff: boolean;
  46448. /**
  46449. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46450. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46451. */
  46452. useRadianceOverAlpha: boolean;
  46453. /**
  46454. * Allows using an object space normal map (instead of tangent space).
  46455. */
  46456. useObjectSpaceNormalMap: boolean;
  46457. /**
  46458. * Allows using the bump map in parallax mode.
  46459. */
  46460. useParallax: boolean;
  46461. /**
  46462. * Allows using the bump map in parallax occlusion mode.
  46463. */
  46464. useParallaxOcclusion: boolean;
  46465. /**
  46466. * Controls the scale bias of the parallax mode.
  46467. */
  46468. parallaxScaleBias: number;
  46469. /**
  46470. * If sets to true, disables all the lights affecting the material.
  46471. */
  46472. disableLighting: boolean;
  46473. /**
  46474. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46475. */
  46476. forceIrradianceInFragment: boolean;
  46477. /**
  46478. * Number of Simultaneous lights allowed on the material.
  46479. */
  46480. maxSimultaneousLights: number;
  46481. /**
  46482. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46483. */
  46484. invertNormalMapX: boolean;
  46485. /**
  46486. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46487. */
  46488. invertNormalMapY: boolean;
  46489. /**
  46490. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46491. */
  46492. twoSidedLighting: boolean;
  46493. /**
  46494. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46495. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46496. */
  46497. useAlphaFresnel: boolean;
  46498. /**
  46499. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46500. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46501. */
  46502. useLinearAlphaFresnel: boolean;
  46503. /**
  46504. * Let user defines the brdf lookup texture used for IBL.
  46505. * A default 8bit version is embedded but you could point at :
  46506. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  46507. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46508. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  46509. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46510. */
  46511. environmentBRDFTexture: Nullable<BaseTexture>;
  46512. /**
  46513. * Force normal to face away from face.
  46514. */
  46515. forceNormalForward: boolean;
  46516. /**
  46517. * Enables specular anti aliasing in the PBR shader.
  46518. * It will both interacts on the Geometry for analytical and IBL lighting.
  46519. * It also prefilter the roughness map based on the bump values.
  46520. */
  46521. enableSpecularAntiAliasing: boolean;
  46522. /**
  46523. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46524. * makes the reflect vector face the model (under horizon).
  46525. */
  46526. useHorizonOcclusion: boolean;
  46527. /**
  46528. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46529. * too much the area relying on ambient texture to define their ambient occlusion.
  46530. */
  46531. useRadianceOcclusion: boolean;
  46532. /**
  46533. * If set to true, no lighting calculations will be applied.
  46534. */
  46535. unlit: boolean;
  46536. /**
  46537. * Gets the image processing configuration used either in this material.
  46538. */
  46539. /**
  46540. * Sets the Default image processing configuration used either in the this material.
  46541. *
  46542. * If sets to null, the scene one is in use.
  46543. */
  46544. imageProcessingConfiguration: ImageProcessingConfiguration;
  46545. /**
  46546. * Gets wether the color curves effect is enabled.
  46547. */
  46548. /**
  46549. * Sets wether the color curves effect is enabled.
  46550. */
  46551. cameraColorCurvesEnabled: boolean;
  46552. /**
  46553. * Gets wether the color grading effect is enabled.
  46554. */
  46555. /**
  46556. * Gets wether the color grading effect is enabled.
  46557. */
  46558. cameraColorGradingEnabled: boolean;
  46559. /**
  46560. * Gets wether tonemapping is enabled or not.
  46561. */
  46562. /**
  46563. * Sets wether tonemapping is enabled or not
  46564. */
  46565. cameraToneMappingEnabled: boolean;
  46566. /**
  46567. * The camera exposure used on this material.
  46568. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46569. * This corresponds to a photographic exposure.
  46570. */
  46571. /**
  46572. * The camera exposure used on this material.
  46573. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46574. * This corresponds to a photographic exposure.
  46575. */
  46576. cameraExposure: number;
  46577. /**
  46578. * Gets The camera contrast used on this material.
  46579. */
  46580. /**
  46581. * Sets The camera contrast used on this material.
  46582. */
  46583. cameraContrast: number;
  46584. /**
  46585. * Gets the Color Grading 2D Lookup Texture.
  46586. */
  46587. /**
  46588. * Sets the Color Grading 2D Lookup Texture.
  46589. */
  46590. cameraColorGradingTexture: Nullable<BaseTexture>;
  46591. /**
  46592. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46593. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46594. * 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;
  46595. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46596. */
  46597. /**
  46598. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46599. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46600. * 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;
  46601. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46602. */
  46603. cameraColorCurves: Nullable<ColorCurves>;
  46604. /**
  46605. * Instantiates a new PBRMaterial instance.
  46606. *
  46607. * @param name The material name
  46608. * @param scene The scene the material will be use in.
  46609. */
  46610. constructor(name: string, scene: Scene);
  46611. /**
  46612. * Returns the name of this material class.
  46613. */
  46614. getClassName(): string;
  46615. /**
  46616. * Makes a duplicate of the current material.
  46617. * @param name - name to use for the new material.
  46618. */
  46619. clone(name: string): PBRMaterial;
  46620. /**
  46621. * Serializes this PBR Material.
  46622. * @returns - An object with the serialized material.
  46623. */
  46624. serialize(): any;
  46625. /**
  46626. * Parses a PBR Material from a serialized object.
  46627. * @param source - Serialized object.
  46628. * @param scene - BJS scene instance.
  46629. * @param rootUrl - url for the scene object
  46630. * @returns - PBRMaterial
  46631. */
  46632. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46633. }
  46634. }
  46635. declare module BABYLON {
  46636. /**
  46637. * Direct draw surface info
  46638. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  46639. */
  46640. export interface DDSInfo {
  46641. /**
  46642. * Width of the texture
  46643. */
  46644. width: number;
  46645. /**
  46646. * Width of the texture
  46647. */
  46648. height: number;
  46649. /**
  46650. * Number of Mipmaps for the texture
  46651. * @see https://en.wikipedia.org/wiki/Mipmap
  46652. */
  46653. mipmapCount: number;
  46654. /**
  46655. * If the textures format is a known fourCC format
  46656. * @see https://www.fourcc.org/
  46657. */
  46658. isFourCC: boolean;
  46659. /**
  46660. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46661. */
  46662. isRGB: boolean;
  46663. /**
  46664. * If the texture is a lumincance format
  46665. */
  46666. isLuminance: boolean;
  46667. /**
  46668. * If this is a cube texture
  46669. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46670. */
  46671. isCube: boolean;
  46672. /**
  46673. * If the texture is a compressed format eg. FOURCC_DXT1
  46674. */
  46675. isCompressed: boolean;
  46676. /**
  46677. * The dxgiFormat of the texture
  46678. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46679. */
  46680. dxgiFormat: number;
  46681. /**
  46682. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46683. */
  46684. textureType: number;
  46685. /**
  46686. * Sphericle polynomial created for the dds texture
  46687. */
  46688. sphericalPolynomial?: SphericalPolynomial;
  46689. }
  46690. /**
  46691. * Class used to provide DDS decompression tools
  46692. */
  46693. export class DDSTools {
  46694. /**
  46695. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46696. */
  46697. static StoreLODInAlphaChannel: boolean;
  46698. /**
  46699. * Gets DDS information from an array buffer
  46700. * @param arrayBuffer defines the array buffer to read data from
  46701. * @returns the DDS information
  46702. */
  46703. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46704. private static _FloatView;
  46705. private static _Int32View;
  46706. private static _ToHalfFloat;
  46707. private static _FromHalfFloat;
  46708. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46709. private static _GetHalfFloatRGBAArrayBuffer;
  46710. private static _GetFloatRGBAArrayBuffer;
  46711. private static _GetFloatAsUIntRGBAArrayBuffer;
  46712. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46713. private static _GetRGBAArrayBuffer;
  46714. private static _ExtractLongWordOrder;
  46715. private static _GetRGBArrayBuffer;
  46716. private static _GetLuminanceArrayBuffer;
  46717. /**
  46718. * Uploads DDS Levels to a Babylon Texture
  46719. * @hidden
  46720. */
  46721. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46722. }
  46723. interface Engine {
  46724. /**
  46725. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46726. * @param rootUrl defines the url where the file to load is located
  46727. * @param scene defines the current scene
  46728. * @param lodScale defines scale to apply to the mip map selection
  46729. * @param lodOffset defines offset to apply to the mip map selection
  46730. * @param onLoad defines an optional callback raised when the texture is loaded
  46731. * @param onError defines an optional callback raised if there is an issue to load the texture
  46732. * @param format defines the format of the data
  46733. * @param forcedExtension defines the extension to use to pick the right loader
  46734. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46735. * @returns the cube texture as an InternalTexture
  46736. */
  46737. 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;
  46738. }
  46739. }
  46740. declare module BABYLON {
  46741. /**
  46742. * Implementation of the DDS Texture Loader.
  46743. * @hidden
  46744. */
  46745. export class _DDSTextureLoader implements IInternalTextureLoader {
  46746. /**
  46747. * Defines wether the loader supports cascade loading the different faces.
  46748. */
  46749. readonly supportCascades: boolean;
  46750. /**
  46751. * This returns if the loader support the current file information.
  46752. * @param extension defines the file extension of the file being loaded
  46753. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46754. * @param fallback defines the fallback internal texture if any
  46755. * @param isBase64 defines whether the texture is encoded as a base64
  46756. * @param isBuffer defines whether the texture data are stored as a buffer
  46757. * @returns true if the loader can load the specified file
  46758. */
  46759. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46760. /**
  46761. * Transform the url before loading if required.
  46762. * @param rootUrl the url of the texture
  46763. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46764. * @returns the transformed texture
  46765. */
  46766. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46767. /**
  46768. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46769. * @param rootUrl the url of the texture
  46770. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46771. * @returns the fallback texture
  46772. */
  46773. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46774. /**
  46775. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46776. * @param data contains the texture data
  46777. * @param texture defines the BabylonJS internal texture
  46778. * @param createPolynomials will be true if polynomials have been requested
  46779. * @param onLoad defines the callback to trigger once the texture is ready
  46780. * @param onError defines the callback to trigger in case of error
  46781. */
  46782. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46783. /**
  46784. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46785. * @param data contains the texture data
  46786. * @param texture defines the BabylonJS internal texture
  46787. * @param callback defines the method to call once ready to upload
  46788. */
  46789. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46790. }
  46791. }
  46792. declare module BABYLON {
  46793. /** @hidden */
  46794. export var rgbdEncodePixelShader: {
  46795. name: string;
  46796. shader: string;
  46797. };
  46798. }
  46799. declare module BABYLON {
  46800. /**
  46801. * Raw texture data and descriptor sufficient for WebGL texture upload
  46802. */
  46803. export interface EnvironmentTextureInfo {
  46804. /**
  46805. * Version of the environment map
  46806. */
  46807. version: number;
  46808. /**
  46809. * Width of image
  46810. */
  46811. width: number;
  46812. /**
  46813. * Irradiance information stored in the file.
  46814. */
  46815. irradiance: any;
  46816. /**
  46817. * Specular information stored in the file.
  46818. */
  46819. specular: any;
  46820. }
  46821. /**
  46822. * Sets of helpers addressing the serialization and deserialization of environment texture
  46823. * stored in a BabylonJS env file.
  46824. * Those files are usually stored as .env files.
  46825. */
  46826. export class EnvironmentTextureTools {
  46827. /**
  46828. * Magic number identifying the env file.
  46829. */
  46830. private static _MagicBytes;
  46831. /**
  46832. * Gets the environment info from an env file.
  46833. * @param data The array buffer containing the .env bytes.
  46834. * @returns the environment file info (the json header) if successfully parsed.
  46835. */
  46836. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46837. /**
  46838. * Creates an environment texture from a loaded cube texture.
  46839. * @param texture defines the cube texture to convert in env file
  46840. * @return a promise containing the environment data if succesfull.
  46841. */
  46842. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46843. /**
  46844. * Creates a JSON representation of the spherical data.
  46845. * @param texture defines the texture containing the polynomials
  46846. * @return the JSON representation of the spherical info
  46847. */
  46848. private static _CreateEnvTextureIrradiance;
  46849. /**
  46850. * Uploads the texture info contained in the env file to the GPU.
  46851. * @param texture defines the internal texture to upload to
  46852. * @param arrayBuffer defines the buffer cotaining the data to load
  46853. * @param info defines the texture info retrieved through the GetEnvInfo method
  46854. * @returns a promise
  46855. */
  46856. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46857. /**
  46858. * Uploads the levels of image data to the GPU.
  46859. * @param texture defines the internal texture to upload to
  46860. * @param imageData defines the array buffer views of image data [mipmap][face]
  46861. * @returns a promise
  46862. */
  46863. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46864. /**
  46865. * Uploads spherical polynomials information to the texture.
  46866. * @param texture defines the texture we are trying to upload the information to
  46867. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46868. */
  46869. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46870. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46871. }
  46872. }
  46873. declare module BABYLON {
  46874. /**
  46875. * Implementation of the ENV Texture Loader.
  46876. * @hidden
  46877. */
  46878. export class _ENVTextureLoader implements IInternalTextureLoader {
  46879. /**
  46880. * Defines wether the loader supports cascade loading the different faces.
  46881. */
  46882. readonly supportCascades: boolean;
  46883. /**
  46884. * This returns if the loader support the current file information.
  46885. * @param extension defines the file extension of the file being loaded
  46886. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46887. * @param fallback defines the fallback internal texture if any
  46888. * @param isBase64 defines whether the texture is encoded as a base64
  46889. * @param isBuffer defines whether the texture data are stored as a buffer
  46890. * @returns true if the loader can load the specified file
  46891. */
  46892. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46893. /**
  46894. * Transform the url before loading if required.
  46895. * @param rootUrl the url of the texture
  46896. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46897. * @returns the transformed texture
  46898. */
  46899. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46900. /**
  46901. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46902. * @param rootUrl the url of the texture
  46903. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46904. * @returns the fallback texture
  46905. */
  46906. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46907. /**
  46908. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46909. * @param data contains the texture data
  46910. * @param texture defines the BabylonJS internal texture
  46911. * @param createPolynomials will be true if polynomials have been requested
  46912. * @param onLoad defines the callback to trigger once the texture is ready
  46913. * @param onError defines the callback to trigger in case of error
  46914. */
  46915. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46916. /**
  46917. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46918. * @param data contains the texture data
  46919. * @param texture defines the BabylonJS internal texture
  46920. * @param callback defines the method to call once ready to upload
  46921. */
  46922. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46923. }
  46924. }
  46925. declare module BABYLON {
  46926. /**
  46927. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46928. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46929. */
  46930. export class KhronosTextureContainer {
  46931. /** contents of the KTX container file */
  46932. arrayBuffer: any;
  46933. private static HEADER_LEN;
  46934. private static COMPRESSED_2D;
  46935. private static COMPRESSED_3D;
  46936. private static TEX_2D;
  46937. private static TEX_3D;
  46938. /**
  46939. * Gets the openGL type
  46940. */
  46941. glType: number;
  46942. /**
  46943. * Gets the openGL type size
  46944. */
  46945. glTypeSize: number;
  46946. /**
  46947. * Gets the openGL format
  46948. */
  46949. glFormat: number;
  46950. /**
  46951. * Gets the openGL internal format
  46952. */
  46953. glInternalFormat: number;
  46954. /**
  46955. * Gets the base internal format
  46956. */
  46957. glBaseInternalFormat: number;
  46958. /**
  46959. * Gets image width in pixel
  46960. */
  46961. pixelWidth: number;
  46962. /**
  46963. * Gets image height in pixel
  46964. */
  46965. pixelHeight: number;
  46966. /**
  46967. * Gets image depth in pixels
  46968. */
  46969. pixelDepth: number;
  46970. /**
  46971. * Gets the number of array elements
  46972. */
  46973. numberOfArrayElements: number;
  46974. /**
  46975. * Gets the number of faces
  46976. */
  46977. numberOfFaces: number;
  46978. /**
  46979. * Gets the number of mipmap levels
  46980. */
  46981. numberOfMipmapLevels: number;
  46982. /**
  46983. * Gets the bytes of key value data
  46984. */
  46985. bytesOfKeyValueData: number;
  46986. /**
  46987. * Gets the load type
  46988. */
  46989. loadType: number;
  46990. /**
  46991. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46992. */
  46993. isInvalid: boolean;
  46994. /**
  46995. * Creates a new KhronosTextureContainer
  46996. * @param arrayBuffer contents of the KTX container file
  46997. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46998. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46999. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  47000. */
  47001. constructor(
  47002. /** contents of the KTX container file */
  47003. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  47004. /**
  47005. * Uploads KTX content to a Babylon Texture.
  47006. * It is assumed that the texture has already been created & is currently bound
  47007. * @hidden
  47008. */
  47009. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  47010. private _upload2DCompressedLevels;
  47011. }
  47012. }
  47013. declare module BABYLON {
  47014. /**
  47015. * Implementation of the KTX Texture Loader.
  47016. * @hidden
  47017. */
  47018. export class _KTXTextureLoader implements IInternalTextureLoader {
  47019. /**
  47020. * Defines wether the loader supports cascade loading the different faces.
  47021. */
  47022. readonly supportCascades: boolean;
  47023. /**
  47024. * This returns if the loader support the current file information.
  47025. * @param extension defines the file extension of the file being loaded
  47026. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47027. * @param fallback defines the fallback internal texture if any
  47028. * @param isBase64 defines whether the texture is encoded as a base64
  47029. * @param isBuffer defines whether the texture data are stored as a buffer
  47030. * @returns true if the loader can load the specified file
  47031. */
  47032. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47033. /**
  47034. * Transform the url before loading if required.
  47035. * @param rootUrl the url of the texture
  47036. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47037. * @returns the transformed texture
  47038. */
  47039. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47040. /**
  47041. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47042. * @param rootUrl the url of the texture
  47043. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47044. * @returns the fallback texture
  47045. */
  47046. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47047. /**
  47048. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47049. * @param data contains the texture data
  47050. * @param texture defines the BabylonJS internal texture
  47051. * @param createPolynomials will be true if polynomials have been requested
  47052. * @param onLoad defines the callback to trigger once the texture is ready
  47053. * @param onError defines the callback to trigger in case of error
  47054. */
  47055. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47056. /**
  47057. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47058. * @param data contains the texture data
  47059. * @param texture defines the BabylonJS internal texture
  47060. * @param callback defines the method to call once ready to upload
  47061. */
  47062. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  47063. }
  47064. }
  47065. declare module BABYLON {
  47066. /**
  47067. * Options for the default xr helper
  47068. */
  47069. export class WebXRDefaultExperienceOptions {
  47070. /**
  47071. * Floor meshes that should be used for teleporting
  47072. */
  47073. floorMeshes: Array<AbstractMesh>;
  47074. }
  47075. /**
  47076. * Default experience which provides a similar setup to the previous webVRExperience
  47077. */
  47078. export class WebXRDefaultExperience {
  47079. /**
  47080. * Base experience
  47081. */
  47082. baseExperience: WebXRExperienceHelper;
  47083. /**
  47084. * Input experience extension
  47085. */
  47086. input: WebXRInput;
  47087. /**
  47088. * Loads the controller models
  47089. */
  47090. controllerModelLoader: WebXRControllerModelLoader;
  47091. /**
  47092. * Enables laser pointer and selection
  47093. */
  47094. pointerSelection: WebXRControllerPointerSelection;
  47095. /**
  47096. * Enables teleportation
  47097. */
  47098. teleportation: WebXRControllerTeleportation;
  47099. /**
  47100. * Enables ui for enetering/exiting xr
  47101. */
  47102. enterExitUI: WebXREnterExitUI;
  47103. /**
  47104. * Default output canvas xr should render to
  47105. */
  47106. outputCanvas: WebXRManagedOutputCanvas;
  47107. /**
  47108. * Creates the default xr experience
  47109. * @param scene scene
  47110. * @param options options for basic configuration
  47111. * @returns resulting WebXRDefaultExperience
  47112. */
  47113. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47114. private constructor();
  47115. /**
  47116. * DIsposes of the experience helper
  47117. */
  47118. dispose(): void;
  47119. }
  47120. }
  47121. declare module BABYLON {
  47122. /** @hidden */
  47123. export var _forceSceneHelpersToBundle: boolean;
  47124. interface Scene {
  47125. /**
  47126. * Creates a default light for the scene.
  47127. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  47128. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  47129. */
  47130. createDefaultLight(replace?: boolean): void;
  47131. /**
  47132. * Creates a default camera for the scene.
  47133. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  47134. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47135. * @param replace has default false, when true replaces the active camera in the scene
  47136. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  47137. */
  47138. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47139. /**
  47140. * Creates a default camera and a default light.
  47141. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  47142. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47143. * @param replace has the default false, when true replaces the active camera/light in the scene
  47144. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  47145. */
  47146. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47147. /**
  47148. * Creates a new sky box
  47149. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  47150. * @param environmentTexture defines the texture to use as environment texture
  47151. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  47152. * @param scale defines the overall scale of the skybox
  47153. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  47154. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  47155. * @returns a new mesh holding the sky box
  47156. */
  47157. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  47158. /**
  47159. * Creates a new environment
  47160. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  47161. * @param options defines the options you can use to configure the environment
  47162. * @returns the new EnvironmentHelper
  47163. */
  47164. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  47165. /**
  47166. * Creates a new VREXperienceHelper
  47167. * @see http://doc.babylonjs.com/how_to/webvr_helper
  47168. * @param webVROptions defines the options used to create the new VREXperienceHelper
  47169. * @returns a new VREXperienceHelper
  47170. */
  47171. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  47172. /**
  47173. * Creates a new WebXRDefaultExperience
  47174. * @see http://doc.babylonjs.com/how_to/webxr
  47175. * @param options experience options
  47176. * @returns a promise for a new WebXRDefaultExperience
  47177. */
  47178. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47179. }
  47180. }
  47181. declare module BABYLON {
  47182. /**
  47183. * Contains position and normal vectors for a vertex
  47184. */
  47185. export class PositionNormalVertex {
  47186. /** the position of the vertex (defaut: 0,0,0) */
  47187. position: Vector3;
  47188. /** the normal of the vertex (defaut: 0,1,0) */
  47189. normal: Vector3;
  47190. /**
  47191. * Creates a PositionNormalVertex
  47192. * @param position the position of the vertex (defaut: 0,0,0)
  47193. * @param normal the normal of the vertex (defaut: 0,1,0)
  47194. */
  47195. constructor(
  47196. /** the position of the vertex (defaut: 0,0,0) */
  47197. position?: Vector3,
  47198. /** the normal of the vertex (defaut: 0,1,0) */
  47199. normal?: Vector3);
  47200. /**
  47201. * Clones the PositionNormalVertex
  47202. * @returns the cloned PositionNormalVertex
  47203. */
  47204. clone(): PositionNormalVertex;
  47205. }
  47206. /**
  47207. * Contains position, normal and uv vectors for a vertex
  47208. */
  47209. export class PositionNormalTextureVertex {
  47210. /** the position of the vertex (defaut: 0,0,0) */
  47211. position: Vector3;
  47212. /** the normal of the vertex (defaut: 0,1,0) */
  47213. normal: Vector3;
  47214. /** the uv of the vertex (default: 0,0) */
  47215. uv: Vector2;
  47216. /**
  47217. * Creates a PositionNormalTextureVertex
  47218. * @param position the position of the vertex (defaut: 0,0,0)
  47219. * @param normal the normal of the vertex (defaut: 0,1,0)
  47220. * @param uv the uv of the vertex (default: 0,0)
  47221. */
  47222. constructor(
  47223. /** the position of the vertex (defaut: 0,0,0) */
  47224. position?: Vector3,
  47225. /** the normal of the vertex (defaut: 0,1,0) */
  47226. normal?: Vector3,
  47227. /** the uv of the vertex (default: 0,0) */
  47228. uv?: Vector2);
  47229. /**
  47230. * Clones the PositionNormalTextureVertex
  47231. * @returns the cloned PositionNormalTextureVertex
  47232. */
  47233. clone(): PositionNormalTextureVertex;
  47234. }
  47235. }
  47236. declare module BABYLON {
  47237. /**
  47238. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  47239. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  47240. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  47241. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47242. */
  47243. export class VideoDome extends TransformNode {
  47244. /**
  47245. * Define the video source as a Monoscopic panoramic 360 video.
  47246. */
  47247. static readonly MODE_MONOSCOPIC: number;
  47248. /**
  47249. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47250. */
  47251. static readonly MODE_TOPBOTTOM: number;
  47252. /**
  47253. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47254. */
  47255. static readonly MODE_SIDEBYSIDE: number;
  47256. private _halfDome;
  47257. private _useDirectMapping;
  47258. /**
  47259. * The video texture being displayed on the sphere
  47260. */
  47261. protected _videoTexture: VideoTexture;
  47262. /**
  47263. * Gets the video texture being displayed on the sphere
  47264. */
  47265. readonly videoTexture: VideoTexture;
  47266. /**
  47267. * The skybox material
  47268. */
  47269. protected _material: BackgroundMaterial;
  47270. /**
  47271. * The surface used for the skybox
  47272. */
  47273. protected _mesh: Mesh;
  47274. /**
  47275. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  47276. */
  47277. private _halfDomeMask;
  47278. /**
  47279. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47280. * Also see the options.resolution property.
  47281. */
  47282. fovMultiplier: number;
  47283. private _videoMode;
  47284. /**
  47285. * Gets or set the current video mode for the video. It can be:
  47286. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  47287. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47288. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47289. */
  47290. videoMode: number;
  47291. /**
  47292. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  47293. *
  47294. */
  47295. /**
  47296. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  47297. */
  47298. halfDome: boolean;
  47299. /**
  47300. * Oberserver used in Stereoscopic VR Mode.
  47301. */
  47302. private _onBeforeCameraRenderObserver;
  47303. /**
  47304. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  47305. * @param name Element's name, child elements will append suffixes for their own names.
  47306. * @param urlsOrVideo defines the url(s) or the video element to use
  47307. * @param options An object containing optional or exposed sub element properties
  47308. */
  47309. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  47310. resolution?: number;
  47311. clickToPlay?: boolean;
  47312. autoPlay?: boolean;
  47313. loop?: boolean;
  47314. size?: number;
  47315. poster?: string;
  47316. faceForward?: boolean;
  47317. useDirectMapping?: boolean;
  47318. halfDomeMode?: boolean;
  47319. }, scene: Scene);
  47320. private _changeVideoMode;
  47321. /**
  47322. * Releases resources associated with this node.
  47323. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47324. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47325. */
  47326. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47327. }
  47328. }
  47329. declare module BABYLON {
  47330. /**
  47331. * This class can be used to get instrumentation data from a Babylon engine
  47332. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47333. */
  47334. export class EngineInstrumentation implements IDisposable {
  47335. /**
  47336. * Define the instrumented engine.
  47337. */
  47338. engine: Engine;
  47339. private _captureGPUFrameTime;
  47340. private _gpuFrameTimeToken;
  47341. private _gpuFrameTime;
  47342. private _captureShaderCompilationTime;
  47343. private _shaderCompilationTime;
  47344. private _onBeginFrameObserver;
  47345. private _onEndFrameObserver;
  47346. private _onBeforeShaderCompilationObserver;
  47347. private _onAfterShaderCompilationObserver;
  47348. /**
  47349. * Gets the perf counter used for GPU frame time
  47350. */
  47351. readonly gpuFrameTimeCounter: PerfCounter;
  47352. /**
  47353. * Gets the GPU frame time capture status
  47354. */
  47355. /**
  47356. * Enable or disable the GPU frame time capture
  47357. */
  47358. captureGPUFrameTime: boolean;
  47359. /**
  47360. * Gets the perf counter used for shader compilation time
  47361. */
  47362. readonly shaderCompilationTimeCounter: PerfCounter;
  47363. /**
  47364. * Gets the shader compilation time capture status
  47365. */
  47366. /**
  47367. * Enable or disable the shader compilation time capture
  47368. */
  47369. captureShaderCompilationTime: boolean;
  47370. /**
  47371. * Instantiates a new engine instrumentation.
  47372. * This class can be used to get instrumentation data from a Babylon engine
  47373. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47374. * @param engine Defines the engine to instrument
  47375. */
  47376. constructor(
  47377. /**
  47378. * Define the instrumented engine.
  47379. */
  47380. engine: Engine);
  47381. /**
  47382. * Dispose and release associated resources.
  47383. */
  47384. dispose(): void;
  47385. }
  47386. }
  47387. declare module BABYLON {
  47388. /**
  47389. * This class can be used to get instrumentation data from a Babylon engine
  47390. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47391. */
  47392. export class SceneInstrumentation implements IDisposable {
  47393. /**
  47394. * Defines the scene to instrument
  47395. */
  47396. scene: Scene;
  47397. private _captureActiveMeshesEvaluationTime;
  47398. private _activeMeshesEvaluationTime;
  47399. private _captureRenderTargetsRenderTime;
  47400. private _renderTargetsRenderTime;
  47401. private _captureFrameTime;
  47402. private _frameTime;
  47403. private _captureRenderTime;
  47404. private _renderTime;
  47405. private _captureInterFrameTime;
  47406. private _interFrameTime;
  47407. private _captureParticlesRenderTime;
  47408. private _particlesRenderTime;
  47409. private _captureSpritesRenderTime;
  47410. private _spritesRenderTime;
  47411. private _capturePhysicsTime;
  47412. private _physicsTime;
  47413. private _captureAnimationsTime;
  47414. private _animationsTime;
  47415. private _captureCameraRenderTime;
  47416. private _cameraRenderTime;
  47417. private _onBeforeActiveMeshesEvaluationObserver;
  47418. private _onAfterActiveMeshesEvaluationObserver;
  47419. private _onBeforeRenderTargetsRenderObserver;
  47420. private _onAfterRenderTargetsRenderObserver;
  47421. private _onAfterRenderObserver;
  47422. private _onBeforeDrawPhaseObserver;
  47423. private _onAfterDrawPhaseObserver;
  47424. private _onBeforeAnimationsObserver;
  47425. private _onBeforeParticlesRenderingObserver;
  47426. private _onAfterParticlesRenderingObserver;
  47427. private _onBeforeSpritesRenderingObserver;
  47428. private _onAfterSpritesRenderingObserver;
  47429. private _onBeforePhysicsObserver;
  47430. private _onAfterPhysicsObserver;
  47431. private _onAfterAnimationsObserver;
  47432. private _onBeforeCameraRenderObserver;
  47433. private _onAfterCameraRenderObserver;
  47434. /**
  47435. * Gets the perf counter used for active meshes evaluation time
  47436. */
  47437. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  47438. /**
  47439. * Gets the active meshes evaluation time capture status
  47440. */
  47441. /**
  47442. * Enable or disable the active meshes evaluation time capture
  47443. */
  47444. captureActiveMeshesEvaluationTime: boolean;
  47445. /**
  47446. * Gets the perf counter used for render targets render time
  47447. */
  47448. readonly renderTargetsRenderTimeCounter: PerfCounter;
  47449. /**
  47450. * Gets the render targets render time capture status
  47451. */
  47452. /**
  47453. * Enable or disable the render targets render time capture
  47454. */
  47455. captureRenderTargetsRenderTime: boolean;
  47456. /**
  47457. * Gets the perf counter used for particles render time
  47458. */
  47459. readonly particlesRenderTimeCounter: PerfCounter;
  47460. /**
  47461. * Gets the particles render time capture status
  47462. */
  47463. /**
  47464. * Enable or disable the particles render time capture
  47465. */
  47466. captureParticlesRenderTime: boolean;
  47467. /**
  47468. * Gets the perf counter used for sprites render time
  47469. */
  47470. readonly spritesRenderTimeCounter: PerfCounter;
  47471. /**
  47472. * Gets the sprites render time capture status
  47473. */
  47474. /**
  47475. * Enable or disable the sprites render time capture
  47476. */
  47477. captureSpritesRenderTime: boolean;
  47478. /**
  47479. * Gets the perf counter used for physics time
  47480. */
  47481. readonly physicsTimeCounter: PerfCounter;
  47482. /**
  47483. * Gets the physics time capture status
  47484. */
  47485. /**
  47486. * Enable or disable the physics time capture
  47487. */
  47488. capturePhysicsTime: boolean;
  47489. /**
  47490. * Gets the perf counter used for animations time
  47491. */
  47492. readonly animationsTimeCounter: PerfCounter;
  47493. /**
  47494. * Gets the animations time capture status
  47495. */
  47496. /**
  47497. * Enable or disable the animations time capture
  47498. */
  47499. captureAnimationsTime: boolean;
  47500. /**
  47501. * Gets the perf counter used for frame time capture
  47502. */
  47503. readonly frameTimeCounter: PerfCounter;
  47504. /**
  47505. * Gets the frame time capture status
  47506. */
  47507. /**
  47508. * Enable or disable the frame time capture
  47509. */
  47510. captureFrameTime: boolean;
  47511. /**
  47512. * Gets the perf counter used for inter-frames time capture
  47513. */
  47514. readonly interFrameTimeCounter: PerfCounter;
  47515. /**
  47516. * Gets the inter-frames time capture status
  47517. */
  47518. /**
  47519. * Enable or disable the inter-frames time capture
  47520. */
  47521. captureInterFrameTime: boolean;
  47522. /**
  47523. * Gets the perf counter used for render time capture
  47524. */
  47525. readonly renderTimeCounter: PerfCounter;
  47526. /**
  47527. * Gets the render time capture status
  47528. */
  47529. /**
  47530. * Enable or disable the render time capture
  47531. */
  47532. captureRenderTime: boolean;
  47533. /**
  47534. * Gets the perf counter used for camera render time capture
  47535. */
  47536. readonly cameraRenderTimeCounter: PerfCounter;
  47537. /**
  47538. * Gets the camera render time capture status
  47539. */
  47540. /**
  47541. * Enable or disable the camera render time capture
  47542. */
  47543. captureCameraRenderTime: boolean;
  47544. /**
  47545. * Gets the perf counter used for draw calls
  47546. */
  47547. readonly drawCallsCounter: PerfCounter;
  47548. /**
  47549. * Instantiates a new scene instrumentation.
  47550. * This class can be used to get instrumentation data from a Babylon engine
  47551. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47552. * @param scene Defines the scene to instrument
  47553. */
  47554. constructor(
  47555. /**
  47556. * Defines the scene to instrument
  47557. */
  47558. scene: Scene);
  47559. /**
  47560. * Dispose and release associated resources.
  47561. */
  47562. dispose(): void;
  47563. }
  47564. }
  47565. declare module BABYLON {
  47566. /** @hidden */
  47567. export var glowMapGenerationPixelShader: {
  47568. name: string;
  47569. shader: string;
  47570. };
  47571. }
  47572. declare module BABYLON {
  47573. /** @hidden */
  47574. export var glowMapGenerationVertexShader: {
  47575. name: string;
  47576. shader: string;
  47577. };
  47578. }
  47579. declare module BABYLON {
  47580. /**
  47581. * Effect layer options. This helps customizing the behaviour
  47582. * of the effect layer.
  47583. */
  47584. export interface IEffectLayerOptions {
  47585. /**
  47586. * Multiplication factor apply to the canvas size to compute the render target size
  47587. * used to generated the objects (the smaller the faster).
  47588. */
  47589. mainTextureRatio: number;
  47590. /**
  47591. * Enforces a fixed size texture to ensure effect stability across devices.
  47592. */
  47593. mainTextureFixedSize?: number;
  47594. /**
  47595. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  47596. */
  47597. alphaBlendingMode: number;
  47598. /**
  47599. * The camera attached to the layer.
  47600. */
  47601. camera: Nullable<Camera>;
  47602. /**
  47603. * The rendering group to draw the layer in.
  47604. */
  47605. renderingGroupId: number;
  47606. }
  47607. /**
  47608. * The effect layer Helps adding post process effect blended with the main pass.
  47609. *
  47610. * This can be for instance use to generate glow or higlight effects on the scene.
  47611. *
  47612. * The effect layer class can not be used directly and is intented to inherited from to be
  47613. * customized per effects.
  47614. */
  47615. export abstract class EffectLayer {
  47616. private _vertexBuffers;
  47617. private _indexBuffer;
  47618. private _cachedDefines;
  47619. private _effectLayerMapGenerationEffect;
  47620. private _effectLayerOptions;
  47621. private _mergeEffect;
  47622. protected _scene: Scene;
  47623. protected _engine: Engine;
  47624. protected _maxSize: number;
  47625. protected _mainTextureDesiredSize: ISize;
  47626. protected _mainTexture: RenderTargetTexture;
  47627. protected _shouldRender: boolean;
  47628. protected _postProcesses: PostProcess[];
  47629. protected _textures: BaseTexture[];
  47630. protected _emissiveTextureAndColor: {
  47631. texture: Nullable<BaseTexture>;
  47632. color: Color4;
  47633. };
  47634. /**
  47635. * The name of the layer
  47636. */
  47637. name: string;
  47638. /**
  47639. * The clear color of the texture used to generate the glow map.
  47640. */
  47641. neutralColor: Color4;
  47642. /**
  47643. * Specifies wether the highlight layer is enabled or not.
  47644. */
  47645. isEnabled: boolean;
  47646. /**
  47647. * Gets the camera attached to the layer.
  47648. */
  47649. readonly camera: Nullable<Camera>;
  47650. /**
  47651. * Gets the rendering group id the layer should render in.
  47652. */
  47653. renderingGroupId: number;
  47654. /**
  47655. * An event triggered when the effect layer has been disposed.
  47656. */
  47657. onDisposeObservable: Observable<EffectLayer>;
  47658. /**
  47659. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  47660. */
  47661. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  47662. /**
  47663. * An event triggered when the generated texture is being merged in the scene.
  47664. */
  47665. onBeforeComposeObservable: Observable<EffectLayer>;
  47666. /**
  47667. * An event triggered when the generated texture has been merged in the scene.
  47668. */
  47669. onAfterComposeObservable: Observable<EffectLayer>;
  47670. /**
  47671. * An event triggered when the efffect layer changes its size.
  47672. */
  47673. onSizeChangedObservable: Observable<EffectLayer>;
  47674. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  47675. /**
  47676. * Instantiates a new effect Layer and references it in the scene.
  47677. * @param name The name of the layer
  47678. * @param scene The scene to use the layer in
  47679. */
  47680. constructor(
  47681. /** The Friendly of the effect in the scene */
  47682. name: string, scene: Scene);
  47683. /**
  47684. * Get the effect name of the layer.
  47685. * @return The effect name
  47686. */
  47687. abstract getEffectName(): string;
  47688. /**
  47689. * Checks for the readiness of the element composing the layer.
  47690. * @param subMesh the mesh to check for
  47691. * @param useInstances specify wether or not to use instances to render the mesh
  47692. * @return true if ready otherwise, false
  47693. */
  47694. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47695. /**
  47696. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47697. * @returns true if the effect requires stencil during the main canvas render pass.
  47698. */
  47699. abstract needStencil(): boolean;
  47700. /**
  47701. * Create the merge effect. This is the shader use to blit the information back
  47702. * to the main canvas at the end of the scene rendering.
  47703. * @returns The effect containing the shader used to merge the effect on the main canvas
  47704. */
  47705. protected abstract _createMergeEffect(): Effect;
  47706. /**
  47707. * Creates the render target textures and post processes used in the effect layer.
  47708. */
  47709. protected abstract _createTextureAndPostProcesses(): void;
  47710. /**
  47711. * Implementation specific of rendering the generating effect on the main canvas.
  47712. * @param effect The effect used to render through
  47713. */
  47714. protected abstract _internalRender(effect: Effect): void;
  47715. /**
  47716. * Sets the required values for both the emissive texture and and the main color.
  47717. */
  47718. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47719. /**
  47720. * Free any resources and references associated to a mesh.
  47721. * Internal use
  47722. * @param mesh The mesh to free.
  47723. */
  47724. abstract _disposeMesh(mesh: Mesh): void;
  47725. /**
  47726. * Serializes this layer (Glow or Highlight for example)
  47727. * @returns a serialized layer object
  47728. */
  47729. abstract serialize?(): any;
  47730. /**
  47731. * Initializes the effect layer with the required options.
  47732. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  47733. */
  47734. protected _init(options: Partial<IEffectLayerOptions>): void;
  47735. /**
  47736. * Generates the index buffer of the full screen quad blending to the main canvas.
  47737. */
  47738. private _generateIndexBuffer;
  47739. /**
  47740. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  47741. */
  47742. private _generateVertexBuffer;
  47743. /**
  47744. * Sets the main texture desired size which is the closest power of two
  47745. * of the engine canvas size.
  47746. */
  47747. private _setMainTextureSize;
  47748. /**
  47749. * Creates the main texture for the effect layer.
  47750. */
  47751. protected _createMainTexture(): void;
  47752. /**
  47753. * Adds specific effects defines.
  47754. * @param defines The defines to add specifics to.
  47755. */
  47756. protected _addCustomEffectDefines(defines: string[]): void;
  47757. /**
  47758. * Checks for the readiness of the element composing the layer.
  47759. * @param subMesh the mesh to check for
  47760. * @param useInstances specify wether or not to use instances to render the mesh
  47761. * @param emissiveTexture the associated emissive texture used to generate the glow
  47762. * @return true if ready otherwise, false
  47763. */
  47764. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  47765. /**
  47766. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  47767. */
  47768. render(): void;
  47769. /**
  47770. * Determine if a given mesh will be used in the current effect.
  47771. * @param mesh mesh to test
  47772. * @returns true if the mesh will be used
  47773. */
  47774. hasMesh(mesh: AbstractMesh): boolean;
  47775. /**
  47776. * Returns true if the layer contains information to display, otherwise false.
  47777. * @returns true if the glow layer should be rendered
  47778. */
  47779. shouldRender(): boolean;
  47780. /**
  47781. * Returns true if the mesh should render, otherwise false.
  47782. * @param mesh The mesh to render
  47783. * @returns true if it should render otherwise false
  47784. */
  47785. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47786. /**
  47787. * Returns true if the mesh can be rendered, otherwise false.
  47788. * @param mesh The mesh to render
  47789. * @param material The material used on the mesh
  47790. * @returns true if it can be rendered otherwise false
  47791. */
  47792. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47793. /**
  47794. * Returns true if the mesh should render, otherwise false.
  47795. * @param mesh The mesh to render
  47796. * @returns true if it should render otherwise false
  47797. */
  47798. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47799. /**
  47800. * Renders the submesh passed in parameter to the generation map.
  47801. */
  47802. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  47803. /**
  47804. * Rebuild the required buffers.
  47805. * @hidden Internal use only.
  47806. */ private _rebuild(): void;
  47807. /**
  47808. * Dispose only the render target textures and post process.
  47809. */
  47810. private _disposeTextureAndPostProcesses;
  47811. /**
  47812. * Dispose the highlight layer and free resources.
  47813. */
  47814. dispose(): void;
  47815. /**
  47816. * Gets the class name of the effect layer
  47817. * @returns the string with the class name of the effect layer
  47818. */
  47819. getClassName(): string;
  47820. /**
  47821. * Creates an effect layer from parsed effect layer data
  47822. * @param parsedEffectLayer defines effect layer data
  47823. * @param scene defines the current scene
  47824. * @param rootUrl defines the root URL containing the effect layer information
  47825. * @returns a parsed effect Layer
  47826. */
  47827. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47828. }
  47829. }
  47830. declare module BABYLON {
  47831. interface AbstractScene {
  47832. /**
  47833. * The list of effect layers (highlights/glow) added to the scene
  47834. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47835. * @see http://doc.babylonjs.com/how_to/glow_layer
  47836. */
  47837. effectLayers: Array<EffectLayer>;
  47838. /**
  47839. * Removes the given effect layer from this scene.
  47840. * @param toRemove defines the effect layer to remove
  47841. * @returns the index of the removed effect layer
  47842. */
  47843. removeEffectLayer(toRemove: EffectLayer): number;
  47844. /**
  47845. * Adds the given effect layer to this scene
  47846. * @param newEffectLayer defines the effect layer to add
  47847. */
  47848. addEffectLayer(newEffectLayer: EffectLayer): void;
  47849. }
  47850. /**
  47851. * Defines the layer scene component responsible to manage any effect layers
  47852. * in a given scene.
  47853. */
  47854. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47855. /**
  47856. * The component name helpfull to identify the component in the list of scene components.
  47857. */
  47858. readonly name: string;
  47859. /**
  47860. * The scene the component belongs to.
  47861. */
  47862. scene: Scene;
  47863. private _engine;
  47864. private _renderEffects;
  47865. private _needStencil;
  47866. private _previousStencilState;
  47867. /**
  47868. * Creates a new instance of the component for the given scene
  47869. * @param scene Defines the scene to register the component in
  47870. */
  47871. constructor(scene: Scene);
  47872. /**
  47873. * Registers the component in a given scene
  47874. */
  47875. register(): void;
  47876. /**
  47877. * Rebuilds the elements related to this component in case of
  47878. * context lost for instance.
  47879. */
  47880. rebuild(): void;
  47881. /**
  47882. * Serializes the component data to the specified json object
  47883. * @param serializationObject The object to serialize to
  47884. */
  47885. serialize(serializationObject: any): void;
  47886. /**
  47887. * Adds all the elements from the container to the scene
  47888. * @param container the container holding the elements
  47889. */
  47890. addFromContainer(container: AbstractScene): void;
  47891. /**
  47892. * Removes all the elements in the container from the scene
  47893. * @param container contains the elements to remove
  47894. * @param dispose if the removed element should be disposed (default: false)
  47895. */
  47896. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47897. /**
  47898. * Disposes the component and the associated ressources.
  47899. */
  47900. dispose(): void;
  47901. private _isReadyForMesh;
  47902. private _renderMainTexture;
  47903. private _setStencil;
  47904. private _setStencilBack;
  47905. private _draw;
  47906. private _drawCamera;
  47907. private _drawRenderingGroup;
  47908. }
  47909. }
  47910. declare module BABYLON {
  47911. /** @hidden */
  47912. export var glowMapMergePixelShader: {
  47913. name: string;
  47914. shader: string;
  47915. };
  47916. }
  47917. declare module BABYLON {
  47918. /** @hidden */
  47919. export var glowMapMergeVertexShader: {
  47920. name: string;
  47921. shader: string;
  47922. };
  47923. }
  47924. declare module BABYLON {
  47925. interface AbstractScene {
  47926. /**
  47927. * Return a the first highlight layer of the scene with a given name.
  47928. * @param name The name of the highlight layer to look for.
  47929. * @return The highlight layer if found otherwise null.
  47930. */
  47931. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47932. }
  47933. /**
  47934. * Glow layer options. This helps customizing the behaviour
  47935. * of the glow layer.
  47936. */
  47937. export interface IGlowLayerOptions {
  47938. /**
  47939. * Multiplication factor apply to the canvas size to compute the render target size
  47940. * used to generated the glowing objects (the smaller the faster).
  47941. */
  47942. mainTextureRatio: number;
  47943. /**
  47944. * Enforces a fixed size texture to ensure resize independant blur.
  47945. */
  47946. mainTextureFixedSize?: number;
  47947. /**
  47948. * How big is the kernel of the blur texture.
  47949. */
  47950. blurKernelSize: number;
  47951. /**
  47952. * The camera attached to the layer.
  47953. */
  47954. camera: Nullable<Camera>;
  47955. /**
  47956. * Enable MSAA by chosing the number of samples.
  47957. */
  47958. mainTextureSamples?: number;
  47959. /**
  47960. * The rendering group to draw the layer in.
  47961. */
  47962. renderingGroupId: number;
  47963. }
  47964. /**
  47965. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47966. *
  47967. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47968. * glowy meshes to your scene.
  47969. *
  47970. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47971. */
  47972. export class GlowLayer extends EffectLayer {
  47973. /**
  47974. * Effect Name of the layer.
  47975. */
  47976. static readonly EffectName: string;
  47977. /**
  47978. * The default blur kernel size used for the glow.
  47979. */
  47980. static DefaultBlurKernelSize: number;
  47981. /**
  47982. * The default texture size ratio used for the glow.
  47983. */
  47984. static DefaultTextureRatio: number;
  47985. /**
  47986. * Sets the kernel size of the blur.
  47987. */
  47988. /**
  47989. * Gets the kernel size of the blur.
  47990. */
  47991. blurKernelSize: number;
  47992. /**
  47993. * Sets the glow intensity.
  47994. */
  47995. /**
  47996. * Gets the glow intensity.
  47997. */
  47998. intensity: number;
  47999. private _options;
  48000. private _intensity;
  48001. private _horizontalBlurPostprocess1;
  48002. private _verticalBlurPostprocess1;
  48003. private _horizontalBlurPostprocess2;
  48004. private _verticalBlurPostprocess2;
  48005. private _blurTexture1;
  48006. private _blurTexture2;
  48007. private _postProcesses1;
  48008. private _postProcesses2;
  48009. private _includedOnlyMeshes;
  48010. private _excludedMeshes;
  48011. /**
  48012. * Callback used to let the user override the color selection on a per mesh basis
  48013. */
  48014. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  48015. /**
  48016. * Callback used to let the user override the texture selection on a per mesh basis
  48017. */
  48018. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  48019. /**
  48020. * Instantiates a new glow Layer and references it to the scene.
  48021. * @param name The name of the layer
  48022. * @param scene The scene to use the layer in
  48023. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  48024. */
  48025. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  48026. /**
  48027. * Get the effect name of the layer.
  48028. * @return The effect name
  48029. */
  48030. getEffectName(): string;
  48031. /**
  48032. * Create the merge effect. This is the shader use to blit the information back
  48033. * to the main canvas at the end of the scene rendering.
  48034. */
  48035. protected _createMergeEffect(): Effect;
  48036. /**
  48037. * Creates the render target textures and post processes used in the glow layer.
  48038. */
  48039. protected _createTextureAndPostProcesses(): void;
  48040. /**
  48041. * Checks for the readiness of the element composing the layer.
  48042. * @param subMesh the mesh to check for
  48043. * @param useInstances specify wether or not to use instances to render the mesh
  48044. * @param emissiveTexture the associated emissive texture used to generate the glow
  48045. * @return true if ready otherwise, false
  48046. */
  48047. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48048. /**
  48049. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48050. */
  48051. needStencil(): boolean;
  48052. /**
  48053. * Returns true if the mesh can be rendered, otherwise false.
  48054. * @param mesh The mesh to render
  48055. * @param material The material used on the mesh
  48056. * @returns true if it can be rendered otherwise false
  48057. */
  48058. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48059. /**
  48060. * Implementation specific of rendering the generating effect on the main canvas.
  48061. * @param effect The effect used to render through
  48062. */
  48063. protected _internalRender(effect: Effect): void;
  48064. /**
  48065. * Sets the required values for both the emissive texture and and the main color.
  48066. */
  48067. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48068. /**
  48069. * Returns true if the mesh should render, otherwise false.
  48070. * @param mesh The mesh to render
  48071. * @returns true if it should render otherwise false
  48072. */
  48073. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48074. /**
  48075. * Adds specific effects defines.
  48076. * @param defines The defines to add specifics to.
  48077. */
  48078. protected _addCustomEffectDefines(defines: string[]): void;
  48079. /**
  48080. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  48081. * @param mesh The mesh to exclude from the glow layer
  48082. */
  48083. addExcludedMesh(mesh: Mesh): void;
  48084. /**
  48085. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  48086. * @param mesh The mesh to remove
  48087. */
  48088. removeExcludedMesh(mesh: Mesh): void;
  48089. /**
  48090. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  48091. * @param mesh The mesh to include in the glow layer
  48092. */
  48093. addIncludedOnlyMesh(mesh: Mesh): void;
  48094. /**
  48095. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  48096. * @param mesh The mesh to remove
  48097. */
  48098. removeIncludedOnlyMesh(mesh: Mesh): void;
  48099. /**
  48100. * Determine if a given mesh will be used in the glow layer
  48101. * @param mesh The mesh to test
  48102. * @returns true if the mesh will be highlighted by the current glow layer
  48103. */
  48104. hasMesh(mesh: AbstractMesh): boolean;
  48105. /**
  48106. * Free any resources and references associated to a mesh.
  48107. * Internal use
  48108. * @param mesh The mesh to free.
  48109. * @hidden
  48110. */ private _disposeMesh(mesh: Mesh): void;
  48111. /**
  48112. * Gets the class name of the effect layer
  48113. * @returns the string with the class name of the effect layer
  48114. */
  48115. getClassName(): string;
  48116. /**
  48117. * Serializes this glow layer
  48118. * @returns a serialized glow layer object
  48119. */
  48120. serialize(): any;
  48121. /**
  48122. * Creates a Glow Layer from parsed glow layer data
  48123. * @param parsedGlowLayer defines glow layer data
  48124. * @param scene defines the current scene
  48125. * @param rootUrl defines the root URL containing the glow layer information
  48126. * @returns a parsed Glow Layer
  48127. */
  48128. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  48129. }
  48130. }
  48131. declare module BABYLON {
  48132. /** @hidden */
  48133. export var glowBlurPostProcessPixelShader: {
  48134. name: string;
  48135. shader: string;
  48136. };
  48137. }
  48138. declare module BABYLON {
  48139. interface AbstractScene {
  48140. /**
  48141. * Return a the first highlight layer of the scene with a given name.
  48142. * @param name The name of the highlight layer to look for.
  48143. * @return The highlight layer if found otherwise null.
  48144. */
  48145. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  48146. }
  48147. /**
  48148. * Highlight layer options. This helps customizing the behaviour
  48149. * of the highlight layer.
  48150. */
  48151. export interface IHighlightLayerOptions {
  48152. /**
  48153. * Multiplication factor apply to the canvas size to compute the render target size
  48154. * used to generated the glowing objects (the smaller the faster).
  48155. */
  48156. mainTextureRatio: number;
  48157. /**
  48158. * Enforces a fixed size texture to ensure resize independant blur.
  48159. */
  48160. mainTextureFixedSize?: number;
  48161. /**
  48162. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  48163. * of the picture to blur (the smaller the faster).
  48164. */
  48165. blurTextureSizeRatio: number;
  48166. /**
  48167. * How big in texel of the blur texture is the vertical blur.
  48168. */
  48169. blurVerticalSize: number;
  48170. /**
  48171. * How big in texel of the blur texture is the horizontal blur.
  48172. */
  48173. blurHorizontalSize: number;
  48174. /**
  48175. * Alpha blending mode used to apply the blur. Default is combine.
  48176. */
  48177. alphaBlendingMode: number;
  48178. /**
  48179. * The camera attached to the layer.
  48180. */
  48181. camera: Nullable<Camera>;
  48182. /**
  48183. * Should we display highlight as a solid stroke?
  48184. */
  48185. isStroke?: boolean;
  48186. /**
  48187. * The rendering group to draw the layer in.
  48188. */
  48189. renderingGroupId: number;
  48190. }
  48191. /**
  48192. * The highlight layer Helps adding a glow effect around a mesh.
  48193. *
  48194. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48195. * glowy meshes to your scene.
  48196. *
  48197. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  48198. */
  48199. export class HighlightLayer extends EffectLayer {
  48200. name: string;
  48201. /**
  48202. * Effect Name of the highlight layer.
  48203. */
  48204. static readonly EffectName: string;
  48205. /**
  48206. * The neutral color used during the preparation of the glow effect.
  48207. * This is black by default as the blend operation is a blend operation.
  48208. */
  48209. static NeutralColor: Color4;
  48210. /**
  48211. * Stencil value used for glowing meshes.
  48212. */
  48213. static GlowingMeshStencilReference: number;
  48214. /**
  48215. * Stencil value used for the other meshes in the scene.
  48216. */
  48217. static NormalMeshStencilReference: number;
  48218. /**
  48219. * Specifies whether or not the inner glow is ACTIVE in the layer.
  48220. */
  48221. innerGlow: boolean;
  48222. /**
  48223. * Specifies whether or not the outer glow is ACTIVE in the layer.
  48224. */
  48225. outerGlow: boolean;
  48226. /**
  48227. * Specifies the horizontal size of the blur.
  48228. */
  48229. /**
  48230. * Gets the horizontal size of the blur.
  48231. */
  48232. blurHorizontalSize: number;
  48233. /**
  48234. * Specifies the vertical size of the blur.
  48235. */
  48236. /**
  48237. * Gets the vertical size of the blur.
  48238. */
  48239. blurVerticalSize: number;
  48240. /**
  48241. * An event triggered when the highlight layer is being blurred.
  48242. */
  48243. onBeforeBlurObservable: Observable<HighlightLayer>;
  48244. /**
  48245. * An event triggered when the highlight layer has been blurred.
  48246. */
  48247. onAfterBlurObservable: Observable<HighlightLayer>;
  48248. private _instanceGlowingMeshStencilReference;
  48249. private _options;
  48250. private _downSamplePostprocess;
  48251. private _horizontalBlurPostprocess;
  48252. private _verticalBlurPostprocess;
  48253. private _blurTexture;
  48254. private _meshes;
  48255. private _excludedMeshes;
  48256. /**
  48257. * Instantiates a new highlight Layer and references it to the scene..
  48258. * @param name The name of the layer
  48259. * @param scene The scene to use the layer in
  48260. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  48261. */
  48262. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  48263. /**
  48264. * Get the effect name of the layer.
  48265. * @return The effect name
  48266. */
  48267. getEffectName(): string;
  48268. /**
  48269. * Create the merge effect. This is the shader use to blit the information back
  48270. * to the main canvas at the end of the scene rendering.
  48271. */
  48272. protected _createMergeEffect(): Effect;
  48273. /**
  48274. * Creates the render target textures and post processes used in the highlight layer.
  48275. */
  48276. protected _createTextureAndPostProcesses(): void;
  48277. /**
  48278. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48279. */
  48280. needStencil(): boolean;
  48281. /**
  48282. * Checks for the readiness of the element composing the layer.
  48283. * @param subMesh the mesh to check for
  48284. * @param useInstances specify wether or not to use instances to render the mesh
  48285. * @param emissiveTexture the associated emissive texture used to generate the glow
  48286. * @return true if ready otherwise, false
  48287. */
  48288. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48289. /**
  48290. * Implementation specific of rendering the generating effect on the main canvas.
  48291. * @param effect The effect used to render through
  48292. */
  48293. protected _internalRender(effect: Effect): void;
  48294. /**
  48295. * Returns true if the layer contains information to display, otherwise false.
  48296. */
  48297. shouldRender(): boolean;
  48298. /**
  48299. * Returns true if the mesh should render, otherwise false.
  48300. * @param mesh The mesh to render
  48301. * @returns true if it should render otherwise false
  48302. */
  48303. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48304. /**
  48305. * Sets the required values for both the emissive texture and and the main color.
  48306. */
  48307. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48308. /**
  48309. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  48310. * @param mesh The mesh to exclude from the highlight layer
  48311. */
  48312. addExcludedMesh(mesh: Mesh): void;
  48313. /**
  48314. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  48315. * @param mesh The mesh to highlight
  48316. */
  48317. removeExcludedMesh(mesh: Mesh): void;
  48318. /**
  48319. * Determine if a given mesh will be highlighted by the current HighlightLayer
  48320. * @param mesh mesh to test
  48321. * @returns true if the mesh will be highlighted by the current HighlightLayer
  48322. */
  48323. hasMesh(mesh: AbstractMesh): boolean;
  48324. /**
  48325. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  48326. * @param mesh The mesh to highlight
  48327. * @param color The color of the highlight
  48328. * @param glowEmissiveOnly Extract the glow from the emissive texture
  48329. */
  48330. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  48331. /**
  48332. * Remove a mesh from the highlight layer in order to make it stop glowing.
  48333. * @param mesh The mesh to highlight
  48334. */
  48335. removeMesh(mesh: Mesh): void;
  48336. /**
  48337. * Force the stencil to the normal expected value for none glowing parts
  48338. */
  48339. private _defaultStencilReference;
  48340. /**
  48341. * Free any resources and references associated to a mesh.
  48342. * Internal use
  48343. * @param mesh The mesh to free.
  48344. * @hidden
  48345. */ private _disposeMesh(mesh: Mesh): void;
  48346. /**
  48347. * Dispose the highlight layer and free resources.
  48348. */
  48349. dispose(): void;
  48350. /**
  48351. * Gets the class name of the effect layer
  48352. * @returns the string with the class name of the effect layer
  48353. */
  48354. getClassName(): string;
  48355. /**
  48356. * Serializes this Highlight layer
  48357. * @returns a serialized Highlight layer object
  48358. */
  48359. serialize(): any;
  48360. /**
  48361. * Creates a Highlight layer from parsed Highlight layer data
  48362. * @param parsedHightlightLayer defines the Highlight layer data
  48363. * @param scene defines the current scene
  48364. * @param rootUrl defines the root URL containing the Highlight layer information
  48365. * @returns a parsed Highlight layer
  48366. */
  48367. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  48368. }
  48369. }
  48370. declare module BABYLON {
  48371. interface AbstractScene {
  48372. /**
  48373. * The list of layers (background and foreground) of the scene
  48374. */
  48375. layers: Array<Layer>;
  48376. }
  48377. /**
  48378. * Defines the layer scene component responsible to manage any layers
  48379. * in a given scene.
  48380. */
  48381. export class LayerSceneComponent implements ISceneComponent {
  48382. /**
  48383. * The component name helpfull to identify the component in the list of scene components.
  48384. */
  48385. readonly name: string;
  48386. /**
  48387. * The scene the component belongs to.
  48388. */
  48389. scene: Scene;
  48390. private _engine;
  48391. /**
  48392. * Creates a new instance of the component for the given scene
  48393. * @param scene Defines the scene to register the component in
  48394. */
  48395. constructor(scene: Scene);
  48396. /**
  48397. * Registers the component in a given scene
  48398. */
  48399. register(): void;
  48400. /**
  48401. * Rebuilds the elements related to this component in case of
  48402. * context lost for instance.
  48403. */
  48404. rebuild(): void;
  48405. /**
  48406. * Disposes the component and the associated ressources.
  48407. */
  48408. dispose(): void;
  48409. private _draw;
  48410. private _drawCameraPredicate;
  48411. private _drawCameraBackground;
  48412. private _drawCameraForeground;
  48413. private _drawRenderTargetPredicate;
  48414. private _drawRenderTargetBackground;
  48415. private _drawRenderTargetForeground;
  48416. /**
  48417. * Adds all the elements from the container to the scene
  48418. * @param container the container holding the elements
  48419. */
  48420. addFromContainer(container: AbstractScene): void;
  48421. /**
  48422. * Removes all the elements in the container from the scene
  48423. * @param container contains the elements to remove
  48424. * @param dispose if the removed element should be disposed (default: false)
  48425. */
  48426. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48427. }
  48428. }
  48429. declare module BABYLON {
  48430. /** @hidden */
  48431. export var layerPixelShader: {
  48432. name: string;
  48433. shader: string;
  48434. };
  48435. }
  48436. declare module BABYLON {
  48437. /** @hidden */
  48438. export var layerVertexShader: {
  48439. name: string;
  48440. shader: string;
  48441. };
  48442. }
  48443. declare module BABYLON {
  48444. /**
  48445. * This represents a full screen 2d layer.
  48446. * This can be useful to display a picture in the background of your scene for instance.
  48447. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48448. */
  48449. export class Layer {
  48450. /**
  48451. * Define the name of the layer.
  48452. */
  48453. name: string;
  48454. /**
  48455. * Define the texture the layer should display.
  48456. */
  48457. texture: Nullable<Texture>;
  48458. /**
  48459. * Is the layer in background or foreground.
  48460. */
  48461. isBackground: boolean;
  48462. /**
  48463. * Define the color of the layer (instead of texture).
  48464. */
  48465. color: Color4;
  48466. /**
  48467. * Define the scale of the layer in order to zoom in out of the texture.
  48468. */
  48469. scale: Vector2;
  48470. /**
  48471. * Define an offset for the layer in order to shift the texture.
  48472. */
  48473. offset: Vector2;
  48474. /**
  48475. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  48476. */
  48477. alphaBlendingMode: number;
  48478. /**
  48479. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  48480. * Alpha test will not mix with the background color in case of transparency.
  48481. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  48482. */
  48483. alphaTest: boolean;
  48484. /**
  48485. * Define a mask to restrict the layer to only some of the scene cameras.
  48486. */
  48487. layerMask: number;
  48488. /**
  48489. * Define the list of render target the layer is visible into.
  48490. */
  48491. renderTargetTextures: RenderTargetTexture[];
  48492. /**
  48493. * Define if the layer is only used in renderTarget or if it also
  48494. * renders in the main frame buffer of the canvas.
  48495. */
  48496. renderOnlyInRenderTargetTextures: boolean;
  48497. private _scene;
  48498. private _vertexBuffers;
  48499. private _indexBuffer;
  48500. private _effect;
  48501. private _alphaTestEffect;
  48502. /**
  48503. * An event triggered when the layer is disposed.
  48504. */
  48505. onDisposeObservable: Observable<Layer>;
  48506. private _onDisposeObserver;
  48507. /**
  48508. * Back compatibility with callback before the onDisposeObservable existed.
  48509. * The set callback will be triggered when the layer has been disposed.
  48510. */
  48511. onDispose: () => void;
  48512. /**
  48513. * An event triggered before rendering the scene
  48514. */
  48515. onBeforeRenderObservable: Observable<Layer>;
  48516. private _onBeforeRenderObserver;
  48517. /**
  48518. * Back compatibility with callback before the onBeforeRenderObservable existed.
  48519. * The set callback will be triggered just before rendering the layer.
  48520. */
  48521. onBeforeRender: () => void;
  48522. /**
  48523. * An event triggered after rendering the scene
  48524. */
  48525. onAfterRenderObservable: Observable<Layer>;
  48526. private _onAfterRenderObserver;
  48527. /**
  48528. * Back compatibility with callback before the onAfterRenderObservable existed.
  48529. * The set callback will be triggered just after rendering the layer.
  48530. */
  48531. onAfterRender: () => void;
  48532. /**
  48533. * Instantiates a new layer.
  48534. * This represents a full screen 2d layer.
  48535. * This can be useful to display a picture in the background of your scene for instance.
  48536. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48537. * @param name Define the name of the layer in the scene
  48538. * @param imgUrl Define the url of the texture to display in the layer
  48539. * @param scene Define the scene the layer belongs to
  48540. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  48541. * @param color Defines a color for the layer
  48542. */
  48543. constructor(
  48544. /**
  48545. * Define the name of the layer.
  48546. */
  48547. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  48548. private _createIndexBuffer;
  48549. /** @hidden */ private _rebuild(): void;
  48550. /**
  48551. * Renders the layer in the scene.
  48552. */
  48553. render(): void;
  48554. /**
  48555. * Disposes and releases the associated ressources.
  48556. */
  48557. dispose(): void;
  48558. }
  48559. }
  48560. declare module BABYLON {
  48561. /** @hidden */
  48562. export var lensFlarePixelShader: {
  48563. name: string;
  48564. shader: string;
  48565. };
  48566. }
  48567. declare module BABYLON {
  48568. /** @hidden */
  48569. export var lensFlareVertexShader: {
  48570. name: string;
  48571. shader: string;
  48572. };
  48573. }
  48574. declare module BABYLON {
  48575. /**
  48576. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48577. * It is usually composed of several `lensFlare`.
  48578. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48579. */
  48580. export class LensFlareSystem {
  48581. /**
  48582. * Define the name of the lens flare system
  48583. */
  48584. name: string;
  48585. /**
  48586. * List of lens flares used in this system.
  48587. */
  48588. lensFlares: LensFlare[];
  48589. /**
  48590. * Define a limit from the border the lens flare can be visible.
  48591. */
  48592. borderLimit: number;
  48593. /**
  48594. * Define a viewport border we do not want to see the lens flare in.
  48595. */
  48596. viewportBorder: number;
  48597. /**
  48598. * Define a predicate which could limit the list of meshes able to occlude the effect.
  48599. */
  48600. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48601. /**
  48602. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  48603. */
  48604. layerMask: number;
  48605. /**
  48606. * Define the id of the lens flare system in the scene.
  48607. * (equal to name by default)
  48608. */
  48609. id: string;
  48610. private _scene;
  48611. private _emitter;
  48612. private _vertexBuffers;
  48613. private _indexBuffer;
  48614. private _effect;
  48615. private _positionX;
  48616. private _positionY;
  48617. private _isEnabled;
  48618. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  48619. /**
  48620. * Instantiates a lens flare system.
  48621. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48622. * It is usually composed of several `lensFlare`.
  48623. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48624. * @param name Define the name of the lens flare system in the scene
  48625. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  48626. * @param scene Define the scene the lens flare system belongs to
  48627. */
  48628. constructor(
  48629. /**
  48630. * Define the name of the lens flare system
  48631. */
  48632. name: string, emitter: any, scene: Scene);
  48633. /**
  48634. * Define if the lens flare system is enabled.
  48635. */
  48636. isEnabled: boolean;
  48637. /**
  48638. * Get the scene the effects belongs to.
  48639. * @returns the scene holding the lens flare system
  48640. */
  48641. getScene(): Scene;
  48642. /**
  48643. * Get the emitter of the lens flare system.
  48644. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48645. * @returns the emitter of the lens flare system
  48646. */
  48647. getEmitter(): any;
  48648. /**
  48649. * Set the emitter of the lens flare system.
  48650. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48651. * @param newEmitter Define the new emitter of the system
  48652. */
  48653. setEmitter(newEmitter: any): void;
  48654. /**
  48655. * Get the lens flare system emitter position.
  48656. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  48657. * @returns the position
  48658. */
  48659. getEmitterPosition(): Vector3;
  48660. /**
  48661. * @hidden
  48662. */
  48663. computeEffectivePosition(globalViewport: Viewport): boolean;
  48664. /** @hidden */ private _isVisible(): boolean;
  48665. /**
  48666. * @hidden
  48667. */
  48668. render(): boolean;
  48669. /**
  48670. * Dispose and release the lens flare with its associated resources.
  48671. */
  48672. dispose(): void;
  48673. /**
  48674. * Parse a lens flare system from a JSON repressentation
  48675. * @param parsedLensFlareSystem Define the JSON to parse
  48676. * @param scene Define the scene the parsed system should be instantiated in
  48677. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  48678. * @returns the parsed system
  48679. */
  48680. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  48681. /**
  48682. * Serialize the current Lens Flare System into a JSON representation.
  48683. * @returns the serialized JSON
  48684. */
  48685. serialize(): any;
  48686. }
  48687. }
  48688. declare module BABYLON {
  48689. /**
  48690. * This represents one of the lens effect in a `lensFlareSystem`.
  48691. * It controls one of the indiviual texture used in the effect.
  48692. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48693. */
  48694. export class LensFlare {
  48695. /**
  48696. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48697. */
  48698. size: number;
  48699. /**
  48700. * 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.
  48701. */
  48702. position: number;
  48703. /**
  48704. * Define the lens color.
  48705. */
  48706. color: Color3;
  48707. /**
  48708. * Define the lens texture.
  48709. */
  48710. texture: Nullable<Texture>;
  48711. /**
  48712. * Define the alpha mode to render this particular lens.
  48713. */
  48714. alphaMode: number;
  48715. private _system;
  48716. /**
  48717. * Creates a new Lens Flare.
  48718. * This represents one of the lens effect in a `lensFlareSystem`.
  48719. * It controls one of the indiviual texture used in the effect.
  48720. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48721. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  48722. * @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.
  48723. * @param color Define the lens color
  48724. * @param imgUrl Define the lens texture url
  48725. * @param system Define the `lensFlareSystem` this flare is part of
  48726. * @returns The newly created Lens Flare
  48727. */
  48728. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  48729. /**
  48730. * Instantiates a new Lens Flare.
  48731. * This represents one of the lens effect in a `lensFlareSystem`.
  48732. * It controls one of the indiviual texture used in the effect.
  48733. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48734. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  48735. * @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.
  48736. * @param color Define the lens color
  48737. * @param imgUrl Define the lens texture url
  48738. * @param system Define the `lensFlareSystem` this flare is part of
  48739. */
  48740. constructor(
  48741. /**
  48742. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48743. */
  48744. size: number,
  48745. /**
  48746. * 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.
  48747. */
  48748. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  48749. /**
  48750. * Dispose and release the lens flare with its associated resources.
  48751. */
  48752. dispose(): void;
  48753. }
  48754. }
  48755. declare module BABYLON {
  48756. interface AbstractScene {
  48757. /**
  48758. * The list of lens flare system added to the scene
  48759. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48760. */
  48761. lensFlareSystems: Array<LensFlareSystem>;
  48762. /**
  48763. * Removes the given lens flare system from this scene.
  48764. * @param toRemove The lens flare system to remove
  48765. * @returns The index of the removed lens flare system
  48766. */
  48767. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  48768. /**
  48769. * Adds the given lens flare system to this scene
  48770. * @param newLensFlareSystem The lens flare system to add
  48771. */
  48772. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  48773. /**
  48774. * Gets a lens flare system using its name
  48775. * @param name defines the name to look for
  48776. * @returns the lens flare system or null if not found
  48777. */
  48778. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  48779. /**
  48780. * Gets a lens flare system using its id
  48781. * @param id defines the id to look for
  48782. * @returns the lens flare system or null if not found
  48783. */
  48784. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  48785. }
  48786. /**
  48787. * Defines the lens flare scene component responsible to manage any lens flares
  48788. * in a given scene.
  48789. */
  48790. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  48791. /**
  48792. * The component name helpfull to identify the component in the list of scene components.
  48793. */
  48794. readonly name: string;
  48795. /**
  48796. * The scene the component belongs to.
  48797. */
  48798. scene: Scene;
  48799. /**
  48800. * Creates a new instance of the component for the given scene
  48801. * @param scene Defines the scene to register the component in
  48802. */
  48803. constructor(scene: Scene);
  48804. /**
  48805. * Registers the component in a given scene
  48806. */
  48807. register(): void;
  48808. /**
  48809. * Rebuilds the elements related to this component in case of
  48810. * context lost for instance.
  48811. */
  48812. rebuild(): void;
  48813. /**
  48814. * Adds all the elements from the container to the scene
  48815. * @param container the container holding the elements
  48816. */
  48817. addFromContainer(container: AbstractScene): void;
  48818. /**
  48819. * Removes all the elements in the container from the scene
  48820. * @param container contains the elements to remove
  48821. * @param dispose if the removed element should be disposed (default: false)
  48822. */
  48823. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48824. /**
  48825. * Serializes the component data to the specified json object
  48826. * @param serializationObject The object to serialize to
  48827. */
  48828. serialize(serializationObject: any): void;
  48829. /**
  48830. * Disposes the component and the associated ressources.
  48831. */
  48832. dispose(): void;
  48833. private _draw;
  48834. }
  48835. }
  48836. declare module BABYLON {
  48837. /**
  48838. * Defines the shadow generator component responsible to manage any shadow generators
  48839. * in a given scene.
  48840. */
  48841. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  48842. /**
  48843. * The component name helpfull to identify the component in the list of scene components.
  48844. */
  48845. readonly name: string;
  48846. /**
  48847. * The scene the component belongs to.
  48848. */
  48849. scene: Scene;
  48850. /**
  48851. * Creates a new instance of the component for the given scene
  48852. * @param scene Defines the scene to register the component in
  48853. */
  48854. constructor(scene: Scene);
  48855. /**
  48856. * Registers the component in a given scene
  48857. */
  48858. register(): void;
  48859. /**
  48860. * Rebuilds the elements related to this component in case of
  48861. * context lost for instance.
  48862. */
  48863. rebuild(): void;
  48864. /**
  48865. * Serializes the component data to the specified json object
  48866. * @param serializationObject The object to serialize to
  48867. */
  48868. serialize(serializationObject: any): void;
  48869. /**
  48870. * Adds all the elements from the container to the scene
  48871. * @param container the container holding the elements
  48872. */
  48873. addFromContainer(container: AbstractScene): void;
  48874. /**
  48875. * Removes all the elements in the container from the scene
  48876. * @param container contains the elements to remove
  48877. * @param dispose if the removed element should be disposed (default: false)
  48878. */
  48879. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48880. /**
  48881. * Rebuilds the elements related to this component in case of
  48882. * context lost for instance.
  48883. */
  48884. dispose(): void;
  48885. private _gatherRenderTargets;
  48886. }
  48887. }
  48888. declare module BABYLON {
  48889. /**
  48890. * A point light is a light defined by an unique point in world space.
  48891. * The light is emitted in every direction from this point.
  48892. * A good example of a point light is a standard light bulb.
  48893. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48894. */
  48895. export class PointLight extends ShadowLight {
  48896. private _shadowAngle;
  48897. /**
  48898. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48899. * This specifies what angle the shadow will use to be created.
  48900. *
  48901. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48902. */
  48903. /**
  48904. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48905. * This specifies what angle the shadow will use to be created.
  48906. *
  48907. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48908. */
  48909. shadowAngle: number;
  48910. /**
  48911. * Gets the direction if it has been set.
  48912. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48913. */
  48914. /**
  48915. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48916. */
  48917. direction: Vector3;
  48918. /**
  48919. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48920. * A PointLight emits the light in every direction.
  48921. * It can cast shadows.
  48922. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48923. * ```javascript
  48924. * var pointLight = new PointLight("pl", camera.position, scene);
  48925. * ```
  48926. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48927. * @param name The light friendly name
  48928. * @param position The position of the point light in the scene
  48929. * @param scene The scene the lights belongs to
  48930. */
  48931. constructor(name: string, position: Vector3, scene: Scene);
  48932. /**
  48933. * Returns the string "PointLight"
  48934. * @returns the class name
  48935. */
  48936. getClassName(): string;
  48937. /**
  48938. * Returns the integer 0.
  48939. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48940. */
  48941. getTypeID(): number;
  48942. /**
  48943. * Specifies wether or not the shadowmap should be a cube texture.
  48944. * @returns true if the shadowmap needs to be a cube texture.
  48945. */
  48946. needCube(): boolean;
  48947. /**
  48948. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48949. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48950. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48951. */
  48952. getShadowDirection(faceIndex?: number): Vector3;
  48953. /**
  48954. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48955. * - fov = PI / 2
  48956. * - aspect ratio : 1.0
  48957. * - z-near and far equal to the active camera minZ and maxZ.
  48958. * Returns the PointLight.
  48959. */
  48960. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48961. protected _buildUniformLayout(): void;
  48962. /**
  48963. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48964. * @param effect The effect to update
  48965. * @param lightIndex The index of the light in the effect to update
  48966. * @returns The point light
  48967. */
  48968. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48969. /**
  48970. * Prepares the list of defines specific to the light type.
  48971. * @param defines the list of defines
  48972. * @param lightIndex defines the index of the light for the effect
  48973. */
  48974. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48975. }
  48976. }
  48977. declare module BABYLON {
  48978. /**
  48979. * Header information of HDR texture files.
  48980. */
  48981. export interface HDRInfo {
  48982. /**
  48983. * The height of the texture in pixels.
  48984. */
  48985. height: number;
  48986. /**
  48987. * The width of the texture in pixels.
  48988. */
  48989. width: number;
  48990. /**
  48991. * The index of the beginning of the data in the binary file.
  48992. */
  48993. dataPosition: number;
  48994. }
  48995. /**
  48996. * This groups tools to convert HDR texture to native colors array.
  48997. */
  48998. export class HDRTools {
  48999. private static Ldexp;
  49000. private static Rgbe2float;
  49001. private static readStringLine;
  49002. /**
  49003. * Reads header information from an RGBE texture stored in a native array.
  49004. * More information on this format are available here:
  49005. * https://en.wikipedia.org/wiki/RGBE_image_format
  49006. *
  49007. * @param uint8array The binary file stored in native array.
  49008. * @return The header information.
  49009. */
  49010. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49011. /**
  49012. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49013. * This RGBE texture needs to store the information as a panorama.
  49014. *
  49015. * More information on this format are available here:
  49016. * https://en.wikipedia.org/wiki/RGBE_image_format
  49017. *
  49018. * @param buffer The binary file stored in an array buffer.
  49019. * @param size The expected size of the extracted cubemap.
  49020. * @return The Cube Map information.
  49021. */
  49022. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49023. /**
  49024. * Returns the pixels data extracted from an RGBE texture.
  49025. * This pixels will be stored left to right up to down in the R G B order in one array.
  49026. *
  49027. * More information on this format are available here:
  49028. * https://en.wikipedia.org/wiki/RGBE_image_format
  49029. *
  49030. * @param uint8array The binary file stored in an array buffer.
  49031. * @param hdrInfo The header information of the file.
  49032. * @return The pixels data in RGB right to left up to down order.
  49033. */
  49034. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49035. private static RGBE_ReadPixels_RLE;
  49036. }
  49037. }
  49038. declare module BABYLON {
  49039. /**
  49040. * This represents a texture coming from an HDR input.
  49041. *
  49042. * The only supported format is currently panorama picture stored in RGBE format.
  49043. * Example of such files can be found on HDRLib: http://hdrlib.com/
  49044. */
  49045. export class HDRCubeTexture extends BaseTexture {
  49046. private static _facesMapping;
  49047. private _generateHarmonics;
  49048. private _noMipmap;
  49049. private _textureMatrix;
  49050. private _size;
  49051. private _onLoad;
  49052. private _onError;
  49053. /**
  49054. * The texture URL.
  49055. */
  49056. url: string;
  49057. /**
  49058. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  49059. */
  49060. coordinatesMode: number;
  49061. protected _isBlocking: boolean;
  49062. /**
  49063. * Sets wether or not the texture is blocking during loading.
  49064. */
  49065. /**
  49066. * Gets wether or not the texture is blocking during loading.
  49067. */
  49068. isBlocking: boolean;
  49069. protected _rotationY: number;
  49070. /**
  49071. * Sets texture matrix rotation angle around Y axis in radians.
  49072. */
  49073. /**
  49074. * Gets texture matrix rotation angle around Y axis radians.
  49075. */
  49076. rotationY: number;
  49077. /**
  49078. * Gets or sets the center of the bounding box associated with the cube texture
  49079. * It must define where the camera used to render the texture was set
  49080. */
  49081. boundingBoxPosition: Vector3;
  49082. private _boundingBoxSize;
  49083. /**
  49084. * Gets or sets the size of the bounding box associated with the cube texture
  49085. * When defined, the cubemap will switch to local mode
  49086. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  49087. * @example https://www.babylonjs-playground.com/#RNASML
  49088. */
  49089. boundingBoxSize: Vector3;
  49090. /**
  49091. * Instantiates an HDRTexture from the following parameters.
  49092. *
  49093. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  49094. * @param scene The scene the texture will be used in
  49095. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49096. * @param noMipmap Forces to not generate the mipmap if true
  49097. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  49098. * @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)
  49099. * @param reserved Reserved flag for internal use.
  49100. */
  49101. 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>);
  49102. /**
  49103. * Get the current class name of the texture useful for serialization or dynamic coding.
  49104. * @returns "HDRCubeTexture"
  49105. */
  49106. getClassName(): string;
  49107. /**
  49108. * Occurs when the file is raw .hdr file.
  49109. */
  49110. private loadTexture;
  49111. clone(): HDRCubeTexture;
  49112. delayLoad(): void;
  49113. /**
  49114. * Get the texture reflection matrix used to rotate/transform the reflection.
  49115. * @returns the reflection matrix
  49116. */
  49117. getReflectionTextureMatrix(): Matrix;
  49118. /**
  49119. * Set the texture reflection matrix used to rotate/transform the reflection.
  49120. * @param value Define the reflection matrix to set
  49121. */
  49122. setReflectionTextureMatrix(value: Matrix): void;
  49123. /**
  49124. * Parses a JSON representation of an HDR Texture in order to create the texture
  49125. * @param parsedTexture Define the JSON representation
  49126. * @param scene Define the scene the texture should be created in
  49127. * @param rootUrl Define the root url in case we need to load relative dependencies
  49128. * @returns the newly created texture after parsing
  49129. */
  49130. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  49131. serialize(): any;
  49132. }
  49133. }
  49134. declare module BABYLON {
  49135. /**
  49136. * Class used to control physics engine
  49137. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49138. */
  49139. export class PhysicsEngine implements IPhysicsEngine {
  49140. private _physicsPlugin;
  49141. /**
  49142. * Global value used to control the smallest number supported by the simulation
  49143. */
  49144. static Epsilon: number;
  49145. private _impostors;
  49146. private _joints;
  49147. /**
  49148. * Gets the gravity vector used by the simulation
  49149. */
  49150. gravity: Vector3;
  49151. /**
  49152. * Factory used to create the default physics plugin.
  49153. * @returns The default physics plugin
  49154. */
  49155. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49156. /**
  49157. * Creates a new Physics Engine
  49158. * @param gravity defines the gravity vector used by the simulation
  49159. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49160. */
  49161. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49162. /**
  49163. * Sets the gravity vector used by the simulation
  49164. * @param gravity defines the gravity vector to use
  49165. */
  49166. setGravity(gravity: Vector3): void;
  49167. /**
  49168. * Set the time step of the physics engine.
  49169. * Default is 1/60.
  49170. * To slow it down, enter 1/600 for example.
  49171. * To speed it up, 1/30
  49172. * @param newTimeStep defines the new timestep to apply to this world.
  49173. */
  49174. setTimeStep(newTimeStep?: number): void;
  49175. /**
  49176. * Get the time step of the physics engine.
  49177. * @returns the current time step
  49178. */
  49179. getTimeStep(): number;
  49180. /**
  49181. * Release all resources
  49182. */
  49183. dispose(): void;
  49184. /**
  49185. * Gets the name of the current physics plugin
  49186. * @returns the name of the plugin
  49187. */
  49188. getPhysicsPluginName(): string;
  49189. /**
  49190. * Adding a new impostor for the impostor tracking.
  49191. * This will be done by the impostor itself.
  49192. * @param impostor the impostor to add
  49193. */
  49194. addImpostor(impostor: PhysicsImpostor): void;
  49195. /**
  49196. * Remove an impostor from the engine.
  49197. * This impostor and its mesh will not longer be updated by the physics engine.
  49198. * @param impostor the impostor to remove
  49199. */
  49200. removeImpostor(impostor: PhysicsImpostor): void;
  49201. /**
  49202. * Add a joint to the physics engine
  49203. * @param mainImpostor defines the main impostor to which the joint is added.
  49204. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49205. * @param joint defines the joint that will connect both impostors.
  49206. */
  49207. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49208. /**
  49209. * Removes a joint from the simulation
  49210. * @param mainImpostor defines the impostor used with the joint
  49211. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49212. * @param joint defines the joint to remove
  49213. */
  49214. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49215. /**
  49216. * Called by the scene. No need to call it.
  49217. * @param delta defines the timespam between frames
  49218. */ private _step(delta: number): void;
  49219. /**
  49220. * Gets the current plugin used to run the simulation
  49221. * @returns current plugin
  49222. */
  49223. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49224. /**
  49225. * Gets the list of physic impostors
  49226. * @returns an array of PhysicsImpostor
  49227. */
  49228. getImpostors(): Array<PhysicsImpostor>;
  49229. /**
  49230. * Gets the impostor for a physics enabled object
  49231. * @param object defines the object impersonated by the impostor
  49232. * @returns the PhysicsImpostor or null if not found
  49233. */
  49234. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49235. /**
  49236. * Gets the impostor for a physics body object
  49237. * @param body defines physics body used by the impostor
  49238. * @returns the PhysicsImpostor or null if not found
  49239. */
  49240. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49241. /**
  49242. * Does a raycast in the physics world
  49243. * @param from when should the ray start?
  49244. * @param to when should the ray end?
  49245. * @returns PhysicsRaycastResult
  49246. */
  49247. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49248. }
  49249. }
  49250. declare module BABYLON {
  49251. /** @hidden */
  49252. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49253. private _useDeltaForWorldStep;
  49254. world: any;
  49255. name: string;
  49256. private _physicsMaterials;
  49257. private _fixedTimeStep;
  49258. private _cannonRaycastResult;
  49259. private _raycastResult;
  49260. private _physicsBodysToRemoveAfterStep;
  49261. BJSCANNON: any;
  49262. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  49263. setGravity(gravity: Vector3): void;
  49264. setTimeStep(timeStep: number): void;
  49265. getTimeStep(): number;
  49266. executeStep(delta: number): void;
  49267. private _removeMarkedPhysicsBodiesFromWorld;
  49268. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49269. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49270. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49271. private _processChildMeshes;
  49272. removePhysicsBody(impostor: PhysicsImpostor): void;
  49273. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49274. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49275. private _addMaterial;
  49276. private _checkWithEpsilon;
  49277. private _createShape;
  49278. private _createHeightmap;
  49279. private _minus90X;
  49280. private _plus90X;
  49281. private _tmpPosition;
  49282. private _tmpDeltaPosition;
  49283. private _tmpUnityRotation;
  49284. private _updatePhysicsBodyTransformation;
  49285. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49286. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49287. isSupported(): boolean;
  49288. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49289. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49290. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49291. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49292. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49293. getBodyMass(impostor: PhysicsImpostor): number;
  49294. getBodyFriction(impostor: PhysicsImpostor): number;
  49295. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49296. getBodyRestitution(impostor: PhysicsImpostor): number;
  49297. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49298. sleepBody(impostor: PhysicsImpostor): void;
  49299. wakeUpBody(impostor: PhysicsImpostor): void;
  49300. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  49301. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49302. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49303. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49304. getRadius(impostor: PhysicsImpostor): number;
  49305. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49306. dispose(): void;
  49307. private _extendNamespace;
  49308. /**
  49309. * Does a raycast in the physics world
  49310. * @param from when should the ray start?
  49311. * @param to when should the ray end?
  49312. * @returns PhysicsRaycastResult
  49313. */
  49314. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49315. }
  49316. }
  49317. declare module BABYLON {
  49318. /** @hidden */
  49319. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  49320. world: any;
  49321. name: string;
  49322. BJSOIMO: any;
  49323. private _raycastResult;
  49324. constructor(iterations?: number, oimoInjection?: any);
  49325. setGravity(gravity: Vector3): void;
  49326. setTimeStep(timeStep: number): void;
  49327. getTimeStep(): number;
  49328. private _tmpImpostorsArray;
  49329. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49330. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49331. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49332. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49333. private _tmpPositionVector;
  49334. removePhysicsBody(impostor: PhysicsImpostor): void;
  49335. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49336. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49337. isSupported(): boolean;
  49338. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49339. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49340. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49341. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49342. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49343. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49344. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49345. getBodyMass(impostor: PhysicsImpostor): number;
  49346. getBodyFriction(impostor: PhysicsImpostor): number;
  49347. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49348. getBodyRestitution(impostor: PhysicsImpostor): number;
  49349. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49350. sleepBody(impostor: PhysicsImpostor): void;
  49351. wakeUpBody(impostor: PhysicsImpostor): void;
  49352. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49353. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  49354. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49355. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49356. getRadius(impostor: PhysicsImpostor): number;
  49357. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49358. dispose(): void;
  49359. /**
  49360. * Does a raycast in the physics world
  49361. * @param from when should the ray start?
  49362. * @param to when should the ray end?
  49363. * @returns PhysicsRaycastResult
  49364. */
  49365. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49366. }
  49367. }
  49368. declare module BABYLON {
  49369. /**
  49370. * Class containing static functions to help procedurally build meshes
  49371. */
  49372. export class RibbonBuilder {
  49373. /**
  49374. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49375. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49376. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49377. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49378. * * 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
  49379. * * 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
  49380. * * 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
  49381. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49382. * * 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
  49383. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49384. * * 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
  49385. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49386. * * 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
  49387. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49388. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49389. * @param name defines the name of the mesh
  49390. * @param options defines the options used to create the mesh
  49391. * @param scene defines the hosting scene
  49392. * @returns the ribbon mesh
  49393. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49394. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49395. */
  49396. static CreateRibbon(name: string, options: {
  49397. pathArray: Vector3[][];
  49398. closeArray?: boolean;
  49399. closePath?: boolean;
  49400. offset?: number;
  49401. updatable?: boolean;
  49402. sideOrientation?: number;
  49403. frontUVs?: Vector4;
  49404. backUVs?: Vector4;
  49405. instance?: Mesh;
  49406. invertUV?: boolean;
  49407. uvs?: Vector2[];
  49408. colors?: Color4[];
  49409. }, scene?: Nullable<Scene>): Mesh;
  49410. }
  49411. }
  49412. declare module BABYLON {
  49413. /**
  49414. * Class containing static functions to help procedurally build meshes
  49415. */
  49416. export class ShapeBuilder {
  49417. /**
  49418. * 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.
  49419. * * 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.
  49420. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49421. * * 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.
  49422. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49423. * * 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
  49424. * * 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
  49425. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49426. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49427. * * 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
  49428. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49430. * @param name defines the name of the mesh
  49431. * @param options defines the options used to create the mesh
  49432. * @param scene defines the hosting scene
  49433. * @returns the extruded shape mesh
  49434. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49435. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49436. */
  49437. static ExtrudeShape(name: string, options: {
  49438. shape: Vector3[];
  49439. path: Vector3[];
  49440. scale?: number;
  49441. rotation?: number;
  49442. cap?: number;
  49443. updatable?: boolean;
  49444. sideOrientation?: number;
  49445. frontUVs?: Vector4;
  49446. backUVs?: Vector4;
  49447. instance?: Mesh;
  49448. invertUV?: boolean;
  49449. }, scene?: Nullable<Scene>): Mesh;
  49450. /**
  49451. * Creates an custom extruded shape mesh.
  49452. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49453. * * 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.
  49454. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49455. * * 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
  49456. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49457. * * 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
  49458. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49459. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49460. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49461. * * 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
  49462. * * 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
  49463. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49464. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49465. * * 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
  49466. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49468. * @param name defines the name of the mesh
  49469. * @param options defines the options used to create the mesh
  49470. * @param scene defines the hosting scene
  49471. * @returns the custom extruded shape mesh
  49472. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49473. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49474. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49475. */
  49476. static ExtrudeShapeCustom(name: string, options: {
  49477. shape: Vector3[];
  49478. path: Vector3[];
  49479. scaleFunction?: any;
  49480. rotationFunction?: any;
  49481. ribbonCloseArray?: boolean;
  49482. ribbonClosePath?: boolean;
  49483. cap?: number;
  49484. updatable?: boolean;
  49485. sideOrientation?: number;
  49486. frontUVs?: Vector4;
  49487. backUVs?: Vector4;
  49488. instance?: Mesh;
  49489. invertUV?: boolean;
  49490. }, scene?: Nullable<Scene>): Mesh;
  49491. private static _ExtrudeShapeGeneric;
  49492. }
  49493. }
  49494. declare module BABYLON {
  49495. /**
  49496. * AmmoJS Physics plugin
  49497. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49498. * @see https://github.com/kripken/ammo.js/
  49499. */
  49500. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  49501. private _useDeltaForWorldStep;
  49502. /**
  49503. * Reference to the Ammo library
  49504. */
  49505. bjsAMMO: any;
  49506. /**
  49507. * Created ammoJS world which physics bodies are added to
  49508. */
  49509. world: any;
  49510. /**
  49511. * Name of the plugin
  49512. */
  49513. name: string;
  49514. private _timeStep;
  49515. private _fixedTimeStep;
  49516. private _maxSteps;
  49517. private _tmpQuaternion;
  49518. private _tmpAmmoTransform;
  49519. private _tmpAmmoQuaternion;
  49520. private _tmpAmmoConcreteContactResultCallback;
  49521. private _collisionConfiguration;
  49522. private _dispatcher;
  49523. private _overlappingPairCache;
  49524. private _solver;
  49525. private _softBodySolver;
  49526. private _tmpAmmoVectorA;
  49527. private _tmpAmmoVectorB;
  49528. private _tmpAmmoVectorC;
  49529. private _tmpAmmoVectorD;
  49530. private _tmpContactCallbackResult;
  49531. private _tmpAmmoVectorRCA;
  49532. private _tmpAmmoVectorRCB;
  49533. private _raycastResult;
  49534. private static readonly DISABLE_COLLISION_FLAG;
  49535. private static readonly KINEMATIC_FLAG;
  49536. private static readonly DISABLE_DEACTIVATION_FLAG;
  49537. /**
  49538. * Initializes the ammoJS plugin
  49539. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  49540. * @param ammoInjection can be used to inject your own ammo reference
  49541. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  49542. */
  49543. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  49544. /**
  49545. * Sets the gravity of the physics world (m/(s^2))
  49546. * @param gravity Gravity to set
  49547. */
  49548. setGravity(gravity: Vector3): void;
  49549. /**
  49550. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  49551. * @param timeStep timestep to use in seconds
  49552. */
  49553. setTimeStep(timeStep: number): void;
  49554. /**
  49555. * 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)
  49556. * @param fixedTimeStep fixedTimeStep to use in seconds
  49557. */
  49558. setFixedTimeStep(fixedTimeStep: number): void;
  49559. /**
  49560. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  49561. * @param maxSteps the maximum number of steps by the physics engine per frame
  49562. */
  49563. setMaxSteps(maxSteps: number): void;
  49564. /**
  49565. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  49566. * @returns the current timestep in seconds
  49567. */
  49568. getTimeStep(): number;
  49569. private _isImpostorInContact;
  49570. private _isImpostorPairInContact;
  49571. private _stepSimulation;
  49572. /**
  49573. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  49574. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  49575. * After the step the babylon meshes are set to the position of the physics imposters
  49576. * @param delta amount of time to step forward
  49577. * @param impostors array of imposters to update before/after the step
  49578. */
  49579. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49580. /**
  49581. * Update babylon mesh to match physics world object
  49582. * @param impostor imposter to match
  49583. */
  49584. private _afterSoftStep;
  49585. /**
  49586. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49587. * @param impostor imposter to match
  49588. */
  49589. private _ropeStep;
  49590. /**
  49591. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49592. * @param impostor imposter to match
  49593. */
  49594. private _softbodyOrClothStep;
  49595. private _tmpVector;
  49596. private _tmpMatrix;
  49597. /**
  49598. * Applies an impulse on the imposter
  49599. * @param impostor imposter to apply impulse to
  49600. * @param force amount of force to be applied to the imposter
  49601. * @param contactPoint the location to apply the impulse on the imposter
  49602. */
  49603. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49604. /**
  49605. * Applies a force on the imposter
  49606. * @param impostor imposter to apply force
  49607. * @param force amount of force to be applied to the imposter
  49608. * @param contactPoint the location to apply the force on the imposter
  49609. */
  49610. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49611. /**
  49612. * Creates a physics body using the plugin
  49613. * @param impostor the imposter to create the physics body on
  49614. */
  49615. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49616. /**
  49617. * Removes the physics body from the imposter and disposes of the body's memory
  49618. * @param impostor imposter to remove the physics body from
  49619. */
  49620. removePhysicsBody(impostor: PhysicsImpostor): void;
  49621. /**
  49622. * Generates a joint
  49623. * @param impostorJoint the imposter joint to create the joint with
  49624. */
  49625. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49626. /**
  49627. * Removes a joint
  49628. * @param impostorJoint the imposter joint to remove the joint from
  49629. */
  49630. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49631. private _addMeshVerts;
  49632. /**
  49633. * Initialise the soft body vertices to match its object's (mesh) vertices
  49634. * Softbody vertices (nodes) are in world space and to match this
  49635. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  49636. * @param impostor to create the softbody for
  49637. */
  49638. private _softVertexData;
  49639. /**
  49640. * Create an impostor's soft body
  49641. * @param impostor to create the softbody for
  49642. */
  49643. private _createSoftbody;
  49644. /**
  49645. * Create cloth for an impostor
  49646. * @param impostor to create the softbody for
  49647. */
  49648. private _createCloth;
  49649. /**
  49650. * Create rope for an impostor
  49651. * @param impostor to create the softbody for
  49652. */
  49653. private _createRope;
  49654. private _addHullVerts;
  49655. private _createShape;
  49656. /**
  49657. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  49658. * @param impostor imposter containing the physics body and babylon object
  49659. */
  49660. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49661. /**
  49662. * Sets the babylon object's position/rotation from the physics body's position/rotation
  49663. * @param impostor imposter containing the physics body and babylon object
  49664. * @param newPosition new position
  49665. * @param newRotation new rotation
  49666. */
  49667. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49668. /**
  49669. * If this plugin is supported
  49670. * @returns true if its supported
  49671. */
  49672. isSupported(): boolean;
  49673. /**
  49674. * Sets the linear velocity of the physics body
  49675. * @param impostor imposter to set the velocity on
  49676. * @param velocity velocity to set
  49677. */
  49678. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49679. /**
  49680. * Sets the angular velocity of the physics body
  49681. * @param impostor imposter to set the velocity on
  49682. * @param velocity velocity to set
  49683. */
  49684. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49685. /**
  49686. * gets the linear velocity
  49687. * @param impostor imposter to get linear velocity from
  49688. * @returns linear velocity
  49689. */
  49690. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49691. /**
  49692. * gets the angular velocity
  49693. * @param impostor imposter to get angular velocity from
  49694. * @returns angular velocity
  49695. */
  49696. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49697. /**
  49698. * Sets the mass of physics body
  49699. * @param impostor imposter to set the mass on
  49700. * @param mass mass to set
  49701. */
  49702. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49703. /**
  49704. * Gets the mass of the physics body
  49705. * @param impostor imposter to get the mass from
  49706. * @returns mass
  49707. */
  49708. getBodyMass(impostor: PhysicsImpostor): number;
  49709. /**
  49710. * Gets friction of the impostor
  49711. * @param impostor impostor to get friction from
  49712. * @returns friction value
  49713. */
  49714. getBodyFriction(impostor: PhysicsImpostor): number;
  49715. /**
  49716. * Sets friction of the impostor
  49717. * @param impostor impostor to set friction on
  49718. * @param friction friction value
  49719. */
  49720. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49721. /**
  49722. * Gets restitution of the impostor
  49723. * @param impostor impostor to get restitution from
  49724. * @returns restitution value
  49725. */
  49726. getBodyRestitution(impostor: PhysicsImpostor): number;
  49727. /**
  49728. * Sets resitution of the impostor
  49729. * @param impostor impostor to set resitution on
  49730. * @param restitution resitution value
  49731. */
  49732. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49733. /**
  49734. * Gets pressure inside the impostor
  49735. * @param impostor impostor to get pressure from
  49736. * @returns pressure value
  49737. */
  49738. getBodyPressure(impostor: PhysicsImpostor): number;
  49739. /**
  49740. * Sets pressure inside a soft body impostor
  49741. * Cloth and rope must remain 0 pressure
  49742. * @param impostor impostor to set pressure on
  49743. * @param pressure pressure value
  49744. */
  49745. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  49746. /**
  49747. * Gets stiffness of the impostor
  49748. * @param impostor impostor to get stiffness from
  49749. * @returns pressure value
  49750. */
  49751. getBodyStiffness(impostor: PhysicsImpostor): number;
  49752. /**
  49753. * Sets stiffness of the impostor
  49754. * @param impostor impostor to set stiffness on
  49755. * @param stiffness stiffness value from 0 to 1
  49756. */
  49757. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  49758. /**
  49759. * Gets velocityIterations of the impostor
  49760. * @param impostor impostor to get velocity iterations from
  49761. * @returns velocityIterations value
  49762. */
  49763. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  49764. /**
  49765. * Sets velocityIterations of the impostor
  49766. * @param impostor impostor to set velocity iterations on
  49767. * @param velocityIterations velocityIterations value
  49768. */
  49769. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  49770. /**
  49771. * Gets positionIterations of the impostor
  49772. * @param impostor impostor to get position iterations from
  49773. * @returns positionIterations value
  49774. */
  49775. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  49776. /**
  49777. * Sets positionIterations of the impostor
  49778. * @param impostor impostor to set position on
  49779. * @param positionIterations positionIterations value
  49780. */
  49781. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  49782. /**
  49783. * Append an anchor to a cloth object
  49784. * @param impostor is the cloth impostor to add anchor to
  49785. * @param otherImpostor is the rigid impostor to anchor to
  49786. * @param width ratio across width from 0 to 1
  49787. * @param height ratio up height from 0 to 1
  49788. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  49789. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  49790. */
  49791. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  49792. /**
  49793. * Append an hook to a rope object
  49794. * @param impostor is the rope impostor to add hook to
  49795. * @param otherImpostor is the rigid impostor to hook to
  49796. * @param length ratio along the rope from 0 to 1
  49797. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  49798. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  49799. */
  49800. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  49801. /**
  49802. * Sleeps the physics body and stops it from being active
  49803. * @param impostor impostor to sleep
  49804. */
  49805. sleepBody(impostor: PhysicsImpostor): void;
  49806. /**
  49807. * Activates the physics body
  49808. * @param impostor impostor to activate
  49809. */
  49810. wakeUpBody(impostor: PhysicsImpostor): void;
  49811. /**
  49812. * Updates the distance parameters of the joint
  49813. * @param joint joint to update
  49814. * @param maxDistance maximum distance of the joint
  49815. * @param minDistance minimum distance of the joint
  49816. */
  49817. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49818. /**
  49819. * Sets a motor on the joint
  49820. * @param joint joint to set motor on
  49821. * @param speed speed of the motor
  49822. * @param maxForce maximum force of the motor
  49823. * @param motorIndex index of the motor
  49824. */
  49825. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49826. /**
  49827. * Sets the motors limit
  49828. * @param joint joint to set limit on
  49829. * @param upperLimit upper limit
  49830. * @param lowerLimit lower limit
  49831. */
  49832. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49833. /**
  49834. * Syncs the position and rotation of a mesh with the impostor
  49835. * @param mesh mesh to sync
  49836. * @param impostor impostor to update the mesh with
  49837. */
  49838. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49839. /**
  49840. * Gets the radius of the impostor
  49841. * @param impostor impostor to get radius from
  49842. * @returns the radius
  49843. */
  49844. getRadius(impostor: PhysicsImpostor): number;
  49845. /**
  49846. * Gets the box size of the impostor
  49847. * @param impostor impostor to get box size from
  49848. * @param result the resulting box size
  49849. */
  49850. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49851. /**
  49852. * Disposes of the impostor
  49853. */
  49854. dispose(): void;
  49855. /**
  49856. * Does a raycast in the physics world
  49857. * @param from when should the ray start?
  49858. * @param to when should the ray end?
  49859. * @returns PhysicsRaycastResult
  49860. */
  49861. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49862. }
  49863. }
  49864. declare module BABYLON {
  49865. interface AbstractScene {
  49866. /**
  49867. * The list of reflection probes added to the scene
  49868. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49869. */
  49870. reflectionProbes: Array<ReflectionProbe>;
  49871. /**
  49872. * Removes the given reflection probe from this scene.
  49873. * @param toRemove The reflection probe to remove
  49874. * @returns The index of the removed reflection probe
  49875. */
  49876. removeReflectionProbe(toRemove: ReflectionProbe): number;
  49877. /**
  49878. * Adds the given reflection probe to this scene.
  49879. * @param newReflectionProbe The reflection probe to add
  49880. */
  49881. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  49882. }
  49883. /**
  49884. * Class used to generate realtime reflection / refraction cube textures
  49885. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49886. */
  49887. export class ReflectionProbe {
  49888. /** defines the name of the probe */
  49889. name: string;
  49890. private _scene;
  49891. private _renderTargetTexture;
  49892. private _projectionMatrix;
  49893. private _viewMatrix;
  49894. private _target;
  49895. private _add;
  49896. private _attachedMesh;
  49897. private _invertYAxis;
  49898. /** Gets or sets probe position (center of the cube map) */
  49899. position: Vector3;
  49900. /**
  49901. * Creates a new reflection probe
  49902. * @param name defines the name of the probe
  49903. * @param size defines the texture resolution (for each face)
  49904. * @param scene defines the hosting scene
  49905. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  49906. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  49907. */
  49908. constructor(
  49909. /** defines the name of the probe */
  49910. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  49911. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  49912. samples: number;
  49913. /** Gets or sets the refresh rate to use (on every frame by default) */
  49914. refreshRate: number;
  49915. /**
  49916. * Gets the hosting scene
  49917. * @returns a Scene
  49918. */
  49919. getScene(): Scene;
  49920. /** Gets the internal CubeTexture used to render to */
  49921. readonly cubeTexture: RenderTargetTexture;
  49922. /** Gets the list of meshes to render */
  49923. readonly renderList: Nullable<AbstractMesh[]>;
  49924. /**
  49925. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  49926. * @param mesh defines the mesh to attach to
  49927. */
  49928. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49929. /**
  49930. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  49931. * @param renderingGroupId The rendering group id corresponding to its index
  49932. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  49933. */
  49934. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  49935. /**
  49936. * Clean all associated resources
  49937. */
  49938. dispose(): void;
  49939. /**
  49940. * Converts the reflection probe information to a readable string for debug purpose.
  49941. * @param fullDetails Supports for multiple levels of logging within scene loading
  49942. * @returns the human readable reflection probe info
  49943. */
  49944. toString(fullDetails?: boolean): string;
  49945. /**
  49946. * Get the class name of the relfection probe.
  49947. * @returns "ReflectionProbe"
  49948. */
  49949. getClassName(): string;
  49950. /**
  49951. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  49952. * @returns The JSON representation of the texture
  49953. */
  49954. serialize(): any;
  49955. /**
  49956. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  49957. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  49958. * @param scene Define the scene the parsed reflection probe should be instantiated in
  49959. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  49960. * @returns The parsed reflection probe if successful
  49961. */
  49962. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  49963. }
  49964. }
  49965. declare module BABYLON {
  49966. /** @hidden */
  49967. export var _BabylonLoaderRegistered: boolean;
  49968. }
  49969. declare module BABYLON {
  49970. /**
  49971. * The Physically based simple base material of BJS.
  49972. *
  49973. * This enables better naming and convention enforcements on top of the pbrMaterial.
  49974. * It is used as the base class for both the specGloss and metalRough conventions.
  49975. */
  49976. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  49977. /**
  49978. * Number of Simultaneous lights allowed on the material.
  49979. */
  49980. maxSimultaneousLights: number;
  49981. /**
  49982. * If sets to true, disables all the lights affecting the material.
  49983. */
  49984. disableLighting: boolean;
  49985. /**
  49986. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  49987. */
  49988. environmentTexture: BaseTexture;
  49989. /**
  49990. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49991. */
  49992. invertNormalMapX: boolean;
  49993. /**
  49994. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49995. */
  49996. invertNormalMapY: boolean;
  49997. /**
  49998. * Normal map used in the model.
  49999. */
  50000. normalTexture: BaseTexture;
  50001. /**
  50002. * Emissivie color used to self-illuminate the model.
  50003. */
  50004. emissiveColor: Color3;
  50005. /**
  50006. * Emissivie texture used to self-illuminate the model.
  50007. */
  50008. emissiveTexture: BaseTexture;
  50009. /**
  50010. * Occlusion Channel Strenght.
  50011. */
  50012. occlusionStrength: number;
  50013. /**
  50014. * Occlusion Texture of the material (adding extra occlusion effects).
  50015. */
  50016. occlusionTexture: BaseTexture;
  50017. /**
  50018. * Defines the alpha limits in alpha test mode.
  50019. */
  50020. alphaCutOff: number;
  50021. /**
  50022. * Gets the current double sided mode.
  50023. */
  50024. /**
  50025. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50026. */
  50027. doubleSided: boolean;
  50028. /**
  50029. * Stores the pre-calculated light information of a mesh in a texture.
  50030. */
  50031. lightmapTexture: BaseTexture;
  50032. /**
  50033. * If true, the light map contains occlusion information instead of lighting info.
  50034. */
  50035. useLightmapAsShadowmap: boolean;
  50036. /**
  50037. * Instantiates a new PBRMaterial instance.
  50038. *
  50039. * @param name The material name
  50040. * @param scene The scene the material will be use in.
  50041. */
  50042. constructor(name: string, scene: Scene);
  50043. getClassName(): string;
  50044. }
  50045. }
  50046. declare module BABYLON {
  50047. /**
  50048. * The PBR material of BJS following the metal roughness convention.
  50049. *
  50050. * This fits to the PBR convention in the GLTF definition:
  50051. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  50052. */
  50053. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  50054. /**
  50055. * The base color has two different interpretations depending on the value of metalness.
  50056. * When the material is a metal, the base color is the specific measured reflectance value
  50057. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  50058. * of the material.
  50059. */
  50060. baseColor: Color3;
  50061. /**
  50062. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  50063. * well as opacity information in the alpha channel.
  50064. */
  50065. baseTexture: BaseTexture;
  50066. /**
  50067. * Specifies the metallic scalar value of the material.
  50068. * Can also be used to scale the metalness values of the metallic texture.
  50069. */
  50070. metallic: number;
  50071. /**
  50072. * Specifies the roughness scalar value of the material.
  50073. * Can also be used to scale the roughness values of the metallic texture.
  50074. */
  50075. roughness: number;
  50076. /**
  50077. * Texture containing both the metallic value in the B channel and the
  50078. * roughness value in the G channel to keep better precision.
  50079. */
  50080. metallicRoughnessTexture: BaseTexture;
  50081. /**
  50082. * Instantiates a new PBRMetalRoughnessMaterial instance.
  50083. *
  50084. * @param name The material name
  50085. * @param scene The scene the material will be use in.
  50086. */
  50087. constructor(name: string, scene: Scene);
  50088. /**
  50089. * Return the currrent class name of the material.
  50090. */
  50091. getClassName(): string;
  50092. /**
  50093. * Makes a duplicate of the current material.
  50094. * @param name - name to use for the new material.
  50095. */
  50096. clone(name: string): PBRMetallicRoughnessMaterial;
  50097. /**
  50098. * Serialize the material to a parsable JSON object.
  50099. */
  50100. serialize(): any;
  50101. /**
  50102. * Parses a JSON object correponding to the serialize function.
  50103. */
  50104. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  50105. }
  50106. }
  50107. declare module BABYLON {
  50108. /**
  50109. * The PBR material of BJS following the specular glossiness convention.
  50110. *
  50111. * This fits to the PBR convention in the GLTF definition:
  50112. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  50113. */
  50114. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  50115. /**
  50116. * Specifies the diffuse color of the material.
  50117. */
  50118. diffuseColor: Color3;
  50119. /**
  50120. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  50121. * channel.
  50122. */
  50123. diffuseTexture: BaseTexture;
  50124. /**
  50125. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  50126. */
  50127. specularColor: Color3;
  50128. /**
  50129. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  50130. */
  50131. glossiness: number;
  50132. /**
  50133. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  50134. */
  50135. specularGlossinessTexture: BaseTexture;
  50136. /**
  50137. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  50138. *
  50139. * @param name The material name
  50140. * @param scene The scene the material will be use in.
  50141. */
  50142. constructor(name: string, scene: Scene);
  50143. /**
  50144. * Return the currrent class name of the material.
  50145. */
  50146. getClassName(): string;
  50147. /**
  50148. * Makes a duplicate of the current material.
  50149. * @param name - name to use for the new material.
  50150. */
  50151. clone(name: string): PBRSpecularGlossinessMaterial;
  50152. /**
  50153. * Serialize the material to a parsable JSON object.
  50154. */
  50155. serialize(): any;
  50156. /**
  50157. * Parses a JSON object correponding to the serialize function.
  50158. */
  50159. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  50160. }
  50161. }
  50162. declare module BABYLON {
  50163. /**
  50164. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  50165. * It can help converting any input color in a desired output one. This can then be used to create effects
  50166. * from sepia, black and white to sixties or futuristic rendering...
  50167. *
  50168. * The only supported format is currently 3dl.
  50169. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  50170. */
  50171. export class ColorGradingTexture extends BaseTexture {
  50172. /**
  50173. * The current texture matrix. (will always be identity in color grading texture)
  50174. */
  50175. private _textureMatrix;
  50176. /**
  50177. * The texture URL.
  50178. */
  50179. url: string;
  50180. /**
  50181. * Empty line regex stored for GC.
  50182. */
  50183. private static _noneEmptyLineRegex;
  50184. private _engine;
  50185. /**
  50186. * Instantiates a ColorGradingTexture from the following parameters.
  50187. *
  50188. * @param url The location of the color gradind data (currently only supporting 3dl)
  50189. * @param scene The scene the texture will be used in
  50190. */
  50191. constructor(url: string, scene: Scene);
  50192. /**
  50193. * Returns the texture matrix used in most of the material.
  50194. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  50195. */
  50196. getTextureMatrix(): Matrix;
  50197. /**
  50198. * Occurs when the file being loaded is a .3dl LUT file.
  50199. */
  50200. private load3dlTexture;
  50201. /**
  50202. * Starts the loading process of the texture.
  50203. */
  50204. private loadTexture;
  50205. /**
  50206. * Clones the color gradind texture.
  50207. */
  50208. clone(): ColorGradingTexture;
  50209. /**
  50210. * Called during delayed load for textures.
  50211. */
  50212. delayLoad(): void;
  50213. /**
  50214. * Parses a color grading texture serialized by Babylon.
  50215. * @param parsedTexture The texture information being parsedTexture
  50216. * @param scene The scene to load the texture in
  50217. * @param rootUrl The root url of the data assets to load
  50218. * @return A color gradind texture
  50219. */
  50220. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  50221. /**
  50222. * Serializes the LUT texture to json format.
  50223. */
  50224. serialize(): any;
  50225. }
  50226. }
  50227. declare module BABYLON {
  50228. /**
  50229. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  50230. */
  50231. export class EquiRectangularCubeTexture extends BaseTexture {
  50232. /** The six faces of the cube. */
  50233. private static _FacesMapping;
  50234. private _noMipmap;
  50235. private _onLoad;
  50236. private _onError;
  50237. /** The size of the cubemap. */
  50238. private _size;
  50239. /** The buffer of the image. */
  50240. private _buffer;
  50241. /** The width of the input image. */
  50242. private _width;
  50243. /** The height of the input image. */
  50244. private _height;
  50245. /** The URL to the image. */
  50246. url: string;
  50247. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  50248. coordinatesMode: number;
  50249. /**
  50250. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  50251. * @param url The location of the image
  50252. * @param scene The scene the texture will be used in
  50253. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50254. * @param noMipmap Forces to not generate the mipmap if true
  50255. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  50256. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  50257. * @param onLoad — defines a callback called when texture is loaded
  50258. * @param onError — defines a callback called if there is an error
  50259. */
  50260. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  50261. /**
  50262. * Load the image data, by putting the image on a canvas and extracting its buffer.
  50263. */
  50264. private loadImage;
  50265. /**
  50266. * Convert the image buffer into a cubemap and create a CubeTexture.
  50267. */
  50268. private loadTexture;
  50269. /**
  50270. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  50271. * @param buffer The ArrayBuffer that should be converted.
  50272. * @returns The buffer as Float32Array.
  50273. */
  50274. private getFloat32ArrayFromArrayBuffer;
  50275. /**
  50276. * Get the current class name of the texture useful for serialization or dynamic coding.
  50277. * @returns "EquiRectangularCubeTexture"
  50278. */
  50279. getClassName(): string;
  50280. /**
  50281. * Create a clone of the current EquiRectangularCubeTexture and return it.
  50282. * @returns A clone of the current EquiRectangularCubeTexture.
  50283. */
  50284. clone(): EquiRectangularCubeTexture;
  50285. }
  50286. }
  50287. declare module BABYLON {
  50288. /**
  50289. * Based on jsTGALoader - Javascript loader for TGA file
  50290. * By Vincent Thibault
  50291. * @see http://blog.robrowser.com/javascript-tga-loader.html
  50292. */
  50293. export class TGATools {
  50294. private static _TYPE_INDEXED;
  50295. private static _TYPE_RGB;
  50296. private static _TYPE_GREY;
  50297. private static _TYPE_RLE_INDEXED;
  50298. private static _TYPE_RLE_RGB;
  50299. private static _TYPE_RLE_GREY;
  50300. private static _ORIGIN_MASK;
  50301. private static _ORIGIN_SHIFT;
  50302. private static _ORIGIN_BL;
  50303. private static _ORIGIN_BR;
  50304. private static _ORIGIN_UL;
  50305. private static _ORIGIN_UR;
  50306. /**
  50307. * Gets the header of a TGA file
  50308. * @param data defines the TGA data
  50309. * @returns the header
  50310. */
  50311. static GetTGAHeader(data: Uint8Array): any;
  50312. /**
  50313. * Uploads TGA content to a Babylon Texture
  50314. * @hidden
  50315. */
  50316. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  50317. /** @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;
  50318. /** @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;
  50319. /** @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;
  50320. /** @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;
  50321. /** @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;
  50322. /** @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;
  50323. }
  50324. }
  50325. declare module BABYLON {
  50326. /**
  50327. * Implementation of the TGA Texture Loader.
  50328. * @hidden
  50329. */
  50330. export class _TGATextureLoader implements IInternalTextureLoader {
  50331. /**
  50332. * Defines wether the loader supports cascade loading the different faces.
  50333. */
  50334. readonly supportCascades: boolean;
  50335. /**
  50336. * This returns if the loader support the current file information.
  50337. * @param extension defines the file extension of the file being loaded
  50338. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50339. * @param fallback defines the fallback internal texture if any
  50340. * @param isBase64 defines whether the texture is encoded as a base64
  50341. * @param isBuffer defines whether the texture data are stored as a buffer
  50342. * @returns true if the loader can load the specified file
  50343. */
  50344. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50345. /**
  50346. * Transform the url before loading if required.
  50347. * @param rootUrl the url of the texture
  50348. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50349. * @returns the transformed texture
  50350. */
  50351. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50352. /**
  50353. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50354. * @param rootUrl the url of the texture
  50355. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50356. * @returns the fallback texture
  50357. */
  50358. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50359. /**
  50360. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50361. * @param data contains the texture data
  50362. * @param texture defines the BabylonJS internal texture
  50363. * @param createPolynomials will be true if polynomials have been requested
  50364. * @param onLoad defines the callback to trigger once the texture is ready
  50365. * @param onError defines the callback to trigger in case of error
  50366. */
  50367. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50368. /**
  50369. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50370. * @param data contains the texture data
  50371. * @param texture defines the BabylonJS internal texture
  50372. * @param callback defines the method to call once ready to upload
  50373. */
  50374. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50375. }
  50376. }
  50377. declare module BABYLON {
  50378. /**
  50379. * Info about the .basis files
  50380. */
  50381. class BasisFileInfo {
  50382. /**
  50383. * If the file has alpha
  50384. */
  50385. hasAlpha: boolean;
  50386. /**
  50387. * Info about each image of the basis file
  50388. */
  50389. images: Array<{
  50390. levels: Array<{
  50391. width: number;
  50392. height: number;
  50393. transcodedPixels: ArrayBufferView;
  50394. }>;
  50395. }>;
  50396. }
  50397. /**
  50398. * Result of transcoding a basis file
  50399. */
  50400. class TranscodeResult {
  50401. /**
  50402. * Info about the .basis file
  50403. */
  50404. fileInfo: BasisFileInfo;
  50405. /**
  50406. * Format to use when loading the file
  50407. */
  50408. format: number;
  50409. }
  50410. /**
  50411. * Configuration options for the Basis transcoder
  50412. */
  50413. export class BasisTranscodeConfiguration {
  50414. /**
  50415. * Supported compression formats used to determine the supported output format of the transcoder
  50416. */
  50417. supportedCompressionFormats?: {
  50418. /**
  50419. * etc1 compression format
  50420. */
  50421. etc1?: boolean;
  50422. /**
  50423. * s3tc compression format
  50424. */
  50425. s3tc?: boolean;
  50426. /**
  50427. * pvrtc compression format
  50428. */
  50429. pvrtc?: boolean;
  50430. /**
  50431. * etc2 compression format
  50432. */
  50433. etc2?: boolean;
  50434. };
  50435. /**
  50436. * If mipmap levels should be loaded for transcoded images (Default: true)
  50437. */
  50438. loadMipmapLevels?: boolean;
  50439. /**
  50440. * Index of a single image to load (Default: all images)
  50441. */
  50442. loadSingleImage?: number;
  50443. }
  50444. /**
  50445. * Used to load .Basis files
  50446. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  50447. */
  50448. export class BasisTools {
  50449. private static _IgnoreSupportedFormats;
  50450. /**
  50451. * URL to use when loading the basis transcoder
  50452. */
  50453. static JSModuleURL: string;
  50454. /**
  50455. * URL to use when loading the wasm module for the transcoder
  50456. */
  50457. static WasmModuleURL: string;
  50458. /**
  50459. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  50460. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  50461. * @returns internal format corresponding to the Basis format
  50462. */
  50463. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  50464. private static _WorkerPromise;
  50465. private static _Worker;
  50466. private static _actionId;
  50467. private static _CreateWorkerAsync;
  50468. /**
  50469. * Transcodes a loaded image file to compressed pixel data
  50470. * @param imageData image data to transcode
  50471. * @param config configuration options for the transcoding
  50472. * @returns a promise resulting in the transcoded image
  50473. */
  50474. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  50475. /**
  50476. * Loads a texture from the transcode result
  50477. * @param texture texture load to
  50478. * @param transcodeResult the result of transcoding the basis file to load from
  50479. */
  50480. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  50481. }
  50482. }
  50483. declare module BABYLON {
  50484. /**
  50485. * Loader for .basis file format
  50486. */
  50487. export class _BasisTextureLoader implements IInternalTextureLoader {
  50488. /**
  50489. * Defines whether the loader supports cascade loading the different faces.
  50490. */
  50491. readonly supportCascades: boolean;
  50492. /**
  50493. * This returns if the loader support the current file information.
  50494. * @param extension defines the file extension of the file being loaded
  50495. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50496. * @param fallback defines the fallback internal texture if any
  50497. * @param isBase64 defines whether the texture is encoded as a base64
  50498. * @param isBuffer defines whether the texture data are stored as a buffer
  50499. * @returns true if the loader can load the specified file
  50500. */
  50501. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50502. /**
  50503. * Transform the url before loading if required.
  50504. * @param rootUrl the url of the texture
  50505. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50506. * @returns the transformed texture
  50507. */
  50508. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50509. /**
  50510. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50511. * @param rootUrl the url of the texture
  50512. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50513. * @returns the fallback texture
  50514. */
  50515. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50516. /**
  50517. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  50518. * @param data contains the texture data
  50519. * @param texture defines the BabylonJS internal texture
  50520. * @param createPolynomials will be true if polynomials have been requested
  50521. * @param onLoad defines the callback to trigger once the texture is ready
  50522. * @param onError defines the callback to trigger in case of error
  50523. */
  50524. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50525. /**
  50526. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50527. * @param data contains the texture data
  50528. * @param texture defines the BabylonJS internal texture
  50529. * @param callback defines the method to call once ready to upload
  50530. */
  50531. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50532. }
  50533. }
  50534. declare module BABYLON {
  50535. /**
  50536. * 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.
  50537. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50538. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50539. */
  50540. export class CustomProceduralTexture extends ProceduralTexture {
  50541. private _animate;
  50542. private _time;
  50543. private _config;
  50544. private _texturePath;
  50545. /**
  50546. * Instantiates a new Custom Procedural Texture.
  50547. * 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.
  50548. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50549. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50550. * @param name Define the name of the texture
  50551. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  50552. * @param size Define the size of the texture to create
  50553. * @param scene Define the scene the texture belongs to
  50554. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50555. * @param generateMipMaps Define if the texture should creates mip maps or not
  50556. */
  50557. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50558. private _loadJson;
  50559. /**
  50560. * Is the texture ready to be used ? (rendered at least once)
  50561. * @returns true if ready, otherwise, false.
  50562. */
  50563. isReady(): boolean;
  50564. /**
  50565. * Render the texture to its associated render target.
  50566. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50567. */
  50568. render(useCameraPostProcess?: boolean): void;
  50569. /**
  50570. * Update the list of dependant textures samplers in the shader.
  50571. */
  50572. updateTextures(): void;
  50573. /**
  50574. * Update the uniform values of the procedural texture in the shader.
  50575. */
  50576. updateShaderUniforms(): void;
  50577. /**
  50578. * Define if the texture animates or not.
  50579. */
  50580. animate: boolean;
  50581. }
  50582. }
  50583. declare module BABYLON {
  50584. /** @hidden */
  50585. export var noisePixelShader: {
  50586. name: string;
  50587. shader: string;
  50588. };
  50589. }
  50590. declare module BABYLON {
  50591. /**
  50592. * Class used to generate noise procedural textures
  50593. */
  50594. export class NoiseProceduralTexture extends ProceduralTexture {
  50595. private _time;
  50596. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  50597. brightness: number;
  50598. /** Defines the number of octaves to process */
  50599. octaves: number;
  50600. /** Defines the level of persistence (0.8 by default) */
  50601. persistence: number;
  50602. /** Gets or sets animation speed factor (default is 1) */
  50603. animationSpeedFactor: number;
  50604. /**
  50605. * Creates a new NoiseProceduralTexture
  50606. * @param name defines the name fo the texture
  50607. * @param size defines the size of the texture (default is 256)
  50608. * @param scene defines the hosting scene
  50609. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  50610. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  50611. */
  50612. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50613. private _updateShaderUniforms;
  50614. protected _getDefines(): string;
  50615. /** Generate the current state of the procedural texture */
  50616. render(useCameraPostProcess?: boolean): void;
  50617. /**
  50618. * Serializes this noise procedural texture
  50619. * @returns a serialized noise procedural texture object
  50620. */
  50621. serialize(): any;
  50622. /**
  50623. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  50624. * @param parsedTexture defines parsed texture data
  50625. * @param scene defines the current scene
  50626. * @param rootUrl defines the root URL containing noise procedural texture information
  50627. * @returns a parsed NoiseProceduralTexture
  50628. */
  50629. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  50630. }
  50631. }
  50632. declare module BABYLON {
  50633. /**
  50634. * Raw cube texture where the raw buffers are passed in
  50635. */
  50636. export class RawCubeTexture extends CubeTexture {
  50637. /**
  50638. * Creates a cube texture where the raw buffers are passed in.
  50639. * @param scene defines the scene the texture is attached to
  50640. * @param data defines the array of data to use to create each face
  50641. * @param size defines the size of the textures
  50642. * @param format defines the format of the data
  50643. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  50644. * @param generateMipMaps defines if the engine should generate the mip levels
  50645. * @param invertY defines if data must be stored with Y axis inverted
  50646. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  50647. * @param compression defines the compression used (null by default)
  50648. */
  50649. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  50650. /**
  50651. * Updates the raw cube texture.
  50652. * @param data defines the data to store
  50653. * @param format defines the data format
  50654. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  50655. * @param invertY defines if data must be stored with Y axis inverted
  50656. * @param compression defines the compression used (null by default)
  50657. * @param level defines which level of the texture to update
  50658. */
  50659. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  50660. /**
  50661. * Updates a raw cube texture with RGBD encoded data.
  50662. * @param data defines the array of data [mipmap][face] to use to create each face
  50663. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  50664. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50665. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50666. * @returns a promsie that resolves when the operation is complete
  50667. */
  50668. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  50669. /**
  50670. * Clones the raw cube texture.
  50671. * @return a new cube texture
  50672. */
  50673. clone(): CubeTexture;
  50674. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  50675. }
  50676. }
  50677. declare module BABYLON {
  50678. /**
  50679. * Class used to store 3D textures containing user data
  50680. */
  50681. export class RawTexture3D extends Texture {
  50682. /** Gets or sets the texture format to use */
  50683. format: number;
  50684. private _engine;
  50685. /**
  50686. * Create a new RawTexture3D
  50687. * @param data defines the data of the texture
  50688. * @param width defines the width of the texture
  50689. * @param height defines the height of the texture
  50690. * @param depth defines the depth of the texture
  50691. * @param format defines the texture format to use
  50692. * @param scene defines the hosting scene
  50693. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  50694. * @param invertY defines if texture must be stored with Y axis inverted
  50695. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  50696. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  50697. */
  50698. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  50699. /** Gets or sets the texture format to use */
  50700. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  50701. /**
  50702. * Update the texture with new data
  50703. * @param data defines the data to store in the texture
  50704. */
  50705. update(data: ArrayBufferView): void;
  50706. }
  50707. }
  50708. declare module BABYLON {
  50709. /**
  50710. * Creates a refraction texture used by refraction channel of the standard material.
  50711. * It is like a mirror but to see through a material.
  50712. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50713. */
  50714. export class RefractionTexture extends RenderTargetTexture {
  50715. /**
  50716. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  50717. * 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.
  50718. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50719. */
  50720. refractionPlane: Plane;
  50721. /**
  50722. * Define how deep under the surface we should see.
  50723. */
  50724. depth: number;
  50725. /**
  50726. * Creates a refraction texture used by refraction channel of the standard material.
  50727. * It is like a mirror but to see through a material.
  50728. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50729. * @param name Define the texture name
  50730. * @param size Define the size of the underlying texture
  50731. * @param scene Define the scene the refraction belongs to
  50732. * @param generateMipMaps Define if we need to generate mips level for the refraction
  50733. */
  50734. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  50735. /**
  50736. * Clone the refraction texture.
  50737. * @returns the cloned texture
  50738. */
  50739. clone(): RefractionTexture;
  50740. /**
  50741. * Serialize the texture to a JSON representation you could use in Parse later on
  50742. * @returns the serialized JSON representation
  50743. */
  50744. serialize(): any;
  50745. }
  50746. }
  50747. declare module BABYLON {
  50748. /**
  50749. * Defines the options related to the creation of an HtmlElementTexture
  50750. */
  50751. export interface IHtmlElementTextureOptions {
  50752. /**
  50753. * Defines wether mip maps should be created or not.
  50754. */
  50755. generateMipMaps?: boolean;
  50756. /**
  50757. * Defines the sampling mode of the texture.
  50758. */
  50759. samplingMode?: number;
  50760. /**
  50761. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  50762. */
  50763. engine: Nullable<Engine>;
  50764. /**
  50765. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  50766. */
  50767. scene: Nullable<Scene>;
  50768. }
  50769. /**
  50770. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  50771. * To be as efficient as possible depending on your constraints nothing aside the first upload
  50772. * is automatically managed.
  50773. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  50774. * in your application.
  50775. *
  50776. * As the update is not automatic, you need to call them manually.
  50777. */
  50778. export class HtmlElementTexture extends BaseTexture {
  50779. /**
  50780. * The texture URL.
  50781. */
  50782. element: HTMLVideoElement | HTMLCanvasElement;
  50783. private static readonly DefaultOptions;
  50784. private _textureMatrix;
  50785. private _engine;
  50786. private _isVideo;
  50787. private _generateMipMaps;
  50788. private _samplingMode;
  50789. /**
  50790. * Instantiates a HtmlElementTexture from the following parameters.
  50791. *
  50792. * @param name Defines the name of the texture
  50793. * @param element Defines the video or canvas the texture is filled with
  50794. * @param options Defines the other none mandatory texture creation options
  50795. */
  50796. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  50797. private _createInternalTexture;
  50798. /**
  50799. * Returns the texture matrix used in most of the material.
  50800. */
  50801. getTextureMatrix(): Matrix;
  50802. /**
  50803. * Updates the content of the texture.
  50804. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  50805. */
  50806. update(invertY?: Nullable<boolean>): void;
  50807. }
  50808. }
  50809. declare module BABYLON {
  50810. /**
  50811. * Enum used to define the target of a block
  50812. */
  50813. export enum NodeMaterialBlockTargets {
  50814. /** Vertex shader */
  50815. Vertex = 1,
  50816. /** Fragment shader */
  50817. Fragment = 2,
  50818. /** Neutral */
  50819. Neutral = 4,
  50820. /** Vertex and Fragment */
  50821. VertexAndFragment = 3
  50822. }
  50823. }
  50824. declare module BABYLON {
  50825. /**
  50826. * Defines the kind of connection point for node based material
  50827. */
  50828. export enum NodeMaterialBlockConnectionPointTypes {
  50829. /** Float */
  50830. Float = 1,
  50831. /** Int */
  50832. Int = 2,
  50833. /** Vector2 */
  50834. Vector2 = 4,
  50835. /** Vector3 */
  50836. Vector3 = 8,
  50837. /** Vector4 */
  50838. Vector4 = 16,
  50839. /** Color3 */
  50840. Color3 = 32,
  50841. /** Color4 */
  50842. Color4 = 64,
  50843. /** Matrix */
  50844. Matrix = 128,
  50845. /** Detect type based on connection */
  50846. AutoDetect = 1024,
  50847. /** Output type that will be defined by input type */
  50848. BasedOnInput = 2048
  50849. }
  50850. }
  50851. declare module BABYLON {
  50852. /**
  50853. * Root class for all node material optimizers
  50854. */
  50855. export class NodeMaterialOptimizer {
  50856. /**
  50857. * Function used to optimize a NodeMaterial graph
  50858. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  50859. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  50860. */
  50861. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  50862. }
  50863. }
  50864. declare module BABYLON {
  50865. /**
  50866. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  50867. */
  50868. export class TransformBlock extends NodeMaterialBlock {
  50869. /**
  50870. * Defines the value to use to complement W value to transform it to a Vector4
  50871. */
  50872. complementW: number;
  50873. /**
  50874. * Defines the value to use to complement z value to transform it to a Vector4
  50875. */
  50876. complementZ: number;
  50877. /**
  50878. * Creates a new TransformBlock
  50879. * @param name defines the block name
  50880. */
  50881. constructor(name: string);
  50882. /**
  50883. * Gets the current class name
  50884. * @returns the class name
  50885. */
  50886. getClassName(): string;
  50887. /**
  50888. * Gets the vector input
  50889. */
  50890. readonly vector: NodeMaterialConnectionPoint;
  50891. /**
  50892. * Gets the output component
  50893. */
  50894. readonly output: NodeMaterialConnectionPoint;
  50895. /**
  50896. * Gets the matrix transform input
  50897. */
  50898. readonly transform: NodeMaterialConnectionPoint;
  50899. protected _buildBlock(state: NodeMaterialBuildState): this;
  50900. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  50901. }
  50902. }
  50903. declare module BABYLON {
  50904. /**
  50905. * Block used to output the vertex position
  50906. */
  50907. export class VertexOutputBlock extends NodeMaterialBlock {
  50908. /**
  50909. * Creates a new VertexOutputBlock
  50910. * @param name defines the block name
  50911. */
  50912. constructor(name: string);
  50913. /**
  50914. * Gets the current class name
  50915. * @returns the class name
  50916. */
  50917. getClassName(): string;
  50918. /**
  50919. * Gets the vector input component
  50920. */
  50921. readonly vector: NodeMaterialConnectionPoint;
  50922. protected _buildBlock(state: NodeMaterialBuildState): this;
  50923. }
  50924. }
  50925. declare module BABYLON {
  50926. /**
  50927. * Block used to output the final color
  50928. */
  50929. export class FragmentOutputBlock extends NodeMaterialBlock {
  50930. /**
  50931. * Create a new FragmentOutputBlock
  50932. * @param name defines the block name
  50933. */
  50934. constructor(name: string);
  50935. /**
  50936. * Gets the current class name
  50937. * @returns the class name
  50938. */
  50939. getClassName(): string;
  50940. /**
  50941. * Gets the rgba input component
  50942. */
  50943. readonly rgba: NodeMaterialConnectionPoint;
  50944. /**
  50945. * Gets the rgb input component
  50946. */
  50947. readonly rgb: NodeMaterialConnectionPoint;
  50948. /**
  50949. * Gets the a input component
  50950. */
  50951. readonly a: NodeMaterialConnectionPoint;
  50952. protected _buildBlock(state: NodeMaterialBuildState): this;
  50953. }
  50954. }
  50955. declare module BABYLON {
  50956. /**
  50957. * Enum used to define well known values e.g. values automatically provided by the system
  50958. */
  50959. export enum NodeMaterialWellKnownValues {
  50960. /** World */
  50961. World = 1,
  50962. /** View */
  50963. View = 2,
  50964. /** Projection */
  50965. Projection = 3,
  50966. /** ViewProjection */
  50967. ViewProjection = 4,
  50968. /** WorldView */
  50969. WorldView = 5,
  50970. /** WorldViewProjection */
  50971. WorldViewProjection = 6,
  50972. /** CameraPosition */
  50973. CameraPosition = 7,
  50974. /** Fog Color */
  50975. FogColor = 8
  50976. }
  50977. }
  50978. declare module BABYLON {
  50979. /**
  50980. * Block used to read a reflection texture from a sampler
  50981. */
  50982. export class ReflectionTextureBlock extends NodeMaterialBlock {
  50983. private _define3DName;
  50984. private _defineCubicName;
  50985. private _defineExplicitName;
  50986. private _defineProjectionName;
  50987. private _defineLocalCubicName;
  50988. private _defineSphericalName;
  50989. private _definePlanarName;
  50990. private _defineEquirectangularName;
  50991. private _defineMirroredEquirectangularFixedName;
  50992. private _defineEquirectangularFixedName;
  50993. private _defineSkyboxName;
  50994. private _cubeSamplerName;
  50995. private _2DSamplerName;
  50996. private _positionUVWName;
  50997. private _directionWName;
  50998. private _reflectionCoordsName;
  50999. private _reflection2DCoordsName;
  51000. private _reflectionColorName;
  51001. private _reflectionMatrixName;
  51002. /**
  51003. * Gets or sets the texture associated with the node
  51004. */
  51005. texture: Nullable<BaseTexture>;
  51006. /**
  51007. * Create a new TextureBlock
  51008. * @param name defines the block name
  51009. */
  51010. constructor(name: string);
  51011. /**
  51012. * Gets the current class name
  51013. * @returns the class name
  51014. */
  51015. getClassName(): string;
  51016. /**
  51017. * Gets the world position input component
  51018. */
  51019. readonly position: NodeMaterialConnectionPoint;
  51020. /**
  51021. * Gets the world position input component
  51022. */
  51023. readonly worldPosition: NodeMaterialConnectionPoint;
  51024. /**
  51025. * Gets the world normal input component
  51026. */
  51027. readonly worldNormal: NodeMaterialConnectionPoint;
  51028. /**
  51029. * Gets the world input component
  51030. */
  51031. readonly world: NodeMaterialConnectionPoint;
  51032. /**
  51033. * Gets the camera (or eye) position component
  51034. */
  51035. readonly cameraPosition: NodeMaterialConnectionPoint;
  51036. /**
  51037. * Gets the view input component
  51038. */
  51039. readonly view: NodeMaterialConnectionPoint;
  51040. /**
  51041. * Gets the rgb output component
  51042. */
  51043. readonly rgb: NodeMaterialConnectionPoint;
  51044. /**
  51045. * Gets the r output component
  51046. */
  51047. readonly r: NodeMaterialConnectionPoint;
  51048. /**
  51049. * Gets the g output component
  51050. */
  51051. readonly g: NodeMaterialConnectionPoint;
  51052. /**
  51053. * Gets the b output component
  51054. */
  51055. readonly b: NodeMaterialConnectionPoint;
  51056. autoConfigure(): void;
  51057. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51058. isReady(): boolean;
  51059. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51060. private _injectVertexCode;
  51061. private _writeOutput;
  51062. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  51063. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51064. }
  51065. }
  51066. declare module BABYLON {
  51067. /**
  51068. * Interface used to configure the node material editor
  51069. */
  51070. export interface INodeMaterialEditorOptions {
  51071. /** Define the URl to load node editor script */
  51072. editorURL?: string;
  51073. }
  51074. /** @hidden */
  51075. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  51076. /** BONES */
  51077. NUM_BONE_INFLUENCERS: number;
  51078. BonesPerMesh: number;
  51079. BONETEXTURE: boolean;
  51080. /** MORPH TARGETS */
  51081. MORPHTARGETS: boolean;
  51082. MORPHTARGETS_NORMAL: boolean;
  51083. MORPHTARGETS_TANGENT: boolean;
  51084. MORPHTARGETS_UV: boolean;
  51085. NUM_MORPH_INFLUENCERS: number;
  51086. /** IMAGE PROCESSING */
  51087. IMAGEPROCESSING: boolean;
  51088. VIGNETTE: boolean;
  51089. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51090. VIGNETTEBLENDMODEOPAQUE: boolean;
  51091. TONEMAPPING: boolean;
  51092. TONEMAPPING_ACES: boolean;
  51093. CONTRAST: boolean;
  51094. EXPOSURE: boolean;
  51095. COLORCURVES: boolean;
  51096. COLORGRADING: boolean;
  51097. COLORGRADING3D: boolean;
  51098. SAMPLER3DGREENDEPTH: boolean;
  51099. SAMPLER3DBGRMAP: boolean;
  51100. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51101. constructor();
  51102. setValue(name: string, value: boolean): void;
  51103. }
  51104. /**
  51105. * Class used to configure NodeMaterial
  51106. */
  51107. export interface INodeMaterialOptions {
  51108. /**
  51109. * Defines if blocks should emit comments
  51110. */
  51111. emitComments: boolean;
  51112. }
  51113. /**
  51114. * Class used to create a node based material built by assembling shader blocks
  51115. */
  51116. export class NodeMaterial extends PushMaterial {
  51117. private static _BuildIdGenerator;
  51118. private _options;
  51119. private _vertexCompilationState;
  51120. private _fragmentCompilationState;
  51121. private _sharedData;
  51122. private _buildId;
  51123. private _buildWasSuccessful;
  51124. private _cachedWorldViewMatrix;
  51125. private _cachedWorldViewProjectionMatrix;
  51126. private _optimizers;
  51127. private _animationFrame;
  51128. /** Define the URl to load node editor script */
  51129. static EditorURL: string;
  51130. private BJSNODEMATERIALEDITOR;
  51131. /** Get the inspector from bundle or global */
  51132. private _getGlobalNodeMaterialEditor;
  51133. /**
  51134. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  51135. */
  51136. ignoreAlpha: boolean;
  51137. /**
  51138. * Defines the maximum number of lights that can be used in the material
  51139. */
  51140. maxSimultaneousLights: number;
  51141. /**
  51142. * Observable raised when the material is built
  51143. */
  51144. onBuildObservable: Observable<NodeMaterial>;
  51145. /**
  51146. * Gets or sets the root nodes of the material vertex shader
  51147. */ private _vertexOutputNodes: NodeMaterialBlock[];
  51148. /**
  51149. * Gets or sets the root nodes of the material fragment (pixel) shader
  51150. */ private _fragmentOutputNodes: NodeMaterialBlock[];
  51151. /** Gets or sets options to control the node material overall behavior */
  51152. options: INodeMaterialOptions;
  51153. /**
  51154. * Default configuration related to image processing available in the standard Material.
  51155. */
  51156. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51157. /**
  51158. * Gets the image processing configuration used either in this material.
  51159. */
  51160. /**
  51161. * Sets the Default image processing configuration used either in the this material.
  51162. *
  51163. * If sets to null, the scene one is in use.
  51164. */
  51165. imageProcessingConfiguration: ImageProcessingConfiguration;
  51166. /**
  51167. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  51168. */
  51169. attachedBlocks: NodeMaterialBlock[];
  51170. /**
  51171. * Create a new node based material
  51172. * @param name defines the material name
  51173. * @param scene defines the hosting scene
  51174. * @param options defines creation option
  51175. */
  51176. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  51177. /**
  51178. * Gets the current class name of the material e.g. "NodeMaterial"
  51179. * @returns the class name
  51180. */
  51181. getClassName(): string;
  51182. /**
  51183. * Keep track of the image processing observer to allow dispose and replace.
  51184. */
  51185. private _imageProcessingObserver;
  51186. /**
  51187. * Attaches a new image processing configuration to the Standard Material.
  51188. * @param configuration
  51189. */
  51190. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51191. /**
  51192. * Get a block by its name
  51193. * @param name defines the name of the block to retrieve
  51194. * @returns the required block or null if not found
  51195. */
  51196. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  51197. /**
  51198. * Gets the list of input blocks attached to this material
  51199. * @returns an array of InputBlocks
  51200. */
  51201. getInputBlocks(): InputBlock[];
  51202. /**
  51203. * Adds a new optimizer to the list of optimizers
  51204. * @param optimizer defines the optimizers to add
  51205. * @returns the current material
  51206. */
  51207. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51208. /**
  51209. * Remove an optimizer from the list of optimizers
  51210. * @param optimizer defines the optimizers to remove
  51211. * @returns the current material
  51212. */
  51213. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51214. /**
  51215. * Add a new block to the list of output nodes
  51216. * @param node defines the node to add
  51217. * @returns the current material
  51218. */
  51219. addOutputNode(node: NodeMaterialBlock): this;
  51220. /**
  51221. * Remove a block from the list of root nodes
  51222. * @param node defines the node to remove
  51223. * @returns the current material
  51224. */
  51225. removeOutputNode(node: NodeMaterialBlock): this;
  51226. private _addVertexOutputNode;
  51227. private _removeVertexOutputNode;
  51228. private _addFragmentOutputNode;
  51229. private _removeFragmentOutputNode;
  51230. /**
  51231. * Specifies if the material will require alpha blending
  51232. * @returns a boolean specifying if alpha blending is needed
  51233. */
  51234. needAlphaBlending(): boolean;
  51235. /**
  51236. * Specifies if this material should be rendered in alpha test mode
  51237. * @returns a boolean specifying if an alpha test is needed.
  51238. */
  51239. needAlphaTesting(): boolean;
  51240. private _initializeBlock;
  51241. private _resetDualBlocks;
  51242. /**
  51243. * Build the material and generates the inner effect
  51244. * @param verbose defines if the build should log activity
  51245. */
  51246. build(verbose?: boolean): void;
  51247. /**
  51248. * Runs an otpimization phase to try to improve the shader code
  51249. */
  51250. optimize(): void;
  51251. private _prepareDefinesForAttributes;
  51252. /**
  51253. * Get if the submesh is ready to be used and all its information available.
  51254. * Child classes can use it to update shaders
  51255. * @param mesh defines the mesh to check
  51256. * @param subMesh defines which submesh to check
  51257. * @param useInstances specifies that instances should be used
  51258. * @returns a boolean indicating that the submesh is ready or not
  51259. */
  51260. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51261. /**
  51262. * Get a string representing the shaders built by the current node graph
  51263. */
  51264. readonly compiledShaders: string;
  51265. /**
  51266. * Binds the world matrix to the material
  51267. * @param world defines the world transformation matrix
  51268. */
  51269. bindOnlyWorldMatrix(world: Matrix): void;
  51270. /**
  51271. * Binds the submesh to this material by preparing the effect and shader to draw
  51272. * @param world defines the world transformation matrix
  51273. * @param mesh defines the mesh containing the submesh
  51274. * @param subMesh defines the submesh to bind the material to
  51275. */
  51276. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51277. /**
  51278. * Gets the active textures from the material
  51279. * @returns an array of textures
  51280. */
  51281. getActiveTextures(): BaseTexture[];
  51282. /**
  51283. * Gets the list of texture blocks
  51284. * @returns an array of texture blocks
  51285. */
  51286. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  51287. /**
  51288. * Specifies if the material uses a texture
  51289. * @param texture defines the texture to check against the material
  51290. * @returns a boolean specifying if the material uses the texture
  51291. */
  51292. hasTexture(texture: BaseTexture): boolean;
  51293. /**
  51294. * Disposes the material
  51295. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  51296. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  51297. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  51298. */
  51299. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  51300. /** Creates the node editor window. */
  51301. private _createNodeEditor;
  51302. /**
  51303. * Launch the node material editor
  51304. * @param config Define the configuration of the editor
  51305. * @return a promise fulfilled when the node editor is visible
  51306. */
  51307. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  51308. /**
  51309. * Clear the current material
  51310. */
  51311. clear(): void;
  51312. /**
  51313. * Clear the current material and set it to a default state
  51314. */
  51315. setToDefault(): void;
  51316. private _gatherBlocks;
  51317. /**
  51318. * Serializes this material in a JSON representation
  51319. * @returns the serialized material object
  51320. */
  51321. serialize(): any;
  51322. private _restoreConnections;
  51323. /**
  51324. * Clear the current graph and load a new one from a serialization object
  51325. * @param source defines the JSON representation of the material
  51326. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  51327. */
  51328. loadFromSerialization(source: any, rootUrl?: string): void;
  51329. /**
  51330. * Creates a node material from parsed material data
  51331. * @param source defines the JSON representation of the material
  51332. * @param scene defines the hosting scene
  51333. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  51334. * @returns a new node material
  51335. */
  51336. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  51337. /**
  51338. * Creates a new node material set to default basic configuration
  51339. * @param name defines the name of the material
  51340. * @param scene defines the hosting scene
  51341. * @returns a new NodeMaterial
  51342. */
  51343. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  51344. }
  51345. }
  51346. declare module BABYLON {
  51347. /**
  51348. * Block used to read a texture from a sampler
  51349. */
  51350. export class TextureBlock extends NodeMaterialBlock {
  51351. private _defineName;
  51352. private _samplerName;
  51353. private _transformedUVName;
  51354. private _textureTransformName;
  51355. private _textureInfoName;
  51356. private _mainUVName;
  51357. private _mainUVDefineName;
  51358. /**
  51359. * Gets or sets the texture associated with the node
  51360. */
  51361. texture: Nullable<BaseTexture>;
  51362. /**
  51363. * Create a new TextureBlock
  51364. * @param name defines the block name
  51365. */
  51366. constructor(name: string);
  51367. /**
  51368. * Gets the current class name
  51369. * @returns the class name
  51370. */
  51371. getClassName(): string;
  51372. /**
  51373. * Gets the uv input component
  51374. */
  51375. readonly uv: NodeMaterialConnectionPoint;
  51376. /**
  51377. * Gets the rgba output component
  51378. */
  51379. readonly rgba: NodeMaterialConnectionPoint;
  51380. /**
  51381. * Gets the rgb output component
  51382. */
  51383. readonly rgb: NodeMaterialConnectionPoint;
  51384. /**
  51385. * Gets the r output component
  51386. */
  51387. readonly r: NodeMaterialConnectionPoint;
  51388. /**
  51389. * Gets the g output component
  51390. */
  51391. readonly g: NodeMaterialConnectionPoint;
  51392. /**
  51393. * Gets the b output component
  51394. */
  51395. readonly b: NodeMaterialConnectionPoint;
  51396. /**
  51397. * Gets the a output component
  51398. */
  51399. readonly a: NodeMaterialConnectionPoint;
  51400. autoConfigure(): void;
  51401. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51402. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51403. isReady(): boolean;
  51404. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51405. private _injectVertexCode;
  51406. private _writeOutput;
  51407. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  51408. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51409. }
  51410. }
  51411. declare module BABYLON {
  51412. /**
  51413. * Class used to store shared data between 2 NodeMaterialBuildState
  51414. */
  51415. export class NodeMaterialBuildStateSharedData {
  51416. /**
  51417. * Gets the list of emitted varyings
  51418. */
  51419. temps: string[];
  51420. /**
  51421. * Gets the list of emitted varyings
  51422. */
  51423. varyings: string[];
  51424. /**
  51425. * Gets the varying declaration string
  51426. */
  51427. varyingDeclaration: string;
  51428. /**
  51429. * Input blocks
  51430. */
  51431. inputBlocks: InputBlock[];
  51432. /**
  51433. * Input blocks
  51434. */
  51435. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  51436. /**
  51437. * Bindable blocks (Blocks that need to set data to the effect)
  51438. */
  51439. bindableBlocks: NodeMaterialBlock[];
  51440. /**
  51441. * List of blocks that can provide a compilation fallback
  51442. */
  51443. blocksWithFallbacks: NodeMaterialBlock[];
  51444. /**
  51445. * List of blocks that can provide a define update
  51446. */
  51447. blocksWithDefines: NodeMaterialBlock[];
  51448. /**
  51449. * List of blocks that can provide a repeatable content
  51450. */
  51451. repeatableContentBlocks: NodeMaterialBlock[];
  51452. /**
  51453. * List of blocks that can provide a dynamic list of uniforms
  51454. */
  51455. dynamicUniformBlocks: NodeMaterialBlock[];
  51456. /**
  51457. * List of blocks that can block the isReady function for the material
  51458. */
  51459. blockingBlocks: NodeMaterialBlock[];
  51460. /**
  51461. * Gets the list of animated inputs
  51462. */
  51463. animatedInputs: InputBlock[];
  51464. /**
  51465. * Build Id used to avoid multiple recompilations
  51466. */
  51467. buildId: number;
  51468. /** List of emitted variables */
  51469. variableNames: {
  51470. [key: string]: number;
  51471. };
  51472. /** List of emitted defines */
  51473. defineNames: {
  51474. [key: string]: number;
  51475. };
  51476. /** Should emit comments? */
  51477. emitComments: boolean;
  51478. /** Emit build activity */
  51479. verbose: boolean;
  51480. /**
  51481. * Gets the compilation hints emitted at compilation time
  51482. */
  51483. hints: {
  51484. needWorldViewMatrix: boolean;
  51485. needWorldViewProjectionMatrix: boolean;
  51486. needAlphaBlending: boolean;
  51487. needAlphaTesting: boolean;
  51488. };
  51489. /**
  51490. * List of compilation checks
  51491. */
  51492. checks: {
  51493. emitVertex: boolean;
  51494. emitFragment: boolean;
  51495. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  51496. };
  51497. /** Creates a new shared data */
  51498. constructor();
  51499. /**
  51500. * Emits console errors and exceptions if there is a failing check
  51501. */
  51502. emitErrors(): void;
  51503. }
  51504. }
  51505. declare module BABYLON {
  51506. /**
  51507. * Class used to store node based material build state
  51508. */
  51509. export class NodeMaterialBuildState {
  51510. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  51511. supportUniformBuffers: boolean;
  51512. /**
  51513. * Gets the list of emitted attributes
  51514. */
  51515. attributes: string[];
  51516. /**
  51517. * Gets the list of emitted uniforms
  51518. */
  51519. uniforms: string[];
  51520. /**
  51521. * Gets the list of emitted uniform buffers
  51522. */
  51523. uniformBuffers: string[];
  51524. /**
  51525. * Gets the list of emitted samplers
  51526. */
  51527. samplers: string[];
  51528. /**
  51529. * Gets the list of emitted functions
  51530. */
  51531. functions: {
  51532. [key: string]: string;
  51533. };
  51534. /**
  51535. * Gets the target of the compilation state
  51536. */
  51537. target: NodeMaterialBlockTargets;
  51538. /**
  51539. * Gets the list of emitted counters
  51540. */
  51541. counters: {
  51542. [key: string]: number;
  51543. };
  51544. /**
  51545. * Shared data between multiple NodeMaterialBuildState instances
  51546. */
  51547. sharedData: NodeMaterialBuildStateSharedData;
  51548. /** @hidden */ private _vertexState: NodeMaterialBuildState;
  51549. /** @hidden */ private _attributeDeclaration: string;
  51550. /** @hidden */ private _uniformDeclaration: string;
  51551. /** @hidden */ private _samplerDeclaration: string;
  51552. /** @hidden */ private _varyingTransfer: string;
  51553. private _repeatableContentAnchorIndex;
  51554. /** @hidden */ private _builtCompilationString: string;
  51555. /**
  51556. * Gets the emitted compilation strings
  51557. */
  51558. compilationString: string;
  51559. /**
  51560. * Finalize the compilation strings
  51561. * @param state defines the current compilation state
  51562. */
  51563. finalize(state: NodeMaterialBuildState): void;
  51564. /** @hidden */ protected readonly _repeatableContentAnchor: string;
  51565. /** @hidden */ private _getFreeVariableName(prefix: string): string;
  51566. /** @hidden */ private _getFreeDefineName(prefix: string): string;
  51567. /** @hidden */ private _excludeVariableName(name: string): void;
  51568. /** @hidden */ private _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  51569. /** @hidden */ private _emitFunction(name: string, code: string, comments: string): void;
  51570. /** @hidden */ private _emitCodeFromInclude(includeName: string, comments: string, options?: {
  51571. replaceStrings?: {
  51572. search: RegExp;
  51573. replace: string;
  51574. }[];
  51575. repeatKey?: string;
  51576. }): string;
  51577. /** @hidden */ private _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  51578. repeatKey?: string;
  51579. removeAttributes?: boolean;
  51580. removeUniforms?: boolean;
  51581. removeVaryings?: boolean;
  51582. removeIfDef?: boolean;
  51583. replaceStrings?: {
  51584. search: RegExp;
  51585. replace: string;
  51586. }[];
  51587. }, storeKey?: string): void;
  51588. /** @hidden */ private _registerTempVariable(name: string): boolean;
  51589. /** @hidden */ private _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  51590. /** @hidden */ private _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  51591. }
  51592. }
  51593. declare module BABYLON {
  51594. /**
  51595. * Defines a block that can be used inside a node based material
  51596. */
  51597. export class NodeMaterialBlock {
  51598. private _buildId;
  51599. private _buildTarget;
  51600. private _target;
  51601. private _isFinalMerger;
  51602. private _isInput;
  51603. /** @hidden */ private _inputs: NodeMaterialConnectionPoint[];
  51604. /** @hidden */ private _outputs: NodeMaterialConnectionPoint[];
  51605. /**
  51606. * Gets or sets the name of the block
  51607. */
  51608. name: string;
  51609. /**
  51610. * Gets or sets the unique id of the node
  51611. */
  51612. uniqueId: number;
  51613. /**
  51614. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  51615. */
  51616. readonly isFinalMerger: boolean;
  51617. /**
  51618. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  51619. */
  51620. readonly isInput: boolean;
  51621. /**
  51622. * Gets or sets the build Id
  51623. */
  51624. buildId: number;
  51625. /**
  51626. * Gets or sets the target of the block
  51627. */
  51628. target: NodeMaterialBlockTargets;
  51629. /**
  51630. * Gets the list of input points
  51631. */
  51632. readonly inputs: NodeMaterialConnectionPoint[];
  51633. /** Gets the list of output points */
  51634. readonly outputs: NodeMaterialConnectionPoint[];
  51635. /**
  51636. * Find an input by its name
  51637. * @param name defines the name of the input to look for
  51638. * @returns the input or null if not found
  51639. */
  51640. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  51641. /**
  51642. * Find an output by its name
  51643. * @param name defines the name of the outputto look for
  51644. * @returns the output or null if not found
  51645. */
  51646. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  51647. /**
  51648. * Creates a new NodeMaterialBlock
  51649. * @param name defines the block name
  51650. * @param target defines the target of that block (Vertex by default)
  51651. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  51652. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  51653. */
  51654. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  51655. /**
  51656. * Initialize the block and prepare the context for build
  51657. * @param state defines the state that will be used for the build
  51658. */
  51659. initialize(state: NodeMaterialBuildState): void;
  51660. /**
  51661. * Bind data to effect. Will only be called for blocks with isBindable === true
  51662. * @param effect defines the effect to bind data to
  51663. * @param nodeMaterial defines the hosting NodeMaterial
  51664. * @param mesh defines the mesh that will be rendered
  51665. */
  51666. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51667. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  51668. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  51669. protected _writeFloat(value: number): string;
  51670. /**
  51671. * Gets the current class name e.g. "NodeMaterialBlock"
  51672. * @returns the class name
  51673. */
  51674. getClassName(): string;
  51675. /**
  51676. * Register a new input. Must be called inside a block constructor
  51677. * @param name defines the connection point name
  51678. * @param type defines the connection point type
  51679. * @param isOptional defines a boolean indicating that this input can be omitted
  51680. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  51681. * @returns the current block
  51682. */
  51683. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  51684. /**
  51685. * Register a new output. Must be called inside a block constructor
  51686. * @param name defines the connection point name
  51687. * @param type defines the connection point type
  51688. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  51689. * @returns the current block
  51690. */
  51691. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  51692. /**
  51693. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  51694. * @param forOutput defines an optional connection point to check compatibility with
  51695. * @returns the first available input or null
  51696. */
  51697. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  51698. /**
  51699. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  51700. * @param forBlock defines an optional block to check compatibility with
  51701. * @returns the first available input or null
  51702. */
  51703. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  51704. /**
  51705. * Gets the sibling of the given output
  51706. * @param current defines the current output
  51707. * @returns the next output in the list or null
  51708. */
  51709. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  51710. /**
  51711. * Connect current block with another block
  51712. * @param other defines the block to connect with
  51713. * @param options define the various options to help pick the right connections
  51714. * @returns the current block
  51715. */
  51716. connectTo(other: NodeMaterialBlock, options?: {
  51717. input?: string;
  51718. output?: string;
  51719. outputSwizzle?: string;
  51720. }): this | undefined;
  51721. protected _buildBlock(state: NodeMaterialBuildState): void;
  51722. /**
  51723. * Add uniforms, samplers and uniform buffers at compilation time
  51724. * @param state defines the state to update
  51725. * @param nodeMaterial defines the node material requesting the update
  51726. * @param defines defines the material defines to update
  51727. */
  51728. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51729. /**
  51730. * Add potential fallbacks if shader compilation fails
  51731. * @param mesh defines the mesh to be rendered
  51732. * @param fallbacks defines the current prioritized list of fallbacks
  51733. */
  51734. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  51735. /**
  51736. * Update defines for shader compilation
  51737. * @param mesh defines the mesh to be rendered
  51738. * @param nodeMaterial defines the node material requesting the update
  51739. * @param defines defines the material defines to update
  51740. * @param useInstances specifies that instances should be used
  51741. */
  51742. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51743. /**
  51744. * Initialize defines for shader compilation
  51745. * @param mesh defines the mesh to be rendered
  51746. * @param nodeMaterial defines the node material requesting the update
  51747. * @param defines defines the material defines to be prepared
  51748. * @param useInstances specifies that instances should be used
  51749. */
  51750. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51751. /**
  51752. * Lets the block try to connect some inputs automatically
  51753. */
  51754. autoConfigure(): void;
  51755. /**
  51756. * Function called when a block is declared as repeatable content generator
  51757. * @param vertexShaderState defines the current compilation state for the vertex shader
  51758. * @param fragmentShaderState defines the current compilation state for the fragment shader
  51759. * @param mesh defines the mesh to be rendered
  51760. * @param defines defines the material defines to update
  51761. */
  51762. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  51763. /**
  51764. * Checks if the block is ready
  51765. * @param mesh defines the mesh to be rendered
  51766. * @param nodeMaterial defines the node material requesting the update
  51767. * @param defines defines the material defines to update
  51768. * @param useInstances specifies that instances should be used
  51769. * @returns true if the block is ready
  51770. */
  51771. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  51772. private _processBuild;
  51773. /**
  51774. * Compile the current node and generate the shader code
  51775. * @param state defines the current compilation state (uniforms, samplers, current string)
  51776. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  51777. * @returns true if already built
  51778. */
  51779. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  51780. /**
  51781. * Clone the current block to a new identical block
  51782. * @param scene defines the hosting scene
  51783. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  51784. * @returns a copy of the current block
  51785. */
  51786. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  51787. /**
  51788. * Serializes this block in a JSON representation
  51789. * @returns the serialized block object
  51790. */
  51791. serialize(): any;
  51792. /** @hidden */ private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51793. }
  51794. }
  51795. declare module BABYLON {
  51796. /**
  51797. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  51798. */
  51799. export enum NodeMaterialBlockConnectionPointMode {
  51800. /** Value is an uniform */
  51801. Uniform = 0,
  51802. /** Value is a mesh attribute */
  51803. Attribute = 1,
  51804. /** Value is a varying between vertex and fragment shaders */
  51805. Varying = 2,
  51806. /** Mode is undefined */
  51807. Undefined = 3
  51808. }
  51809. }
  51810. declare module BABYLON {
  51811. /**
  51812. * Enum defining the type of animations supported by InputBlock
  51813. */
  51814. export enum AnimatedInputBlockTypes {
  51815. /** No animation */
  51816. None = 0,
  51817. /** Time based animation. Will only work for floats */
  51818. Time = 1
  51819. }
  51820. }
  51821. declare module BABYLON {
  51822. /**
  51823. * Block used to expose an input value
  51824. */
  51825. export class InputBlock extends NodeMaterialBlock {
  51826. private _mode;
  51827. private _associatedVariableName;
  51828. private _storedValue;
  51829. private _valueCallback;
  51830. private _type;
  51831. private _animationType;
  51832. /** @hidden */ private _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  51833. /** Gets or sets a boolean indicating that this input can be edited in the Inspector */
  51834. visibleInInspector: boolean;
  51835. /**
  51836. * Gets or sets the connection point type (default is float)
  51837. */
  51838. readonly type: NodeMaterialBlockConnectionPointTypes;
  51839. /**
  51840. * Creates a new InputBlock
  51841. * @param name defines the block name
  51842. * @param target defines the target of that block (Vertex by default)
  51843. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  51844. */
  51845. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  51846. /**
  51847. * Gets the output component
  51848. */
  51849. readonly output: NodeMaterialConnectionPoint;
  51850. /**
  51851. * Set the source of this connection point to a vertex attribute
  51852. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  51853. * @returns the current connection point
  51854. */
  51855. setAsAttribute(attributeName?: string): InputBlock;
  51856. /**
  51857. * Set the source of this connection point to a well known value
  51858. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  51859. * @returns the current connection point
  51860. */
  51861. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  51862. /**
  51863. * Gets or sets the value of that point.
  51864. * Please note that this value will be ignored if valueCallback is defined
  51865. */
  51866. value: any;
  51867. /**
  51868. * Gets or sets a callback used to get the value of that point.
  51869. * Please note that setting this value will force the connection point to ignore the value property
  51870. */
  51871. valueCallback: () => any;
  51872. /**
  51873. * Gets or sets the associated variable name in the shader
  51874. */
  51875. associatedVariableName: string;
  51876. /** Gets or sets the type of animation applied to the input */
  51877. animationType: AnimatedInputBlockTypes;
  51878. /**
  51879. * Gets a boolean indicating that this connection point not defined yet
  51880. */
  51881. readonly isUndefined: boolean;
  51882. /**
  51883. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  51884. * In this case the connection point name must be the name of the uniform to use.
  51885. * Can only be set on inputs
  51886. */
  51887. isUniform: boolean;
  51888. /**
  51889. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  51890. * In this case the connection point name must be the name of the attribute to use
  51891. * Can only be set on inputs
  51892. */
  51893. isAttribute: boolean;
  51894. /**
  51895. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  51896. * Can only be set on exit points
  51897. */
  51898. isVarying: boolean;
  51899. /**
  51900. * Gets a boolean indicating that the current connection point is a well known value
  51901. */
  51902. readonly isWellKnownValue: boolean;
  51903. /**
  51904. * Gets or sets the current well known value or null if not defined as well know value
  51905. */
  51906. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  51907. /**
  51908. * Gets the current class name
  51909. * @returns the class name
  51910. */
  51911. getClassName(): string;
  51912. /**
  51913. * Animate the input if animationType !== None
  51914. * @param scene defines the rendering scene
  51915. */
  51916. animate(scene: Scene): void;
  51917. private _emitDefine;
  51918. /**
  51919. * Set the input block to its default value (based on its type)
  51920. */
  51921. setDefaultValue(): void;
  51922. private _emit;
  51923. /** @hidden */ private _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  51924. /** @hidden */ private _transmit(effect: Effect, scene: Scene): void;
  51925. protected _buildBlock(state: NodeMaterialBuildState): void;
  51926. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51927. }
  51928. }
  51929. declare module BABYLON {
  51930. /**
  51931. * Defines a connection point for a block
  51932. */
  51933. export class NodeMaterialConnectionPoint {
  51934. /** @hidden */ private _ownerBlock: NodeMaterialBlock;
  51935. /** @hidden */ private _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  51936. private _endpoints;
  51937. private _associatedVariableName;
  51938. /** @hidden */ private _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  51939. private _type;
  51940. /** @hidden */ private _enforceAssociatedVariableName: boolean;
  51941. /**
  51942. * Gets or sets the additional types supported byt this connection point
  51943. */
  51944. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  51945. /**
  51946. * Gets or sets the associated variable name in the shader
  51947. */
  51948. associatedVariableName: string;
  51949. /**
  51950. * Gets or sets the connection point type (default is float)
  51951. */
  51952. type: NodeMaterialBlockConnectionPointTypes;
  51953. /**
  51954. * Gets or sets the connection point name
  51955. */
  51956. name: string;
  51957. /**
  51958. * Gets or sets a boolean indicating that this connection point can be omitted
  51959. */
  51960. isOptional: boolean;
  51961. /**
  51962. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  51963. */
  51964. define: string;
  51965. /** Gets or sets the target of that connection point */
  51966. target: NodeMaterialBlockTargets;
  51967. /**
  51968. * Gets a boolean indicating that the current point is connected
  51969. */
  51970. readonly isConnected: boolean;
  51971. /**
  51972. * Gets a boolean indicating that the current point is connected to an input block
  51973. */
  51974. readonly isConnectedToInputBlock: boolean;
  51975. /**
  51976. * Gets a the connected input block (if any)
  51977. */
  51978. readonly connectInputBlock: Nullable<InputBlock>;
  51979. /** Get the other side of the connection (if any) */
  51980. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  51981. /** Get the block that owns this connection point */
  51982. readonly ownerBlock: NodeMaterialBlock;
  51983. /** Get the block connected on the other side of this connection (if any) */
  51984. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  51985. /** Get the block connected on the endpoints of this connection (if any) */
  51986. readonly connectedBlocks: Array<NodeMaterialBlock>;
  51987. /** Gets the list of connected endpoints */
  51988. readonly endpoints: NodeMaterialConnectionPoint[];
  51989. /** Gets a boolean indicating if that output point is connected to at least one input */
  51990. readonly hasEndpoints: boolean;
  51991. /**
  51992. * Creates a new connection point
  51993. * @param name defines the connection point name
  51994. * @param ownerBlock defines the block hosting this connection point
  51995. */
  51996. constructor(name: string, ownerBlock: NodeMaterialBlock);
  51997. /**
  51998. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  51999. * @returns the class name
  52000. */
  52001. getClassName(): string;
  52002. /**
  52003. * Gets an boolean indicating if the current point can be connected to another point
  52004. * @param connectionPoint defines the other connection point
  52005. * @returns true if the connection is possible
  52006. */
  52007. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  52008. /**
  52009. * Connect this point to another connection point
  52010. * @param connectionPoint defines the other connection point
  52011. * @returns the current connection point
  52012. */
  52013. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  52014. /**
  52015. * Disconnect this point from one of his endpoint
  52016. * @param endpoint defines the other connection point
  52017. * @returns the current connection point
  52018. */
  52019. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  52020. /**
  52021. * Serializes this point in a JSON representation
  52022. * @returns the serialized point object
  52023. */
  52024. serialize(): any;
  52025. }
  52026. }
  52027. declare module BABYLON {
  52028. /**
  52029. * Block used to add support for vertex skinning (bones)
  52030. */
  52031. export class BonesBlock extends NodeMaterialBlock {
  52032. /**
  52033. * Creates a new BonesBlock
  52034. * @param name defines the block name
  52035. */
  52036. constructor(name: string);
  52037. /**
  52038. * Initialize the block and prepare the context for build
  52039. * @param state defines the state that will be used for the build
  52040. */
  52041. initialize(state: NodeMaterialBuildState): void;
  52042. /**
  52043. * Gets the current class name
  52044. * @returns the class name
  52045. */
  52046. getClassName(): string;
  52047. /**
  52048. * Gets the matrix indices input component
  52049. */
  52050. readonly matricesIndices: NodeMaterialConnectionPoint;
  52051. /**
  52052. * Gets the matrix weights input component
  52053. */
  52054. readonly matricesWeights: NodeMaterialConnectionPoint;
  52055. /**
  52056. * Gets the extra matrix indices input component
  52057. */
  52058. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  52059. /**
  52060. * Gets the extra matrix weights input component
  52061. */
  52062. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  52063. /**
  52064. * Gets the world input component
  52065. */
  52066. readonly world: NodeMaterialConnectionPoint;
  52067. /**
  52068. * Gets the output component
  52069. */
  52070. readonly output: NodeMaterialConnectionPoint;
  52071. autoConfigure(): void;
  52072. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52073. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52074. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52075. protected _buildBlock(state: NodeMaterialBuildState): this;
  52076. }
  52077. }
  52078. declare module BABYLON {
  52079. /**
  52080. * Block used to add support for instances
  52081. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  52082. */
  52083. export class InstancesBlock extends NodeMaterialBlock {
  52084. /**
  52085. * Creates a new InstancesBlock
  52086. * @param name defines the block name
  52087. */
  52088. constructor(name: string);
  52089. /**
  52090. * Gets the current class name
  52091. * @returns the class name
  52092. */
  52093. getClassName(): string;
  52094. /**
  52095. * Gets the first world row input component
  52096. */
  52097. readonly world0: NodeMaterialConnectionPoint;
  52098. /**
  52099. * Gets the second world row input component
  52100. */
  52101. readonly world1: NodeMaterialConnectionPoint;
  52102. /**
  52103. * Gets the third world row input component
  52104. */
  52105. readonly world2: NodeMaterialConnectionPoint;
  52106. /**
  52107. * Gets the forth world row input component
  52108. */
  52109. readonly world3: NodeMaterialConnectionPoint;
  52110. /**
  52111. * Gets the world input component
  52112. */
  52113. readonly world: NodeMaterialConnectionPoint;
  52114. /**
  52115. * Gets the output component
  52116. */
  52117. readonly output: NodeMaterialConnectionPoint;
  52118. autoConfigure(): void;
  52119. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52120. protected _buildBlock(state: NodeMaterialBuildState): this;
  52121. }
  52122. }
  52123. declare module BABYLON {
  52124. /**
  52125. * Block used to add morph targets support to vertex shader
  52126. */
  52127. export class MorphTargetsBlock extends NodeMaterialBlock {
  52128. private _repeatableContentAnchor;
  52129. private _repeatebleContentGenerated;
  52130. /**
  52131. * Create a new MorphTargetsBlock
  52132. * @param name defines the block name
  52133. */
  52134. constructor(name: string);
  52135. /**
  52136. * Gets the current class name
  52137. * @returns the class name
  52138. */
  52139. getClassName(): string;
  52140. /**
  52141. * Gets the position input component
  52142. */
  52143. readonly position: NodeMaterialConnectionPoint;
  52144. /**
  52145. * Gets the normal input component
  52146. */
  52147. readonly normal: NodeMaterialConnectionPoint;
  52148. /**
  52149. * Gets the tangent input component
  52150. */
  52151. readonly tangent: NodeMaterialConnectionPoint;
  52152. /**
  52153. * Gets the tangent input component
  52154. */
  52155. readonly uv: NodeMaterialConnectionPoint;
  52156. /**
  52157. * Gets the position output component
  52158. */
  52159. readonly positionOutput: NodeMaterialConnectionPoint;
  52160. /**
  52161. * Gets the normal output component
  52162. */
  52163. readonly normalOutput: NodeMaterialConnectionPoint;
  52164. /**
  52165. * Gets the tangent output component
  52166. */
  52167. readonly tangentOutput: NodeMaterialConnectionPoint;
  52168. /**
  52169. * Gets the tangent output component
  52170. */
  52171. readonly uvOutput: NodeMaterialConnectionPoint;
  52172. initialize(state: NodeMaterialBuildState): void;
  52173. autoConfigure(): void;
  52174. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52175. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52176. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  52177. protected _buildBlock(state: NodeMaterialBuildState): this;
  52178. }
  52179. }
  52180. declare module BABYLON {
  52181. /**
  52182. * Block used to add an alpha test in the fragment shader
  52183. */
  52184. export class AlphaTestBlock extends NodeMaterialBlock {
  52185. /**
  52186. * Gets or sets the alpha value where alpha testing happens
  52187. */
  52188. alphaCutOff: number;
  52189. /**
  52190. * Create a new AlphaTestBlock
  52191. * @param name defines the block name
  52192. */
  52193. constructor(name: string);
  52194. /**
  52195. * Gets the current class name
  52196. * @returns the class name
  52197. */
  52198. getClassName(): string;
  52199. /**
  52200. * Gets the color input component
  52201. */
  52202. readonly color: NodeMaterialConnectionPoint;
  52203. /**
  52204. * Gets the alpha input component
  52205. */
  52206. readonly alpha: NodeMaterialConnectionPoint;
  52207. protected _buildBlock(state: NodeMaterialBuildState): this;
  52208. }
  52209. }
  52210. declare module BABYLON {
  52211. /**
  52212. * Block used to compute fresnel value
  52213. */
  52214. export class FresnelBlock extends NodeMaterialBlock {
  52215. /**
  52216. * Create a new FresnelBlock
  52217. * @param name defines the block name
  52218. */
  52219. constructor(name: string);
  52220. /**
  52221. * Gets the current class name
  52222. * @returns the class name
  52223. */
  52224. getClassName(): string;
  52225. /**
  52226. * Gets the world position input component
  52227. */
  52228. readonly worldPosition: NodeMaterialConnectionPoint;
  52229. /**
  52230. * Gets the world normal input component
  52231. */
  52232. readonly worldNormal: NodeMaterialConnectionPoint;
  52233. /**
  52234. * Gets the camera (or eye) position component
  52235. */
  52236. readonly cameraPosition: NodeMaterialConnectionPoint;
  52237. /**
  52238. * Gets the bias input component
  52239. */
  52240. readonly bias: NodeMaterialConnectionPoint;
  52241. /**
  52242. * Gets the camera (or eye) position component
  52243. */
  52244. readonly power: NodeMaterialConnectionPoint;
  52245. /**
  52246. * Gets the fresnel output component
  52247. */
  52248. readonly fresnel: NodeMaterialConnectionPoint;
  52249. autoConfigure(): void;
  52250. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52251. }
  52252. }
  52253. declare module BABYLON {
  52254. /**
  52255. * Block used to add image processing support to fragment shader
  52256. */
  52257. export class ImageProcessingBlock extends NodeMaterialBlock {
  52258. /**
  52259. * Create a new ImageProcessingBlock
  52260. * @param name defines the block name
  52261. */
  52262. constructor(name: string);
  52263. /**
  52264. * Gets the current class name
  52265. * @returns the class name
  52266. */
  52267. getClassName(): string;
  52268. /**
  52269. * Gets the color input component
  52270. */
  52271. readonly color: NodeMaterialConnectionPoint;
  52272. /**
  52273. * Gets the output component
  52274. */
  52275. readonly output: NodeMaterialConnectionPoint;
  52276. /**
  52277. * Initialize the block and prepare the context for build
  52278. * @param state defines the state that will be used for the build
  52279. */
  52280. initialize(state: NodeMaterialBuildState): void;
  52281. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  52282. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52283. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52284. protected _buildBlock(state: NodeMaterialBuildState): this;
  52285. }
  52286. }
  52287. declare module BABYLON {
  52288. /**
  52289. * Block used to add support for scene fog
  52290. */
  52291. export class FogBlock extends NodeMaterialBlock {
  52292. private _fogDistanceName;
  52293. private _fogParameters;
  52294. /**
  52295. * Create a new FogBlock
  52296. * @param name defines the block name
  52297. */
  52298. constructor(name: string);
  52299. /**
  52300. * Gets the current class name
  52301. * @returns the class name
  52302. */
  52303. getClassName(): string;
  52304. /**
  52305. * Gets the world position input component
  52306. */
  52307. readonly worldPosition: NodeMaterialConnectionPoint;
  52308. /**
  52309. * Gets the view input component
  52310. */
  52311. readonly view: NodeMaterialConnectionPoint;
  52312. /**
  52313. * Gets the color input component
  52314. */
  52315. readonly color: NodeMaterialConnectionPoint;
  52316. /**
  52317. * Gets the fog color input component
  52318. */
  52319. readonly fogColor: NodeMaterialConnectionPoint;
  52320. /**
  52321. * Gets the output component
  52322. */
  52323. readonly output: NodeMaterialConnectionPoint;
  52324. autoConfigure(): void;
  52325. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52326. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52327. protected _buildBlock(state: NodeMaterialBuildState): this;
  52328. }
  52329. }
  52330. declare module BABYLON {
  52331. /**
  52332. * Block used to add light in the fragment shader
  52333. */
  52334. export class LightBlock extends NodeMaterialBlock {
  52335. private _lightId;
  52336. /**
  52337. * Gets or sets the light associated with this block
  52338. */
  52339. light: Nullable<Light>;
  52340. /**
  52341. * Create a new LightBlock
  52342. * @param name defines the block name
  52343. */
  52344. constructor(name: string);
  52345. /**
  52346. * Gets the current class name
  52347. * @returns the class name
  52348. */
  52349. getClassName(): string;
  52350. /**
  52351. * Gets the world position input component
  52352. */
  52353. readonly worldPosition: NodeMaterialConnectionPoint;
  52354. /**
  52355. * Gets the world normal input component
  52356. */
  52357. readonly worldNormal: NodeMaterialConnectionPoint;
  52358. /**
  52359. * Gets the camera (or eye) position component
  52360. */
  52361. readonly cameraPosition: NodeMaterialConnectionPoint;
  52362. /**
  52363. * Gets the diffuse output component
  52364. */
  52365. readonly diffuseOutput: NodeMaterialConnectionPoint;
  52366. /**
  52367. * Gets the specular output component
  52368. */
  52369. readonly specularOutput: NodeMaterialConnectionPoint;
  52370. autoConfigure(): void;
  52371. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52372. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52373. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52374. private _injectVertexCode;
  52375. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52376. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52377. }
  52378. }
  52379. declare module BABYLON {
  52380. /**
  52381. * Block used to multiply 2 values
  52382. */
  52383. export class MultiplyBlock extends NodeMaterialBlock {
  52384. /**
  52385. * Creates a new MultiplyBlock
  52386. * @param name defines the block name
  52387. */
  52388. constructor(name: string);
  52389. /**
  52390. * Gets the current class name
  52391. * @returns the class name
  52392. */
  52393. getClassName(): string;
  52394. /**
  52395. * Gets the left operand input component
  52396. */
  52397. readonly left: NodeMaterialConnectionPoint;
  52398. /**
  52399. * Gets the right operand input component
  52400. */
  52401. readonly right: NodeMaterialConnectionPoint;
  52402. /**
  52403. * Gets the output component
  52404. */
  52405. readonly output: NodeMaterialConnectionPoint;
  52406. protected _buildBlock(state: NodeMaterialBuildState): this;
  52407. }
  52408. }
  52409. declare module BABYLON {
  52410. /**
  52411. * Block used to add 2 vectors
  52412. */
  52413. export class AddBlock extends NodeMaterialBlock {
  52414. /**
  52415. * Creates a new AddBlock
  52416. * @param name defines the block name
  52417. */
  52418. constructor(name: string);
  52419. /**
  52420. * Gets the current class name
  52421. * @returns the class name
  52422. */
  52423. getClassName(): string;
  52424. /**
  52425. * Gets the left operand input component
  52426. */
  52427. readonly left: NodeMaterialConnectionPoint;
  52428. /**
  52429. * Gets the right operand input component
  52430. */
  52431. readonly right: NodeMaterialConnectionPoint;
  52432. /**
  52433. * Gets the output component
  52434. */
  52435. readonly output: NodeMaterialConnectionPoint;
  52436. protected _buildBlock(state: NodeMaterialBuildState): this;
  52437. }
  52438. }
  52439. declare module BABYLON {
  52440. /**
  52441. * Block used to scale a vector by a float
  52442. */
  52443. export class ScaleBlock extends NodeMaterialBlock {
  52444. /**
  52445. * Creates a new ScaleBlock
  52446. * @param name defines the block name
  52447. */
  52448. constructor(name: string);
  52449. /**
  52450. * Gets the current class name
  52451. * @returns the class name
  52452. */
  52453. getClassName(): string;
  52454. /**
  52455. * Gets the input component
  52456. */
  52457. readonly input: NodeMaterialConnectionPoint;
  52458. /**
  52459. * Gets the factor input component
  52460. */
  52461. readonly factor: NodeMaterialConnectionPoint;
  52462. /**
  52463. * Gets the output component
  52464. */
  52465. readonly output: NodeMaterialConnectionPoint;
  52466. protected _buildBlock(state: NodeMaterialBuildState): this;
  52467. }
  52468. }
  52469. declare module BABYLON {
  52470. /**
  52471. * Block used to clamp a float
  52472. */
  52473. export class ClampBlock extends NodeMaterialBlock {
  52474. /** Gets or sets the minimum range */
  52475. minimum: number;
  52476. /** Gets or sets the maximum range */
  52477. maximum: number;
  52478. /**
  52479. * Creates a new ClampBlock
  52480. * @param name defines the block name
  52481. */
  52482. constructor(name: string);
  52483. /**
  52484. * Gets the current class name
  52485. * @returns the class name
  52486. */
  52487. getClassName(): string;
  52488. /**
  52489. * Gets the value input component
  52490. */
  52491. readonly value: NodeMaterialConnectionPoint;
  52492. /**
  52493. * Gets the output component
  52494. */
  52495. readonly output: NodeMaterialConnectionPoint;
  52496. protected _buildBlock(state: NodeMaterialBuildState): this;
  52497. }
  52498. }
  52499. declare module BABYLON {
  52500. /**
  52501. * Block used to apply a cross product between 2 vectors
  52502. */
  52503. export class CrossBlock extends NodeMaterialBlock {
  52504. /**
  52505. * Creates a new CrossBlock
  52506. * @param name defines the block name
  52507. */
  52508. constructor(name: string);
  52509. /**
  52510. * Gets the current class name
  52511. * @returns the class name
  52512. */
  52513. getClassName(): string;
  52514. /**
  52515. * Gets the left operand input component
  52516. */
  52517. readonly left: NodeMaterialConnectionPoint;
  52518. /**
  52519. * Gets the right operand input component
  52520. */
  52521. readonly right: NodeMaterialConnectionPoint;
  52522. /**
  52523. * Gets the output component
  52524. */
  52525. readonly output: NodeMaterialConnectionPoint;
  52526. protected _buildBlock(state: NodeMaterialBuildState): this;
  52527. }
  52528. }
  52529. declare module BABYLON {
  52530. /**
  52531. * Block used to apply a dot product between 2 vectors
  52532. */
  52533. export class DotBlock extends NodeMaterialBlock {
  52534. /**
  52535. * Creates a new DotBlock
  52536. * @param name defines the block name
  52537. */
  52538. constructor(name: string);
  52539. /**
  52540. * Gets the current class name
  52541. * @returns the class name
  52542. */
  52543. getClassName(): string;
  52544. /**
  52545. * Gets the left operand input component
  52546. */
  52547. readonly left: NodeMaterialConnectionPoint;
  52548. /**
  52549. * Gets the right operand input component
  52550. */
  52551. readonly right: NodeMaterialConnectionPoint;
  52552. /**
  52553. * Gets the output component
  52554. */
  52555. readonly output: NodeMaterialConnectionPoint;
  52556. protected _buildBlock(state: NodeMaterialBuildState): this;
  52557. }
  52558. }
  52559. declare module BABYLON {
  52560. /**
  52561. * Block used to remap a float from a range to a new one
  52562. */
  52563. export class RemapBlock extends NodeMaterialBlock {
  52564. /**
  52565. * Gets or sets the source range
  52566. */
  52567. sourceRange: Vector2;
  52568. /**
  52569. * Gets or sets the target range
  52570. */
  52571. targetRange: Vector2;
  52572. /**
  52573. * Creates a new RemapBlock
  52574. * @param name defines the block name
  52575. */
  52576. constructor(name: string);
  52577. /**
  52578. * Gets the current class name
  52579. * @returns the class name
  52580. */
  52581. getClassName(): string;
  52582. /**
  52583. * Gets the input component
  52584. */
  52585. readonly input: NodeMaterialConnectionPoint;
  52586. /**
  52587. * Gets the output component
  52588. */
  52589. readonly output: NodeMaterialConnectionPoint;
  52590. protected _buildBlock(state: NodeMaterialBuildState): this;
  52591. }
  52592. }
  52593. declare module BABYLON {
  52594. /**
  52595. * Block used to normalize a vector
  52596. */
  52597. export class NormalizeBlock extends NodeMaterialBlock {
  52598. /**
  52599. * Creates a new NormalizeBlock
  52600. * @param name defines the block name
  52601. */
  52602. constructor(name: string);
  52603. /**
  52604. * Gets the current class name
  52605. * @returns the class name
  52606. */
  52607. getClassName(): string;
  52608. /**
  52609. * Gets the input component
  52610. */
  52611. readonly input: NodeMaterialConnectionPoint;
  52612. /**
  52613. * Gets the output component
  52614. */
  52615. readonly output: NodeMaterialConnectionPoint;
  52616. protected _buildBlock(state: NodeMaterialBuildState): this;
  52617. }
  52618. }
  52619. declare module BABYLON {
  52620. /**
  52621. * Operations supported by the Trigonometry block
  52622. */
  52623. export enum TrigonometryBlockOperations {
  52624. /** Cos */
  52625. Cos = 0,
  52626. /** Sin */
  52627. Sin = 1,
  52628. /** Abs */
  52629. Abs = 2
  52630. }
  52631. /**
  52632. * Block used to apply trigonometry operation to floats
  52633. */
  52634. export class TrigonometryBlock extends NodeMaterialBlock {
  52635. /**
  52636. * Gets or sets the operation applied by the block
  52637. */
  52638. operation: TrigonometryBlockOperations;
  52639. /**
  52640. * Creates a new TrigonometryBlock
  52641. * @param name defines the block name
  52642. */
  52643. constructor(name: string);
  52644. /**
  52645. * Gets the current class name
  52646. * @returns the class name
  52647. */
  52648. getClassName(): string;
  52649. /**
  52650. * Gets the input component
  52651. */
  52652. readonly input: NodeMaterialConnectionPoint;
  52653. /**
  52654. * Gets the output component
  52655. */
  52656. readonly output: NodeMaterialConnectionPoint;
  52657. protected _buildBlock(state: NodeMaterialBuildState): this;
  52658. }
  52659. }
  52660. declare module BABYLON {
  52661. /**
  52662. * Block used to create a Color3/4 out of individual inputs (one for each component)
  52663. */
  52664. export class ColorMergerBlock extends NodeMaterialBlock {
  52665. /**
  52666. * Create a new ColorMergerBlock
  52667. * @param name defines the block name
  52668. */
  52669. constructor(name: string);
  52670. /**
  52671. * Gets the current class name
  52672. * @returns the class name
  52673. */
  52674. getClassName(): string;
  52675. /**
  52676. * Gets the r component (input)
  52677. */
  52678. readonly r: NodeMaterialConnectionPoint;
  52679. /**
  52680. * Gets the g component (input)
  52681. */
  52682. readonly g: NodeMaterialConnectionPoint;
  52683. /**
  52684. * Gets the b component (input)
  52685. */
  52686. readonly b: NodeMaterialConnectionPoint;
  52687. /**
  52688. * Gets the a component (input)
  52689. */
  52690. readonly a: NodeMaterialConnectionPoint;
  52691. /**
  52692. * Gets the rgba component (output)
  52693. */
  52694. readonly rgba: NodeMaterialConnectionPoint;
  52695. /**
  52696. * Gets the rgb component (output)
  52697. */
  52698. readonly rgb: NodeMaterialConnectionPoint;
  52699. protected _buildBlock(state: NodeMaterialBuildState): this;
  52700. }
  52701. }
  52702. declare module BABYLON {
  52703. /**
  52704. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  52705. */
  52706. export class VectorMergerBlock extends NodeMaterialBlock {
  52707. /**
  52708. * Create a new VectorMergerBlock
  52709. * @param name defines the block name
  52710. */
  52711. constructor(name: string);
  52712. /**
  52713. * Gets the current class name
  52714. * @returns the class name
  52715. */
  52716. getClassName(): string;
  52717. /**
  52718. * Gets the x component (input)
  52719. */
  52720. readonly x: NodeMaterialConnectionPoint;
  52721. /**
  52722. * Gets the y component (input)
  52723. */
  52724. readonly y: NodeMaterialConnectionPoint;
  52725. /**
  52726. * Gets the z component (input)
  52727. */
  52728. readonly z: NodeMaterialConnectionPoint;
  52729. /**
  52730. * Gets the w component (input)
  52731. */
  52732. readonly w: NodeMaterialConnectionPoint;
  52733. /**
  52734. * Gets the xyzw component (output)
  52735. */
  52736. readonly xyzw: NodeMaterialConnectionPoint;
  52737. /**
  52738. * Gets the xyz component (output)
  52739. */
  52740. readonly xyz: NodeMaterialConnectionPoint;
  52741. /**
  52742. * Gets the xy component (output)
  52743. */
  52744. readonly xy: NodeMaterialConnectionPoint;
  52745. protected _buildBlock(state: NodeMaterialBuildState): this;
  52746. }
  52747. }
  52748. declare module BABYLON {
  52749. /**
  52750. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  52751. */
  52752. export class ColorSplitterBlock extends NodeMaterialBlock {
  52753. /**
  52754. * Create a new ColorSplitterBlock
  52755. * @param name defines the block name
  52756. */
  52757. constructor(name: string);
  52758. /**
  52759. * Gets the current class name
  52760. * @returns the class name
  52761. */
  52762. getClassName(): string;
  52763. /**
  52764. * Gets the rgba component (input)
  52765. */
  52766. readonly rgba: NodeMaterialConnectionPoint;
  52767. /**
  52768. * Gets the rgb component (input)
  52769. */
  52770. readonly rgbIn: NodeMaterialConnectionPoint;
  52771. /**
  52772. * Gets the rgb component (output)
  52773. */
  52774. readonly rgbOut: NodeMaterialConnectionPoint;
  52775. /**
  52776. * Gets the r component (output)
  52777. */
  52778. readonly r: NodeMaterialConnectionPoint;
  52779. /**
  52780. * Gets the g component (output)
  52781. */
  52782. readonly g: NodeMaterialConnectionPoint;
  52783. /**
  52784. * Gets the b component (output)
  52785. */
  52786. readonly b: NodeMaterialConnectionPoint;
  52787. /**
  52788. * Gets the a component (output)
  52789. */
  52790. readonly a: NodeMaterialConnectionPoint;
  52791. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52792. }
  52793. }
  52794. declare module BABYLON {
  52795. /**
  52796. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  52797. */
  52798. export class VectorSplitterBlock extends NodeMaterialBlock {
  52799. /**
  52800. * Create a new VectorSplitterBlock
  52801. * @param name defines the block name
  52802. */
  52803. constructor(name: string);
  52804. /**
  52805. * Gets the current class name
  52806. * @returns the class name
  52807. */
  52808. getClassName(): string;
  52809. /**
  52810. * Gets the xyzw component (input)
  52811. */
  52812. readonly xyzw: NodeMaterialConnectionPoint;
  52813. /**
  52814. * Gets the xyz component (input)
  52815. */
  52816. readonly xyzIn: NodeMaterialConnectionPoint;
  52817. /**
  52818. * Gets the xy component (input)
  52819. */
  52820. readonly xyIn: NodeMaterialConnectionPoint;
  52821. /**
  52822. * Gets the xyz component (output)
  52823. */
  52824. readonly xyzOut: NodeMaterialConnectionPoint;
  52825. /**
  52826. * Gets the xy component (output)
  52827. */
  52828. readonly xyOut: NodeMaterialConnectionPoint;
  52829. /**
  52830. * Gets the x component (output)
  52831. */
  52832. readonly x: NodeMaterialConnectionPoint;
  52833. /**
  52834. * Gets the y component (output)
  52835. */
  52836. readonly y: NodeMaterialConnectionPoint;
  52837. /**
  52838. * Gets the z component (output)
  52839. */
  52840. readonly z: NodeMaterialConnectionPoint;
  52841. /**
  52842. * Gets the w component (output)
  52843. */
  52844. readonly w: NodeMaterialConnectionPoint;
  52845. protected _buildBlock(state: NodeMaterialBuildState): this;
  52846. }
  52847. }
  52848. declare module BABYLON {
  52849. /**
  52850. * Effect Render Options
  52851. */
  52852. export interface IEffectRendererOptions {
  52853. /**
  52854. * Defines the vertices positions.
  52855. */
  52856. positions?: number[];
  52857. /**
  52858. * Defines the indices.
  52859. */
  52860. indices?: number[];
  52861. }
  52862. /**
  52863. * Helper class to render one or more effects
  52864. */
  52865. export class EffectRenderer {
  52866. private engine;
  52867. private static _DefaultOptions;
  52868. private _vertexBuffers;
  52869. private _indexBuffer;
  52870. private _ringBufferIndex;
  52871. private _ringScreenBuffer;
  52872. private _fullscreenViewport;
  52873. private _getNextFrameBuffer;
  52874. /**
  52875. * Creates an effect renderer
  52876. * @param engine the engine to use for rendering
  52877. * @param options defines the options of the effect renderer
  52878. */
  52879. constructor(engine: Engine, options?: IEffectRendererOptions);
  52880. /**
  52881. * Sets the current viewport in normalized coordinates 0-1
  52882. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  52883. */
  52884. setViewport(viewport?: Viewport): void;
  52885. /**
  52886. * Sets the current effect wrapper to use during draw.
  52887. * The effect needs to be ready before calling this api.
  52888. * This also sets the default full screen position attribute.
  52889. * @param effectWrapper Defines the effect to draw with
  52890. */
  52891. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  52892. /**
  52893. * Draws a full screen quad.
  52894. */
  52895. draw(): void;
  52896. /**
  52897. * renders one or more effects to a specified texture
  52898. * @param effectWrappers list of effects to renderer
  52899. * @param outputTexture texture to draw to, if null it will render to the screen
  52900. */
  52901. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  52902. /**
  52903. * Disposes of the effect renderer
  52904. */
  52905. dispose(): void;
  52906. }
  52907. /**
  52908. * Options to create an EffectWrapper
  52909. */
  52910. interface EffectWrapperCreationOptions {
  52911. /**
  52912. * Engine to use to create the effect
  52913. */
  52914. engine: Engine;
  52915. /**
  52916. * Fragment shader for the effect
  52917. */
  52918. fragmentShader: string;
  52919. /**
  52920. * Vertex shader for the effect
  52921. */
  52922. vertexShader?: string;
  52923. /**
  52924. * Attributes to use in the shader
  52925. */
  52926. attributeNames?: Array<string>;
  52927. /**
  52928. * Uniforms to use in the shader
  52929. */
  52930. uniformNames?: Array<string>;
  52931. /**
  52932. * Texture sampler names to use in the shader
  52933. */
  52934. samplerNames?: Array<string>;
  52935. /**
  52936. * The friendly name of the effect displayed in Spector.
  52937. */
  52938. name?: string;
  52939. }
  52940. /**
  52941. * Wraps an effect to be used for rendering
  52942. */
  52943. export class EffectWrapper {
  52944. /**
  52945. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  52946. */
  52947. onApplyObservable: Observable<{}>;
  52948. /**
  52949. * The underlying effect
  52950. */
  52951. effect: Effect;
  52952. /**
  52953. * Creates an effect to be renderer
  52954. * @param creationOptions options to create the effect
  52955. */
  52956. constructor(creationOptions: EffectWrapperCreationOptions);
  52957. /**
  52958. * Disposes of the effect wrapper
  52959. */
  52960. dispose(): void;
  52961. }
  52962. }
  52963. declare module BABYLON {
  52964. /**
  52965. * Helper class to push actions to a pool of workers.
  52966. */
  52967. export class WorkerPool implements IDisposable {
  52968. private _workerInfos;
  52969. private _pendingActions;
  52970. /**
  52971. * Constructor
  52972. * @param workers Array of workers to use for actions
  52973. */
  52974. constructor(workers: Array<Worker>);
  52975. /**
  52976. * Terminates all workers and clears any pending actions.
  52977. */
  52978. dispose(): void;
  52979. /**
  52980. * Pushes an action to the worker pool. If all the workers are active, the action will be
  52981. * pended until a worker has completed its action.
  52982. * @param action The action to perform. Call onComplete when the action is complete.
  52983. */
  52984. push(action: (worker: Worker, onComplete: () => void) => void): void;
  52985. private _execute;
  52986. }
  52987. }
  52988. declare module BABYLON {
  52989. /**
  52990. * Configuration for Draco compression
  52991. */
  52992. export interface IDracoCompressionConfiguration {
  52993. /**
  52994. * Configuration for the decoder.
  52995. */
  52996. decoder: {
  52997. /**
  52998. * The url to the WebAssembly module.
  52999. */
  53000. wasmUrl?: string;
  53001. /**
  53002. * The url to the WebAssembly binary.
  53003. */
  53004. wasmBinaryUrl?: string;
  53005. /**
  53006. * The url to the fallback JavaScript module.
  53007. */
  53008. fallbackUrl?: string;
  53009. };
  53010. }
  53011. /**
  53012. * Draco compression (https://google.github.io/draco/)
  53013. *
  53014. * This class wraps the Draco module.
  53015. *
  53016. * **Encoder**
  53017. *
  53018. * The encoder is not currently implemented.
  53019. *
  53020. * **Decoder**
  53021. *
  53022. * 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.
  53023. *
  53024. * To update the configuration, use the following code:
  53025. * ```javascript
  53026. * DracoCompression.Configuration = {
  53027. * decoder: {
  53028. * wasmUrl: "<url to the WebAssembly library>",
  53029. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  53030. * fallbackUrl: "<url to the fallback JavaScript library>",
  53031. * }
  53032. * };
  53033. * ```
  53034. *
  53035. * 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.
  53036. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  53037. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  53038. *
  53039. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  53040. * ```javascript
  53041. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  53042. * ```
  53043. *
  53044. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  53045. */
  53046. export class DracoCompression implements IDisposable {
  53047. private _workerPoolPromise?;
  53048. private _decoderModulePromise?;
  53049. /**
  53050. * The configuration. Defaults to the following urls:
  53051. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  53052. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  53053. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  53054. */
  53055. static Configuration: IDracoCompressionConfiguration;
  53056. /**
  53057. * Returns true if the decoder configuration is available.
  53058. */
  53059. static readonly DecoderAvailable: boolean;
  53060. /**
  53061. * Default number of workers to create when creating the draco compression object.
  53062. */
  53063. static DefaultNumWorkers: number;
  53064. private static GetDefaultNumWorkers;
  53065. private static _Default;
  53066. /**
  53067. * Default instance for the draco compression object.
  53068. */
  53069. static readonly Default: DracoCompression;
  53070. /**
  53071. * Constructor
  53072. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  53073. */
  53074. constructor(numWorkers?: number);
  53075. /**
  53076. * Stop all async operations and release resources.
  53077. */
  53078. dispose(): void;
  53079. /**
  53080. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  53081. * @returns a promise that resolves when ready
  53082. */
  53083. whenReadyAsync(): Promise<void>;
  53084. /**
  53085. * Decode Draco compressed mesh data to vertex data.
  53086. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  53087. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  53088. * @returns A promise that resolves with the decoded vertex data
  53089. */
  53090. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  53091. [kind: string]: number;
  53092. }): Promise<VertexData>;
  53093. }
  53094. }
  53095. declare module BABYLON {
  53096. /**
  53097. * Class for building Constructive Solid Geometry
  53098. */
  53099. export class CSG {
  53100. private polygons;
  53101. /**
  53102. * The world matrix
  53103. */
  53104. matrix: Matrix;
  53105. /**
  53106. * Stores the position
  53107. */
  53108. position: Vector3;
  53109. /**
  53110. * Stores the rotation
  53111. */
  53112. rotation: Vector3;
  53113. /**
  53114. * Stores the rotation quaternion
  53115. */
  53116. rotationQuaternion: Nullable<Quaternion>;
  53117. /**
  53118. * Stores the scaling vector
  53119. */
  53120. scaling: Vector3;
  53121. /**
  53122. * Convert the Mesh to CSG
  53123. * @param mesh The Mesh to convert to CSG
  53124. * @returns A new CSG from the Mesh
  53125. */
  53126. static FromMesh(mesh: Mesh): CSG;
  53127. /**
  53128. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  53129. * @param polygons Polygons used to construct a CSG solid
  53130. */
  53131. private static FromPolygons;
  53132. /**
  53133. * Clones, or makes a deep copy, of the CSG
  53134. * @returns A new CSG
  53135. */
  53136. clone(): CSG;
  53137. /**
  53138. * Unions this CSG with another CSG
  53139. * @param csg The CSG to union against this CSG
  53140. * @returns The unioned CSG
  53141. */
  53142. union(csg: CSG): CSG;
  53143. /**
  53144. * Unions this CSG with another CSG in place
  53145. * @param csg The CSG to union against this CSG
  53146. */
  53147. unionInPlace(csg: CSG): void;
  53148. /**
  53149. * Subtracts this CSG with another CSG
  53150. * @param csg The CSG to subtract against this CSG
  53151. * @returns A new CSG
  53152. */
  53153. subtract(csg: CSG): CSG;
  53154. /**
  53155. * Subtracts this CSG with another CSG in place
  53156. * @param csg The CSG to subtact against this CSG
  53157. */
  53158. subtractInPlace(csg: CSG): void;
  53159. /**
  53160. * Intersect this CSG with another CSG
  53161. * @param csg The CSG to intersect against this CSG
  53162. * @returns A new CSG
  53163. */
  53164. intersect(csg: CSG): CSG;
  53165. /**
  53166. * Intersects this CSG with another CSG in place
  53167. * @param csg The CSG to intersect against this CSG
  53168. */
  53169. intersectInPlace(csg: CSG): void;
  53170. /**
  53171. * Return a new CSG solid with solid and empty space switched. This solid is
  53172. * not modified.
  53173. * @returns A new CSG solid with solid and empty space switched
  53174. */
  53175. inverse(): CSG;
  53176. /**
  53177. * Inverses the CSG in place
  53178. */
  53179. inverseInPlace(): void;
  53180. /**
  53181. * This is used to keep meshes transformations so they can be restored
  53182. * when we build back a Babylon Mesh
  53183. * NB : All CSG operations are performed in world coordinates
  53184. * @param csg The CSG to copy the transform attributes from
  53185. * @returns This CSG
  53186. */
  53187. copyTransformAttributes(csg: CSG): CSG;
  53188. /**
  53189. * Build Raw mesh from CSG
  53190. * Coordinates here are in world space
  53191. * @param name The name of the mesh geometry
  53192. * @param scene The Scene
  53193. * @param keepSubMeshes Specifies if the submeshes should be kept
  53194. * @returns A new Mesh
  53195. */
  53196. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  53197. /**
  53198. * Build Mesh from CSG taking material and transforms into account
  53199. * @param name The name of the Mesh
  53200. * @param material The material of the Mesh
  53201. * @param scene The Scene
  53202. * @param keepSubMeshes Specifies if submeshes should be kept
  53203. * @returns The new Mesh
  53204. */
  53205. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  53206. }
  53207. }
  53208. declare module BABYLON {
  53209. /**
  53210. * Class used to create a trail following a mesh
  53211. */
  53212. export class TrailMesh extends Mesh {
  53213. private _generator;
  53214. private _autoStart;
  53215. private _running;
  53216. private _diameter;
  53217. private _length;
  53218. private _sectionPolygonPointsCount;
  53219. private _sectionVectors;
  53220. private _sectionNormalVectors;
  53221. private _beforeRenderObserver;
  53222. /**
  53223. * @constructor
  53224. * @param name The value used by scene.getMeshByName() to do a lookup.
  53225. * @param generator The mesh to generate a trail.
  53226. * @param scene The scene to add this mesh to.
  53227. * @param diameter Diameter of trailing mesh. Default is 1.
  53228. * @param length Length of trailing mesh. Default is 60.
  53229. * @param autoStart Automatically start trailing mesh. Default true.
  53230. */
  53231. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  53232. /**
  53233. * "TrailMesh"
  53234. * @returns "TrailMesh"
  53235. */
  53236. getClassName(): string;
  53237. private _createMesh;
  53238. /**
  53239. * Start trailing mesh.
  53240. */
  53241. start(): void;
  53242. /**
  53243. * Stop trailing mesh.
  53244. */
  53245. stop(): void;
  53246. /**
  53247. * Update trailing mesh geometry.
  53248. */
  53249. update(): void;
  53250. /**
  53251. * Returns a new TrailMesh object.
  53252. * @param name is a string, the name given to the new mesh
  53253. * @param newGenerator use new generator object for cloned trail mesh
  53254. * @returns a new mesh
  53255. */
  53256. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  53257. /**
  53258. * Serializes this trail mesh
  53259. * @param serializationObject object to write serialization to
  53260. */
  53261. serialize(serializationObject: any): void;
  53262. /**
  53263. * Parses a serialized trail mesh
  53264. * @param parsedMesh the serialized mesh
  53265. * @param scene the scene to create the trail mesh in
  53266. * @returns the created trail mesh
  53267. */
  53268. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  53269. }
  53270. }
  53271. declare module BABYLON {
  53272. /**
  53273. * Class containing static functions to help procedurally build meshes
  53274. */
  53275. export class TiledBoxBuilder {
  53276. /**
  53277. * Creates a box mesh
  53278. * faceTiles sets the pattern, tile size and number of tiles for a face * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of 6 Color3 elements) and `faceUV` (an array of 6 Vector4 elements)
  53279. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53280. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53281. * * 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
  53282. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53283. * @param name defines the name of the mesh
  53284. * @param options defines the options used to create the mesh
  53285. * @param scene defines the hosting scene
  53286. * @returns the box mesh
  53287. */
  53288. static CreateTiledBox(name: string, options: {
  53289. pattern?: number;
  53290. width?: number;
  53291. height?: number;
  53292. depth?: number;
  53293. tileSize?: number;
  53294. tileWidth?: number;
  53295. tileHeight?: number;
  53296. alignHorizontal?: number;
  53297. alignVertical?: number;
  53298. faceUV?: Vector4[];
  53299. faceColors?: Color4[];
  53300. sideOrientation?: number;
  53301. updatable?: boolean;
  53302. }, scene?: Nullable<Scene>): Mesh;
  53303. }
  53304. }
  53305. declare module BABYLON {
  53306. /**
  53307. * Class containing static functions to help procedurally build meshes
  53308. */
  53309. export class TorusKnotBuilder {
  53310. /**
  53311. * Creates a torus knot mesh
  53312. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  53313. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  53314. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  53315. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  53316. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53317. * * 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
  53318. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53319. * @param name defines the name of the mesh
  53320. * @param options defines the options used to create the mesh
  53321. * @param scene defines the hosting scene
  53322. * @returns the torus knot mesh
  53323. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  53324. */
  53325. static CreateTorusKnot(name: string, options: {
  53326. radius?: number;
  53327. tube?: number;
  53328. radialSegments?: number;
  53329. tubularSegments?: number;
  53330. p?: number;
  53331. q?: number;
  53332. updatable?: boolean;
  53333. sideOrientation?: number;
  53334. frontUVs?: Vector4;
  53335. backUVs?: Vector4;
  53336. }, scene: any): Mesh;
  53337. }
  53338. }
  53339. declare module BABYLON {
  53340. /**
  53341. * Polygon
  53342. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  53343. */
  53344. export class Polygon {
  53345. /**
  53346. * Creates a rectangle
  53347. * @param xmin bottom X coord
  53348. * @param ymin bottom Y coord
  53349. * @param xmax top X coord
  53350. * @param ymax top Y coord
  53351. * @returns points that make the resulting rectation
  53352. */
  53353. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  53354. /**
  53355. * Creates a circle
  53356. * @param radius radius of circle
  53357. * @param cx scale in x
  53358. * @param cy scale in y
  53359. * @param numberOfSides number of sides that make up the circle
  53360. * @returns points that make the resulting circle
  53361. */
  53362. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  53363. /**
  53364. * Creates a polygon from input string
  53365. * @param input Input polygon data
  53366. * @returns the parsed points
  53367. */
  53368. static Parse(input: string): Vector2[];
  53369. /**
  53370. * Starts building a polygon from x and y coordinates
  53371. * @param x x coordinate
  53372. * @param y y coordinate
  53373. * @returns the started path2
  53374. */
  53375. static StartingAt(x: number, y: number): Path2;
  53376. }
  53377. /**
  53378. * Builds a polygon
  53379. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  53380. */
  53381. export class PolygonMeshBuilder {
  53382. private _points;
  53383. private _outlinepoints;
  53384. private _holes;
  53385. private _name;
  53386. private _scene;
  53387. private _epoints;
  53388. private _eholes;
  53389. private _addToepoint;
  53390. /**
  53391. * Babylon reference to the earcut plugin.
  53392. */
  53393. bjsEarcut: any;
  53394. /**
  53395. * Creates a PolygonMeshBuilder
  53396. * @param name name of the builder
  53397. * @param contours Path of the polygon
  53398. * @param scene scene to add to when creating the mesh
  53399. * @param earcutInjection can be used to inject your own earcut reference
  53400. */
  53401. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  53402. /**
  53403. * Adds a whole within the polygon
  53404. * @param hole Array of points defining the hole
  53405. * @returns this
  53406. */
  53407. addHole(hole: Vector2[]): PolygonMeshBuilder;
  53408. /**
  53409. * Creates the polygon
  53410. * @param updatable If the mesh should be updatable
  53411. * @param depth The depth of the mesh created
  53412. * @returns the created mesh
  53413. */
  53414. build(updatable?: boolean, depth?: number): Mesh;
  53415. /**
  53416. * Creates the polygon
  53417. * @param depth The depth of the mesh created
  53418. * @returns the created VertexData
  53419. */
  53420. buildVertexData(depth?: number): VertexData;
  53421. /**
  53422. * Adds a side to the polygon
  53423. * @param positions points that make the polygon
  53424. * @param normals normals of the polygon
  53425. * @param uvs uvs of the polygon
  53426. * @param indices indices of the polygon
  53427. * @param bounds bounds of the polygon
  53428. * @param points points of the polygon
  53429. * @param depth depth of the polygon
  53430. * @param flip flip of the polygon
  53431. */
  53432. private addSide;
  53433. }
  53434. }
  53435. declare module BABYLON {
  53436. /**
  53437. * Class containing static functions to help procedurally build meshes
  53438. */
  53439. export class PolygonBuilder {
  53440. /**
  53441. * Creates a polygon mesh
  53442. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  53443. * * 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
  53444. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53445. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53446. * * 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)
  53447. * * Remember you can only change the shape positions, not their number when updating a polygon
  53448. * @param name defines the name of the mesh
  53449. * @param options defines the options used to create the mesh
  53450. * @param scene defines the hosting scene
  53451. * @param earcutInjection can be used to inject your own earcut reference
  53452. * @returns the polygon mesh
  53453. */
  53454. static CreatePolygon(name: string, options: {
  53455. shape: Vector3[];
  53456. holes?: Vector3[][];
  53457. depth?: number;
  53458. faceUV?: Vector4[];
  53459. faceColors?: Color4[];
  53460. updatable?: boolean;
  53461. sideOrientation?: number;
  53462. frontUVs?: Vector4;
  53463. backUVs?: Vector4;
  53464. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53465. /**
  53466. * Creates an extruded polygon mesh, with depth in the Y direction.
  53467. * * 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)
  53468. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53469. * @param name defines the name of the mesh
  53470. * @param options defines the options used to create the mesh
  53471. * @param scene defines the hosting scene
  53472. * @param earcutInjection can be used to inject your own earcut reference
  53473. * @returns the polygon mesh
  53474. */
  53475. static ExtrudePolygon(name: string, options: {
  53476. shape: Vector3[];
  53477. holes?: Vector3[][];
  53478. depth?: number;
  53479. faceUV?: Vector4[];
  53480. faceColors?: Color4[];
  53481. updatable?: boolean;
  53482. sideOrientation?: number;
  53483. frontUVs?: Vector4;
  53484. backUVs?: Vector4;
  53485. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53486. }
  53487. }
  53488. declare module BABYLON {
  53489. /**
  53490. * Class containing static functions to help procedurally build meshes
  53491. */
  53492. export class LatheBuilder {
  53493. /**
  53494. * Creates lathe mesh.
  53495. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  53496. * * 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
  53497. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  53498. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  53499. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  53500. * * 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
  53501. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  53502. * * 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
  53503. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53504. * * 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
  53505. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53507. * @param name defines the name of the mesh
  53508. * @param options defines the options used to create the mesh
  53509. * @param scene defines the hosting scene
  53510. * @returns the lathe mesh
  53511. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  53512. */
  53513. static CreateLathe(name: string, options: {
  53514. shape: Vector3[];
  53515. radius?: number;
  53516. tessellation?: number;
  53517. clip?: number;
  53518. arc?: number;
  53519. closed?: boolean;
  53520. updatable?: boolean;
  53521. sideOrientation?: number;
  53522. frontUVs?: Vector4;
  53523. backUVs?: Vector4;
  53524. cap?: number;
  53525. invertUV?: boolean;
  53526. }, scene?: Nullable<Scene>): Mesh;
  53527. }
  53528. }
  53529. declare module BABYLON {
  53530. /**
  53531. * Class containing static functions to help procedurally build meshes
  53532. */
  53533. export class TiledPlaneBuilder {
  53534. /**
  53535. * Creates a tiled plane mesh
  53536. * * The parameter `pattern` will, depending on value, do nothing or
  53537. * * * flip (reflect about central vertical) alternate tiles across and up
  53538. * * * flip every tile on alternate rows
  53539. * * * rotate (180 degs) alternate tiles across and up
  53540. * * * rotate every tile on alternate rows
  53541. * * * flip and rotate alternate tiles across and up
  53542. * * * flip and rotate every tile on alternate rows
  53543. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  53544. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  53545. * * 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
  53546. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53547. * * 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)
  53548. * * 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)
  53549. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53550. * @param name defines the name of the mesh
  53551. * @param options defines the options used to create the mesh
  53552. * @param scene defines the hosting scene
  53553. * @returns the box mesh
  53554. */
  53555. static CreateTiledPlane(name: string, options: {
  53556. pattern?: number;
  53557. tileSize?: number;
  53558. tileWidth?: number;
  53559. tileHeight?: number;
  53560. size?: number;
  53561. width?: number;
  53562. height?: number;
  53563. alignHorizontal?: number;
  53564. alignVertical?: number;
  53565. sideOrientation?: number;
  53566. frontUVs?: Vector4;
  53567. backUVs?: Vector4;
  53568. updatable?: boolean;
  53569. }, scene?: Nullable<Scene>): Mesh;
  53570. }
  53571. }
  53572. declare module BABYLON {
  53573. /**
  53574. * Class containing static functions to help procedurally build meshes
  53575. */
  53576. export class TubeBuilder {
  53577. /**
  53578. * Creates a tube mesh.
  53579. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53580. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  53581. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  53582. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  53583. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  53584. * * 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)
  53585. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  53586. * * 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
  53587. * * 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
  53588. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53589. * * 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
  53590. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53592. * @param name defines the name of the mesh
  53593. * @param options defines the options used to create the mesh
  53594. * @param scene defines the hosting scene
  53595. * @returns the tube mesh
  53596. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53597. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  53598. */
  53599. static CreateTube(name: string, options: {
  53600. path: Vector3[];
  53601. radius?: number;
  53602. tessellation?: number;
  53603. radiusFunction?: {
  53604. (i: number, distance: number): number;
  53605. };
  53606. cap?: number;
  53607. arc?: number;
  53608. updatable?: boolean;
  53609. sideOrientation?: number;
  53610. frontUVs?: Vector4;
  53611. backUVs?: Vector4;
  53612. instance?: Mesh;
  53613. invertUV?: boolean;
  53614. }, scene?: Nullable<Scene>): Mesh;
  53615. }
  53616. }
  53617. declare module BABYLON {
  53618. /**
  53619. * Class containing static functions to help procedurally build meshes
  53620. */
  53621. export class IcoSphereBuilder {
  53622. /**
  53623. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  53624. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  53625. * * 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`)
  53626. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  53627. * * 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
  53628. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53629. * * 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
  53630. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53631. * @param name defines the name of the mesh
  53632. * @param options defines the options used to create the mesh
  53633. * @param scene defines the hosting scene
  53634. * @returns the icosahedron mesh
  53635. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  53636. */
  53637. static CreateIcoSphere(name: string, options: {
  53638. radius?: number;
  53639. radiusX?: number;
  53640. radiusY?: number;
  53641. radiusZ?: number;
  53642. flat?: boolean;
  53643. subdivisions?: number;
  53644. sideOrientation?: number;
  53645. frontUVs?: Vector4;
  53646. backUVs?: Vector4;
  53647. updatable?: boolean;
  53648. }, scene?: Nullable<Scene>): Mesh;
  53649. }
  53650. }
  53651. declare module BABYLON {
  53652. /**
  53653. * Class containing static functions to help procedurally build meshes
  53654. */
  53655. export class DecalBuilder {
  53656. /**
  53657. * Creates a decal mesh.
  53658. * 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
  53659. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  53660. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  53661. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  53662. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  53663. * @param name defines the name of the mesh
  53664. * @param sourceMesh defines the mesh where the decal must be applied
  53665. * @param options defines the options used to create the mesh
  53666. * @param scene defines the hosting scene
  53667. * @returns the decal mesh
  53668. * @see https://doc.babylonjs.com/how_to/decals
  53669. */
  53670. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  53671. position?: Vector3;
  53672. normal?: Vector3;
  53673. size?: Vector3;
  53674. angle?: number;
  53675. }): Mesh;
  53676. }
  53677. }
  53678. declare module BABYLON {
  53679. /**
  53680. * Class containing static functions to help procedurally build meshes
  53681. */
  53682. export class MeshBuilder {
  53683. /**
  53684. * Creates a box mesh
  53685. * * The parameter `size` sets the size (float) of each box side (default 1)
  53686. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  53687. * * 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)
  53688. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53689. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53690. * * 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
  53691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53692. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53693. * @param name defines the name of the mesh
  53694. * @param options defines the options used to create the mesh
  53695. * @param scene defines the hosting scene
  53696. * @returns the box mesh
  53697. */
  53698. static CreateBox(name: string, options: {
  53699. size?: number;
  53700. width?: number;
  53701. height?: number;
  53702. depth?: number;
  53703. faceUV?: Vector4[];
  53704. faceColors?: Color4[];
  53705. sideOrientation?: number;
  53706. frontUVs?: Vector4;
  53707. backUVs?: Vector4;
  53708. updatable?: boolean;
  53709. }, scene?: Nullable<Scene>): Mesh;
  53710. /**
  53711. * Creates a tiled box mesh
  53712. * * faceTiles sets the pattern, tile size and number of tiles for a face
  53713. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53714. * @param name defines the name of the mesh
  53715. * @param options defines the options used to create the mesh
  53716. * @param scene defines the hosting scene
  53717. * @returns the tiled box mesh
  53718. */
  53719. static CreateTiledBox(name: string, options: {
  53720. pattern?: number;
  53721. size?: number;
  53722. width?: number;
  53723. height?: number;
  53724. depth: number;
  53725. tileSize?: number;
  53726. tileWidth?: number;
  53727. tileHeight?: number;
  53728. faceUV?: Vector4[];
  53729. faceColors?: Color4[];
  53730. alignHorizontal?: number;
  53731. alignVertical?: number;
  53732. sideOrientation?: number;
  53733. updatable?: boolean;
  53734. }, scene?: Nullable<Scene>): Mesh;
  53735. /**
  53736. * Creates a sphere mesh
  53737. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  53738. * * 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`)
  53739. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  53740. * * 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
  53741. * * 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)
  53742. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53743. * * 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
  53744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53745. * @param name defines the name of the mesh
  53746. * @param options defines the options used to create the mesh
  53747. * @param scene defines the hosting scene
  53748. * @returns the sphere mesh
  53749. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  53750. */
  53751. static CreateSphere(name: string, options: {
  53752. segments?: number;
  53753. diameter?: number;
  53754. diameterX?: number;
  53755. diameterY?: number;
  53756. diameterZ?: number;
  53757. arc?: number;
  53758. slice?: number;
  53759. sideOrientation?: number;
  53760. frontUVs?: Vector4;
  53761. backUVs?: Vector4;
  53762. updatable?: boolean;
  53763. }, scene?: Nullable<Scene>): Mesh;
  53764. /**
  53765. * Creates a plane polygonal mesh. By default, this is a disc
  53766. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  53767. * * 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
  53768. * * 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
  53769. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53770. * * 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
  53771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53772. * @param name defines the name of the mesh
  53773. * @param options defines the options used to create the mesh
  53774. * @param scene defines the hosting scene
  53775. * @returns the plane polygonal mesh
  53776. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  53777. */
  53778. static CreateDisc(name: string, options: {
  53779. radius?: number;
  53780. tessellation?: number;
  53781. arc?: number;
  53782. updatable?: boolean;
  53783. sideOrientation?: number;
  53784. frontUVs?: Vector4;
  53785. backUVs?: Vector4;
  53786. }, scene?: Nullable<Scene>): Mesh;
  53787. /**
  53788. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  53789. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  53790. * * 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`)
  53791. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  53792. * * 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
  53793. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53794. * * 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
  53795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53796. * @param name defines the name of the mesh
  53797. * @param options defines the options used to create the mesh
  53798. * @param scene defines the hosting scene
  53799. * @returns the icosahedron mesh
  53800. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  53801. */
  53802. static CreateIcoSphere(name: string, options: {
  53803. radius?: number;
  53804. radiusX?: number;
  53805. radiusY?: number;
  53806. radiusZ?: number;
  53807. flat?: boolean;
  53808. subdivisions?: number;
  53809. sideOrientation?: number;
  53810. frontUVs?: Vector4;
  53811. backUVs?: Vector4;
  53812. updatable?: boolean;
  53813. }, scene?: Nullable<Scene>): Mesh;
  53814. /**
  53815. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53816. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53817. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53818. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53819. * * 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
  53820. * * 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
  53821. * * 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
  53822. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53823. * * 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
  53824. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53825. * * 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
  53826. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53827. * * 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
  53828. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53829. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53830. * @param name defines the name of the mesh
  53831. * @param options defines the options used to create the mesh
  53832. * @param scene defines the hosting scene
  53833. * @returns the ribbon mesh
  53834. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53835. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53836. */
  53837. static CreateRibbon(name: string, options: {
  53838. pathArray: Vector3[][];
  53839. closeArray?: boolean;
  53840. closePath?: boolean;
  53841. offset?: number;
  53842. updatable?: boolean;
  53843. sideOrientation?: number;
  53844. frontUVs?: Vector4;
  53845. backUVs?: Vector4;
  53846. instance?: Mesh;
  53847. invertUV?: boolean;
  53848. uvs?: Vector2[];
  53849. colors?: Color4[];
  53850. }, scene?: Nullable<Scene>): Mesh;
  53851. /**
  53852. * Creates a cylinder or a cone mesh
  53853. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  53854. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  53855. * * 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.
  53856. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  53857. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  53858. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  53859. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  53860. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  53861. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  53862. * * 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).
  53863. * * 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
  53864. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  53865. * * 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
  53866. * * 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.
  53867. * * If `enclose` is false, a ring surface is one element.
  53868. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  53869. * * 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
  53870. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53871. * * 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
  53872. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53873. * @param name defines the name of the mesh
  53874. * @param options defines the options used to create the mesh
  53875. * @param scene defines the hosting scene
  53876. * @returns the cylinder mesh
  53877. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  53878. */
  53879. static CreateCylinder(name: string, options: {
  53880. height?: number;
  53881. diameterTop?: number;
  53882. diameterBottom?: number;
  53883. diameter?: number;
  53884. tessellation?: number;
  53885. subdivisions?: number;
  53886. arc?: number;
  53887. faceColors?: Color4[];
  53888. faceUV?: Vector4[];
  53889. updatable?: boolean;
  53890. hasRings?: boolean;
  53891. enclose?: boolean;
  53892. cap?: number;
  53893. sideOrientation?: number;
  53894. frontUVs?: Vector4;
  53895. backUVs?: Vector4;
  53896. }, scene?: Nullable<Scene>): Mesh;
  53897. /**
  53898. * Creates a torus mesh
  53899. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  53900. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  53901. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  53902. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53903. * * 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
  53904. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53905. * @param name defines the name of the mesh
  53906. * @param options defines the options used to create the mesh
  53907. * @param scene defines the hosting scene
  53908. * @returns the torus mesh
  53909. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  53910. */
  53911. static CreateTorus(name: string, options: {
  53912. diameter?: number;
  53913. thickness?: number;
  53914. tessellation?: number;
  53915. updatable?: boolean;
  53916. sideOrientation?: number;
  53917. frontUVs?: Vector4;
  53918. backUVs?: Vector4;
  53919. }, scene?: Nullable<Scene>): Mesh;
  53920. /**
  53921. * Creates a torus knot mesh
  53922. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  53923. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  53924. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  53925. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  53926. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53927. * * 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
  53928. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53929. * @param name defines the name of the mesh
  53930. * @param options defines the options used to create the mesh
  53931. * @param scene defines the hosting scene
  53932. * @returns the torus knot mesh
  53933. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  53934. */
  53935. static CreateTorusKnot(name: string, options: {
  53936. radius?: number;
  53937. tube?: number;
  53938. radialSegments?: number;
  53939. tubularSegments?: number;
  53940. p?: number;
  53941. q?: number;
  53942. updatable?: boolean;
  53943. sideOrientation?: number;
  53944. frontUVs?: Vector4;
  53945. backUVs?: Vector4;
  53946. }, scene?: Nullable<Scene>): Mesh;
  53947. /**
  53948. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  53949. * * 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
  53950. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  53951. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  53952. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  53953. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  53954. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  53955. * * 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
  53956. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  53957. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53958. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  53959. * @param name defines the name of the new line system
  53960. * @param options defines the options used to create the line system
  53961. * @param scene defines the hosting scene
  53962. * @returns a new line system mesh
  53963. */
  53964. static CreateLineSystem(name: string, options: {
  53965. lines: Vector3[][];
  53966. updatable?: boolean;
  53967. instance?: Nullable<LinesMesh>;
  53968. colors?: Nullable<Color4[][]>;
  53969. useVertexAlpha?: boolean;
  53970. }, scene: Nullable<Scene>): LinesMesh;
  53971. /**
  53972. * Creates a line mesh
  53973. * 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
  53974. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  53975. * * The parameter `points` is an array successive Vector3
  53976. * * 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
  53977. * * The optional parameter `colors` is an array of successive Color4, one per line point
  53978. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  53979. * * When updating an instance, remember that only point positions can change, not the number of points
  53980. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53981. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  53982. * @param name defines the name of the new line system
  53983. * @param options defines the options used to create the line system
  53984. * @param scene defines the hosting scene
  53985. * @returns a new line mesh
  53986. */
  53987. static CreateLines(name: string, options: {
  53988. points: Vector3[];
  53989. updatable?: boolean;
  53990. instance?: Nullable<LinesMesh>;
  53991. colors?: Color4[];
  53992. useVertexAlpha?: boolean;
  53993. }, scene?: Nullable<Scene>): LinesMesh;
  53994. /**
  53995. * Creates a dashed line mesh
  53996. * * 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
  53997. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  53998. * * The parameter `points` is an array successive Vector3
  53999. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  54000. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  54001. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  54002. * * 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
  54003. * * When updating an instance, remember that only point positions can change, not the number of points
  54004. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54005. * @param name defines the name of the mesh
  54006. * @param options defines the options used to create the mesh
  54007. * @param scene defines the hosting scene
  54008. * @returns the dashed line mesh
  54009. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  54010. */
  54011. static CreateDashedLines(name: string, options: {
  54012. points: Vector3[];
  54013. dashSize?: number;
  54014. gapSize?: number;
  54015. dashNb?: number;
  54016. updatable?: boolean;
  54017. instance?: LinesMesh;
  54018. }, scene?: Nullable<Scene>): LinesMesh;
  54019. /**
  54020. * 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.
  54021. * * 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.
  54022. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54023. * * 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.
  54024. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54025. * * 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
  54026. * * 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
  54027. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54028. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54029. * * 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
  54030. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54031. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54032. * @param name defines the name of the mesh
  54033. * @param options defines the options used to create the mesh
  54034. * @param scene defines the hosting scene
  54035. * @returns the extruded shape mesh
  54036. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54037. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54038. */
  54039. static ExtrudeShape(name: string, options: {
  54040. shape: Vector3[];
  54041. path: Vector3[];
  54042. scale?: number;
  54043. rotation?: number;
  54044. cap?: number;
  54045. updatable?: boolean;
  54046. sideOrientation?: number;
  54047. frontUVs?: Vector4;
  54048. backUVs?: Vector4;
  54049. instance?: Mesh;
  54050. invertUV?: boolean;
  54051. }, scene?: Nullable<Scene>): Mesh;
  54052. /**
  54053. * Creates an custom extruded shape mesh.
  54054. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54055. * * 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.
  54056. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54057. * * 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
  54058. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54059. * * 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
  54060. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54061. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54062. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54063. * * 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
  54064. * * 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
  54065. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54066. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54067. * * 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
  54068. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54069. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54070. * @param name defines the name of the mesh
  54071. * @param options defines the options used to create the mesh
  54072. * @param scene defines the hosting scene
  54073. * @returns the custom extruded shape mesh
  54074. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54075. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54076. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54077. */
  54078. static ExtrudeShapeCustom(name: string, options: {
  54079. shape: Vector3[];
  54080. path: Vector3[];
  54081. scaleFunction?: any;
  54082. rotationFunction?: any;
  54083. ribbonCloseArray?: boolean;
  54084. ribbonClosePath?: boolean;
  54085. cap?: number;
  54086. updatable?: boolean;
  54087. sideOrientation?: number;
  54088. frontUVs?: Vector4;
  54089. backUVs?: Vector4;
  54090. instance?: Mesh;
  54091. invertUV?: boolean;
  54092. }, scene?: Nullable<Scene>): Mesh;
  54093. /**
  54094. * Creates lathe mesh.
  54095. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  54096. * * 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
  54097. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  54098. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  54099. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  54100. * * 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
  54101. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  54102. * * 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
  54103. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54104. * * 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
  54105. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54107. * @param name defines the name of the mesh
  54108. * @param options defines the options used to create the mesh
  54109. * @param scene defines the hosting scene
  54110. * @returns the lathe mesh
  54111. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  54112. */
  54113. static CreateLathe(name: string, options: {
  54114. shape: Vector3[];
  54115. radius?: number;
  54116. tessellation?: number;
  54117. clip?: number;
  54118. arc?: number;
  54119. closed?: boolean;
  54120. updatable?: boolean;
  54121. sideOrientation?: number;
  54122. frontUVs?: Vector4;
  54123. backUVs?: Vector4;
  54124. cap?: number;
  54125. invertUV?: boolean;
  54126. }, scene?: Nullable<Scene>): Mesh;
  54127. /**
  54128. * Creates a tiled plane mesh
  54129. * * You can set a limited pattern arrangement with the tiles
  54130. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54131. * * 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
  54132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54133. * @param name defines the name of the mesh
  54134. * @param options defines the options used to create the mesh
  54135. * @param scene defines the hosting scene
  54136. * @returns the plane mesh
  54137. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  54138. */
  54139. static CreateTiledPlane(name: string, options: {
  54140. pattern?: number;
  54141. tileSize?: number;
  54142. tileWidth?: number;
  54143. tileHeight?: number;
  54144. size?: number;
  54145. width?: number;
  54146. height?: number;
  54147. alignHorizontal?: number;
  54148. alignVertical?: number;
  54149. sideOrientation?: number;
  54150. frontUVs?: Vector4;
  54151. backUVs?: Vector4;
  54152. updatable?: boolean;
  54153. }, scene?: Nullable<Scene>): Mesh;
  54154. /**
  54155. * Creates a plane mesh
  54156. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  54157. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  54158. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  54159. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54160. * * 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
  54161. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54162. * @param name defines the name of the mesh
  54163. * @param options defines the options used to create the mesh
  54164. * @param scene defines the hosting scene
  54165. * @returns the plane mesh
  54166. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  54167. */
  54168. static CreatePlane(name: string, options: {
  54169. size?: number;
  54170. width?: number;
  54171. height?: number;
  54172. sideOrientation?: number;
  54173. frontUVs?: Vector4;
  54174. backUVs?: Vector4;
  54175. updatable?: boolean;
  54176. sourcePlane?: Plane;
  54177. }, scene?: Nullable<Scene>): Mesh;
  54178. /**
  54179. * Creates a ground mesh
  54180. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  54181. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  54182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54183. * @param name defines the name of the mesh
  54184. * @param options defines the options used to create the mesh
  54185. * @param scene defines the hosting scene
  54186. * @returns the ground mesh
  54187. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  54188. */
  54189. static CreateGround(name: string, options: {
  54190. width?: number;
  54191. height?: number;
  54192. subdivisions?: number;
  54193. subdivisionsX?: number;
  54194. subdivisionsY?: number;
  54195. updatable?: boolean;
  54196. }, scene?: Nullable<Scene>): Mesh;
  54197. /**
  54198. * Creates a tiled ground mesh
  54199. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  54200. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  54201. * * 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
  54202. * * 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
  54203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54204. * @param name defines the name of the mesh
  54205. * @param options defines the options used to create the mesh
  54206. * @param scene defines the hosting scene
  54207. * @returns the tiled ground mesh
  54208. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  54209. */
  54210. static CreateTiledGround(name: string, options: {
  54211. xmin: number;
  54212. zmin: number;
  54213. xmax: number;
  54214. zmax: number;
  54215. subdivisions?: {
  54216. w: number;
  54217. h: number;
  54218. };
  54219. precision?: {
  54220. w: number;
  54221. h: number;
  54222. };
  54223. updatable?: boolean;
  54224. }, scene?: Nullable<Scene>): Mesh;
  54225. /**
  54226. * Creates a ground mesh from a height map
  54227. * * The parameter `url` sets the URL of the height map image resource.
  54228. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  54229. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  54230. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  54231. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  54232. * * 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.
  54233. * * 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).
  54234. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  54235. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54236. * @param name defines the name of the mesh
  54237. * @param url defines the url to the height map
  54238. * @param options defines the options used to create the mesh
  54239. * @param scene defines the hosting scene
  54240. * @returns the ground mesh
  54241. * @see https://doc.babylonjs.com/babylon101/height_map
  54242. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  54243. */
  54244. static CreateGroundFromHeightMap(name: string, url: string, options: {
  54245. width?: number;
  54246. height?: number;
  54247. subdivisions?: number;
  54248. minHeight?: number;
  54249. maxHeight?: number;
  54250. colorFilter?: Color3;
  54251. alphaFilter?: number;
  54252. updatable?: boolean;
  54253. onReady?: (mesh: GroundMesh) => void;
  54254. }, scene?: Nullable<Scene>): GroundMesh;
  54255. /**
  54256. * Creates a polygon mesh
  54257. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  54258. * * 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
  54259. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54261. * * 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)
  54262. * * Remember you can only change the shape positions, not their number when updating a polygon
  54263. * @param name defines the name of the mesh
  54264. * @param options defines the options used to create the mesh
  54265. * @param scene defines the hosting scene
  54266. * @param earcutInjection can be used to inject your own earcut reference
  54267. * @returns the polygon mesh
  54268. */
  54269. static CreatePolygon(name: string, options: {
  54270. shape: Vector3[];
  54271. holes?: Vector3[][];
  54272. depth?: number;
  54273. faceUV?: Vector4[];
  54274. faceColors?: Color4[];
  54275. updatable?: boolean;
  54276. sideOrientation?: number;
  54277. frontUVs?: Vector4;
  54278. backUVs?: Vector4;
  54279. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54280. /**
  54281. * Creates an extruded polygon mesh, with depth in the Y direction.
  54282. * * 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)
  54283. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54284. * @param name defines the name of the mesh
  54285. * @param options defines the options used to create the mesh
  54286. * @param scene defines the hosting scene
  54287. * @param earcutInjection can be used to inject your own earcut reference
  54288. * @returns the polygon mesh
  54289. */
  54290. static ExtrudePolygon(name: string, options: {
  54291. shape: Vector3[];
  54292. holes?: Vector3[][];
  54293. depth?: number;
  54294. faceUV?: Vector4[];
  54295. faceColors?: Color4[];
  54296. updatable?: boolean;
  54297. sideOrientation?: number;
  54298. frontUVs?: Vector4;
  54299. backUVs?: Vector4;
  54300. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54301. /**
  54302. * Creates a tube mesh.
  54303. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54304. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  54305. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  54306. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  54307. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  54308. * * 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)
  54309. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  54310. * * 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
  54311. * * 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
  54312. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54313. * * 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
  54314. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54316. * @param name defines the name of the mesh
  54317. * @param options defines the options used to create the mesh
  54318. * @param scene defines the hosting scene
  54319. * @returns the tube mesh
  54320. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54321. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  54322. */
  54323. static CreateTube(name: string, options: {
  54324. path: Vector3[];
  54325. radius?: number;
  54326. tessellation?: number;
  54327. radiusFunction?: {
  54328. (i: number, distance: number): number;
  54329. };
  54330. cap?: number;
  54331. arc?: number;
  54332. updatable?: boolean;
  54333. sideOrientation?: number;
  54334. frontUVs?: Vector4;
  54335. backUVs?: Vector4;
  54336. instance?: Mesh;
  54337. invertUV?: boolean;
  54338. }, scene?: Nullable<Scene>): Mesh;
  54339. /**
  54340. * Creates a polyhedron mesh
  54341. * * 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
  54342. * * The parameter `size` (positive float, default 1) sets the polygon size
  54343. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  54344. * * 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`
  54345. * * 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
  54346. * * 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)`)
  54347. * * 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
  54348. * * 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
  54349. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54350. * * 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
  54351. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54352. * @param name defines the name of the mesh
  54353. * @param options defines the options used to create the mesh
  54354. * @param scene defines the hosting scene
  54355. * @returns the polyhedron mesh
  54356. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  54357. */
  54358. static CreatePolyhedron(name: string, options: {
  54359. type?: number;
  54360. size?: number;
  54361. sizeX?: number;
  54362. sizeY?: number;
  54363. sizeZ?: number;
  54364. custom?: any;
  54365. faceUV?: Vector4[];
  54366. faceColors?: Color4[];
  54367. flat?: boolean;
  54368. updatable?: boolean;
  54369. sideOrientation?: number;
  54370. frontUVs?: Vector4;
  54371. backUVs?: Vector4;
  54372. }, scene?: Nullable<Scene>): Mesh;
  54373. /**
  54374. * Creates a decal mesh.
  54375. * 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
  54376. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  54377. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  54378. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  54379. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  54380. * @param name defines the name of the mesh
  54381. * @param sourceMesh defines the mesh where the decal must be applied
  54382. * @param options defines the options used to create the mesh
  54383. * @param scene defines the hosting scene
  54384. * @returns the decal mesh
  54385. * @see https://doc.babylonjs.com/how_to/decals
  54386. */
  54387. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  54388. position?: Vector3;
  54389. normal?: Vector3;
  54390. size?: Vector3;
  54391. angle?: number;
  54392. }): Mesh;
  54393. }
  54394. }
  54395. declare module BABYLON {
  54396. /**
  54397. * A simplifier interface for future simplification implementations
  54398. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54399. */
  54400. export interface ISimplifier {
  54401. /**
  54402. * Simplification of a given mesh according to the given settings.
  54403. * Since this requires computation, it is assumed that the function runs async.
  54404. * @param settings The settings of the simplification, including quality and distance
  54405. * @param successCallback A callback that will be called after the mesh was simplified.
  54406. * @param errorCallback in case of an error, this callback will be called. optional.
  54407. */
  54408. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  54409. }
  54410. /**
  54411. * Expected simplification settings.
  54412. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  54413. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54414. */
  54415. export interface ISimplificationSettings {
  54416. /**
  54417. * Gets or sets the expected quality
  54418. */
  54419. quality: number;
  54420. /**
  54421. * Gets or sets the distance when this optimized version should be used
  54422. */
  54423. distance: number;
  54424. /**
  54425. * Gets an already optimized mesh
  54426. */
  54427. optimizeMesh?: boolean;
  54428. }
  54429. /**
  54430. * Class used to specify simplification options
  54431. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54432. */
  54433. export class SimplificationSettings implements ISimplificationSettings {
  54434. /** expected quality */
  54435. quality: number;
  54436. /** distance when this optimized version should be used */
  54437. distance: number;
  54438. /** already optimized mesh */
  54439. optimizeMesh?: boolean | undefined;
  54440. /**
  54441. * Creates a SimplificationSettings
  54442. * @param quality expected quality
  54443. * @param distance distance when this optimized version should be used
  54444. * @param optimizeMesh already optimized mesh
  54445. */
  54446. constructor(
  54447. /** expected quality */
  54448. quality: number,
  54449. /** distance when this optimized version should be used */
  54450. distance: number,
  54451. /** already optimized mesh */
  54452. optimizeMesh?: boolean | undefined);
  54453. }
  54454. /**
  54455. * Interface used to define a simplification task
  54456. */
  54457. export interface ISimplificationTask {
  54458. /**
  54459. * Array of settings
  54460. */
  54461. settings: Array<ISimplificationSettings>;
  54462. /**
  54463. * Simplification type
  54464. */
  54465. simplificationType: SimplificationType;
  54466. /**
  54467. * Mesh to simplify
  54468. */
  54469. mesh: Mesh;
  54470. /**
  54471. * Callback called on success
  54472. */
  54473. successCallback?: () => void;
  54474. /**
  54475. * Defines if parallel processing can be used
  54476. */
  54477. parallelProcessing: boolean;
  54478. }
  54479. /**
  54480. * Queue used to order the simplification tasks
  54481. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54482. */
  54483. export class SimplificationQueue {
  54484. private _simplificationArray;
  54485. /**
  54486. * Gets a boolean indicating that the process is still running
  54487. */
  54488. running: boolean;
  54489. /**
  54490. * Creates a new queue
  54491. */
  54492. constructor();
  54493. /**
  54494. * Adds a new simplification task
  54495. * @param task defines a task to add
  54496. */
  54497. addTask(task: ISimplificationTask): void;
  54498. /**
  54499. * Execute next task
  54500. */
  54501. executeNext(): void;
  54502. /**
  54503. * Execute a simplification task
  54504. * @param task defines the task to run
  54505. */
  54506. runSimplification(task: ISimplificationTask): void;
  54507. private getSimplifier;
  54508. }
  54509. /**
  54510. * The implemented types of simplification
  54511. * At the moment only Quadratic Error Decimation is implemented
  54512. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54513. */
  54514. export enum SimplificationType {
  54515. /** Quadratic error decimation */
  54516. QUADRATIC = 0
  54517. }
  54518. }
  54519. declare module BABYLON {
  54520. interface Scene {
  54521. /** @hidden (Backing field) */ private _simplificationQueue: SimplificationQueue;
  54522. /**
  54523. * Gets or sets the simplification queue attached to the scene
  54524. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54525. */
  54526. simplificationQueue: SimplificationQueue;
  54527. }
  54528. interface Mesh {
  54529. /**
  54530. * Simplify the mesh according to the given array of settings.
  54531. * Function will return immediately and will simplify async
  54532. * @param settings a collection of simplification settings
  54533. * @param parallelProcessing should all levels calculate parallel or one after the other
  54534. * @param simplificationType the type of simplification to run
  54535. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  54536. * @returns the current mesh
  54537. */
  54538. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  54539. }
  54540. /**
  54541. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  54542. * created in a scene
  54543. */
  54544. export class SimplicationQueueSceneComponent implements ISceneComponent {
  54545. /**
  54546. * The component name helpfull to identify the component in the list of scene components.
  54547. */
  54548. readonly name: string;
  54549. /**
  54550. * The scene the component belongs to.
  54551. */
  54552. scene: Scene;
  54553. /**
  54554. * Creates a new instance of the component for the given scene
  54555. * @param scene Defines the scene to register the component in
  54556. */
  54557. constructor(scene: Scene);
  54558. /**
  54559. * Registers the component in a given scene
  54560. */
  54561. register(): void;
  54562. /**
  54563. * Rebuilds the elements related to this component in case of
  54564. * context lost for instance.
  54565. */
  54566. rebuild(): void;
  54567. /**
  54568. * Disposes the component and the associated ressources
  54569. */
  54570. dispose(): void;
  54571. private _beforeCameraUpdate;
  54572. }
  54573. }
  54574. declare module BABYLON {
  54575. /**
  54576. * Navigation plugin interface to add navigation constrained by a navigation mesh
  54577. */
  54578. export interface INavigationEnginePlugin {
  54579. /**
  54580. * plugin name
  54581. */
  54582. name: string;
  54583. /**
  54584. * Creates a navigation mesh
  54585. * @param meshes array of all the geometry used to compute the navigatio mesh
  54586. * @param parameters bunch of parameters used to filter geometry
  54587. */
  54588. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  54589. /**
  54590. * Create a navigation mesh debug mesh
  54591. * @param scene is where the mesh will be added
  54592. * @returns debug display mesh
  54593. */
  54594. createDebugNavMesh(scene: Scene): Mesh;
  54595. /**
  54596. * Get a navigation mesh constrained position, closest to the parameter position
  54597. * @param position world position
  54598. * @returns the closest point to position constrained by the navigation mesh
  54599. */
  54600. getClosestPoint(position: Vector3): Vector3;
  54601. /**
  54602. * Get a navigation mesh constrained position, within a particular radius
  54603. * @param position world position
  54604. * @param maxRadius the maximum distance to the constrained world position
  54605. * @returns the closest point to position constrained by the navigation mesh
  54606. */
  54607. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  54608. /**
  54609. * Compute the final position from a segment made of destination-position
  54610. * @param position world position
  54611. * @param destination world position
  54612. * @returns the resulting point along the navmesh
  54613. */
  54614. moveAlong(position: Vector3, destination: Vector3): Vector3;
  54615. /**
  54616. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  54617. * @param start world position
  54618. * @param end world position
  54619. * @returns array containing world position composing the path
  54620. */
  54621. computePath(start: Vector3, end: Vector3): Vector3[];
  54622. /**
  54623. * If this plugin is supported
  54624. * @returns true if plugin is supported
  54625. */
  54626. isSupported(): boolean;
  54627. /**
  54628. * Create a new Crowd so you can add agents
  54629. * @param maxAgents the maximum agent count in the crowd
  54630. * @param maxAgentRadius the maximum radius an agent can have
  54631. * @param scene to attach the crowd to
  54632. * @returns the crowd you can add agents to
  54633. */
  54634. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  54635. /**
  54636. * Release all resources
  54637. */
  54638. dispose(): void;
  54639. }
  54640. /**
  54641. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  54642. */
  54643. export interface ICrowd {
  54644. /**
  54645. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  54646. * You can attach anything to that node. The node position is updated in the scene update tick.
  54647. * @param pos world position that will be constrained by the navigation mesh
  54648. * @param parameters agent parameters
  54649. * @param transform hooked to the agent that will be update by the scene
  54650. * @returns agent index
  54651. */
  54652. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  54653. /**
  54654. * Returns the agent position in world space
  54655. * @param index agent index returned by addAgent
  54656. * @returns world space position
  54657. */
  54658. getAgentPosition(index: number): Vector3;
  54659. /**
  54660. * Gets the agent velocity in world space
  54661. * @param index agent index returned by addAgent
  54662. * @returns world space velocity
  54663. */
  54664. getAgentVelocity(index: number): Vector3;
  54665. /**
  54666. * remove a particular agent previously created
  54667. * @param index agent index returned by addAgent
  54668. */
  54669. removeAgent(index: number): void;
  54670. /**
  54671. * get the list of all agents attached to this crowd
  54672. * @returns list of agent indices
  54673. */
  54674. getAgents(): number[];
  54675. /**
  54676. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  54677. * @param deltaTime in seconds
  54678. */
  54679. update(deltaTime: number): void;
  54680. /**
  54681. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  54682. * @param index agent index returned by addAgent
  54683. * @param destination targeted world position
  54684. */
  54685. agentGoto(index: number, destination: Vector3): void;
  54686. /**
  54687. * Release all resources
  54688. */
  54689. dispose(): void;
  54690. }
  54691. /**
  54692. * Configures an agent
  54693. */
  54694. export interface IAgentParameters {
  54695. /**
  54696. * Agent radius. [Limit: >= 0]
  54697. */
  54698. radius: number;
  54699. /**
  54700. * Agent height. [Limit: > 0]
  54701. */
  54702. height: number;
  54703. /**
  54704. * Maximum allowed acceleration. [Limit: >= 0]
  54705. */
  54706. maxAcceleration: number;
  54707. /**
  54708. * Maximum allowed speed. [Limit: >= 0]
  54709. */
  54710. maxSpeed: number;
  54711. /**
  54712. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  54713. */
  54714. collisionQueryRange: number;
  54715. /**
  54716. * The path visibility optimization range. [Limit: > 0]
  54717. */
  54718. pathOptimizationRange: number;
  54719. /**
  54720. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  54721. */
  54722. separationWeight: number;
  54723. }
  54724. /**
  54725. * Configures the navigation mesh creation
  54726. */
  54727. export interface INavMeshParameters {
  54728. /**
  54729. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  54730. */
  54731. cs: number;
  54732. /**
  54733. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  54734. */
  54735. ch: number;
  54736. /**
  54737. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  54738. */
  54739. walkableSlopeAngle: number;
  54740. /**
  54741. * Minimum floor to 'ceiling' height that will still allow the floor area to
  54742. * be considered walkable. [Limit: >= 3] [Units: vx]
  54743. */
  54744. walkableHeight: number;
  54745. /**
  54746. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  54747. */
  54748. walkableClimb: number;
  54749. /**
  54750. * The distance to erode/shrink the walkable area of the heightfield away from
  54751. * obstructions. [Limit: >=0] [Units: vx]
  54752. */
  54753. walkableRadius: number;
  54754. /**
  54755. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  54756. */
  54757. maxEdgeLen: number;
  54758. /**
  54759. * The maximum distance a simplfied contour's border edges should deviate
  54760. * the original raw contour. [Limit: >=0] [Units: vx]
  54761. */
  54762. maxSimplificationError: number;
  54763. /**
  54764. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  54765. */
  54766. minRegionArea: number;
  54767. /**
  54768. * Any regions with a span count smaller than this value will, if possible,
  54769. * be merged with larger regions. [Limit: >=0] [Units: vx]
  54770. */
  54771. mergeRegionArea: number;
  54772. /**
  54773. * The maximum number of vertices allowed for polygons generated during the
  54774. * contour to polygon conversion process. [Limit: >= 3]
  54775. */
  54776. maxVertsPerPoly: number;
  54777. /**
  54778. * Sets the sampling distance to use when generating the detail mesh.
  54779. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  54780. */
  54781. detailSampleDist: number;
  54782. /**
  54783. * The maximum distance the detail mesh surface should deviate from heightfield
  54784. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  54785. */
  54786. detailSampleMaxError: number;
  54787. }
  54788. }
  54789. declare module BABYLON {
  54790. /**
  54791. * RecastJS navigation plugin
  54792. */
  54793. export class RecastJSPlugin implements INavigationEnginePlugin {
  54794. /**
  54795. * Reference to the Recast library
  54796. */
  54797. bjsRECAST: any;
  54798. /**
  54799. * plugin name
  54800. */
  54801. name: string;
  54802. /**
  54803. * the first navmesh created. We might extend this to support multiple navmeshes
  54804. */
  54805. navMesh: any;
  54806. /**
  54807. * Initializes the recastJS plugin
  54808. * @param recastInjection can be used to inject your own recast reference
  54809. */
  54810. constructor(recastInjection?: any);
  54811. /**
  54812. * Creates a navigation mesh
  54813. * @param meshes array of all the geometry used to compute the navigatio mesh
  54814. * @param parameters bunch of parameters used to filter geometry
  54815. */
  54816. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  54817. /**
  54818. * Create a navigation mesh debug mesh
  54819. * @param scene is where the mesh will be added
  54820. * @returns debug display mesh
  54821. */
  54822. createDebugNavMesh(scene: Scene): Mesh;
  54823. /**
  54824. * Get a navigation mesh constrained position, closest to the parameter position
  54825. * @param position world position
  54826. * @returns the closest point to position constrained by the navigation mesh
  54827. */
  54828. getClosestPoint(position: Vector3): Vector3;
  54829. /**
  54830. * Get a navigation mesh constrained position, within a particular radius
  54831. * @param position world position
  54832. * @param maxRadius the maximum distance to the constrained world position
  54833. * @returns the closest point to position constrained by the navigation mesh
  54834. */
  54835. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  54836. /**
  54837. * Compute the final position from a segment made of destination-position
  54838. * @param position world position
  54839. * @param destination world position
  54840. * @returns the resulting point along the navmesh
  54841. */
  54842. moveAlong(position: Vector3, destination: Vector3): Vector3;
  54843. /**
  54844. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  54845. * @param start world position
  54846. * @param end world position
  54847. * @returns array containing world position composing the path
  54848. */
  54849. computePath(start: Vector3, end: Vector3): Vector3[];
  54850. /**
  54851. * Create a new Crowd so you can add agents
  54852. * @param maxAgents the maximum agent count in the crowd
  54853. * @param maxAgentRadius the maximum radius an agent can have
  54854. * @param scene to attach the crowd to
  54855. * @returns the crowd you can add agents to
  54856. */
  54857. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  54858. /**
  54859. * Disposes
  54860. */
  54861. dispose(): void;
  54862. /**
  54863. * If this plugin is supported
  54864. * @returns true if plugin is supported
  54865. */
  54866. isSupported(): boolean;
  54867. }
  54868. /**
  54869. * Recast detour crowd implementation
  54870. */
  54871. export class RecastJSCrowd implements ICrowd {
  54872. /**
  54873. * Recast/detour plugin
  54874. */
  54875. bjsRECASTPlugin: RecastJSPlugin;
  54876. /**
  54877. * Link to the detour crowd
  54878. */
  54879. recastCrowd: any;
  54880. /**
  54881. * One transform per agent
  54882. */
  54883. transforms: TransformNode[];
  54884. /**
  54885. * All agents created
  54886. */
  54887. agents: number[];
  54888. /**
  54889. * Link to the scene is kept to unregister the crowd from the scene
  54890. */
  54891. private _scene;
  54892. /**
  54893. * Observer for crowd updates
  54894. */
  54895. private _onBeforeAnimationsObserver;
  54896. /**
  54897. * Constructor
  54898. * @param plugin recastJS plugin
  54899. * @param maxAgents the maximum agent count in the crowd
  54900. * @param maxAgentRadius the maximum radius an agent can have
  54901. * @param scene to attach the crowd to
  54902. * @returns the crowd you can add agents to
  54903. */
  54904. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  54905. /**
  54906. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  54907. * You can attach anything to that node. The node position is updated in the scene update tick.
  54908. * @param pos world position that will be constrained by the navigation mesh
  54909. * @param parameters agent parameters
  54910. * @param transform hooked to the agent that will be update by the scene
  54911. * @returns agent index
  54912. */
  54913. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  54914. /**
  54915. * Returns the agent position in world space
  54916. * @param index agent index returned by addAgent
  54917. * @returns world space position
  54918. */
  54919. getAgentPosition(index: number): Vector3;
  54920. /**
  54921. * Returns the agent velocity in world space
  54922. * @param index agent index returned by addAgent
  54923. * @returns world space velocity
  54924. */
  54925. getAgentVelocity(index: number): Vector3;
  54926. /**
  54927. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  54928. * @param index agent index returned by addAgent
  54929. * @param destination targeted world position
  54930. */
  54931. agentGoto(index: number, destination: Vector3): void;
  54932. /**
  54933. * remove a particular agent previously created
  54934. * @param index agent index returned by addAgent
  54935. */
  54936. removeAgent(index: number): void;
  54937. /**
  54938. * get the list of all agents attached to this crowd
  54939. * @returns list of agent indices
  54940. */
  54941. getAgents(): number[];
  54942. /**
  54943. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  54944. * @param deltaTime in seconds
  54945. */
  54946. update(deltaTime: number): void;
  54947. /**
  54948. * Release all resources
  54949. */
  54950. dispose(): void;
  54951. }
  54952. }
  54953. declare module BABYLON {
  54954. /**
  54955. * Class used to enable access to IndexedDB
  54956. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  54957. */
  54958. export class Database implements IOfflineProvider {
  54959. private _callbackManifestChecked;
  54960. private _currentSceneUrl;
  54961. private _db;
  54962. private _enableSceneOffline;
  54963. private _enableTexturesOffline;
  54964. private _manifestVersionFound;
  54965. private _mustUpdateRessources;
  54966. private _hasReachedQuota;
  54967. private _isSupported;
  54968. private _idbFactory;
  54969. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  54970. private static IsUASupportingBlobStorage;
  54971. /**
  54972. * Gets a boolean indicating if Database storate is enabled (off by default)
  54973. */
  54974. static IDBStorageEnabled: boolean;
  54975. /**
  54976. * Gets a boolean indicating if scene must be saved in the database
  54977. */
  54978. readonly enableSceneOffline: boolean;
  54979. /**
  54980. * Gets a boolean indicating if textures must be saved in the database
  54981. */
  54982. readonly enableTexturesOffline: boolean;
  54983. /**
  54984. * Creates a new Database
  54985. * @param urlToScene defines the url to load the scene
  54986. * @param callbackManifestChecked defines the callback to use when manifest is checked
  54987. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  54988. */
  54989. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  54990. private static _ParseURL;
  54991. private static _ReturnFullUrlLocation;
  54992. private _checkManifestFile;
  54993. /**
  54994. * Open the database and make it available
  54995. * @param successCallback defines the callback to call on success
  54996. * @param errorCallback defines the callback to call on error
  54997. */
  54998. open(successCallback: () => void, errorCallback: () => void): void;
  54999. /**
  55000. * Loads an image from the database
  55001. * @param url defines the url to load from
  55002. * @param image defines the target DOM image
  55003. */
  55004. loadImage(url: string, image: HTMLImageElement): void;
  55005. private _loadImageFromDBAsync;
  55006. private _saveImageIntoDBAsync;
  55007. private _checkVersionFromDB;
  55008. private _loadVersionFromDBAsync;
  55009. private _saveVersionIntoDBAsync;
  55010. /**
  55011. * Loads a file from database
  55012. * @param url defines the URL to load from
  55013. * @param sceneLoaded defines a callback to call on success
  55014. * @param progressCallBack defines a callback to call when progress changed
  55015. * @param errorCallback defines a callback to call on error
  55016. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  55017. */
  55018. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  55019. private _loadFileAsync;
  55020. private _saveFileAsync;
  55021. /**
  55022. * Validates if xhr data is correct
  55023. * @param xhr defines the request to validate
  55024. * @param dataType defines the expected data type
  55025. * @returns true if data is correct
  55026. */
  55027. private static _ValidateXHRData;
  55028. }
  55029. }
  55030. declare module BABYLON {
  55031. /** @hidden */
  55032. export var gpuUpdateParticlesPixelShader: {
  55033. name: string;
  55034. shader: string;
  55035. };
  55036. }
  55037. declare module BABYLON {
  55038. /** @hidden */
  55039. export var gpuUpdateParticlesVertexShader: {
  55040. name: string;
  55041. shader: string;
  55042. };
  55043. }
  55044. declare module BABYLON {
  55045. /** @hidden */
  55046. export var clipPlaneFragmentDeclaration2: {
  55047. name: string;
  55048. shader: string;
  55049. };
  55050. }
  55051. declare module BABYLON {
  55052. /** @hidden */
  55053. export var gpuRenderParticlesPixelShader: {
  55054. name: string;
  55055. shader: string;
  55056. };
  55057. }
  55058. declare module BABYLON {
  55059. /** @hidden */
  55060. export var clipPlaneVertexDeclaration2: {
  55061. name: string;
  55062. shader: string;
  55063. };
  55064. }
  55065. declare module BABYLON {
  55066. /** @hidden */
  55067. export var gpuRenderParticlesVertexShader: {
  55068. name: string;
  55069. shader: string;
  55070. };
  55071. }
  55072. declare module BABYLON {
  55073. /**
  55074. * This represents a GPU particle system in Babylon
  55075. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  55076. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  55077. */
  55078. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  55079. /**
  55080. * The layer mask we are rendering the particles through.
  55081. */
  55082. layerMask: number;
  55083. private _capacity;
  55084. private _activeCount;
  55085. private _currentActiveCount;
  55086. private _accumulatedCount;
  55087. private _renderEffect;
  55088. private _updateEffect;
  55089. private _buffer0;
  55090. private _buffer1;
  55091. private _spriteBuffer;
  55092. private _updateVAO;
  55093. private _renderVAO;
  55094. private _targetIndex;
  55095. private _sourceBuffer;
  55096. private _targetBuffer;
  55097. private _engine;
  55098. private _currentRenderId;
  55099. private _started;
  55100. private _stopped;
  55101. private _timeDelta;
  55102. private _randomTexture;
  55103. private _randomTexture2;
  55104. private _attributesStrideSize;
  55105. private _updateEffectOptions;
  55106. private _randomTextureSize;
  55107. private _actualFrame;
  55108. private readonly _rawTextureWidth;
  55109. /**
  55110. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  55111. */
  55112. static readonly IsSupported: boolean;
  55113. /**
  55114. * An event triggered when the system is disposed.
  55115. */
  55116. onDisposeObservable: Observable<GPUParticleSystem>;
  55117. /**
  55118. * Gets the maximum number of particles active at the same time.
  55119. * @returns The max number of active particles.
  55120. */
  55121. getCapacity(): number;
  55122. /**
  55123. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  55124. * to override the particles.
  55125. */
  55126. forceDepthWrite: boolean;
  55127. /**
  55128. * Gets or set the number of active particles
  55129. */
  55130. activeParticleCount: number;
  55131. private _preWarmDone;
  55132. /**
  55133. * Is this system ready to be used/rendered
  55134. * @return true if the system is ready
  55135. */
  55136. isReady(): boolean;
  55137. /**
  55138. * Gets if the system has been started. (Note: this will still be true after stop is called)
  55139. * @returns True if it has been started, otherwise false.
  55140. */
  55141. isStarted(): boolean;
  55142. /**
  55143. * Starts the particle system and begins to emit
  55144. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  55145. */
  55146. start(delay?: number): void;
  55147. /**
  55148. * Stops the particle system.
  55149. */
  55150. stop(): void;
  55151. /**
  55152. * Remove all active particles
  55153. */
  55154. reset(): void;
  55155. /**
  55156. * Returns the string "GPUParticleSystem"
  55157. * @returns a string containing the class name
  55158. */
  55159. getClassName(): string;
  55160. private _colorGradientsTexture;
  55161. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  55162. /**
  55163. * Adds a new color gradient
  55164. * @param gradient defines the gradient to use (between 0 and 1)
  55165. * @param color1 defines the color to affect to the specified gradient
  55166. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  55167. * @returns the current particle system
  55168. */
  55169. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  55170. /**
  55171. * Remove a specific color gradient
  55172. * @param gradient defines the gradient to remove
  55173. * @returns the current particle system
  55174. */
  55175. removeColorGradient(gradient: number): GPUParticleSystem;
  55176. private _angularSpeedGradientsTexture;
  55177. private _sizeGradientsTexture;
  55178. private _velocityGradientsTexture;
  55179. private _limitVelocityGradientsTexture;
  55180. private _dragGradientsTexture;
  55181. private _addFactorGradient;
  55182. /**
  55183. * Adds a new size gradient
  55184. * @param gradient defines the gradient to use (between 0 and 1)
  55185. * @param factor defines the size factor to affect to the specified gradient
  55186. * @returns the current particle system
  55187. */
  55188. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  55189. /**
  55190. * Remove a specific size gradient
  55191. * @param gradient defines the gradient to remove
  55192. * @returns the current particle system
  55193. */
  55194. removeSizeGradient(gradient: number): GPUParticleSystem;
  55195. /**
  55196. * Adds a new angular speed gradient
  55197. * @param gradient defines the gradient to use (between 0 and 1)
  55198. * @param factor defines the angular speed to affect to the specified gradient
  55199. * @returns the current particle system
  55200. */
  55201. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  55202. /**
  55203. * Remove a specific angular speed gradient
  55204. * @param gradient defines the gradient to remove
  55205. * @returns the current particle system
  55206. */
  55207. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  55208. /**
  55209. * Adds a new velocity gradient
  55210. * @param gradient defines the gradient to use (between 0 and 1)
  55211. * @param factor defines the velocity to affect to the specified gradient
  55212. * @returns the current particle system
  55213. */
  55214. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  55215. /**
  55216. * Remove a specific velocity gradient
  55217. * @param gradient defines the gradient to remove
  55218. * @returns the current particle system
  55219. */
  55220. removeVelocityGradient(gradient: number): GPUParticleSystem;
  55221. /**
  55222. * Adds a new limit velocity gradient
  55223. * @param gradient defines the gradient to use (between 0 and 1)
  55224. * @param factor defines the limit velocity value to affect to the specified gradient
  55225. * @returns the current particle system
  55226. */
  55227. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  55228. /**
  55229. * Remove a specific limit velocity gradient
  55230. * @param gradient defines the gradient to remove
  55231. * @returns the current particle system
  55232. */
  55233. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  55234. /**
  55235. * Adds a new drag gradient
  55236. * @param gradient defines the gradient to use (between 0 and 1)
  55237. * @param factor defines the drag value to affect to the specified gradient
  55238. * @returns the current particle system
  55239. */
  55240. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  55241. /**
  55242. * Remove a specific drag gradient
  55243. * @param gradient defines the gradient to remove
  55244. * @returns the current particle system
  55245. */
  55246. removeDragGradient(gradient: number): GPUParticleSystem;
  55247. /**
  55248. * Not supported by GPUParticleSystem
  55249. * @param gradient defines the gradient to use (between 0 and 1)
  55250. * @param factor defines the emit rate value to affect to the specified gradient
  55251. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  55252. * @returns the current particle system
  55253. */
  55254. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  55255. /**
  55256. * Not supported by GPUParticleSystem
  55257. * @param gradient defines the gradient to remove
  55258. * @returns the current particle system
  55259. */
  55260. removeEmitRateGradient(gradient: number): IParticleSystem;
  55261. /**
  55262. * Not supported by GPUParticleSystem
  55263. * @param gradient defines the gradient to use (between 0 and 1)
  55264. * @param factor defines the start size value to affect to the specified gradient
  55265. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  55266. * @returns the current particle system
  55267. */
  55268. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  55269. /**
  55270. * Not supported by GPUParticleSystem
  55271. * @param gradient defines the gradient to remove
  55272. * @returns the current particle system
  55273. */
  55274. removeStartSizeGradient(gradient: number): IParticleSystem;
  55275. /**
  55276. * Not supported by GPUParticleSystem
  55277. * @param gradient defines the gradient to use (between 0 and 1)
  55278. * @param min defines the color remap minimal range
  55279. * @param max defines the color remap maximal range
  55280. * @returns the current particle system
  55281. */
  55282. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  55283. /**
  55284. * Not supported by GPUParticleSystem
  55285. * @param gradient defines the gradient to remove
  55286. * @returns the current particle system
  55287. */
  55288. removeColorRemapGradient(): IParticleSystem;
  55289. /**
  55290. * Not supported by GPUParticleSystem
  55291. * @param gradient defines the gradient to use (between 0 and 1)
  55292. * @param min defines the alpha remap minimal range
  55293. * @param max defines the alpha remap maximal range
  55294. * @returns the current particle system
  55295. */
  55296. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  55297. /**
  55298. * Not supported by GPUParticleSystem
  55299. * @param gradient defines the gradient to remove
  55300. * @returns the current particle system
  55301. */
  55302. removeAlphaRemapGradient(): IParticleSystem;
  55303. /**
  55304. * Not supported by GPUParticleSystem
  55305. * @param gradient defines the gradient to use (between 0 and 1)
  55306. * @param color defines the color to affect to the specified gradient
  55307. * @returns the current particle system
  55308. */
  55309. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  55310. /**
  55311. * Not supported by GPUParticleSystem
  55312. * @param gradient defines the gradient to remove
  55313. * @returns the current particle system
  55314. */
  55315. removeRampGradient(): IParticleSystem;
  55316. /**
  55317. * Not supported by GPUParticleSystem
  55318. * @returns the list of ramp gradients
  55319. */
  55320. getRampGradients(): Nullable<Array<Color3Gradient>>;
  55321. /**
  55322. * Not supported by GPUParticleSystem
  55323. * Gets or sets a boolean indicating that ramp gradients must be used
  55324. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  55325. */
  55326. useRampGradients: boolean;
  55327. /**
  55328. * Not supported by GPUParticleSystem
  55329. * @param gradient defines the gradient to use (between 0 and 1)
  55330. * @param factor defines the life time factor to affect to the specified gradient
  55331. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  55332. * @returns the current particle system
  55333. */
  55334. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  55335. /**
  55336. * Not supported by GPUParticleSystem
  55337. * @param gradient defines the gradient to remove
  55338. * @returns the current particle system
  55339. */
  55340. removeLifeTimeGradient(gradient: number): IParticleSystem;
  55341. /**
  55342. * Instantiates a GPU particle system.
  55343. * 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.
  55344. * @param name The name of the particle system
  55345. * @param options The options used to create the system
  55346. * @param scene The scene the particle system belongs to
  55347. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  55348. */
  55349. constructor(name: string, options: Partial<{
  55350. capacity: number;
  55351. randomTextureSize: number;
  55352. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  55353. protected _reset(): void;
  55354. private _createUpdateVAO;
  55355. private _createRenderVAO;
  55356. private _initialize;
  55357. /** @hidden */ private _recreateUpdateEffect(): void;
  55358. /** @hidden */ private _recreateRenderEffect(): void;
  55359. /**
  55360. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  55361. * @param preWarm defines if we are in the pre-warmimg phase
  55362. */
  55363. animate(preWarm?: boolean): void;
  55364. private _createFactorGradientTexture;
  55365. private _createSizeGradientTexture;
  55366. private _createAngularSpeedGradientTexture;
  55367. private _createVelocityGradientTexture;
  55368. private _createLimitVelocityGradientTexture;
  55369. private _createDragGradientTexture;
  55370. private _createColorGradientTexture;
  55371. /**
  55372. * Renders the particle system in its current state
  55373. * @param preWarm defines if the system should only update the particles but not render them
  55374. * @returns the current number of particles
  55375. */
  55376. render(preWarm?: boolean): number;
  55377. /**
  55378. * Rebuilds the particle system
  55379. */
  55380. rebuild(): void;
  55381. private _releaseBuffers;
  55382. private _releaseVAOs;
  55383. /**
  55384. * Disposes the particle system and free the associated resources
  55385. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  55386. */
  55387. dispose(disposeTexture?: boolean): void;
  55388. /**
  55389. * Clones the particle system.
  55390. * @param name The name of the cloned object
  55391. * @param newEmitter The new emitter to use
  55392. * @returns the cloned particle system
  55393. */
  55394. clone(name: string, newEmitter: any): GPUParticleSystem;
  55395. /**
  55396. * Serializes the particle system to a JSON object.
  55397. * @returns the JSON object
  55398. */
  55399. serialize(): any;
  55400. /**
  55401. * Parses a JSON object to create a GPU particle system.
  55402. * @param parsedParticleSystem The JSON object to parse
  55403. * @param scene The scene to create the particle system in
  55404. * @param rootUrl The root url to use to load external dependencies like texture
  55405. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  55406. * @returns the parsed GPU particle system
  55407. */
  55408. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  55409. }
  55410. }
  55411. declare module BABYLON {
  55412. /**
  55413. * Represents a set of particle systems working together to create a specific effect
  55414. */
  55415. export class ParticleSystemSet implements IDisposable {
  55416. private _emitterCreationOptions;
  55417. private _emitterNode;
  55418. /**
  55419. * Gets the particle system list
  55420. */
  55421. systems: IParticleSystem[];
  55422. /**
  55423. * Gets the emitter node used with this set
  55424. */
  55425. readonly emitterNode: Nullable<TransformNode>;
  55426. /**
  55427. * Creates a new emitter mesh as a sphere
  55428. * @param options defines the options used to create the sphere
  55429. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  55430. * @param scene defines the hosting scene
  55431. */
  55432. setEmitterAsSphere(options: {
  55433. diameter: number;
  55434. segments: number;
  55435. color: Color3;
  55436. }, renderingGroupId: number, scene: Scene): void;
  55437. /**
  55438. * Starts all particle systems of the set
  55439. * @param emitter defines an optional mesh to use as emitter for the particle systems
  55440. */
  55441. start(emitter?: AbstractMesh): void;
  55442. /**
  55443. * Release all associated resources
  55444. */
  55445. dispose(): void;
  55446. /**
  55447. * Serialize the set into a JSON compatible object
  55448. * @returns a JSON compatible representation of the set
  55449. */
  55450. serialize(): any;
  55451. /**
  55452. * Parse a new ParticleSystemSet from a serialized source
  55453. * @param data defines a JSON compatible representation of the set
  55454. * @param scene defines the hosting scene
  55455. * @param gpu defines if we want GPU particles or CPU particles
  55456. * @returns a new ParticleSystemSet
  55457. */
  55458. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  55459. }
  55460. }
  55461. declare module BABYLON {
  55462. /**
  55463. * This class is made for on one-liner static method to help creating particle system set.
  55464. */
  55465. export class ParticleHelper {
  55466. /**
  55467. * Gets or sets base Assets URL
  55468. */
  55469. static BaseAssetsUrl: string;
  55470. /**
  55471. * Create a default particle system that you can tweak
  55472. * @param emitter defines the emitter to use
  55473. * @param capacity defines the system capacity (default is 500 particles)
  55474. * @param scene defines the hosting scene
  55475. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  55476. * @returns the new Particle system
  55477. */
  55478. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  55479. /**
  55480. * This is the main static method (one-liner) of this helper to create different particle systems
  55481. * @param type This string represents the type to the particle system to create
  55482. * @param scene The scene where the particle system should live
  55483. * @param gpu If the system will use gpu
  55484. * @returns the ParticleSystemSet created
  55485. */
  55486. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  55487. /**
  55488. * Static function used to export a particle system to a ParticleSystemSet variable.
  55489. * Please note that the emitter shape is not exported
  55490. * @param systems defines the particle systems to export
  55491. * @returns the created particle system set
  55492. */
  55493. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  55494. }
  55495. }
  55496. declare module BABYLON {
  55497. interface Engine {
  55498. /**
  55499. * Create an effect to use with particle systems.
  55500. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  55501. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  55502. * @param uniformsNames defines a list of attribute names
  55503. * @param samplers defines an array of string used to represent textures
  55504. * @param defines defines the string containing the defines to use to compile the shaders
  55505. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  55506. * @param onCompiled defines a function to call when the effect creation is successful
  55507. * @param onError defines a function to call when the effect creation has failed
  55508. * @returns the new Effect
  55509. */
  55510. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  55511. }
  55512. interface Mesh {
  55513. /**
  55514. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  55515. * @returns an array of IParticleSystem
  55516. */
  55517. getEmittedParticleSystems(): IParticleSystem[];
  55518. /**
  55519. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  55520. * @returns an array of IParticleSystem
  55521. */
  55522. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  55523. }
  55524. /**
  55525. * @hidden
  55526. */
  55527. export var _IDoNeedToBeInTheBuild: number;
  55528. }
  55529. declare module BABYLON {
  55530. interface Scene {
  55531. /** @hidden (Backing field) */ private _physicsEngine: Nullable<IPhysicsEngine>;
  55532. /**
  55533. * Gets the current physics engine
  55534. * @returns a IPhysicsEngine or null if none attached
  55535. */
  55536. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  55537. /**
  55538. * Enables physics to the current scene
  55539. * @param gravity defines the scene's gravity for the physics engine
  55540. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  55541. * @return a boolean indicating if the physics engine was initialized
  55542. */
  55543. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  55544. /**
  55545. * Disables and disposes the physics engine associated with the scene
  55546. */
  55547. disablePhysicsEngine(): void;
  55548. /**
  55549. * Gets a boolean indicating if there is an active physics engine
  55550. * @returns a boolean indicating if there is an active physics engine
  55551. */
  55552. isPhysicsEnabled(): boolean;
  55553. /**
  55554. * Deletes a physics compound impostor
  55555. * @param compound defines the compound to delete
  55556. */
  55557. deleteCompoundImpostor(compound: any): void;
  55558. /**
  55559. * An event triggered when physic simulation is about to be run
  55560. */
  55561. onBeforePhysicsObservable: Observable<Scene>;
  55562. /**
  55563. * An event triggered when physic simulation has been done
  55564. */
  55565. onAfterPhysicsObservable: Observable<Scene>;
  55566. }
  55567. interface AbstractMesh {
  55568. /** @hidden */ private _physicsImpostor: Nullable<PhysicsImpostor>;
  55569. /**
  55570. * Gets or sets impostor used for physic simulation
  55571. * @see http://doc.babylonjs.com/features/physics_engine
  55572. */
  55573. physicsImpostor: Nullable<PhysicsImpostor>;
  55574. /**
  55575. * Gets the current physics impostor
  55576. * @see http://doc.babylonjs.com/features/physics_engine
  55577. * @returns a physics impostor or null
  55578. */
  55579. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  55580. /** Apply a physic impulse to the mesh
  55581. * @param force defines the force to apply
  55582. * @param contactPoint defines where to apply the force
  55583. * @returns the current mesh
  55584. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55585. */
  55586. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  55587. /**
  55588. * Creates a physic joint between two meshes
  55589. * @param otherMesh defines the other mesh to use
  55590. * @param pivot1 defines the pivot to use on this mesh
  55591. * @param pivot2 defines the pivot to use on the other mesh
  55592. * @param options defines additional options (can be plugin dependent)
  55593. * @returns the current mesh
  55594. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  55595. */
  55596. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  55597. /** @hidden */ private _disposePhysicsObserver: Nullable<Observer<Node>>;
  55598. }
  55599. /**
  55600. * Defines the physics engine scene component responsible to manage a physics engine
  55601. */
  55602. export class PhysicsEngineSceneComponent implements ISceneComponent {
  55603. /**
  55604. * The component name helpful to identify the component in the list of scene components.
  55605. */
  55606. readonly name: string;
  55607. /**
  55608. * The scene the component belongs to.
  55609. */
  55610. scene: Scene;
  55611. /**
  55612. * Creates a new instance of the component for the given scene
  55613. * @param scene Defines the scene to register the component in
  55614. */
  55615. constructor(scene: Scene);
  55616. /**
  55617. * Registers the component in a given scene
  55618. */
  55619. register(): void;
  55620. /**
  55621. * Rebuilds the elements related to this component in case of
  55622. * context lost for instance.
  55623. */
  55624. rebuild(): void;
  55625. /**
  55626. * Disposes the component and the associated ressources
  55627. */
  55628. dispose(): void;
  55629. }
  55630. }
  55631. declare module BABYLON {
  55632. /**
  55633. * A helper for physics simulations
  55634. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55635. */
  55636. export class PhysicsHelper {
  55637. private _scene;
  55638. private _physicsEngine;
  55639. /**
  55640. * Initializes the Physics helper
  55641. * @param scene Babylon.js scene
  55642. */
  55643. constructor(scene: Scene);
  55644. /**
  55645. * Applies a radial explosion impulse
  55646. * @param origin the origin of the explosion
  55647. * @param radiusOrEventOptions the radius or the options of radial explosion
  55648. * @param strength the explosion strength
  55649. * @param falloff possible options: Constant & Linear. Defaults to Constant
  55650. * @returns A physics radial explosion event, or null
  55651. */
  55652. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  55653. /**
  55654. * Applies a radial explosion force
  55655. * @param origin the origin of the explosion
  55656. * @param radiusOrEventOptions the radius or the options of radial explosion
  55657. * @param strength the explosion strength
  55658. * @param falloff possible options: Constant & Linear. Defaults to Constant
  55659. * @returns A physics radial explosion event, or null
  55660. */
  55661. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  55662. /**
  55663. * Creates a gravitational field
  55664. * @param origin the origin of the explosion
  55665. * @param radiusOrEventOptions the radius or the options of radial explosion
  55666. * @param strength the explosion strength
  55667. * @param falloff possible options: Constant & Linear. Defaults to Constant
  55668. * @returns A physics gravitational field event, or null
  55669. */
  55670. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  55671. /**
  55672. * Creates a physics updraft event
  55673. * @param origin the origin of the updraft
  55674. * @param radiusOrEventOptions the radius or the options of the updraft
  55675. * @param strength the strength of the updraft
  55676. * @param height the height of the updraft
  55677. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  55678. * @returns A physics updraft event, or null
  55679. */
  55680. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  55681. /**
  55682. * Creates a physics vortex event
  55683. * @param origin the of the vortex
  55684. * @param radiusOrEventOptions the radius or the options of the vortex
  55685. * @param strength the strength of the vortex
  55686. * @param height the height of the vortex
  55687. * @returns a Physics vortex event, or null
  55688. * A physics vortex event or null
  55689. */
  55690. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  55691. }
  55692. /**
  55693. * Represents a physics radial explosion event
  55694. */
  55695. class PhysicsRadialExplosionEvent {
  55696. private _scene;
  55697. private _options;
  55698. private _sphere;
  55699. private _dataFetched;
  55700. /**
  55701. * Initializes a radial explosioin event
  55702. * @param _scene BabylonJS scene
  55703. * @param _options The options for the vortex event
  55704. */
  55705. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  55706. /**
  55707. * Returns the data related to the radial explosion event (sphere).
  55708. * @returns The radial explosion event data
  55709. */
  55710. getData(): PhysicsRadialExplosionEventData;
  55711. /**
  55712. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  55713. * @param impostor A physics imposter
  55714. * @param origin the origin of the explosion
  55715. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  55716. */
  55717. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  55718. /**
  55719. * Triggers affecterd impostors callbacks
  55720. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  55721. */
  55722. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  55723. /**
  55724. * Disposes the sphere.
  55725. * @param force Specifies if the sphere should be disposed by force
  55726. */
  55727. dispose(force?: boolean): void;
  55728. /*** Helpers ***/
  55729. private _prepareSphere;
  55730. private _intersectsWithSphere;
  55731. }
  55732. /**
  55733. * Represents a gravitational field event
  55734. */
  55735. class PhysicsGravitationalFieldEvent {
  55736. private _physicsHelper;
  55737. private _scene;
  55738. private _origin;
  55739. private _options;
  55740. private _tickCallback;
  55741. private _sphere;
  55742. private _dataFetched;
  55743. /**
  55744. * Initializes the physics gravitational field event
  55745. * @param _physicsHelper A physics helper
  55746. * @param _scene BabylonJS scene
  55747. * @param _origin The origin position of the gravitational field event
  55748. * @param _options The options for the vortex event
  55749. */
  55750. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  55751. /**
  55752. * Returns the data related to the gravitational field event (sphere).
  55753. * @returns A gravitational field event
  55754. */
  55755. getData(): PhysicsGravitationalFieldEventData;
  55756. /**
  55757. * Enables the gravitational field.
  55758. */
  55759. enable(): void;
  55760. /**
  55761. * Disables the gravitational field.
  55762. */
  55763. disable(): void;
  55764. /**
  55765. * Disposes the sphere.
  55766. * @param force The force to dispose from the gravitational field event
  55767. */
  55768. dispose(force?: boolean): void;
  55769. private _tick;
  55770. }
  55771. /**
  55772. * Represents a physics updraft event
  55773. */
  55774. class PhysicsUpdraftEvent {
  55775. private _scene;
  55776. private _origin;
  55777. private _options;
  55778. private _physicsEngine;
  55779. private _originTop;
  55780. private _originDirection;
  55781. private _tickCallback;
  55782. private _cylinder;
  55783. private _cylinderPosition;
  55784. private _dataFetched;
  55785. /**
  55786. * Initializes the physics updraft event
  55787. * @param _scene BabylonJS scene
  55788. * @param _origin The origin position of the updraft
  55789. * @param _options The options for the updraft event
  55790. */
  55791. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  55792. /**
  55793. * Returns the data related to the updraft event (cylinder).
  55794. * @returns A physics updraft event
  55795. */
  55796. getData(): PhysicsUpdraftEventData;
  55797. /**
  55798. * Enables the updraft.
  55799. */
  55800. enable(): void;
  55801. /**
  55802. * Disables the updraft.
  55803. */
  55804. disable(): void;
  55805. /**
  55806. * Disposes the cylinder.
  55807. * @param force Specifies if the updraft should be disposed by force
  55808. */
  55809. dispose(force?: boolean): void;
  55810. private getImpostorHitData;
  55811. private _tick;
  55812. /*** Helpers ***/
  55813. private _prepareCylinder;
  55814. private _intersectsWithCylinder;
  55815. }
  55816. /**
  55817. * Represents a physics vortex event
  55818. */
  55819. class PhysicsVortexEvent {
  55820. private _scene;
  55821. private _origin;
  55822. private _options;
  55823. private _physicsEngine;
  55824. private _originTop;
  55825. private _tickCallback;
  55826. private _cylinder;
  55827. private _cylinderPosition;
  55828. private _dataFetched;
  55829. /**
  55830. * Initializes the physics vortex event
  55831. * @param _scene The BabylonJS scene
  55832. * @param _origin The origin position of the vortex
  55833. * @param _options The options for the vortex event
  55834. */
  55835. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  55836. /**
  55837. * Returns the data related to the vortex event (cylinder).
  55838. * @returns The physics vortex event data
  55839. */
  55840. getData(): PhysicsVortexEventData;
  55841. /**
  55842. * Enables the vortex.
  55843. */
  55844. enable(): void;
  55845. /**
  55846. * Disables the cortex.
  55847. */
  55848. disable(): void;
  55849. /**
  55850. * Disposes the sphere.
  55851. * @param force
  55852. */
  55853. dispose(force?: boolean): void;
  55854. private getImpostorHitData;
  55855. private _tick;
  55856. /*** Helpers ***/
  55857. private _prepareCylinder;
  55858. private _intersectsWithCylinder;
  55859. }
  55860. /**
  55861. * Options fot the radial explosion event
  55862. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55863. */
  55864. export class PhysicsRadialExplosionEventOptions {
  55865. /**
  55866. * The radius of the sphere for the radial explosion.
  55867. */
  55868. radius: number;
  55869. /**
  55870. * The strenth of the explosion.
  55871. */
  55872. strength: number;
  55873. /**
  55874. * The strenght of the force in correspondence to the distance of the affected object
  55875. */
  55876. falloff: PhysicsRadialImpulseFalloff;
  55877. /**
  55878. * Sphere options for the radial explosion.
  55879. */
  55880. sphere: {
  55881. segments: number;
  55882. diameter: number;
  55883. };
  55884. /**
  55885. * Sphere options for the radial explosion.
  55886. */
  55887. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  55888. }
  55889. /**
  55890. * Options fot the updraft event
  55891. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55892. */
  55893. export class PhysicsUpdraftEventOptions {
  55894. /**
  55895. * The radius of the cylinder for the vortex
  55896. */
  55897. radius: number;
  55898. /**
  55899. * The strenth of the updraft.
  55900. */
  55901. strength: number;
  55902. /**
  55903. * The height of the cylinder for the updraft.
  55904. */
  55905. height: number;
  55906. /**
  55907. * The mode for the the updraft.
  55908. */
  55909. updraftMode: PhysicsUpdraftMode;
  55910. }
  55911. /**
  55912. * Options fot the vortex event
  55913. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55914. */
  55915. export class PhysicsVortexEventOptions {
  55916. /**
  55917. * The radius of the cylinder for the vortex
  55918. */
  55919. radius: number;
  55920. /**
  55921. * The strenth of the vortex.
  55922. */
  55923. strength: number;
  55924. /**
  55925. * The height of the cylinder for the vortex.
  55926. */
  55927. height: number;
  55928. /**
  55929. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  55930. */
  55931. centripetalForceThreshold: number;
  55932. /**
  55933. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  55934. */
  55935. centripetalForceMultiplier: number;
  55936. /**
  55937. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  55938. */
  55939. centrifugalForceMultiplier: number;
  55940. /**
  55941. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  55942. */
  55943. updraftForceMultiplier: number;
  55944. }
  55945. /**
  55946. * The strenght of the force in correspondence to the distance of the affected object
  55947. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55948. */
  55949. export enum PhysicsRadialImpulseFalloff {
  55950. /** Defines that impulse is constant in strength across it's whole radius */
  55951. Constant = 0,
  55952. /** Defines that impulse gets weaker if it's further from the origin */
  55953. Linear = 1
  55954. }
  55955. /**
  55956. * The strength of the force in correspondence to the distance of the affected object
  55957. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55958. */
  55959. export enum PhysicsUpdraftMode {
  55960. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  55961. Center = 0,
  55962. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  55963. Perpendicular = 1
  55964. }
  55965. /**
  55966. * Interface for a physics hit data
  55967. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55968. */
  55969. export interface PhysicsHitData {
  55970. /**
  55971. * The force applied at the contact point
  55972. */
  55973. force: Vector3;
  55974. /**
  55975. * The contact point
  55976. */
  55977. contactPoint: Vector3;
  55978. /**
  55979. * The distance from the origin to the contact point
  55980. */
  55981. distanceFromOrigin: number;
  55982. }
  55983. /**
  55984. * Interface for radial explosion event data
  55985. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55986. */
  55987. export interface PhysicsRadialExplosionEventData {
  55988. /**
  55989. * A sphere used for the radial explosion event
  55990. */
  55991. sphere: Mesh;
  55992. }
  55993. /**
  55994. * Interface for gravitational field event data
  55995. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55996. */
  55997. export interface PhysicsGravitationalFieldEventData {
  55998. /**
  55999. * A sphere mesh used for the gravitational field event
  56000. */
  56001. sphere: Mesh;
  56002. }
  56003. /**
  56004. * Interface for updraft event data
  56005. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56006. */
  56007. export interface PhysicsUpdraftEventData {
  56008. /**
  56009. * A cylinder used for the updraft event
  56010. */
  56011. cylinder: Mesh;
  56012. }
  56013. /**
  56014. * Interface for vortex event data
  56015. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56016. */
  56017. export interface PhysicsVortexEventData {
  56018. /**
  56019. * A cylinder used for the vortex event
  56020. */
  56021. cylinder: Mesh;
  56022. }
  56023. /**
  56024. * Interface for an affected physics impostor
  56025. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56026. */
  56027. export interface PhysicsAffectedImpostorWithData {
  56028. /**
  56029. * The impostor affected by the effect
  56030. */
  56031. impostor: PhysicsImpostor;
  56032. /**
  56033. * The data about the hit/horce from the explosion
  56034. */
  56035. hitData: PhysicsHitData;
  56036. }
  56037. }
  56038. declare module BABYLON {
  56039. /** @hidden */
  56040. export var blackAndWhitePixelShader: {
  56041. name: string;
  56042. shader: string;
  56043. };
  56044. }
  56045. declare module BABYLON {
  56046. /**
  56047. * Post process used to render in black and white
  56048. */
  56049. export class BlackAndWhitePostProcess extends PostProcess {
  56050. /**
  56051. * Linear about to convert he result to black and white (default: 1)
  56052. */
  56053. degree: number;
  56054. /**
  56055. * Creates a black and white post process
  56056. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  56057. * @param name The name of the effect.
  56058. * @param options The required width/height ratio to downsize to before computing the render pass.
  56059. * @param camera The camera to apply the render pass to.
  56060. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56061. * @param engine The engine which the post process will be applied. (default: current engine)
  56062. * @param reusable If the post process can be reused on the same frame. (default: false)
  56063. */
  56064. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56065. }
  56066. }
  56067. declare module BABYLON {
  56068. /**
  56069. * This represents a set of one or more post processes in Babylon.
  56070. * A post process can be used to apply a shader to a texture after it is rendered.
  56071. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56072. */
  56073. export class PostProcessRenderEffect {
  56074. private _postProcesses;
  56075. private _getPostProcesses;
  56076. private _singleInstance;
  56077. private _cameras;
  56078. private _indicesForCamera;
  56079. /**
  56080. * Name of the effect
  56081. * @hidden
  56082. */ private _name: string;
  56083. /**
  56084. * Instantiates a post process render effect.
  56085. * A post process can be used to apply a shader to a texture after it is rendered.
  56086. * @param engine The engine the effect is tied to
  56087. * @param name The name of the effect
  56088. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  56089. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  56090. */
  56091. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  56092. /**
  56093. * Checks if all the post processes in the effect are supported.
  56094. */
  56095. readonly isSupported: boolean;
  56096. /**
  56097. * Updates the current state of the effect
  56098. * @hidden
  56099. */ private _update(): void;
  56100. /**
  56101. * Attaches the effect on cameras
  56102. * @param cameras The camera to attach to.
  56103. * @hidden
  56104. */ private _attachCameras(cameras: Camera): void;
  56105. /**
  56106. * Attaches the effect on cameras
  56107. * @param cameras The camera to attach to.
  56108. * @hidden
  56109. */ private _attachCameras(cameras: Camera[]): void;
  56110. /**
  56111. * Detaches the effect on cameras
  56112. * @param cameras The camera to detatch from.
  56113. * @hidden
  56114. */ private _detachCameras(cameras: Camera): void;
  56115. /**
  56116. * Detatches the effect on cameras
  56117. * @param cameras The camera to detatch from.
  56118. * @hidden
  56119. */ private _detachCameras(cameras: Camera[]): void;
  56120. /**
  56121. * Enables the effect on given cameras
  56122. * @param cameras The camera to enable.
  56123. * @hidden
  56124. */ private _enable(cameras: Camera): void;
  56125. /**
  56126. * Enables the effect on given cameras
  56127. * @param cameras The camera to enable.
  56128. * @hidden
  56129. */ private _enable(cameras: Nullable<Camera[]>): void;
  56130. /**
  56131. * Disables the effect on the given cameras
  56132. * @param cameras The camera to disable.
  56133. * @hidden
  56134. */ private _disable(cameras: Camera): void;
  56135. /**
  56136. * Disables the effect on the given cameras
  56137. * @param cameras The camera to disable.
  56138. * @hidden
  56139. */ private _disable(cameras: Nullable<Camera[]>): void;
  56140. /**
  56141. * Gets a list of the post processes contained in the effect.
  56142. * @param camera The camera to get the post processes on.
  56143. * @returns The list of the post processes in the effect.
  56144. */
  56145. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  56146. }
  56147. }
  56148. declare module BABYLON {
  56149. /** @hidden */
  56150. export var extractHighlightsPixelShader: {
  56151. name: string;
  56152. shader: string;
  56153. };
  56154. }
  56155. declare module BABYLON {
  56156. /**
  56157. * 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.
  56158. */
  56159. export class ExtractHighlightsPostProcess extends PostProcess {
  56160. /**
  56161. * The luminance threshold, pixels below this value will be set to black.
  56162. */
  56163. threshold: number;
  56164. /** @hidden */ private _exposure: number;
  56165. /**
  56166. * Post process which has the input texture to be used when performing highlight extraction
  56167. * @hidden
  56168. */ private _inputPostProcess: Nullable<PostProcess>;
  56169. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56170. }
  56171. }
  56172. declare module BABYLON {
  56173. /** @hidden */
  56174. export var bloomMergePixelShader: {
  56175. name: string;
  56176. shader: string;
  56177. };
  56178. }
  56179. declare module BABYLON {
  56180. /**
  56181. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  56182. */
  56183. export class BloomMergePostProcess extends PostProcess {
  56184. /** Weight of the bloom to be added to the original input. */
  56185. weight: number;
  56186. /**
  56187. * Creates a new instance of @see BloomMergePostProcess
  56188. * @param name The name of the effect.
  56189. * @param originalFromInput Post process which's input will be used for the merge.
  56190. * @param blurred Blurred highlights post process which's output will be used.
  56191. * @param weight Weight of the bloom to be added to the original input.
  56192. * @param options The required width/height ratio to downsize to before computing the render pass.
  56193. * @param camera The camera to apply the render pass to.
  56194. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56195. * @param engine The engine which the post process will be applied. (default: current engine)
  56196. * @param reusable If the post process can be reused on the same frame. (default: false)
  56197. * @param textureType Type of textures used when performing the post process. (default: 0)
  56198. * @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)
  56199. */
  56200. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  56201. /** Weight of the bloom to be added to the original input. */
  56202. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56203. }
  56204. }
  56205. declare module BABYLON {
  56206. /**
  56207. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  56208. */
  56209. export class BloomEffect extends PostProcessRenderEffect {
  56210. private bloomScale;
  56211. /**
  56212. * @hidden Internal
  56213. */ private _effects: Array<PostProcess>;
  56214. /**
  56215. * @hidden Internal
  56216. */ private _downscale: ExtractHighlightsPostProcess;
  56217. private _blurX;
  56218. private _blurY;
  56219. private _merge;
  56220. /**
  56221. * The luminance threshold to find bright areas of the image to bloom.
  56222. */
  56223. threshold: number;
  56224. /**
  56225. * The strength of the bloom.
  56226. */
  56227. weight: number;
  56228. /**
  56229. * Specifies the size of the bloom blur kernel, relative to the final output size
  56230. */
  56231. kernel: number;
  56232. /**
  56233. * Creates a new instance of @see BloomEffect
  56234. * @param scene The scene the effect belongs to.
  56235. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  56236. * @param bloomKernel The size of the kernel to be used when applying the blur.
  56237. * @param bloomWeight The the strength of bloom.
  56238. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  56239. * @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)
  56240. */
  56241. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  56242. /**
  56243. * Disposes each of the internal effects for a given camera.
  56244. * @param camera The camera to dispose the effect on.
  56245. */
  56246. disposeEffects(camera: Camera): void;
  56247. /**
  56248. * @hidden Internal
  56249. */ private _updateEffects(): void;
  56250. /**
  56251. * Internal
  56252. * @returns if all the contained post processes are ready.
  56253. * @hidden
  56254. */ private _isReady(): boolean;
  56255. }
  56256. }
  56257. declare module BABYLON {
  56258. /** @hidden */
  56259. export var chromaticAberrationPixelShader: {
  56260. name: string;
  56261. shader: string;
  56262. };
  56263. }
  56264. declare module BABYLON {
  56265. /**
  56266. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  56267. */
  56268. export class ChromaticAberrationPostProcess extends PostProcess {
  56269. /**
  56270. * The amount of seperation of rgb channels (default: 30)
  56271. */
  56272. aberrationAmount: number;
  56273. /**
  56274. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  56275. */
  56276. radialIntensity: number;
  56277. /**
  56278. * 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))
  56279. */
  56280. direction: Vector2;
  56281. /**
  56282. * 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))
  56283. */
  56284. centerPosition: Vector2;
  56285. /**
  56286. * Creates a new instance ChromaticAberrationPostProcess
  56287. * @param name The name of the effect.
  56288. * @param screenWidth The width of the screen to apply the effect on.
  56289. * @param screenHeight The height of the screen to apply the effect on.
  56290. * @param options The required width/height ratio to downsize to before computing the render pass.
  56291. * @param camera The camera to apply the render pass to.
  56292. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56293. * @param engine The engine which the post process will be applied. (default: current engine)
  56294. * @param reusable If the post process can be reused on the same frame. (default: false)
  56295. * @param textureType Type of textures used when performing the post process. (default: 0)
  56296. * @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)
  56297. */
  56298. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56299. }
  56300. }
  56301. declare module BABYLON {
  56302. /** @hidden */
  56303. export var circleOfConfusionPixelShader: {
  56304. name: string;
  56305. shader: string;
  56306. };
  56307. }
  56308. declare module BABYLON {
  56309. /**
  56310. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  56311. */
  56312. export class CircleOfConfusionPostProcess extends PostProcess {
  56313. /**
  56314. * 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.
  56315. */
  56316. lensSize: number;
  56317. /**
  56318. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  56319. */
  56320. fStop: number;
  56321. /**
  56322. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  56323. */
  56324. focusDistance: number;
  56325. /**
  56326. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  56327. */
  56328. focalLength: number;
  56329. private _depthTexture;
  56330. /**
  56331. * Creates a new instance CircleOfConfusionPostProcess
  56332. * @param name The name of the effect.
  56333. * @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.
  56334. * @param options The required width/height ratio to downsize to before computing the render pass.
  56335. * @param camera The camera to apply the render pass to.
  56336. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56337. * @param engine The engine which the post process will be applied. (default: current engine)
  56338. * @param reusable If the post process can be reused on the same frame. (default: false)
  56339. * @param textureType Type of textures used when performing the post process. (default: 0)
  56340. * @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)
  56341. */
  56342. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56343. /**
  56344. * 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.
  56345. */
  56346. depthTexture: RenderTargetTexture;
  56347. }
  56348. }
  56349. declare module BABYLON {
  56350. /** @hidden */
  56351. export var colorCorrectionPixelShader: {
  56352. name: string;
  56353. shader: string;
  56354. };
  56355. }
  56356. declare module BABYLON {
  56357. /**
  56358. *
  56359. * This post-process allows the modification of rendered colors by using
  56360. * a 'look-up table' (LUT). This effect is also called Color Grading.
  56361. *
  56362. * The object needs to be provided an url to a texture containing the color
  56363. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  56364. * Use an image editing software to tweak the LUT to match your needs.
  56365. *
  56366. * For an example of a color LUT, see here:
  56367. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  56368. * For explanations on color grading, see here:
  56369. * @see http://udn.epicgames.com/Three/ColorGrading.html
  56370. *
  56371. */
  56372. export class ColorCorrectionPostProcess extends PostProcess {
  56373. private _colorTableTexture;
  56374. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56375. }
  56376. }
  56377. declare module BABYLON {
  56378. /** @hidden */
  56379. export var convolutionPixelShader: {
  56380. name: string;
  56381. shader: string;
  56382. };
  56383. }
  56384. declare module BABYLON {
  56385. /**
  56386. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  56387. * input texture to perform effects such as edge detection or sharpening
  56388. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  56389. */
  56390. export class ConvolutionPostProcess extends PostProcess {
  56391. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  56392. kernel: number[];
  56393. /**
  56394. * Creates a new instance ConvolutionPostProcess
  56395. * @param name The name of the effect.
  56396. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  56397. * @param options The required width/height ratio to downsize to before computing the render pass.
  56398. * @param camera The camera to apply the render pass to.
  56399. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56400. * @param engine The engine which the post process will be applied. (default: current engine)
  56401. * @param reusable If the post process can be reused on the same frame. (default: false)
  56402. * @param textureType Type of textures used when performing the post process. (default: 0)
  56403. */
  56404. constructor(name: string,
  56405. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  56406. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  56407. /**
  56408. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  56409. */
  56410. static EdgeDetect0Kernel: number[];
  56411. /**
  56412. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  56413. */
  56414. static EdgeDetect1Kernel: number[];
  56415. /**
  56416. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  56417. */
  56418. static EdgeDetect2Kernel: number[];
  56419. /**
  56420. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  56421. */
  56422. static SharpenKernel: number[];
  56423. /**
  56424. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  56425. */
  56426. static EmbossKernel: number[];
  56427. /**
  56428. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  56429. */
  56430. static GaussianKernel: number[];
  56431. }
  56432. }
  56433. declare module BABYLON {
  56434. /**
  56435. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  56436. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  56437. * based on samples that have a large difference in distance than the center pixel.
  56438. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  56439. */
  56440. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  56441. direction: Vector2;
  56442. /**
  56443. * Creates a new instance CircleOfConfusionPostProcess
  56444. * @param name The name of the effect.
  56445. * @param scene The scene the effect belongs to.
  56446. * @param direction The direction the blur should be applied.
  56447. * @param kernel The size of the kernel used to blur.
  56448. * @param options The required width/height ratio to downsize to before computing the render pass.
  56449. * @param camera The camera to apply the render pass to.
  56450. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  56451. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  56452. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56453. * @param engine The engine which the post process will be applied. (default: current engine)
  56454. * @param reusable If the post process can be reused on the same frame. (default: false)
  56455. * @param textureType Type of textures used when performing the post process. (default: 0)
  56456. * @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)
  56457. */
  56458. 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);
  56459. }
  56460. }
  56461. declare module BABYLON {
  56462. /** @hidden */
  56463. export var depthOfFieldMergePixelShader: {
  56464. name: string;
  56465. shader: string;
  56466. };
  56467. }
  56468. declare module BABYLON {
  56469. /**
  56470. * Options to be set when merging outputs from the default pipeline.
  56471. */
  56472. export class DepthOfFieldMergePostProcessOptions {
  56473. /**
  56474. * The original image to merge on top of
  56475. */
  56476. originalFromInput: PostProcess;
  56477. /**
  56478. * Parameters to perform the merge of the depth of field effect
  56479. */
  56480. depthOfField?: {
  56481. circleOfConfusion: PostProcess;
  56482. blurSteps: Array<PostProcess>;
  56483. };
  56484. /**
  56485. * Parameters to perform the merge of bloom effect
  56486. */
  56487. bloom?: {
  56488. blurred: PostProcess;
  56489. weight: number;
  56490. };
  56491. }
  56492. /**
  56493. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  56494. */
  56495. export class DepthOfFieldMergePostProcess extends PostProcess {
  56496. private blurSteps;
  56497. /**
  56498. * Creates a new instance of DepthOfFieldMergePostProcess
  56499. * @param name The name of the effect.
  56500. * @param originalFromInput Post process which's input will be used for the merge.
  56501. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  56502. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  56503. * @param options The required width/height ratio to downsize to before computing the render pass.
  56504. * @param camera The camera to apply the render pass to.
  56505. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56506. * @param engine The engine which the post process will be applied. (default: current engine)
  56507. * @param reusable If the post process can be reused on the same frame. (default: false)
  56508. * @param textureType Type of textures used when performing the post process. (default: 0)
  56509. * @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)
  56510. */
  56511. 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);
  56512. /**
  56513. * Updates the effect with the current post process compile time values and recompiles the shader.
  56514. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  56515. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  56516. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  56517. * @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
  56518. * @param onCompiled Called when the shader has been compiled.
  56519. * @param onError Called if there is an error when compiling a shader.
  56520. */
  56521. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  56522. }
  56523. }
  56524. declare module BABYLON {
  56525. /**
  56526. * Specifies the level of max blur that should be applied when using the depth of field effect
  56527. */
  56528. export enum DepthOfFieldEffectBlurLevel {
  56529. /**
  56530. * Subtle blur
  56531. */
  56532. Low = 0,
  56533. /**
  56534. * Medium blur
  56535. */
  56536. Medium = 1,
  56537. /**
  56538. * Large blur
  56539. */
  56540. High = 2
  56541. }
  56542. /**
  56543. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  56544. */
  56545. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  56546. private _circleOfConfusion;
  56547. /**
  56548. * @hidden Internal, blurs from high to low
  56549. */ private _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  56550. private _depthOfFieldBlurY;
  56551. private _dofMerge;
  56552. /**
  56553. * @hidden Internal post processes in depth of field effect
  56554. */ private _effects: Array<PostProcess>;
  56555. /**
  56556. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  56557. */
  56558. focalLength: number;
  56559. /**
  56560. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  56561. */
  56562. fStop: number;
  56563. /**
  56564. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  56565. */
  56566. focusDistance: number;
  56567. /**
  56568. * 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.
  56569. */
  56570. lensSize: number;
  56571. /**
  56572. * Creates a new instance DepthOfFieldEffect
  56573. * @param scene The scene the effect belongs to.
  56574. * @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.
  56575. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  56576. * @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)
  56577. */
  56578. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  56579. /**
  56580. * Get the current class name of the current effet
  56581. * @returns "DepthOfFieldEffect"
  56582. */
  56583. getClassName(): string;
  56584. /**
  56585. * 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.
  56586. */
  56587. depthTexture: RenderTargetTexture;
  56588. /**
  56589. * Disposes each of the internal effects for a given camera.
  56590. * @param camera The camera to dispose the effect on.
  56591. */
  56592. disposeEffects(camera: Camera): void;
  56593. /**
  56594. * @hidden Internal
  56595. */ private _updateEffects(): void;
  56596. /**
  56597. * Internal
  56598. * @returns if all the contained post processes are ready.
  56599. * @hidden
  56600. */ private _isReady(): boolean;
  56601. }
  56602. }
  56603. declare module BABYLON {
  56604. /** @hidden */
  56605. export var displayPassPixelShader: {
  56606. name: string;
  56607. shader: string;
  56608. };
  56609. }
  56610. declare module BABYLON {
  56611. /**
  56612. * DisplayPassPostProcess which produces an output the same as it's input
  56613. */
  56614. export class DisplayPassPostProcess extends PostProcess {
  56615. /**
  56616. * Creates the DisplayPassPostProcess
  56617. * @param name The name of the effect.
  56618. * @param options The required width/height ratio to downsize to before computing the render pass.
  56619. * @param camera The camera to apply the render pass to.
  56620. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56621. * @param engine The engine which the post process will be applied. (default: current engine)
  56622. * @param reusable If the post process can be reused on the same frame. (default: false)
  56623. */
  56624. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56625. }
  56626. }
  56627. declare module BABYLON {
  56628. /** @hidden */
  56629. export var filterPixelShader: {
  56630. name: string;
  56631. shader: string;
  56632. };
  56633. }
  56634. declare module BABYLON {
  56635. /**
  56636. * Applies a kernel filter to the image
  56637. */
  56638. export class FilterPostProcess extends PostProcess {
  56639. /** The matrix to be applied to the image */
  56640. kernelMatrix: Matrix;
  56641. /**
  56642. *
  56643. * @param name The name of the effect.
  56644. * @param kernelMatrix The matrix to be applied to the image
  56645. * @param options The required width/height ratio to downsize to before computing the render pass.
  56646. * @param camera The camera to apply the render pass to.
  56647. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56648. * @param engine The engine which the post process will be applied. (default: current engine)
  56649. * @param reusable If the post process can be reused on the same frame. (default: false)
  56650. */
  56651. constructor(name: string,
  56652. /** The matrix to be applied to the image */
  56653. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56654. }
  56655. }
  56656. declare module BABYLON {
  56657. /** @hidden */
  56658. export var fxaaPixelShader: {
  56659. name: string;
  56660. shader: string;
  56661. };
  56662. }
  56663. declare module BABYLON {
  56664. /** @hidden */
  56665. export var fxaaVertexShader: {
  56666. name: string;
  56667. shader: string;
  56668. };
  56669. }
  56670. declare module BABYLON {
  56671. /**
  56672. * Fxaa post process
  56673. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  56674. */
  56675. export class FxaaPostProcess extends PostProcess {
  56676. /** @hidden */
  56677. texelWidth: number;
  56678. /** @hidden */
  56679. texelHeight: number;
  56680. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  56681. private _getDefines;
  56682. }
  56683. }
  56684. declare module BABYLON {
  56685. /** @hidden */
  56686. export var grainPixelShader: {
  56687. name: string;
  56688. shader: string;
  56689. };
  56690. }
  56691. declare module BABYLON {
  56692. /**
  56693. * The GrainPostProcess adds noise to the image at mid luminance levels
  56694. */
  56695. export class GrainPostProcess extends PostProcess {
  56696. /**
  56697. * The intensity of the grain added (default: 30)
  56698. */
  56699. intensity: number;
  56700. /**
  56701. * If the grain should be randomized on every frame
  56702. */
  56703. animated: boolean;
  56704. /**
  56705. * Creates a new instance of @see GrainPostProcess
  56706. * @param name The name of the effect.
  56707. * @param options The required width/height ratio to downsize to before computing the render pass.
  56708. * @param camera The camera to apply the render pass to.
  56709. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56710. * @param engine The engine which the post process will be applied. (default: current engine)
  56711. * @param reusable If the post process can be reused on the same frame. (default: false)
  56712. * @param textureType Type of textures used when performing the post process. (default: 0)
  56713. * @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)
  56714. */
  56715. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56716. }
  56717. }
  56718. declare module BABYLON {
  56719. /** @hidden */
  56720. export var highlightsPixelShader: {
  56721. name: string;
  56722. shader: string;
  56723. };
  56724. }
  56725. declare module BABYLON {
  56726. /**
  56727. * Extracts highlights from the image
  56728. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  56729. */
  56730. export class HighlightsPostProcess extends PostProcess {
  56731. /**
  56732. * Extracts highlights from the image
  56733. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  56734. * @param name The name of the effect.
  56735. * @param options The required width/height ratio to downsize to before computing the render pass.
  56736. * @param camera The camera to apply the render pass to.
  56737. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56738. * @param engine The engine which the post process will be applied. (default: current engine)
  56739. * @param reusable If the post process can be reused on the same frame. (default: false)
  56740. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  56741. */
  56742. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  56743. }
  56744. }
  56745. declare module BABYLON {
  56746. /** @hidden */
  56747. export var mrtFragmentDeclaration: {
  56748. name: string;
  56749. shader: string;
  56750. };
  56751. }
  56752. declare module BABYLON {
  56753. /** @hidden */
  56754. export var geometryPixelShader: {
  56755. name: string;
  56756. shader: string;
  56757. };
  56758. }
  56759. declare module BABYLON {
  56760. /** @hidden */
  56761. export var geometryVertexShader: {
  56762. name: string;
  56763. shader: string;
  56764. };
  56765. }
  56766. declare module BABYLON {
  56767. /** @hidden */
  56768. interface ISavedTransformationMatrix {
  56769. world: Matrix;
  56770. viewProjection: Matrix;
  56771. }
  56772. /**
  56773. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  56774. */
  56775. export class GeometryBufferRenderer {
  56776. /**
  56777. * Constant used to retrieve the position texture index in the G-Buffer textures array
  56778. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  56779. */
  56780. static readonly POSITION_TEXTURE_TYPE: number;
  56781. /**
  56782. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  56783. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  56784. */
  56785. static readonly VELOCITY_TEXTURE_TYPE: number;
  56786. /**
  56787. * Dictionary used to store the previous transformation matrices of each rendered mesh
  56788. * in order to compute objects velocities when enableVelocity is set to "true"
  56789. * @hidden
  56790. */ private _previousTransformationMatrices: {
  56791. [index: number]: ISavedTransformationMatrix;
  56792. };
  56793. /**
  56794. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  56795. * in order to compute objects velocities when enableVelocity is set to "true"
  56796. * @hidden
  56797. */ private _previousBonesTransformationMatrices: {
  56798. [index: number]: Float32Array;
  56799. };
  56800. /**
  56801. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  56802. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  56803. */
  56804. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  56805. private _scene;
  56806. private _multiRenderTarget;
  56807. private _ratio;
  56808. private _enablePosition;
  56809. private _enableVelocity;
  56810. private _positionIndex;
  56811. private _velocityIndex;
  56812. protected _effect: Effect;
  56813. protected _cachedDefines: string;
  56814. /**
  56815. * Set the render list (meshes to be rendered) used in the G buffer.
  56816. */
  56817. renderList: Mesh[];
  56818. /**
  56819. * Gets wether or not G buffer are supported by the running hardware.
  56820. * This requires draw buffer supports
  56821. */
  56822. readonly isSupported: boolean;
  56823. /**
  56824. * Returns the index of the given texture type in the G-Buffer textures array
  56825. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  56826. * @returns the index of the given texture type in the G-Buffer textures array
  56827. */
  56828. getTextureIndex(textureType: number): number;
  56829. /**
  56830. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  56831. */
  56832. /**
  56833. * Sets whether or not objects positions are enabled for the G buffer.
  56834. */
  56835. enablePosition: boolean;
  56836. /**
  56837. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  56838. */
  56839. /**
  56840. * Sets wether or not objects velocities are enabled for the G buffer.
  56841. */
  56842. enableVelocity: boolean;
  56843. /**
  56844. * Gets the scene associated with the buffer.
  56845. */
  56846. readonly scene: Scene;
  56847. /**
  56848. * Gets the ratio used by the buffer during its creation.
  56849. * How big is the buffer related to the main canvas.
  56850. */
  56851. readonly ratio: number;
  56852. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  56853. /**
  56854. * Creates a new G Buffer for the scene
  56855. * @param scene The scene the buffer belongs to
  56856. * @param ratio How big is the buffer related to the main canvas.
  56857. */
  56858. constructor(scene: Scene, ratio?: number);
  56859. /**
  56860. * Checks wether everything is ready to render a submesh to the G buffer.
  56861. * @param subMesh the submesh to check readiness for
  56862. * @param useInstances is the mesh drawn using instance or not
  56863. * @returns true if ready otherwise false
  56864. */
  56865. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56866. /**
  56867. * Gets the current underlying G Buffer.
  56868. * @returns the buffer
  56869. */
  56870. getGBuffer(): MultiRenderTarget;
  56871. /**
  56872. * Gets the number of samples used to render the buffer (anti aliasing).
  56873. */
  56874. /**
  56875. * Sets the number of samples used to render the buffer (anti aliasing).
  56876. */
  56877. samples: number;
  56878. /**
  56879. * Disposes the renderer and frees up associated resources.
  56880. */
  56881. dispose(): void;
  56882. protected _createRenderTargets(): void;
  56883. private _copyBonesTransformationMatrices;
  56884. }
  56885. }
  56886. declare module BABYLON {
  56887. interface Scene {
  56888. /** @hidden (Backing field) */ private _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  56889. /**
  56890. * Gets or Sets the current geometry buffer associated to the scene.
  56891. */
  56892. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  56893. /**
  56894. * Enables a GeometryBufferRender and associates it with the scene
  56895. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  56896. * @returns the GeometryBufferRenderer
  56897. */
  56898. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  56899. /**
  56900. * Disables the GeometryBufferRender associated with the scene
  56901. */
  56902. disableGeometryBufferRenderer(): void;
  56903. }
  56904. /**
  56905. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  56906. * in several rendering techniques.
  56907. */
  56908. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  56909. /**
  56910. * The component name helpful to identify the component in the list of scene components.
  56911. */
  56912. readonly name: string;
  56913. /**
  56914. * The scene the component belongs to.
  56915. */
  56916. scene: Scene;
  56917. /**
  56918. * Creates a new instance of the component for the given scene
  56919. * @param scene Defines the scene to register the component in
  56920. */
  56921. constructor(scene: Scene);
  56922. /**
  56923. * Registers the component in a given scene
  56924. */
  56925. register(): void;
  56926. /**
  56927. * Rebuilds the elements related to this component in case of
  56928. * context lost for instance.
  56929. */
  56930. rebuild(): void;
  56931. /**
  56932. * Disposes the component and the associated ressources
  56933. */
  56934. dispose(): void;
  56935. private _gatherRenderTargets;
  56936. }
  56937. }
  56938. declare module BABYLON {
  56939. /** @hidden */
  56940. export var motionBlurPixelShader: {
  56941. name: string;
  56942. shader: string;
  56943. };
  56944. }
  56945. declare module BABYLON {
  56946. /**
  56947. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  56948. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  56949. * As an example, all you have to do is to create the post-process:
  56950. * var mb = new BABYLON.MotionBlurPostProcess(
  56951. * 'mb', // The name of the effect.
  56952. * scene, // The scene containing the objects to blur according to their velocity.
  56953. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  56954. * camera // The camera to apply the render pass to.
  56955. * );
  56956. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  56957. */
  56958. export class MotionBlurPostProcess extends PostProcess {
  56959. /**
  56960. * Defines how much the image is blurred by the movement. Default value is equal to 1
  56961. */
  56962. motionStrength: number;
  56963. /**
  56964. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  56965. */
  56966. /**
  56967. * Sets the number of iterations to be used for motion blur quality
  56968. */
  56969. motionBlurSamples: number;
  56970. private _motionBlurSamples;
  56971. private _geometryBufferRenderer;
  56972. /**
  56973. * Creates a new instance MotionBlurPostProcess
  56974. * @param name The name of the effect.
  56975. * @param scene The scene containing the objects to blur according to their velocity.
  56976. * @param options The required width/height ratio to downsize to before computing the render pass.
  56977. * @param camera The camera to apply the render pass to.
  56978. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56979. * @param engine The engine which the post process will be applied. (default: current engine)
  56980. * @param reusable If the post process can be reused on the same frame. (default: false)
  56981. * @param textureType Type of textures used when performing the post process. (default: 0)
  56982. * @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)
  56983. */
  56984. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56985. /**
  56986. * Excludes the given skinned mesh from computing bones velocities.
  56987. * Computing bones velocities can have a cost and that cost. The cost can be saved by calling this function and by passing the skinned mesh reference to ignore.
  56988. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  56989. */
  56990. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  56991. /**
  56992. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  56993. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  56994. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  56995. */
  56996. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  56997. /**
  56998. * Disposes the post process.
  56999. * @param camera The camera to dispose the post process on.
  57000. */
  57001. dispose(camera?: Camera): void;
  57002. }
  57003. }
  57004. declare module BABYLON {
  57005. /** @hidden */
  57006. export var refractionPixelShader: {
  57007. name: string;
  57008. shader: string;
  57009. };
  57010. }
  57011. declare module BABYLON {
  57012. /**
  57013. * Post process which applies a refractin texture
  57014. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  57015. */
  57016. export class RefractionPostProcess extends PostProcess {
  57017. /** the base color of the refraction (used to taint the rendering) */
  57018. color: Color3;
  57019. /** simulated refraction depth */
  57020. depth: number;
  57021. /** the coefficient of the base color (0 to remove base color tainting) */
  57022. colorLevel: number;
  57023. private _refTexture;
  57024. private _ownRefractionTexture;
  57025. /**
  57026. * Gets or sets the refraction texture
  57027. * Please note that you are responsible for disposing the texture if you set it manually
  57028. */
  57029. refractionTexture: Texture;
  57030. /**
  57031. * Initializes the RefractionPostProcess
  57032. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  57033. * @param name The name of the effect.
  57034. * @param refractionTextureUrl Url of the refraction texture to use
  57035. * @param color the base color of the refraction (used to taint the rendering)
  57036. * @param depth simulated refraction depth
  57037. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  57038. * @param camera The camera to apply the render pass to.
  57039. * @param options The required width/height ratio to downsize to before computing the render pass.
  57040. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57041. * @param engine The engine which the post process will be applied. (default: current engine)
  57042. * @param reusable If the post process can be reused on the same frame. (default: false)
  57043. */
  57044. constructor(name: string, refractionTextureUrl: string,
  57045. /** the base color of the refraction (used to taint the rendering) */
  57046. color: Color3,
  57047. /** simulated refraction depth */
  57048. depth: number,
  57049. /** the coefficient of the base color (0 to remove base color tainting) */
  57050. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57051. /**
  57052. * Disposes of the post process
  57053. * @param camera Camera to dispose post process on
  57054. */
  57055. dispose(camera: Camera): void;
  57056. }
  57057. }
  57058. declare module BABYLON {
  57059. /** @hidden */
  57060. export var sharpenPixelShader: {
  57061. name: string;
  57062. shader: string;
  57063. };
  57064. }
  57065. declare module BABYLON {
  57066. /**
  57067. * The SharpenPostProcess applies a sharpen kernel to every pixel
  57068. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  57069. */
  57070. export class SharpenPostProcess extends PostProcess {
  57071. /**
  57072. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  57073. */
  57074. colorAmount: number;
  57075. /**
  57076. * How much sharpness should be applied (default: 0.3)
  57077. */
  57078. edgeAmount: number;
  57079. /**
  57080. * Creates a new instance ConvolutionPostProcess
  57081. * @param name The name of the effect.
  57082. * @param options The required width/height ratio to downsize to before computing the render pass.
  57083. * @param camera The camera to apply the render pass to.
  57084. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57085. * @param engine The engine which the post process will be applied. (default: current engine)
  57086. * @param reusable If the post process can be reused on the same frame. (default: false)
  57087. * @param textureType Type of textures used when performing the post process. (default: 0)
  57088. * @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)
  57089. */
  57090. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57091. }
  57092. }
  57093. declare module BABYLON {
  57094. /**
  57095. * PostProcessRenderPipeline
  57096. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57097. */
  57098. export class PostProcessRenderPipeline {
  57099. private engine;
  57100. private _renderEffects;
  57101. private _renderEffectsForIsolatedPass;
  57102. /**
  57103. * List of inspectable custom properties (used by the Inspector)
  57104. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  57105. */
  57106. inspectableCustomProperties: IInspectable[];
  57107. /**
  57108. * @hidden
  57109. */
  57110. protected _cameras: Camera[];
  57111. /** @hidden */ private _name: string;
  57112. /**
  57113. * Gets pipeline name
  57114. */
  57115. readonly name: string;
  57116. /**
  57117. * Initializes a PostProcessRenderPipeline
  57118. * @param engine engine to add the pipeline to
  57119. * @param name name of the pipeline
  57120. */
  57121. constructor(engine: Engine, name: string);
  57122. /**
  57123. * Gets the class name
  57124. * @returns "PostProcessRenderPipeline"
  57125. */
  57126. getClassName(): string;
  57127. /**
  57128. * If all the render effects in the pipeline are supported
  57129. */
  57130. readonly isSupported: boolean;
  57131. /**
  57132. * Adds an effect to the pipeline
  57133. * @param renderEffect the effect to add
  57134. */
  57135. addEffect(renderEffect: PostProcessRenderEffect): void;
  57136. /** @hidden */ private _rebuild(): void;
  57137. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera): void;
  57138. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  57139. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  57140. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  57141. /** @hidden */ private _attachCameras(cameras: Camera, unique: boolean): void;
  57142. /** @hidden */ private _attachCameras(cameras: Camera[], unique: boolean): void;
  57143. /** @hidden */ private _detachCameras(cameras: Camera): void;
  57144. /** @hidden */ private _detachCameras(cameras: Nullable<Camera[]>): void;
  57145. /** @hidden */ private _update(): void;
  57146. /** @hidden */ private _reset(): void;
  57147. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  57148. /**
  57149. * Disposes of the pipeline
  57150. */
  57151. dispose(): void;
  57152. }
  57153. }
  57154. declare module BABYLON {
  57155. /**
  57156. * PostProcessRenderPipelineManager class
  57157. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57158. */
  57159. export class PostProcessRenderPipelineManager {
  57160. private _renderPipelines;
  57161. /**
  57162. * Initializes a PostProcessRenderPipelineManager
  57163. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57164. */
  57165. constructor();
  57166. /**
  57167. * Gets the list of supported render pipelines
  57168. */
  57169. readonly supportedPipelines: PostProcessRenderPipeline[];
  57170. /**
  57171. * Adds a pipeline to the manager
  57172. * @param renderPipeline The pipeline to add
  57173. */
  57174. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  57175. /**
  57176. * Attaches a camera to the pipeline
  57177. * @param renderPipelineName The name of the pipeline to attach to
  57178. * @param cameras the camera to attach
  57179. * @param unique if the camera can be attached multiple times to the pipeline
  57180. */
  57181. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  57182. /**
  57183. * Detaches a camera from the pipeline
  57184. * @param renderPipelineName The name of the pipeline to detach from
  57185. * @param cameras the camera to detach
  57186. */
  57187. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  57188. /**
  57189. * Enables an effect by name on a pipeline
  57190. * @param renderPipelineName the name of the pipeline to enable the effect in
  57191. * @param renderEffectName the name of the effect to enable
  57192. * @param cameras the cameras that the effect should be enabled on
  57193. */
  57194. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  57195. /**
  57196. * Disables an effect by name on a pipeline
  57197. * @param renderPipelineName the name of the pipeline to disable the effect in
  57198. * @param renderEffectName the name of the effect to disable
  57199. * @param cameras the cameras that the effect should be disabled on
  57200. */
  57201. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  57202. /**
  57203. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  57204. */
  57205. update(): void;
  57206. /** @hidden */ private _rebuild(): void;
  57207. /**
  57208. * Disposes of the manager and pipelines
  57209. */
  57210. dispose(): void;
  57211. }
  57212. }
  57213. declare module BABYLON {
  57214. interface Scene {
  57215. /** @hidden (Backing field) */ private _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  57216. /**
  57217. * Gets the postprocess render pipeline manager
  57218. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57219. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  57220. */
  57221. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  57222. }
  57223. /**
  57224. * Defines the Render Pipeline scene component responsible to rendering pipelines
  57225. */
  57226. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  57227. /**
  57228. * The component name helpfull to identify the component in the list of scene components.
  57229. */
  57230. readonly name: string;
  57231. /**
  57232. * The scene the component belongs to.
  57233. */
  57234. scene: Scene;
  57235. /**
  57236. * Creates a new instance of the component for the given scene
  57237. * @param scene Defines the scene to register the component in
  57238. */
  57239. constructor(scene: Scene);
  57240. /**
  57241. * Registers the component in a given scene
  57242. */
  57243. register(): void;
  57244. /**
  57245. * Rebuilds the elements related to this component in case of
  57246. * context lost for instance.
  57247. */
  57248. rebuild(): void;
  57249. /**
  57250. * Disposes the component and the associated ressources
  57251. */
  57252. dispose(): void;
  57253. private _gatherRenderTargets;
  57254. }
  57255. }
  57256. declare module BABYLON {
  57257. /**
  57258. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  57259. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  57260. */
  57261. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  57262. private _scene;
  57263. private _camerasToBeAttached;
  57264. /**
  57265. * ID of the sharpen post process,
  57266. */
  57267. private readonly SharpenPostProcessId;
  57268. /**
  57269. * @ignore
  57270. * ID of the image processing post process;
  57271. */
  57272. readonly ImageProcessingPostProcessId: string;
  57273. /**
  57274. * @ignore
  57275. * ID of the Fast Approximate Anti-Aliasing post process;
  57276. */
  57277. readonly FxaaPostProcessId: string;
  57278. /**
  57279. * ID of the chromatic aberration post process,
  57280. */
  57281. private readonly ChromaticAberrationPostProcessId;
  57282. /**
  57283. * ID of the grain post process
  57284. */
  57285. private readonly GrainPostProcessId;
  57286. /**
  57287. * Sharpen post process which will apply a sharpen convolution to enhance edges
  57288. */
  57289. sharpen: SharpenPostProcess;
  57290. private _sharpenEffect;
  57291. private bloom;
  57292. /**
  57293. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  57294. */
  57295. depthOfField: DepthOfFieldEffect;
  57296. /**
  57297. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  57298. */
  57299. fxaa: FxaaPostProcess;
  57300. /**
  57301. * Image post processing pass used to perform operations such as tone mapping or color grading.
  57302. */
  57303. imageProcessing: ImageProcessingPostProcess;
  57304. /**
  57305. * Chromatic aberration post process which will shift rgb colors in the image
  57306. */
  57307. chromaticAberration: ChromaticAberrationPostProcess;
  57308. private _chromaticAberrationEffect;
  57309. /**
  57310. * Grain post process which add noise to the image
  57311. */
  57312. grain: GrainPostProcess;
  57313. private _grainEffect;
  57314. /**
  57315. * Glow post process which adds a glow to emissive areas of the image
  57316. */
  57317. private _glowLayer;
  57318. /**
  57319. * Animations which can be used to tweak settings over a period of time
  57320. */
  57321. animations: Animation[];
  57322. private _imageProcessingConfigurationObserver;
  57323. private _sharpenEnabled;
  57324. private _bloomEnabled;
  57325. private _depthOfFieldEnabled;
  57326. private _depthOfFieldBlurLevel;
  57327. private _fxaaEnabled;
  57328. private _imageProcessingEnabled;
  57329. private _defaultPipelineTextureType;
  57330. private _bloomScale;
  57331. private _chromaticAberrationEnabled;
  57332. private _grainEnabled;
  57333. private _buildAllowed;
  57334. /**
  57335. * Gets active scene
  57336. */
  57337. readonly scene: Scene;
  57338. /**
  57339. * Enable or disable the sharpen process from the pipeline
  57340. */
  57341. sharpenEnabled: boolean;
  57342. private _resizeObserver;
  57343. private _hardwareScaleLevel;
  57344. private _bloomKernel;
  57345. /**
  57346. * Specifies the size of the bloom blur kernel, relative to the final output size
  57347. */
  57348. bloomKernel: number;
  57349. /**
  57350. * Specifies the weight of the bloom in the final rendering
  57351. */
  57352. private _bloomWeight;
  57353. /**
  57354. * Specifies the luma threshold for the area that will be blurred by the bloom
  57355. */
  57356. private _bloomThreshold;
  57357. private _hdr;
  57358. /**
  57359. * The strength of the bloom.
  57360. */
  57361. bloomWeight: number;
  57362. /**
  57363. * The strength of the bloom.
  57364. */
  57365. bloomThreshold: number;
  57366. /**
  57367. * The scale of the bloom, lower value will provide better performance.
  57368. */
  57369. bloomScale: number;
  57370. /**
  57371. * Enable or disable the bloom from the pipeline
  57372. */
  57373. bloomEnabled: boolean;
  57374. private _rebuildBloom;
  57375. /**
  57376. * If the depth of field is enabled.
  57377. */
  57378. depthOfFieldEnabled: boolean;
  57379. /**
  57380. * Blur level of the depth of field effect. (Higher blur will effect performance)
  57381. */
  57382. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  57383. /**
  57384. * If the anti aliasing is enabled.
  57385. */
  57386. fxaaEnabled: boolean;
  57387. private _samples;
  57388. /**
  57389. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  57390. */
  57391. samples: number;
  57392. /**
  57393. * If image processing is enabled.
  57394. */
  57395. imageProcessingEnabled: boolean;
  57396. /**
  57397. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  57398. */
  57399. glowLayerEnabled: boolean;
  57400. /**
  57401. * Gets the glow layer (or null if not defined)
  57402. */
  57403. readonly glowLayer: Nullable<GlowLayer>;
  57404. /**
  57405. * Enable or disable the chromaticAberration process from the pipeline
  57406. */
  57407. chromaticAberrationEnabled: boolean;
  57408. /**
  57409. * Enable or disable the grain process from the pipeline
  57410. */
  57411. grainEnabled: boolean;
  57412. /**
  57413. * @constructor
  57414. * @param name - The rendering pipeline name (default: "")
  57415. * @param hdr - If high dynamic range textures should be used (default: true)
  57416. * @param scene - The scene linked to this pipeline (default: the last created scene)
  57417. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  57418. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  57419. */
  57420. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  57421. /**
  57422. * Get the class name
  57423. * @returns "DefaultRenderingPipeline"
  57424. */
  57425. getClassName(): string;
  57426. /**
  57427. * Force the compilation of the entire pipeline.
  57428. */
  57429. prepare(): void;
  57430. private _hasCleared;
  57431. private _prevPostProcess;
  57432. private _prevPrevPostProcess;
  57433. private _setAutoClearAndTextureSharing;
  57434. private _depthOfFieldSceneObserver;
  57435. private _buildPipeline;
  57436. private _disposePostProcesses;
  57437. /**
  57438. * Adds a camera to the pipeline
  57439. * @param camera the camera to be added
  57440. */
  57441. addCamera(camera: Camera): void;
  57442. /**
  57443. * Removes a camera from the pipeline
  57444. * @param camera the camera to remove
  57445. */
  57446. removeCamera(camera: Camera): void;
  57447. /**
  57448. * Dispose of the pipeline and stop all post processes
  57449. */
  57450. dispose(): void;
  57451. /**
  57452. * Serialize the rendering pipeline (Used when exporting)
  57453. * @returns the serialized object
  57454. */
  57455. serialize(): any;
  57456. /**
  57457. * Parse the serialized pipeline
  57458. * @param source Source pipeline.
  57459. * @param scene The scene to load the pipeline to.
  57460. * @param rootUrl The URL of the serialized pipeline.
  57461. * @returns An instantiated pipeline from the serialized object.
  57462. */
  57463. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  57464. }
  57465. }
  57466. declare module BABYLON {
  57467. /** @hidden */
  57468. export var lensHighlightsPixelShader: {
  57469. name: string;
  57470. shader: string;
  57471. };
  57472. }
  57473. declare module BABYLON {
  57474. /** @hidden */
  57475. export var depthOfFieldPixelShader: {
  57476. name: string;
  57477. shader: string;
  57478. };
  57479. }
  57480. declare module BABYLON {
  57481. /**
  57482. * BABYLON.JS Chromatic Aberration GLSL Shader
  57483. * Author: Olivier Guyot
  57484. * Separates very slightly R, G and B colors on the edges of the screen
  57485. * Inspired by Francois Tarlier & Martins Upitis
  57486. */
  57487. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  57488. /**
  57489. * @ignore
  57490. * The chromatic aberration PostProcess id in the pipeline
  57491. */
  57492. LensChromaticAberrationEffect: string;
  57493. /**
  57494. * @ignore
  57495. * The highlights enhancing PostProcess id in the pipeline
  57496. */
  57497. HighlightsEnhancingEffect: string;
  57498. /**
  57499. * @ignore
  57500. * The depth-of-field PostProcess id in the pipeline
  57501. */
  57502. LensDepthOfFieldEffect: string;
  57503. private _scene;
  57504. private _depthTexture;
  57505. private _grainTexture;
  57506. private _chromaticAberrationPostProcess;
  57507. private _highlightsPostProcess;
  57508. private _depthOfFieldPostProcess;
  57509. private _edgeBlur;
  57510. private _grainAmount;
  57511. private _chromaticAberration;
  57512. private _distortion;
  57513. private _highlightsGain;
  57514. private _highlightsThreshold;
  57515. private _dofDistance;
  57516. private _dofAperture;
  57517. private _dofDarken;
  57518. private _dofPentagon;
  57519. private _blurNoise;
  57520. /**
  57521. * @constructor
  57522. *
  57523. * Effect parameters are as follow:
  57524. * {
  57525. * chromatic_aberration: number; // from 0 to x (1 for realism)
  57526. * edge_blur: number; // from 0 to x (1 for realism)
  57527. * distortion: number; // from 0 to x (1 for realism)
  57528. * grain_amount: number; // from 0 to 1
  57529. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  57530. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  57531. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  57532. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  57533. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  57534. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  57535. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  57536. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  57537. * }
  57538. * Note: if an effect parameter is unset, effect is disabled
  57539. *
  57540. * @param name The rendering pipeline name
  57541. * @param parameters - An object containing all parameters (see above)
  57542. * @param scene The scene linked to this pipeline
  57543. * @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)
  57544. * @param cameras The array of cameras that the rendering pipeline will be attached to
  57545. */
  57546. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  57547. /**
  57548. * Get the class name
  57549. * @returns "LensRenderingPipeline"
  57550. */
  57551. getClassName(): string;
  57552. /**
  57553. * Gets associated scene
  57554. */
  57555. readonly scene: Scene;
  57556. /**
  57557. * Gets or sets the edge blur
  57558. */
  57559. edgeBlur: number;
  57560. /**
  57561. * Gets or sets the grain amount
  57562. */
  57563. grainAmount: number;
  57564. /**
  57565. * Gets or sets the chromatic aberration amount
  57566. */
  57567. chromaticAberration: number;
  57568. /**
  57569. * Gets or sets the depth of field aperture
  57570. */
  57571. dofAperture: number;
  57572. /**
  57573. * Gets or sets the edge distortion
  57574. */
  57575. edgeDistortion: number;
  57576. /**
  57577. * Gets or sets the depth of field distortion
  57578. */
  57579. dofDistortion: number;
  57580. /**
  57581. * Gets or sets the darken out of focus amount
  57582. */
  57583. darkenOutOfFocus: number;
  57584. /**
  57585. * Gets or sets a boolean indicating if blur noise is enabled
  57586. */
  57587. blurNoise: boolean;
  57588. /**
  57589. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  57590. */
  57591. pentagonBokeh: boolean;
  57592. /**
  57593. * Gets or sets the highlight grain amount
  57594. */
  57595. highlightsGain: number;
  57596. /**
  57597. * Gets or sets the highlight threshold
  57598. */
  57599. highlightsThreshold: number;
  57600. /**
  57601. * Sets the amount of blur at the edges
  57602. * @param amount blur amount
  57603. */
  57604. setEdgeBlur(amount: number): void;
  57605. /**
  57606. * Sets edge blur to 0
  57607. */
  57608. disableEdgeBlur(): void;
  57609. /**
  57610. * Sets the amout of grain
  57611. * @param amount Amount of grain
  57612. */
  57613. setGrainAmount(amount: number): void;
  57614. /**
  57615. * Set grain amount to 0
  57616. */
  57617. disableGrain(): void;
  57618. /**
  57619. * Sets the chromatic aberration amount
  57620. * @param amount amount of chromatic aberration
  57621. */
  57622. setChromaticAberration(amount: number): void;
  57623. /**
  57624. * Sets chromatic aberration amount to 0
  57625. */
  57626. disableChromaticAberration(): void;
  57627. /**
  57628. * Sets the EdgeDistortion amount
  57629. * @param amount amount of EdgeDistortion
  57630. */
  57631. setEdgeDistortion(amount: number): void;
  57632. /**
  57633. * Sets edge distortion to 0
  57634. */
  57635. disableEdgeDistortion(): void;
  57636. /**
  57637. * Sets the FocusDistance amount
  57638. * @param amount amount of FocusDistance
  57639. */
  57640. setFocusDistance(amount: number): void;
  57641. /**
  57642. * Disables depth of field
  57643. */
  57644. disableDepthOfField(): void;
  57645. /**
  57646. * Sets the Aperture amount
  57647. * @param amount amount of Aperture
  57648. */
  57649. setAperture(amount: number): void;
  57650. /**
  57651. * Sets the DarkenOutOfFocus amount
  57652. * @param amount amount of DarkenOutOfFocus
  57653. */
  57654. setDarkenOutOfFocus(amount: number): void;
  57655. private _pentagonBokehIsEnabled;
  57656. /**
  57657. * Creates a pentagon bokeh effect
  57658. */
  57659. enablePentagonBokeh(): void;
  57660. /**
  57661. * Disables the pentagon bokeh effect
  57662. */
  57663. disablePentagonBokeh(): void;
  57664. /**
  57665. * Enables noise blur
  57666. */
  57667. enableNoiseBlur(): void;
  57668. /**
  57669. * Disables noise blur
  57670. */
  57671. disableNoiseBlur(): void;
  57672. /**
  57673. * Sets the HighlightsGain amount
  57674. * @param amount amount of HighlightsGain
  57675. */
  57676. setHighlightsGain(amount: number): void;
  57677. /**
  57678. * Sets the HighlightsThreshold amount
  57679. * @param amount amount of HighlightsThreshold
  57680. */
  57681. setHighlightsThreshold(amount: number): void;
  57682. /**
  57683. * Disables highlights
  57684. */
  57685. disableHighlights(): void;
  57686. /**
  57687. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  57688. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  57689. */
  57690. dispose(disableDepthRender?: boolean): void;
  57691. private _createChromaticAberrationPostProcess;
  57692. private _createHighlightsPostProcess;
  57693. private _createDepthOfFieldPostProcess;
  57694. private _createGrainTexture;
  57695. }
  57696. }
  57697. declare module BABYLON {
  57698. /** @hidden */
  57699. export var ssao2PixelShader: {
  57700. name: string;
  57701. shader: string;
  57702. };
  57703. }
  57704. declare module BABYLON {
  57705. /** @hidden */
  57706. export var ssaoCombinePixelShader: {
  57707. name: string;
  57708. shader: string;
  57709. };
  57710. }
  57711. declare module BABYLON {
  57712. /**
  57713. * Render pipeline to produce ssao effect
  57714. */
  57715. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  57716. /**
  57717. * @ignore
  57718. * The PassPostProcess id in the pipeline that contains the original scene color
  57719. */
  57720. SSAOOriginalSceneColorEffect: string;
  57721. /**
  57722. * @ignore
  57723. * The SSAO PostProcess id in the pipeline
  57724. */
  57725. SSAORenderEffect: string;
  57726. /**
  57727. * @ignore
  57728. * The horizontal blur PostProcess id in the pipeline
  57729. */
  57730. SSAOBlurHRenderEffect: string;
  57731. /**
  57732. * @ignore
  57733. * The vertical blur PostProcess id in the pipeline
  57734. */
  57735. SSAOBlurVRenderEffect: string;
  57736. /**
  57737. * @ignore
  57738. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  57739. */
  57740. SSAOCombineRenderEffect: string;
  57741. /**
  57742. * The output strength of the SSAO post-process. Default value is 1.0.
  57743. */
  57744. totalStrength: number;
  57745. /**
  57746. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  57747. */
  57748. maxZ: number;
  57749. /**
  57750. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  57751. */
  57752. minZAspect: number;
  57753. private _samples;
  57754. /**
  57755. * Number of samples used for the SSAO calculations. Default value is 8
  57756. */
  57757. samples: number;
  57758. private _textureSamples;
  57759. /**
  57760. * Number of samples to use for antialiasing
  57761. */
  57762. textureSamples: number;
  57763. /**
  57764. * Ratio object used for SSAO ratio and blur ratio
  57765. */
  57766. private _ratio;
  57767. /**
  57768. * Dynamically generated sphere sampler.
  57769. */
  57770. private _sampleSphere;
  57771. /**
  57772. * Blur filter offsets
  57773. */
  57774. private _samplerOffsets;
  57775. private _expensiveBlur;
  57776. /**
  57777. * If bilateral blur should be used
  57778. */
  57779. expensiveBlur: boolean;
  57780. /**
  57781. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  57782. */
  57783. radius: number;
  57784. /**
  57785. * The base color of the SSAO post-process
  57786. * The final result is "base + ssao" between [0, 1]
  57787. */
  57788. base: number;
  57789. /**
  57790. * Support test.
  57791. */
  57792. static readonly IsSupported: boolean;
  57793. private _scene;
  57794. private _depthTexture;
  57795. private _normalTexture;
  57796. private _randomTexture;
  57797. private _originalColorPostProcess;
  57798. private _ssaoPostProcess;
  57799. private _blurHPostProcess;
  57800. private _blurVPostProcess;
  57801. private _ssaoCombinePostProcess;
  57802. private _firstUpdate;
  57803. /**
  57804. * Gets active scene
  57805. */
  57806. readonly scene: Scene;
  57807. /**
  57808. * @constructor
  57809. * @param name The rendering pipeline name
  57810. * @param scene The scene linked to this pipeline
  57811. * @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 }
  57812. * @param cameras The array of cameras that the rendering pipeline will be attached to
  57813. */
  57814. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  57815. /**
  57816. * Get the class name
  57817. * @returns "SSAO2RenderingPipeline"
  57818. */
  57819. getClassName(): string;
  57820. /**
  57821. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  57822. */
  57823. dispose(disableGeometryBufferRenderer?: boolean): void;
  57824. private _createBlurPostProcess;
  57825. /** @hidden */ private _rebuild(): void;
  57826. private _bits;
  57827. private _radicalInverse_VdC;
  57828. private _hammersley;
  57829. private _hemisphereSample_uniform;
  57830. private _generateHemisphere;
  57831. private _createSSAOPostProcess;
  57832. private _createSSAOCombinePostProcess;
  57833. private _createRandomTexture;
  57834. /**
  57835. * Serialize the rendering pipeline (Used when exporting)
  57836. * @returns the serialized object
  57837. */
  57838. serialize(): any;
  57839. /**
  57840. * Parse the serialized pipeline
  57841. * @param source Source pipeline.
  57842. * @param scene The scene to load the pipeline to.
  57843. * @param rootUrl The URL of the serialized pipeline.
  57844. * @returns An instantiated pipeline from the serialized object.
  57845. */
  57846. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  57847. }
  57848. }
  57849. declare module BABYLON {
  57850. /** @hidden */
  57851. export var ssaoPixelShader: {
  57852. name: string;
  57853. shader: string;
  57854. };
  57855. }
  57856. declare module BABYLON {
  57857. /**
  57858. * Render pipeline to produce ssao effect
  57859. */
  57860. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  57861. /**
  57862. * @ignore
  57863. * The PassPostProcess id in the pipeline that contains the original scene color
  57864. */
  57865. SSAOOriginalSceneColorEffect: string;
  57866. /**
  57867. * @ignore
  57868. * The SSAO PostProcess id in the pipeline
  57869. */
  57870. SSAORenderEffect: string;
  57871. /**
  57872. * @ignore
  57873. * The horizontal blur PostProcess id in the pipeline
  57874. */
  57875. SSAOBlurHRenderEffect: string;
  57876. /**
  57877. * @ignore
  57878. * The vertical blur PostProcess id in the pipeline
  57879. */
  57880. SSAOBlurVRenderEffect: string;
  57881. /**
  57882. * @ignore
  57883. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  57884. */
  57885. SSAOCombineRenderEffect: string;
  57886. /**
  57887. * The output strength of the SSAO post-process. Default value is 1.0.
  57888. */
  57889. totalStrength: number;
  57890. /**
  57891. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  57892. */
  57893. radius: number;
  57894. /**
  57895. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  57896. * Must not be equal to fallOff and superior to fallOff.
  57897. * Default value is 0.0075
  57898. */
  57899. area: number;
  57900. /**
  57901. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  57902. * Must not be equal to area and inferior to area.
  57903. * Default value is 0.000001
  57904. */
  57905. fallOff: number;
  57906. /**
  57907. * The base color of the SSAO post-process
  57908. * The final result is "base + ssao" between [0, 1]
  57909. */
  57910. base: number;
  57911. private _scene;
  57912. private _depthTexture;
  57913. private _randomTexture;
  57914. private _originalColorPostProcess;
  57915. private _ssaoPostProcess;
  57916. private _blurHPostProcess;
  57917. private _blurVPostProcess;
  57918. private _ssaoCombinePostProcess;
  57919. private _firstUpdate;
  57920. /**
  57921. * Gets active scene
  57922. */
  57923. readonly scene: Scene;
  57924. /**
  57925. * @constructor
  57926. * @param name - The rendering pipeline name
  57927. * @param scene - The scene linked to this pipeline
  57928. * @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 }
  57929. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  57930. */
  57931. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  57932. /**
  57933. * Get the class name
  57934. * @returns "SSAORenderingPipeline"
  57935. */
  57936. getClassName(): string;
  57937. /**
  57938. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  57939. */
  57940. dispose(disableDepthRender?: boolean): void;
  57941. private _createBlurPostProcess;
  57942. /** @hidden */ private _rebuild(): void;
  57943. private _createSSAOPostProcess;
  57944. private _createSSAOCombinePostProcess;
  57945. private _createRandomTexture;
  57946. }
  57947. }
  57948. declare module BABYLON {
  57949. /** @hidden */
  57950. export var standardPixelShader: {
  57951. name: string;
  57952. shader: string;
  57953. };
  57954. }
  57955. declare module BABYLON {
  57956. /**
  57957. * Standard rendering pipeline
  57958. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  57959. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  57960. */
  57961. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  57962. /**
  57963. * Public members
  57964. */
  57965. /**
  57966. * Post-process which contains the original scene color before the pipeline applies all the effects
  57967. */
  57968. originalPostProcess: Nullable<PostProcess>;
  57969. /**
  57970. * Post-process used to down scale an image x4
  57971. */
  57972. downSampleX4PostProcess: Nullable<PostProcess>;
  57973. /**
  57974. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  57975. */
  57976. brightPassPostProcess: Nullable<PostProcess>;
  57977. /**
  57978. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  57979. */
  57980. blurHPostProcesses: PostProcess[];
  57981. /**
  57982. * Post-process array storing all the vertical blur post-processes used by the pipeline
  57983. */
  57984. blurVPostProcesses: PostProcess[];
  57985. /**
  57986. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  57987. */
  57988. textureAdderPostProcess: Nullable<PostProcess>;
  57989. /**
  57990. * Post-process used to create volumetric lighting effect
  57991. */
  57992. volumetricLightPostProcess: Nullable<PostProcess>;
  57993. /**
  57994. * Post-process used to smooth the previous volumetric light post-process on the X axis
  57995. */
  57996. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  57997. /**
  57998. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  57999. */
  58000. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  58001. /**
  58002. * Post-process used to merge the volumetric light effect and the real scene color
  58003. */
  58004. volumetricLightMergePostProces: Nullable<PostProcess>;
  58005. /**
  58006. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  58007. */
  58008. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  58009. /**
  58010. * Base post-process used to calculate the average luminance of the final image for HDR
  58011. */
  58012. luminancePostProcess: Nullable<PostProcess>;
  58013. /**
  58014. * Post-processes used to create down sample post-processes in order to get
  58015. * the average luminance of the final image for HDR
  58016. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  58017. */
  58018. luminanceDownSamplePostProcesses: PostProcess[];
  58019. /**
  58020. * Post-process used to create a HDR effect (light adaptation)
  58021. */
  58022. hdrPostProcess: Nullable<PostProcess>;
  58023. /**
  58024. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  58025. */
  58026. textureAdderFinalPostProcess: Nullable<PostProcess>;
  58027. /**
  58028. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  58029. */
  58030. lensFlareFinalPostProcess: Nullable<PostProcess>;
  58031. /**
  58032. * Post-process used to merge the final HDR post-process and the real scene color
  58033. */
  58034. hdrFinalPostProcess: Nullable<PostProcess>;
  58035. /**
  58036. * Post-process used to create a lens flare effect
  58037. */
  58038. lensFlarePostProcess: Nullable<PostProcess>;
  58039. /**
  58040. * Post-process that merges the result of the lens flare post-process and the real scene color
  58041. */
  58042. lensFlareComposePostProcess: Nullable<PostProcess>;
  58043. /**
  58044. * Post-process used to create a motion blur effect
  58045. */
  58046. motionBlurPostProcess: Nullable<PostProcess>;
  58047. /**
  58048. * Post-process used to create a depth of field effect
  58049. */
  58050. depthOfFieldPostProcess: Nullable<PostProcess>;
  58051. /**
  58052. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  58053. */
  58054. fxaaPostProcess: Nullable<FxaaPostProcess>;
  58055. /**
  58056. * Represents the brightness threshold in order to configure the illuminated surfaces
  58057. */
  58058. brightThreshold: number;
  58059. /**
  58060. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  58061. */
  58062. blurWidth: number;
  58063. /**
  58064. * Sets if the blur for highlighted surfaces must be only horizontal
  58065. */
  58066. horizontalBlur: boolean;
  58067. /**
  58068. * Gets the overall exposure used by the pipeline
  58069. */
  58070. /**
  58071. * Sets the overall exposure used by the pipeline
  58072. */
  58073. exposure: number;
  58074. /**
  58075. * Texture used typically to simulate "dirty" on camera lens
  58076. */
  58077. lensTexture: Nullable<Texture>;
  58078. /**
  58079. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  58080. */
  58081. volumetricLightCoefficient: number;
  58082. /**
  58083. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  58084. */
  58085. volumetricLightPower: number;
  58086. /**
  58087. * Used the set the blur intensity to smooth the volumetric lights
  58088. */
  58089. volumetricLightBlurScale: number;
  58090. /**
  58091. * Light (spot or directional) used to generate the volumetric lights rays
  58092. * The source light must have a shadow generate so the pipeline can get its
  58093. * depth map
  58094. */
  58095. sourceLight: Nullable<SpotLight | DirectionalLight>;
  58096. /**
  58097. * For eye adaptation, represents the minimum luminance the eye can see
  58098. */
  58099. hdrMinimumLuminance: number;
  58100. /**
  58101. * For eye adaptation, represents the decrease luminance speed
  58102. */
  58103. hdrDecreaseRate: number;
  58104. /**
  58105. * For eye adaptation, represents the increase luminance speed
  58106. */
  58107. hdrIncreaseRate: number;
  58108. /**
  58109. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  58110. */
  58111. /**
  58112. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  58113. */
  58114. hdrAutoExposure: boolean;
  58115. /**
  58116. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  58117. */
  58118. lensColorTexture: Nullable<Texture>;
  58119. /**
  58120. * The overall strengh for the lens flare effect
  58121. */
  58122. lensFlareStrength: number;
  58123. /**
  58124. * Dispersion coefficient for lens flare ghosts
  58125. */
  58126. lensFlareGhostDispersal: number;
  58127. /**
  58128. * Main lens flare halo width
  58129. */
  58130. lensFlareHaloWidth: number;
  58131. /**
  58132. * Based on the lens distortion effect, defines how much the lens flare result
  58133. * is distorted
  58134. */
  58135. lensFlareDistortionStrength: number;
  58136. /**
  58137. * Lens star texture must be used to simulate rays on the flares and is available
  58138. * in the documentation
  58139. */
  58140. lensStarTexture: Nullable<Texture>;
  58141. /**
  58142. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  58143. * flare effect by taking account of the dirt texture
  58144. */
  58145. lensFlareDirtTexture: Nullable<Texture>;
  58146. /**
  58147. * Represents the focal length for the depth of field effect
  58148. */
  58149. depthOfFieldDistance: number;
  58150. /**
  58151. * Represents the blur intensity for the blurred part of the depth of field effect
  58152. */
  58153. depthOfFieldBlurWidth: number;
  58154. /**
  58155. * Gets how much the image is blurred by the movement while using the motion blur post-process
  58156. */
  58157. /**
  58158. * Sets how much the image is blurred by the movement while using the motion blur post-process
  58159. */
  58160. motionStrength: number;
  58161. /**
  58162. * Gets wether or not the motion blur post-process is object based or screen based.
  58163. */
  58164. /**
  58165. * Sets wether or not the motion blur post-process should be object based or screen based
  58166. */
  58167. objectBasedMotionBlur: boolean;
  58168. /**
  58169. * List of animations for the pipeline (IAnimatable implementation)
  58170. */
  58171. animations: Animation[];
  58172. /**
  58173. * Private members
  58174. */
  58175. private _scene;
  58176. private _currentDepthOfFieldSource;
  58177. private _basePostProcess;
  58178. private _fixedExposure;
  58179. private _currentExposure;
  58180. private _hdrAutoExposure;
  58181. private _hdrCurrentLuminance;
  58182. private _motionStrength;
  58183. private _isObjectBasedMotionBlur;
  58184. private _floatTextureType;
  58185. private _camerasToBeAttached;
  58186. private _ratio;
  58187. private _bloomEnabled;
  58188. private _depthOfFieldEnabled;
  58189. private _vlsEnabled;
  58190. private _lensFlareEnabled;
  58191. private _hdrEnabled;
  58192. private _motionBlurEnabled;
  58193. private _fxaaEnabled;
  58194. private _motionBlurSamples;
  58195. private _volumetricLightStepsCount;
  58196. private _samples;
  58197. /**
  58198. * @ignore
  58199. * Specifies if the bloom pipeline is enabled
  58200. */
  58201. BloomEnabled: boolean;
  58202. /**
  58203. * @ignore
  58204. * Specifies if the depth of field pipeline is enabed
  58205. */
  58206. DepthOfFieldEnabled: boolean;
  58207. /**
  58208. * @ignore
  58209. * Specifies if the lens flare pipeline is enabed
  58210. */
  58211. LensFlareEnabled: boolean;
  58212. /**
  58213. * @ignore
  58214. * Specifies if the HDR pipeline is enabled
  58215. */
  58216. HDREnabled: boolean;
  58217. /**
  58218. * @ignore
  58219. * Specifies if the volumetric lights scattering effect is enabled
  58220. */
  58221. VLSEnabled: boolean;
  58222. /**
  58223. * @ignore
  58224. * Specifies if the motion blur effect is enabled
  58225. */
  58226. MotionBlurEnabled: boolean;
  58227. /**
  58228. * Specifies if anti-aliasing is enabled
  58229. */
  58230. fxaaEnabled: boolean;
  58231. /**
  58232. * Specifies the number of steps used to calculate the volumetric lights
  58233. * Typically in interval [50, 200]
  58234. */
  58235. volumetricLightStepsCount: number;
  58236. /**
  58237. * Specifies the number of samples used for the motion blur effect
  58238. * Typically in interval [16, 64]
  58239. */
  58240. motionBlurSamples: number;
  58241. /**
  58242. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  58243. */
  58244. samples: number;
  58245. /**
  58246. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  58247. * @constructor
  58248. * @param name The rendering pipeline name
  58249. * @param scene The scene linked to this pipeline
  58250. * @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)
  58251. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  58252. * @param cameras The array of cameras that the rendering pipeline will be attached to
  58253. */
  58254. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  58255. private _buildPipeline;
  58256. private _createDownSampleX4PostProcess;
  58257. private _createBrightPassPostProcess;
  58258. private _createBlurPostProcesses;
  58259. private _createTextureAdderPostProcess;
  58260. private _createVolumetricLightPostProcess;
  58261. private _createLuminancePostProcesses;
  58262. private _createHdrPostProcess;
  58263. private _createLensFlarePostProcess;
  58264. private _createDepthOfFieldPostProcess;
  58265. private _createMotionBlurPostProcess;
  58266. private _getDepthTexture;
  58267. private _disposePostProcesses;
  58268. /**
  58269. * Dispose of the pipeline and stop all post processes
  58270. */
  58271. dispose(): void;
  58272. /**
  58273. * Serialize the rendering pipeline (Used when exporting)
  58274. * @returns the serialized object
  58275. */
  58276. serialize(): any;
  58277. /**
  58278. * Parse the serialized pipeline
  58279. * @param source Source pipeline.
  58280. * @param scene The scene to load the pipeline to.
  58281. * @param rootUrl The URL of the serialized pipeline.
  58282. * @returns An instantiated pipeline from the serialized object.
  58283. */
  58284. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  58285. /**
  58286. * Luminance steps
  58287. */
  58288. static LuminanceSteps: number;
  58289. }
  58290. }
  58291. declare module BABYLON {
  58292. /** @hidden */
  58293. export var tonemapPixelShader: {
  58294. name: string;
  58295. shader: string;
  58296. };
  58297. }
  58298. declare module BABYLON {
  58299. /** Defines operator used for tonemapping */
  58300. export enum TonemappingOperator {
  58301. /** Hable */
  58302. Hable = 0,
  58303. /** Reinhard */
  58304. Reinhard = 1,
  58305. /** HejiDawson */
  58306. HejiDawson = 2,
  58307. /** Photographic */
  58308. Photographic = 3
  58309. }
  58310. /**
  58311. * Defines a post process to apply tone mapping
  58312. */
  58313. export class TonemapPostProcess extends PostProcess {
  58314. private _operator;
  58315. /** Defines the required exposure adjustement */
  58316. exposureAdjustment: number;
  58317. /**
  58318. * Creates a new TonemapPostProcess
  58319. * @param name defines the name of the postprocess
  58320. * @param _operator defines the operator to use
  58321. * @param exposureAdjustment defines the required exposure adjustement
  58322. * @param camera defines the camera to use (can be null)
  58323. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  58324. * @param engine defines the hosting engine (can be ignore if camera is set)
  58325. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  58326. */
  58327. constructor(name: string, _operator: TonemappingOperator,
  58328. /** Defines the required exposure adjustement */
  58329. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  58330. }
  58331. }
  58332. declare module BABYLON {
  58333. /** @hidden */
  58334. export var depthVertexShader: {
  58335. name: string;
  58336. shader: string;
  58337. };
  58338. }
  58339. declare module BABYLON {
  58340. /** @hidden */
  58341. export var volumetricLightScatteringPixelShader: {
  58342. name: string;
  58343. shader: string;
  58344. };
  58345. }
  58346. declare module BABYLON {
  58347. /** @hidden */
  58348. export var volumetricLightScatteringPassVertexShader: {
  58349. name: string;
  58350. shader: string;
  58351. };
  58352. }
  58353. declare module BABYLON {
  58354. /** @hidden */
  58355. export var volumetricLightScatteringPassPixelShader: {
  58356. name: string;
  58357. shader: string;
  58358. };
  58359. }
  58360. declare module BABYLON {
  58361. /**
  58362. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  58363. */
  58364. export class VolumetricLightScatteringPostProcess extends PostProcess {
  58365. private _volumetricLightScatteringPass;
  58366. private _volumetricLightScatteringRTT;
  58367. private _viewPort;
  58368. private _screenCoordinates;
  58369. private _cachedDefines;
  58370. /**
  58371. * If not undefined, the mesh position is computed from the attached node position
  58372. */
  58373. attachedNode: {
  58374. position: Vector3;
  58375. };
  58376. /**
  58377. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  58378. */
  58379. customMeshPosition: Vector3;
  58380. /**
  58381. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  58382. */
  58383. useCustomMeshPosition: boolean;
  58384. /**
  58385. * If the post-process should inverse the light scattering direction
  58386. */
  58387. invert: boolean;
  58388. /**
  58389. * The internal mesh used by the post-process
  58390. */
  58391. mesh: Mesh;
  58392. /**
  58393. * @hidden
  58394. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  58395. */
  58396. useDiffuseColor: boolean;
  58397. /**
  58398. * Array containing the excluded meshes not rendered in the internal pass
  58399. */
  58400. excludedMeshes: AbstractMesh[];
  58401. /**
  58402. * Controls the overall intensity of the post-process
  58403. */
  58404. exposure: number;
  58405. /**
  58406. * Dissipates each sample's contribution in range [0, 1]
  58407. */
  58408. decay: number;
  58409. /**
  58410. * Controls the overall intensity of each sample
  58411. */
  58412. weight: number;
  58413. /**
  58414. * Controls the density of each sample
  58415. */
  58416. density: number;
  58417. /**
  58418. * @constructor
  58419. * @param name The post-process name
  58420. * @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)
  58421. * @param camera The camera that the post-process will be attached to
  58422. * @param mesh The mesh used to create the light scattering
  58423. * @param samples The post-process quality, default 100
  58424. * @param samplingModeThe post-process filtering mode
  58425. * @param engine The babylon engine
  58426. * @param reusable If the post-process is reusable
  58427. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  58428. */
  58429. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  58430. /**
  58431. * Returns the string "VolumetricLightScatteringPostProcess"
  58432. * @returns "VolumetricLightScatteringPostProcess"
  58433. */
  58434. getClassName(): string;
  58435. private _isReady;
  58436. /**
  58437. * Sets the new light position for light scattering effect
  58438. * @param position The new custom light position
  58439. */
  58440. setCustomMeshPosition(position: Vector3): void;
  58441. /**
  58442. * Returns the light position for light scattering effect
  58443. * @return Vector3 The custom light position
  58444. */
  58445. getCustomMeshPosition(): Vector3;
  58446. /**
  58447. * Disposes the internal assets and detaches the post-process from the camera
  58448. */
  58449. dispose(camera: Camera): void;
  58450. /**
  58451. * Returns the render target texture used by the post-process
  58452. * @return the render target texture used by the post-process
  58453. */
  58454. getPass(): RenderTargetTexture;
  58455. private _meshExcluded;
  58456. private _createPass;
  58457. private _updateMeshScreenCoordinates;
  58458. /**
  58459. * Creates a default mesh for the Volumeric Light Scattering post-process
  58460. * @param name The mesh name
  58461. * @param scene The scene where to create the mesh
  58462. * @return the default mesh
  58463. */
  58464. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  58465. }
  58466. }
  58467. declare module BABYLON {
  58468. interface Scene {
  58469. /** @hidden (Backing field) */ private _boundingBoxRenderer: BoundingBoxRenderer;
  58470. /** @hidden (Backing field) */ private _forceShowBoundingBoxes: boolean;
  58471. /**
  58472. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  58473. */
  58474. forceShowBoundingBoxes: boolean;
  58475. /**
  58476. * Gets the bounding box renderer associated with the scene
  58477. * @returns a BoundingBoxRenderer
  58478. */
  58479. getBoundingBoxRenderer(): BoundingBoxRenderer;
  58480. }
  58481. interface AbstractMesh {
  58482. /** @hidden (Backing field) */ private _showBoundingBox: boolean;
  58483. /**
  58484. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  58485. */
  58486. showBoundingBox: boolean;
  58487. }
  58488. /**
  58489. * Component responsible of rendering the bounding box of the meshes in a scene.
  58490. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  58491. */
  58492. export class BoundingBoxRenderer implements ISceneComponent {
  58493. /**
  58494. * The component name helpfull to identify the component in the list of scene components.
  58495. */
  58496. readonly name: string;
  58497. /**
  58498. * The scene the component belongs to.
  58499. */
  58500. scene: Scene;
  58501. /**
  58502. * Color of the bounding box lines placed in front of an object
  58503. */
  58504. frontColor: Color3;
  58505. /**
  58506. * Color of the bounding box lines placed behind an object
  58507. */
  58508. backColor: Color3;
  58509. /**
  58510. * Defines if the renderer should show the back lines or not
  58511. */
  58512. showBackLines: boolean;
  58513. /**
  58514. * @hidden
  58515. */
  58516. renderList: SmartArray<BoundingBox>;
  58517. private _colorShader;
  58518. private _vertexBuffers;
  58519. private _indexBuffer;
  58520. private _fillIndexBuffer;
  58521. private _fillIndexData;
  58522. /**
  58523. * Instantiates a new bounding box renderer in a scene.
  58524. * @param scene the scene the renderer renders in
  58525. */
  58526. constructor(scene: Scene);
  58527. /**
  58528. * Registers the component in a given scene
  58529. */
  58530. register(): void;
  58531. private _evaluateSubMesh;
  58532. private _activeMesh;
  58533. private _prepareRessources;
  58534. private _createIndexBuffer;
  58535. /**
  58536. * Rebuilds the elements related to this component in case of
  58537. * context lost for instance.
  58538. */
  58539. rebuild(): void;
  58540. /**
  58541. * @hidden
  58542. */
  58543. reset(): void;
  58544. /**
  58545. * Render the bounding boxes of a specific rendering group
  58546. * @param renderingGroupId defines the rendering group to render
  58547. */
  58548. render(renderingGroupId: number): void;
  58549. /**
  58550. * In case of occlusion queries, we can render the occlusion bounding box through this method
  58551. * @param mesh Define the mesh to render the occlusion bounding box for
  58552. */
  58553. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  58554. /**
  58555. * Dispose and release the resources attached to this renderer.
  58556. */
  58557. dispose(): void;
  58558. }
  58559. }
  58560. declare module BABYLON {
  58561. /** @hidden */
  58562. export var depthPixelShader: {
  58563. name: string;
  58564. shader: string;
  58565. };
  58566. }
  58567. declare module BABYLON {
  58568. /**
  58569. * This represents a depth renderer in Babylon.
  58570. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  58571. */
  58572. export class DepthRenderer {
  58573. private _scene;
  58574. private _depthMap;
  58575. private _effect;
  58576. private readonly _storeNonLinearDepth;
  58577. private readonly _clearColor;
  58578. /** Get if the depth renderer is using packed depth or not */
  58579. readonly isPacked: boolean;
  58580. private _cachedDefines;
  58581. private _camera;
  58582. /**
  58583. * Specifiess that the depth renderer will only be used within
  58584. * the camera it is created for.
  58585. * This can help forcing its rendering during the camera processing.
  58586. */
  58587. useOnlyInActiveCamera: boolean;
  58588. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  58589. /**
  58590. * Instantiates a depth renderer
  58591. * @param scene The scene the renderer belongs to
  58592. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  58593. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  58594. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  58595. */
  58596. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  58597. /**
  58598. * Creates the depth rendering effect and checks if the effect is ready.
  58599. * @param subMesh The submesh to be used to render the depth map of
  58600. * @param useInstances If multiple world instances should be used
  58601. * @returns if the depth renderer is ready to render the depth map
  58602. */
  58603. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58604. /**
  58605. * Gets the texture which the depth map will be written to.
  58606. * @returns The depth map texture
  58607. */
  58608. getDepthMap(): RenderTargetTexture;
  58609. /**
  58610. * Disposes of the depth renderer.
  58611. */
  58612. dispose(): void;
  58613. }
  58614. }
  58615. declare module BABYLON {
  58616. interface Scene {
  58617. /** @hidden (Backing field) */ private _depthRenderer: {
  58618. [id: string]: DepthRenderer;
  58619. };
  58620. /**
  58621. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  58622. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  58623. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  58624. * @returns the created depth renderer
  58625. */
  58626. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  58627. /**
  58628. * Disables a depth renderer for a given camera
  58629. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  58630. */
  58631. disableDepthRenderer(camera?: Nullable<Camera>): void;
  58632. }
  58633. /**
  58634. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  58635. * in several rendering techniques.
  58636. */
  58637. export class DepthRendererSceneComponent implements ISceneComponent {
  58638. /**
  58639. * The component name helpfull to identify the component in the list of scene components.
  58640. */
  58641. readonly name: string;
  58642. /**
  58643. * The scene the component belongs to.
  58644. */
  58645. scene: Scene;
  58646. /**
  58647. * Creates a new instance of the component for the given scene
  58648. * @param scene Defines the scene to register the component in
  58649. */
  58650. constructor(scene: Scene);
  58651. /**
  58652. * Registers the component in a given scene
  58653. */
  58654. register(): void;
  58655. /**
  58656. * Rebuilds the elements related to this component in case of
  58657. * context lost for instance.
  58658. */
  58659. rebuild(): void;
  58660. /**
  58661. * Disposes the component and the associated ressources
  58662. */
  58663. dispose(): void;
  58664. private _gatherRenderTargets;
  58665. private _gatherActiveCameraRenderTargets;
  58666. }
  58667. }
  58668. declare module BABYLON {
  58669. /** @hidden */
  58670. export var outlinePixelShader: {
  58671. name: string;
  58672. shader: string;
  58673. };
  58674. }
  58675. declare module BABYLON {
  58676. /** @hidden */
  58677. export var outlineVertexShader: {
  58678. name: string;
  58679. shader: string;
  58680. };
  58681. }
  58682. declare module BABYLON {
  58683. interface Scene {
  58684. /** @hidden */ private _outlineRenderer: OutlineRenderer;
  58685. /**
  58686. * Gets the outline renderer associated with the scene
  58687. * @returns a OutlineRenderer
  58688. */
  58689. getOutlineRenderer(): OutlineRenderer;
  58690. }
  58691. interface AbstractMesh {
  58692. /** @hidden (Backing field) */ private _renderOutline: boolean;
  58693. /**
  58694. * Gets or sets a boolean indicating if the outline must be rendered as well
  58695. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  58696. */
  58697. renderOutline: boolean;
  58698. /** @hidden (Backing field) */ private _renderOverlay: boolean;
  58699. /**
  58700. * Gets or sets a boolean indicating if the overlay must be rendered as well
  58701. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  58702. */
  58703. renderOverlay: boolean;
  58704. }
  58705. /**
  58706. * This class is responsible to draw bothe outline/overlay of meshes.
  58707. * It should not be used directly but through the available method on mesh.
  58708. */
  58709. export class OutlineRenderer implements ISceneComponent {
  58710. /**
  58711. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  58712. */
  58713. private static _StencilReference;
  58714. /**
  58715. * The name of the component. Each component must have a unique name.
  58716. */
  58717. name: string;
  58718. /**
  58719. * The scene the component belongs to.
  58720. */
  58721. scene: Scene;
  58722. /**
  58723. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  58724. */
  58725. zOffset: number;
  58726. private _engine;
  58727. private _effect;
  58728. private _cachedDefines;
  58729. private _savedDepthWrite;
  58730. /**
  58731. * Instantiates a new outline renderer. (There could be only one per scene).
  58732. * @param scene Defines the scene it belongs to
  58733. */
  58734. constructor(scene: Scene);
  58735. /**
  58736. * Register the component to one instance of a scene.
  58737. */
  58738. register(): void;
  58739. /**
  58740. * Rebuilds the elements related to this component in case of
  58741. * context lost for instance.
  58742. */
  58743. rebuild(): void;
  58744. /**
  58745. * Disposes the component and the associated ressources.
  58746. */
  58747. dispose(): void;
  58748. /**
  58749. * Renders the outline in the canvas.
  58750. * @param subMesh Defines the sumesh to render
  58751. * @param batch Defines the batch of meshes in case of instances
  58752. * @param useOverlay Defines if the rendering is for the overlay or the outline
  58753. */
  58754. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  58755. /**
  58756. * Returns whether or not the outline renderer is ready for a given submesh.
  58757. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  58758. * @param subMesh Defines the submesh to check readyness for
  58759. * @param useInstances Defines wheter wee are trying to render instances or not
  58760. * @returns true if ready otherwise false
  58761. */
  58762. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58763. private _beforeRenderingMesh;
  58764. private _afterRenderingMesh;
  58765. }
  58766. }
  58767. declare module BABYLON {
  58768. /**
  58769. * Class used to manage multiple sprites of different sizes on the same spritesheet
  58770. * @see http://doc.babylonjs.com/babylon101/sprites
  58771. */
  58772. export class SpritePackedManager extends SpriteManager {
  58773. /** defines the packed manager's name */
  58774. name: string;
  58775. /**
  58776. * Creates a new sprite manager from a packed sprite sheet
  58777. * @param name defines the manager's name
  58778. * @param imgUrl defines the sprite sheet url
  58779. * @param capacity defines the maximum allowed number of sprites
  58780. * @param scene defines the hosting scene
  58781. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  58782. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  58783. * @param samplingMode defines the smapling mode to use with spritesheet
  58784. * @param fromPacked set to true; do not alter
  58785. */
  58786. constructor(
  58787. /** defines the packed manager's name */
  58788. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  58789. }
  58790. }
  58791. declare module BABYLON {
  58792. /**
  58793. * Defines the list of states available for a task inside a AssetsManager
  58794. */
  58795. export enum AssetTaskState {
  58796. /**
  58797. * Initialization
  58798. */
  58799. INIT = 0,
  58800. /**
  58801. * Running
  58802. */
  58803. RUNNING = 1,
  58804. /**
  58805. * Done
  58806. */
  58807. DONE = 2,
  58808. /**
  58809. * Error
  58810. */
  58811. ERROR = 3
  58812. }
  58813. /**
  58814. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  58815. */
  58816. export abstract class AbstractAssetTask {
  58817. /**
  58818. * Task name
  58819. */ name: string;
  58820. /**
  58821. * Callback called when the task is successful
  58822. */
  58823. onSuccess: (task: any) => void;
  58824. /**
  58825. * Callback called when the task is not successful
  58826. */
  58827. onError: (task: any, message?: string, exception?: any) => void;
  58828. /**
  58829. * Creates a new AssetsManager
  58830. * @param name defines the name of the task
  58831. */
  58832. constructor(
  58833. /**
  58834. * Task name
  58835. */ name: string);
  58836. private _isCompleted;
  58837. private _taskState;
  58838. private _errorObject;
  58839. /**
  58840. * Get if the task is completed
  58841. */
  58842. readonly isCompleted: boolean;
  58843. /**
  58844. * Gets the current state of the task
  58845. */
  58846. readonly taskState: AssetTaskState;
  58847. /**
  58848. * Gets the current error object (if task is in error)
  58849. */
  58850. readonly errorObject: {
  58851. message?: string;
  58852. exception?: any;
  58853. };
  58854. /**
  58855. * Internal only
  58856. * @hidden
  58857. */ private _setErrorObject(message?: string, exception?: any): void;
  58858. /**
  58859. * Execute the current task
  58860. * @param scene defines the scene where you want your assets to be loaded
  58861. * @param onSuccess is a callback called when the task is successfully executed
  58862. * @param onError is a callback called if an error occurs
  58863. */
  58864. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58865. /**
  58866. * Execute the current task
  58867. * @param scene defines the scene where you want your assets to be loaded
  58868. * @param onSuccess is a callback called when the task is successfully executed
  58869. * @param onError is a callback called if an error occurs
  58870. */
  58871. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58872. /**
  58873. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  58874. * This can be used with failed tasks that have the reason for failure fixed.
  58875. */
  58876. reset(): void;
  58877. private onErrorCallback;
  58878. private onDoneCallback;
  58879. }
  58880. /**
  58881. * Define the interface used by progress events raised during assets loading
  58882. */
  58883. export interface IAssetsProgressEvent {
  58884. /**
  58885. * Defines the number of remaining tasks to process
  58886. */
  58887. remainingCount: number;
  58888. /**
  58889. * Defines the total number of tasks
  58890. */
  58891. totalCount: number;
  58892. /**
  58893. * Defines the task that was just processed
  58894. */
  58895. task: AbstractAssetTask;
  58896. }
  58897. /**
  58898. * Class used to share progress information about assets loading
  58899. */
  58900. export class AssetsProgressEvent implements IAssetsProgressEvent {
  58901. /**
  58902. * Defines the number of remaining tasks to process
  58903. */
  58904. remainingCount: number;
  58905. /**
  58906. * Defines the total number of tasks
  58907. */
  58908. totalCount: number;
  58909. /**
  58910. * Defines the task that was just processed
  58911. */
  58912. task: AbstractAssetTask;
  58913. /**
  58914. * Creates a AssetsProgressEvent
  58915. * @param remainingCount defines the number of remaining tasks to process
  58916. * @param totalCount defines the total number of tasks
  58917. * @param task defines the task that was just processed
  58918. */
  58919. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  58920. }
  58921. /**
  58922. * Define a task used by AssetsManager to load meshes
  58923. */
  58924. export class MeshAssetTask extends AbstractAssetTask {
  58925. /**
  58926. * Defines the name of the task
  58927. */
  58928. name: string;
  58929. /**
  58930. * Defines the list of mesh's names you want to load
  58931. */
  58932. meshesNames: any;
  58933. /**
  58934. * Defines the root url to use as a base to load your meshes and associated resources
  58935. */
  58936. rootUrl: string;
  58937. /**
  58938. * Defines the filename of the scene to load from
  58939. */
  58940. sceneFilename: string;
  58941. /**
  58942. * Gets the list of loaded meshes
  58943. */
  58944. loadedMeshes: Array<AbstractMesh>;
  58945. /**
  58946. * Gets the list of loaded particle systems
  58947. */
  58948. loadedParticleSystems: Array<IParticleSystem>;
  58949. /**
  58950. * Gets the list of loaded skeletons
  58951. */
  58952. loadedSkeletons: Array<Skeleton>;
  58953. /**
  58954. * Gets the list of loaded animation groups
  58955. */
  58956. loadedAnimationGroups: Array<AnimationGroup>;
  58957. /**
  58958. * Callback called when the task is successful
  58959. */
  58960. onSuccess: (task: MeshAssetTask) => void;
  58961. /**
  58962. * Callback called when the task is successful
  58963. */
  58964. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  58965. /**
  58966. * Creates a new MeshAssetTask
  58967. * @param name defines the name of the task
  58968. * @param meshesNames defines the list of mesh's names you want to load
  58969. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  58970. * @param sceneFilename defines the filename of the scene to load from
  58971. */
  58972. constructor(
  58973. /**
  58974. * Defines the name of the task
  58975. */
  58976. name: string,
  58977. /**
  58978. * Defines the list of mesh's names you want to load
  58979. */
  58980. meshesNames: any,
  58981. /**
  58982. * Defines the root url to use as a base to load your meshes and associated resources
  58983. */
  58984. rootUrl: string,
  58985. /**
  58986. * Defines the filename of the scene to load from
  58987. */
  58988. sceneFilename: string);
  58989. /**
  58990. * Execute the current task
  58991. * @param scene defines the scene where you want your assets to be loaded
  58992. * @param onSuccess is a callback called when the task is successfully executed
  58993. * @param onError is a callback called if an error occurs
  58994. */
  58995. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58996. }
  58997. /**
  58998. * Define a task used by AssetsManager to load text content
  58999. */
  59000. export class TextFileAssetTask extends AbstractAssetTask {
  59001. /**
  59002. * Defines the name of the task
  59003. */
  59004. name: string;
  59005. /**
  59006. * Defines the location of the file to load
  59007. */
  59008. url: string;
  59009. /**
  59010. * Gets the loaded text string
  59011. */
  59012. text: string;
  59013. /**
  59014. * Callback called when the task is successful
  59015. */
  59016. onSuccess: (task: TextFileAssetTask) => void;
  59017. /**
  59018. * Callback called when the task is successful
  59019. */
  59020. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  59021. /**
  59022. * Creates a new TextFileAssetTask object
  59023. * @param name defines the name of the task
  59024. * @param url defines the location of the file to load
  59025. */
  59026. constructor(
  59027. /**
  59028. * Defines the name of the task
  59029. */
  59030. name: string,
  59031. /**
  59032. * Defines the location of the file to load
  59033. */
  59034. url: string);
  59035. /**
  59036. * Execute the current task
  59037. * @param scene defines the scene where you want your assets to be loaded
  59038. * @param onSuccess is a callback called when the task is successfully executed
  59039. * @param onError is a callback called if an error occurs
  59040. */
  59041. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59042. }
  59043. /**
  59044. * Define a task used by AssetsManager to load binary data
  59045. */
  59046. export class BinaryFileAssetTask extends AbstractAssetTask {
  59047. /**
  59048. * Defines the name of the task
  59049. */
  59050. name: string;
  59051. /**
  59052. * Defines the location of the file to load
  59053. */
  59054. url: string;
  59055. /**
  59056. * Gets the lodaded data (as an array buffer)
  59057. */
  59058. data: ArrayBuffer;
  59059. /**
  59060. * Callback called when the task is successful
  59061. */
  59062. onSuccess: (task: BinaryFileAssetTask) => void;
  59063. /**
  59064. * Callback called when the task is successful
  59065. */
  59066. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  59067. /**
  59068. * Creates a new BinaryFileAssetTask object
  59069. * @param name defines the name of the new task
  59070. * @param url defines the location of the file to load
  59071. */
  59072. constructor(
  59073. /**
  59074. * Defines the name of the task
  59075. */
  59076. name: string,
  59077. /**
  59078. * Defines the location of the file to load
  59079. */
  59080. url: string);
  59081. /**
  59082. * Execute the current task
  59083. * @param scene defines the scene where you want your assets to be loaded
  59084. * @param onSuccess is a callback called when the task is successfully executed
  59085. * @param onError is a callback called if an error occurs
  59086. */
  59087. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59088. }
  59089. /**
  59090. * Define a task used by AssetsManager to load images
  59091. */
  59092. export class ImageAssetTask extends AbstractAssetTask {
  59093. /**
  59094. * Defines the name of the task
  59095. */
  59096. name: string;
  59097. /**
  59098. * Defines the location of the image to load
  59099. */
  59100. url: string;
  59101. /**
  59102. * Gets the loaded images
  59103. */
  59104. image: HTMLImageElement;
  59105. /**
  59106. * Callback called when the task is successful
  59107. */
  59108. onSuccess: (task: ImageAssetTask) => void;
  59109. /**
  59110. * Callback called when the task is successful
  59111. */
  59112. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  59113. /**
  59114. * Creates a new ImageAssetTask
  59115. * @param name defines the name of the task
  59116. * @param url defines the location of the image to load
  59117. */
  59118. constructor(
  59119. /**
  59120. * Defines the name of the task
  59121. */
  59122. name: string,
  59123. /**
  59124. * Defines the location of the image to load
  59125. */
  59126. url: string);
  59127. /**
  59128. * Execute the current task
  59129. * @param scene defines the scene where you want your assets to be loaded
  59130. * @param onSuccess is a callback called when the task is successfully executed
  59131. * @param onError is a callback called if an error occurs
  59132. */
  59133. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59134. }
  59135. /**
  59136. * Defines the interface used by texture loading tasks
  59137. */
  59138. export interface ITextureAssetTask<TEX extends BaseTexture> {
  59139. /**
  59140. * Gets the loaded texture
  59141. */
  59142. texture: TEX;
  59143. }
  59144. /**
  59145. * Define a task used by AssetsManager to load 2D textures
  59146. */
  59147. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  59148. /**
  59149. * Defines the name of the task
  59150. */
  59151. name: string;
  59152. /**
  59153. * Defines the location of the file to load
  59154. */
  59155. url: string;
  59156. /**
  59157. * Defines if mipmap should not be generated (default is false)
  59158. */
  59159. noMipmap?: boolean | undefined;
  59160. /**
  59161. * Defines if texture must be inverted on Y axis (default is false)
  59162. */
  59163. invertY?: boolean | undefined;
  59164. /**
  59165. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  59166. */
  59167. samplingMode: number;
  59168. /**
  59169. * Gets the loaded texture
  59170. */
  59171. texture: Texture;
  59172. /**
  59173. * Callback called when the task is successful
  59174. */
  59175. onSuccess: (task: TextureAssetTask) => void;
  59176. /**
  59177. * Callback called when the task is successful
  59178. */
  59179. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  59180. /**
  59181. * Creates a new TextureAssetTask object
  59182. * @param name defines the name of the task
  59183. * @param url defines the location of the file to load
  59184. * @param noMipmap defines if mipmap should not be generated (default is false)
  59185. * @param invertY defines if texture must be inverted on Y axis (default is false)
  59186. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  59187. */
  59188. constructor(
  59189. /**
  59190. * Defines the name of the task
  59191. */
  59192. name: string,
  59193. /**
  59194. * Defines the location of the file to load
  59195. */
  59196. url: string,
  59197. /**
  59198. * Defines if mipmap should not be generated (default is false)
  59199. */
  59200. noMipmap?: boolean | undefined,
  59201. /**
  59202. * Defines if texture must be inverted on Y axis (default is false)
  59203. */
  59204. invertY?: boolean | undefined,
  59205. /**
  59206. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  59207. */
  59208. samplingMode?: number);
  59209. /**
  59210. * Execute the current task
  59211. * @param scene defines the scene where you want your assets to be loaded
  59212. * @param onSuccess is a callback called when the task is successfully executed
  59213. * @param onError is a callback called if an error occurs
  59214. */
  59215. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59216. }
  59217. /**
  59218. * Define a task used by AssetsManager to load cube textures
  59219. */
  59220. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  59221. /**
  59222. * Defines the name of the task
  59223. */
  59224. name: string;
  59225. /**
  59226. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  59227. */
  59228. url: string;
  59229. /**
  59230. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  59231. */
  59232. extensions?: string[] | undefined;
  59233. /**
  59234. * Defines if mipmaps should not be generated (default is false)
  59235. */
  59236. noMipmap?: boolean | undefined;
  59237. /**
  59238. * Defines the explicit list of files (undefined by default)
  59239. */
  59240. files?: string[] | undefined;
  59241. /**
  59242. * Gets the loaded texture
  59243. */
  59244. texture: CubeTexture;
  59245. /**
  59246. * Callback called when the task is successful
  59247. */
  59248. onSuccess: (task: CubeTextureAssetTask) => void;
  59249. /**
  59250. * Callback called when the task is successful
  59251. */
  59252. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  59253. /**
  59254. * Creates a new CubeTextureAssetTask
  59255. * @param name defines the name of the task
  59256. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  59257. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  59258. * @param noMipmap defines if mipmaps should not be generated (default is false)
  59259. * @param files defines the explicit list of files (undefined by default)
  59260. */
  59261. constructor(
  59262. /**
  59263. * Defines the name of the task
  59264. */
  59265. name: string,
  59266. /**
  59267. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  59268. */
  59269. url: string,
  59270. /**
  59271. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  59272. */
  59273. extensions?: string[] | undefined,
  59274. /**
  59275. * Defines if mipmaps should not be generated (default is false)
  59276. */
  59277. noMipmap?: boolean | undefined,
  59278. /**
  59279. * Defines the explicit list of files (undefined by default)
  59280. */
  59281. files?: string[] | undefined);
  59282. /**
  59283. * Execute the current task
  59284. * @param scene defines the scene where you want your assets to be loaded
  59285. * @param onSuccess is a callback called when the task is successfully executed
  59286. * @param onError is a callback called if an error occurs
  59287. */
  59288. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59289. }
  59290. /**
  59291. * Define a task used by AssetsManager to load HDR cube textures
  59292. */
  59293. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  59294. /**
  59295. * Defines the name of the task
  59296. */
  59297. name: string;
  59298. /**
  59299. * Defines the location of the file to load
  59300. */
  59301. url: string;
  59302. /**
  59303. * Defines the desired size (the more it increases the longer the generation will be)
  59304. */
  59305. size: number;
  59306. /**
  59307. * Defines if mipmaps should not be generated (default is false)
  59308. */
  59309. noMipmap: boolean;
  59310. /**
  59311. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  59312. */
  59313. generateHarmonics: boolean;
  59314. /**
  59315. * 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)
  59316. */
  59317. gammaSpace: boolean;
  59318. /**
  59319. * Internal Use Only
  59320. */
  59321. reserved: boolean;
  59322. /**
  59323. * Gets the loaded texture
  59324. */
  59325. texture: HDRCubeTexture;
  59326. /**
  59327. * Callback called when the task is successful
  59328. */
  59329. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  59330. /**
  59331. * Callback called when the task is successful
  59332. */
  59333. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  59334. /**
  59335. * Creates a new HDRCubeTextureAssetTask object
  59336. * @param name defines the name of the task
  59337. * @param url defines the location of the file to load
  59338. * @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.
  59339. * @param noMipmap defines if mipmaps should not be generated (default is false)
  59340. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  59341. * @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)
  59342. * @param reserved Internal use only
  59343. */
  59344. constructor(
  59345. /**
  59346. * Defines the name of the task
  59347. */
  59348. name: string,
  59349. /**
  59350. * Defines the location of the file to load
  59351. */
  59352. url: string,
  59353. /**
  59354. * Defines the desired size (the more it increases the longer the generation will be)
  59355. */
  59356. size: number,
  59357. /**
  59358. * Defines if mipmaps should not be generated (default is false)
  59359. */
  59360. noMipmap?: boolean,
  59361. /**
  59362. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  59363. */
  59364. generateHarmonics?: boolean,
  59365. /**
  59366. * 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)
  59367. */
  59368. gammaSpace?: boolean,
  59369. /**
  59370. * Internal Use Only
  59371. */
  59372. reserved?: boolean);
  59373. /**
  59374. * Execute the current task
  59375. * @param scene defines the scene where you want your assets to be loaded
  59376. * @param onSuccess is a callback called when the task is successfully executed
  59377. * @param onError is a callback called if an error occurs
  59378. */
  59379. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59380. }
  59381. /**
  59382. * Define a task used by AssetsManager to load Equirectangular cube textures
  59383. */
  59384. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  59385. /**
  59386. * Defines the name of the task
  59387. */
  59388. name: string;
  59389. /**
  59390. * Defines the location of the file to load
  59391. */
  59392. url: string;
  59393. /**
  59394. * Defines the desired size (the more it increases the longer the generation will be)
  59395. */
  59396. size: number;
  59397. /**
  59398. * Defines if mipmaps should not be generated (default is false)
  59399. */
  59400. noMipmap: boolean;
  59401. /**
  59402. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  59403. * but the standard material would require them in Gamma space) (default is true)
  59404. */
  59405. gammaSpace: boolean;
  59406. /**
  59407. * Gets the loaded texture
  59408. */
  59409. texture: EquiRectangularCubeTexture;
  59410. /**
  59411. * Callback called when the task is successful
  59412. */
  59413. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  59414. /**
  59415. * Callback called when the task is successful
  59416. */
  59417. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  59418. /**
  59419. * Creates a new EquiRectangularCubeTextureAssetTask object
  59420. * @param name defines the name of the task
  59421. * @param url defines the location of the file to load
  59422. * @param size defines the desired size (the more it increases the longer the generation will be)
  59423. * If the size is omitted this implies you are using a preprocessed cubemap.
  59424. * @param noMipmap defines if mipmaps should not be generated (default is false)
  59425. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  59426. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  59427. * (default is true)
  59428. */
  59429. constructor(
  59430. /**
  59431. * Defines the name of the task
  59432. */
  59433. name: string,
  59434. /**
  59435. * Defines the location of the file to load
  59436. */
  59437. url: string,
  59438. /**
  59439. * Defines the desired size (the more it increases the longer the generation will be)
  59440. */
  59441. size: number,
  59442. /**
  59443. * Defines if mipmaps should not be generated (default is false)
  59444. */
  59445. noMipmap?: boolean,
  59446. /**
  59447. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  59448. * but the standard material would require them in Gamma space) (default is true)
  59449. */
  59450. gammaSpace?: boolean);
  59451. /**
  59452. * Execute the current task
  59453. * @param scene defines the scene where you want your assets to be loaded
  59454. * @param onSuccess is a callback called when the task is successfully executed
  59455. * @param onError is a callback called if an error occurs
  59456. */
  59457. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59458. }
  59459. /**
  59460. * This class can be used to easily import assets into a scene
  59461. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  59462. */
  59463. export class AssetsManager {
  59464. private _scene;
  59465. private _isLoading;
  59466. protected _tasks: AbstractAssetTask[];
  59467. protected _waitingTasksCount: number;
  59468. protected _totalTasksCount: number;
  59469. /**
  59470. * Callback called when all tasks are processed
  59471. */
  59472. onFinish: (tasks: AbstractAssetTask[]) => void;
  59473. /**
  59474. * Callback called when a task is successful
  59475. */
  59476. onTaskSuccess: (task: AbstractAssetTask) => void;
  59477. /**
  59478. * Callback called when a task had an error
  59479. */
  59480. onTaskError: (task: AbstractAssetTask) => void;
  59481. /**
  59482. * Callback called when a task is done (whatever the result is)
  59483. */
  59484. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  59485. /**
  59486. * Observable called when all tasks are processed
  59487. */
  59488. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  59489. /**
  59490. * Observable called when a task had an error
  59491. */
  59492. onTaskErrorObservable: Observable<AbstractAssetTask>;
  59493. /**
  59494. * Observable called when all tasks were executed
  59495. */
  59496. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  59497. /**
  59498. * Observable called when a task is done (whatever the result is)
  59499. */
  59500. onProgressObservable: Observable<IAssetsProgressEvent>;
  59501. /**
  59502. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  59503. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  59504. */
  59505. useDefaultLoadingScreen: boolean;
  59506. /**
  59507. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  59508. * when all assets have been downloaded.
  59509. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  59510. */
  59511. autoHideLoadingUI: boolean;
  59512. /**
  59513. * Creates a new AssetsManager
  59514. * @param scene defines the scene to work on
  59515. */
  59516. constructor(scene: Scene);
  59517. /**
  59518. * Add a MeshAssetTask to the list of active tasks
  59519. * @param taskName defines the name of the new task
  59520. * @param meshesNames defines the name of meshes to load
  59521. * @param rootUrl defines the root url to use to locate files
  59522. * @param sceneFilename defines the filename of the scene file
  59523. * @returns a new MeshAssetTask object
  59524. */
  59525. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  59526. /**
  59527. * Add a TextFileAssetTask to the list of active tasks
  59528. * @param taskName defines the name of the new task
  59529. * @param url defines the url of the file to load
  59530. * @returns a new TextFileAssetTask object
  59531. */
  59532. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  59533. /**
  59534. * Add a BinaryFileAssetTask to the list of active tasks
  59535. * @param taskName defines the name of the new task
  59536. * @param url defines the url of the file to load
  59537. * @returns a new BinaryFileAssetTask object
  59538. */
  59539. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  59540. /**
  59541. * Add a ImageAssetTask to the list of active tasks
  59542. * @param taskName defines the name of the new task
  59543. * @param url defines the url of the file to load
  59544. * @returns a new ImageAssetTask object
  59545. */
  59546. addImageTask(taskName: string, url: string): ImageAssetTask;
  59547. /**
  59548. * Add a TextureAssetTask to the list of active tasks
  59549. * @param taskName defines the name of the new task
  59550. * @param url defines the url of the file to load
  59551. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  59552. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  59553. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59554. * @returns a new TextureAssetTask object
  59555. */
  59556. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  59557. /**
  59558. * Add a CubeTextureAssetTask to the list of active tasks
  59559. * @param taskName defines the name of the new task
  59560. * @param url defines the url of the file to load
  59561. * @param extensions defines the extension to use to load the cube map (can be null)
  59562. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  59563. * @param files defines the list of files to load (can be null)
  59564. * @returns a new CubeTextureAssetTask object
  59565. */
  59566. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  59567. /**
  59568. *
  59569. * Add a HDRCubeTextureAssetTask to the list of active tasks
  59570. * @param taskName defines the name of the new task
  59571. * @param url defines the url of the file to load
  59572. * @param size defines the size you want for the cubemap (can be null)
  59573. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  59574. * @param generateHarmonics defines if you want to automatically generate (true by default)
  59575. * @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)
  59576. * @param reserved Internal use only
  59577. * @returns a new HDRCubeTextureAssetTask object
  59578. */
  59579. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  59580. /**
  59581. *
  59582. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  59583. * @param taskName defines the name of the new task
  59584. * @param url defines the url of the file to load
  59585. * @param size defines the size you want for the cubemap (can be null)
  59586. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  59587. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  59588. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  59589. * @returns a new EquiRectangularCubeTextureAssetTask object
  59590. */
  59591. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  59592. /**
  59593. * Remove a task from the assets manager.
  59594. * @param task the task to remove
  59595. */
  59596. removeTask(task: AbstractAssetTask): void;
  59597. private _decreaseWaitingTasksCount;
  59598. private _runTask;
  59599. /**
  59600. * Reset the AssetsManager and remove all tasks
  59601. * @return the current instance of the AssetsManager
  59602. */
  59603. reset(): AssetsManager;
  59604. /**
  59605. * Start the loading process
  59606. * @return the current instance of the AssetsManager
  59607. */
  59608. load(): AssetsManager;
  59609. /**
  59610. * Start the loading process as an async operation
  59611. * @return a promise returning the list of failed tasks
  59612. */
  59613. loadAsync(): Promise<void>;
  59614. }
  59615. }
  59616. declare module BABYLON {
  59617. /**
  59618. * Wrapper class for promise with external resolve and reject.
  59619. */
  59620. export class Deferred<T> {
  59621. /**
  59622. * The promise associated with this deferred object.
  59623. */
  59624. readonly promise: Promise<T>;
  59625. private _resolve;
  59626. private _reject;
  59627. /**
  59628. * The resolve method of the promise associated with this deferred object.
  59629. */
  59630. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  59631. /**
  59632. * The reject method of the promise associated with this deferred object.
  59633. */
  59634. readonly reject: (reason?: any) => void;
  59635. /**
  59636. * Constructor for this deferred object.
  59637. */
  59638. constructor();
  59639. }
  59640. }
  59641. declare module BABYLON {
  59642. /**
  59643. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  59644. */
  59645. export class MeshExploder {
  59646. private _centerMesh;
  59647. private _meshes;
  59648. private _meshesOrigins;
  59649. private _toCenterVectors;
  59650. private _scaledDirection;
  59651. private _newPosition;
  59652. private _centerPosition;
  59653. /**
  59654. * Explodes meshes from a center mesh.
  59655. * @param meshes The meshes to explode.
  59656. * @param centerMesh The mesh to be center of explosion.
  59657. */
  59658. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  59659. private _setCenterMesh;
  59660. /**
  59661. * Get class name
  59662. * @returns "MeshExploder"
  59663. */
  59664. getClassName(): string;
  59665. /**
  59666. * "Exploded meshes"
  59667. * @returns Array of meshes with the centerMesh at index 0.
  59668. */
  59669. getMeshes(): Array<Mesh>;
  59670. /**
  59671. * Explodes meshes giving a specific direction
  59672. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  59673. */
  59674. explode(direction?: number): void;
  59675. }
  59676. }
  59677. declare module BABYLON {
  59678. /**
  59679. * Class used to help managing file picking and drag'n'drop
  59680. */
  59681. export class FilesInput {
  59682. /**
  59683. * List of files ready to be loaded
  59684. */
  59685. static readonly FilesToLoad: {
  59686. [key: string]: File;
  59687. };
  59688. /**
  59689. * Callback called when a file is processed
  59690. */
  59691. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  59692. private _engine;
  59693. private _currentScene;
  59694. private _sceneLoadedCallback;
  59695. private _progressCallback;
  59696. private _additionalRenderLoopLogicCallback;
  59697. private _textureLoadingCallback;
  59698. private _startingProcessingFilesCallback;
  59699. private _onReloadCallback;
  59700. private _errorCallback;
  59701. private _elementToMonitor;
  59702. private _sceneFileToLoad;
  59703. private _filesToLoad;
  59704. /**
  59705. * Creates a new FilesInput
  59706. * @param engine defines the rendering engine
  59707. * @param scene defines the hosting scene
  59708. * @param sceneLoadedCallback callback called when scene is loaded
  59709. * @param progressCallback callback called to track progress
  59710. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  59711. * @param textureLoadingCallback callback called when a texture is loading
  59712. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  59713. * @param onReloadCallback callback called when a reload is requested
  59714. * @param errorCallback callback call if an error occurs
  59715. */
  59716. 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);
  59717. private _dragEnterHandler;
  59718. private _dragOverHandler;
  59719. private _dropHandler;
  59720. /**
  59721. * Calls this function to listen to drag'n'drop events on a specific DOM element
  59722. * @param elementToMonitor defines the DOM element to track
  59723. */
  59724. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  59725. /**
  59726. * Release all associated resources
  59727. */
  59728. dispose(): void;
  59729. private renderFunction;
  59730. private drag;
  59731. private drop;
  59732. private _traverseFolder;
  59733. private _processFiles;
  59734. /**
  59735. * Load files from a drop event
  59736. * @param event defines the drop event to use as source
  59737. */
  59738. loadFiles(event: any): void;
  59739. private _processReload;
  59740. /**
  59741. * Reload the current scene from the loaded files
  59742. */
  59743. reload(): void;
  59744. }
  59745. }
  59746. declare module BABYLON {
  59747. /**
  59748. * Defines the root class used to create scene optimization to use with SceneOptimizer
  59749. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59750. */
  59751. export class SceneOptimization {
  59752. /**
  59753. * Defines the priority of this optimization (0 by default which means first in the list)
  59754. */
  59755. priority: number;
  59756. /**
  59757. * Gets a string describing the action executed by the current optimization
  59758. * @returns description string
  59759. */
  59760. getDescription(): string;
  59761. /**
  59762. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59763. * @param scene defines the current scene where to apply this optimization
  59764. * @param optimizer defines the current optimizer
  59765. * @returns true if everything that can be done was applied
  59766. */
  59767. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59768. /**
  59769. * Creates the SceneOptimization object
  59770. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59771. * @param desc defines the description associated with the optimization
  59772. */
  59773. constructor(
  59774. /**
  59775. * Defines the priority of this optimization (0 by default which means first in the list)
  59776. */
  59777. priority?: number);
  59778. }
  59779. /**
  59780. * Defines an optimization used to reduce the size of render target textures
  59781. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59782. */
  59783. export class TextureOptimization extends SceneOptimization {
  59784. /**
  59785. * Defines the priority of this optimization (0 by default which means first in the list)
  59786. */
  59787. priority: number;
  59788. /**
  59789. * 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
  59790. */
  59791. maximumSize: number;
  59792. /**
  59793. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  59794. */
  59795. step: number;
  59796. /**
  59797. * Gets a string describing the action executed by the current optimization
  59798. * @returns description string
  59799. */
  59800. getDescription(): string;
  59801. /**
  59802. * Creates the TextureOptimization object
  59803. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59804. * @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
  59805. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  59806. */
  59807. constructor(
  59808. /**
  59809. * Defines the priority of this optimization (0 by default which means first in the list)
  59810. */
  59811. priority?: number,
  59812. /**
  59813. * 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
  59814. */
  59815. maximumSize?: number,
  59816. /**
  59817. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  59818. */
  59819. step?: number);
  59820. /**
  59821. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59822. * @param scene defines the current scene where to apply this optimization
  59823. * @param optimizer defines the current optimizer
  59824. * @returns true if everything that can be done was applied
  59825. */
  59826. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59827. }
  59828. /**
  59829. * Defines an optimization used to increase or decrease the rendering resolution
  59830. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59831. */
  59832. export class HardwareScalingOptimization extends SceneOptimization {
  59833. /**
  59834. * Defines the priority of this optimization (0 by default which means first in the list)
  59835. */
  59836. priority: number;
  59837. /**
  59838. * Defines the maximum scale to use (2 by default)
  59839. */
  59840. maximumScale: number;
  59841. /**
  59842. * Defines the step to use between two passes (0.5 by default)
  59843. */
  59844. step: number;
  59845. private _currentScale;
  59846. private _directionOffset;
  59847. /**
  59848. * Gets a string describing the action executed by the current optimization
  59849. * @return description string
  59850. */
  59851. getDescription(): string;
  59852. /**
  59853. * Creates the HardwareScalingOptimization object
  59854. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59855. * @param maximumScale defines the maximum scale to use (2 by default)
  59856. * @param step defines the step to use between two passes (0.5 by default)
  59857. */
  59858. constructor(
  59859. /**
  59860. * Defines the priority of this optimization (0 by default which means first in the list)
  59861. */
  59862. priority?: number,
  59863. /**
  59864. * Defines the maximum scale to use (2 by default)
  59865. */
  59866. maximumScale?: number,
  59867. /**
  59868. * Defines the step to use between two passes (0.5 by default)
  59869. */
  59870. step?: number);
  59871. /**
  59872. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59873. * @param scene defines the current scene where to apply this optimization
  59874. * @param optimizer defines the current optimizer
  59875. * @returns true if everything that can be done was applied
  59876. */
  59877. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59878. }
  59879. /**
  59880. * Defines an optimization used to remove shadows
  59881. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59882. */
  59883. export class ShadowsOptimization extends SceneOptimization {
  59884. /**
  59885. * Gets a string describing the action executed by the current optimization
  59886. * @return description string
  59887. */
  59888. getDescription(): string;
  59889. /**
  59890. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59891. * @param scene defines the current scene where to apply this optimization
  59892. * @param optimizer defines the current optimizer
  59893. * @returns true if everything that can be done was applied
  59894. */
  59895. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59896. }
  59897. /**
  59898. * Defines an optimization used to turn post-processes off
  59899. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59900. */
  59901. export class PostProcessesOptimization extends SceneOptimization {
  59902. /**
  59903. * Gets a string describing the action executed by the current optimization
  59904. * @return description string
  59905. */
  59906. getDescription(): string;
  59907. /**
  59908. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59909. * @param scene defines the current scene where to apply this optimization
  59910. * @param optimizer defines the current optimizer
  59911. * @returns true if everything that can be done was applied
  59912. */
  59913. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59914. }
  59915. /**
  59916. * Defines an optimization used to turn lens flares off
  59917. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59918. */
  59919. export class LensFlaresOptimization extends SceneOptimization {
  59920. /**
  59921. * Gets a string describing the action executed by the current optimization
  59922. * @return description string
  59923. */
  59924. getDescription(): string;
  59925. /**
  59926. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59927. * @param scene defines the current scene where to apply this optimization
  59928. * @param optimizer defines the current optimizer
  59929. * @returns true if everything that can be done was applied
  59930. */
  59931. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59932. }
  59933. /**
  59934. * Defines an optimization based on user defined callback.
  59935. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59936. */
  59937. export class CustomOptimization extends SceneOptimization {
  59938. /**
  59939. * Callback called to apply the custom optimization.
  59940. */
  59941. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  59942. /**
  59943. * Callback called to get custom description
  59944. */
  59945. onGetDescription: () => string;
  59946. /**
  59947. * Gets a string describing the action executed by the current optimization
  59948. * @returns description string
  59949. */
  59950. getDescription(): string;
  59951. /**
  59952. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59953. * @param scene defines the current scene where to apply this optimization
  59954. * @param optimizer defines the current optimizer
  59955. * @returns true if everything that can be done was applied
  59956. */
  59957. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59958. }
  59959. /**
  59960. * Defines an optimization used to turn particles off
  59961. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59962. */
  59963. export class ParticlesOptimization extends SceneOptimization {
  59964. /**
  59965. * Gets a string describing the action executed by the current optimization
  59966. * @return description string
  59967. */
  59968. getDescription(): string;
  59969. /**
  59970. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59971. * @param scene defines the current scene where to apply this optimization
  59972. * @param optimizer defines the current optimizer
  59973. * @returns true if everything that can be done was applied
  59974. */
  59975. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59976. }
  59977. /**
  59978. * Defines an optimization used to turn render targets off
  59979. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59980. */
  59981. export class RenderTargetsOptimization extends SceneOptimization {
  59982. /**
  59983. * Gets a string describing the action executed by the current optimization
  59984. * @return description string
  59985. */
  59986. getDescription(): string;
  59987. /**
  59988. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59989. * @param scene defines the current scene where to apply this optimization
  59990. * @param optimizer defines the current optimizer
  59991. * @returns true if everything that can be done was applied
  59992. */
  59993. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59994. }
  59995. /**
  59996. * Defines an optimization used to merge meshes with compatible materials
  59997. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59998. */
  59999. export class MergeMeshesOptimization extends SceneOptimization {
  60000. private static _UpdateSelectionTree;
  60001. /**
  60002. * Gets or sets a boolean which defines if optimization octree has to be updated
  60003. */
  60004. /**
  60005. * Gets or sets a boolean which defines if optimization octree has to be updated
  60006. */
  60007. static UpdateSelectionTree: boolean;
  60008. /**
  60009. * Gets a string describing the action executed by the current optimization
  60010. * @return description string
  60011. */
  60012. getDescription(): string;
  60013. private _canBeMerged;
  60014. /**
  60015. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60016. * @param scene defines the current scene where to apply this optimization
  60017. * @param optimizer defines the current optimizer
  60018. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  60019. * @returns true if everything that can be done was applied
  60020. */
  60021. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  60022. }
  60023. /**
  60024. * Defines a list of options used by SceneOptimizer
  60025. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60026. */
  60027. export class SceneOptimizerOptions {
  60028. /**
  60029. * Defines the target frame rate to reach (60 by default)
  60030. */
  60031. targetFrameRate: number;
  60032. /**
  60033. * Defines the interval between two checkes (2000ms by default)
  60034. */
  60035. trackerDuration: number;
  60036. /**
  60037. * Gets the list of optimizations to apply
  60038. */
  60039. optimizations: SceneOptimization[];
  60040. /**
  60041. * Creates a new list of options used by SceneOptimizer
  60042. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  60043. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  60044. */
  60045. constructor(
  60046. /**
  60047. * Defines the target frame rate to reach (60 by default)
  60048. */
  60049. targetFrameRate?: number,
  60050. /**
  60051. * Defines the interval between two checkes (2000ms by default)
  60052. */
  60053. trackerDuration?: number);
  60054. /**
  60055. * Add a new optimization
  60056. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  60057. * @returns the current SceneOptimizerOptions
  60058. */
  60059. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  60060. /**
  60061. * Add a new custom optimization
  60062. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  60063. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  60064. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60065. * @returns the current SceneOptimizerOptions
  60066. */
  60067. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  60068. /**
  60069. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  60070. * @param targetFrameRate defines the target frame rate (60 by default)
  60071. * @returns a SceneOptimizerOptions object
  60072. */
  60073. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  60074. /**
  60075. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  60076. * @param targetFrameRate defines the target frame rate (60 by default)
  60077. * @returns a SceneOptimizerOptions object
  60078. */
  60079. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  60080. /**
  60081. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  60082. * @param targetFrameRate defines the target frame rate (60 by default)
  60083. * @returns a SceneOptimizerOptions object
  60084. */
  60085. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  60086. }
  60087. /**
  60088. * Class used to run optimizations in order to reach a target frame rate
  60089. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60090. */
  60091. export class SceneOptimizer implements IDisposable {
  60092. private _isRunning;
  60093. private _options;
  60094. private _scene;
  60095. private _currentPriorityLevel;
  60096. private _targetFrameRate;
  60097. private _trackerDuration;
  60098. private _currentFrameRate;
  60099. private _sceneDisposeObserver;
  60100. private _improvementMode;
  60101. /**
  60102. * Defines an observable called when the optimizer reaches the target frame rate
  60103. */
  60104. onSuccessObservable: Observable<SceneOptimizer>;
  60105. /**
  60106. * Defines an observable called when the optimizer enables an optimization
  60107. */
  60108. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  60109. /**
  60110. * Defines an observable called when the optimizer is not able to reach the target frame rate
  60111. */
  60112. onFailureObservable: Observable<SceneOptimizer>;
  60113. /**
  60114. * Gets a boolean indicating if the optimizer is in improvement mode
  60115. */
  60116. readonly isInImprovementMode: boolean;
  60117. /**
  60118. * Gets the current priority level (0 at start)
  60119. */
  60120. readonly currentPriorityLevel: number;
  60121. /**
  60122. * Gets the current frame rate checked by the SceneOptimizer
  60123. */
  60124. readonly currentFrameRate: number;
  60125. /**
  60126. * Gets or sets the current target frame rate (60 by default)
  60127. */
  60128. /**
  60129. * Gets or sets the current target frame rate (60 by default)
  60130. */
  60131. targetFrameRate: number;
  60132. /**
  60133. * Gets or sets the current interval between two checks (every 2000ms by default)
  60134. */
  60135. /**
  60136. * Gets or sets the current interval between two checks (every 2000ms by default)
  60137. */
  60138. trackerDuration: number;
  60139. /**
  60140. * Gets the list of active optimizations
  60141. */
  60142. readonly optimizations: SceneOptimization[];
  60143. /**
  60144. * Creates a new SceneOptimizer
  60145. * @param scene defines the scene to work on
  60146. * @param options defines the options to use with the SceneOptimizer
  60147. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  60148. * @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)
  60149. */
  60150. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  60151. /**
  60152. * Stops the current optimizer
  60153. */
  60154. stop(): void;
  60155. /**
  60156. * Reset the optimizer to initial step (current priority level = 0)
  60157. */
  60158. reset(): void;
  60159. /**
  60160. * Start the optimizer. By default it will try to reach a specific framerate
  60161. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  60162. */
  60163. start(): void;
  60164. private _checkCurrentState;
  60165. /**
  60166. * Release all resources
  60167. */
  60168. dispose(): void;
  60169. /**
  60170. * Helper function to create a SceneOptimizer with one single line of code
  60171. * @param scene defines the scene to work on
  60172. * @param options defines the options to use with the SceneOptimizer
  60173. * @param onSuccess defines a callback to call on success
  60174. * @param onFailure defines a callback to call on failure
  60175. * @returns the new SceneOptimizer object
  60176. */
  60177. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  60178. }
  60179. }
  60180. declare module BABYLON {
  60181. /**
  60182. * Class used to serialize a scene into a string
  60183. */
  60184. export class SceneSerializer {
  60185. /**
  60186. * Clear cache used by a previous serialization
  60187. */
  60188. static ClearCache(): void;
  60189. /**
  60190. * Serialize a scene into a JSON compatible object
  60191. * @param scene defines the scene to serialize
  60192. * @returns a JSON compatible object
  60193. */
  60194. static Serialize(scene: Scene): any;
  60195. /**
  60196. * Serialize a mesh into a JSON compatible object
  60197. * @param toSerialize defines the mesh to serialize
  60198. * @param withParents defines if parents must be serialized as well
  60199. * @param withChildren defines if children must be serialized as well
  60200. * @returns a JSON compatible object
  60201. */
  60202. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  60203. }
  60204. }
  60205. declare module BABYLON {
  60206. /**
  60207. * Class used to host texture specific utilities
  60208. */
  60209. export class TextureTools {
  60210. /**
  60211. * Uses the GPU to create a copy texture rescaled at a given size
  60212. * @param texture Texture to copy from
  60213. * @param width defines the desired width
  60214. * @param height defines the desired height
  60215. * @param useBilinearMode defines if bilinear mode has to be used
  60216. * @return the generated texture
  60217. */
  60218. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  60219. }
  60220. }
  60221. declare module BABYLON {
  60222. /**
  60223. * This represents the different options available for the video capture.
  60224. */
  60225. export interface VideoRecorderOptions {
  60226. /** Defines the mime type of the video. */
  60227. mimeType: string;
  60228. /** Defines the FPS the video should be recorded at. */
  60229. fps: number;
  60230. /** Defines the chunk size for the recording data. */
  60231. recordChunckSize: number;
  60232. /** The audio tracks to attach to the recording. */
  60233. audioTracks?: MediaStreamTrack[];
  60234. }
  60235. /**
  60236. * This can help with recording videos from BabylonJS.
  60237. * This is based on the available WebRTC functionalities of the browser.
  60238. *
  60239. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  60240. */
  60241. export class VideoRecorder {
  60242. private static readonly _defaultOptions;
  60243. /**
  60244. * Returns whether or not the VideoRecorder is available in your browser.
  60245. * @param engine Defines the Babylon Engine.
  60246. * @returns true if supported otherwise false.
  60247. */
  60248. static IsSupported(engine: Engine): boolean;
  60249. private readonly _options;
  60250. private _canvas;
  60251. private _mediaRecorder;
  60252. private _recordedChunks;
  60253. private _fileName;
  60254. private _resolve;
  60255. private _reject;
  60256. /**
  60257. * True when a recording is already in progress.
  60258. */
  60259. readonly isRecording: boolean;
  60260. /**
  60261. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  60262. * @param engine Defines the BabylonJS Engine you wish to record.
  60263. * @param options Defines options that can be used to customize the capture.
  60264. */
  60265. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  60266. /**
  60267. * Stops the current recording before the default capture timeout passed in the startRecording function.
  60268. */
  60269. stopRecording(): void;
  60270. /**
  60271. * Starts recording the canvas for a max duration specified in parameters.
  60272. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  60273. * If null no automatic download will start and you can rely on the promise to get the data back.
  60274. * @param maxDuration Defines the maximum recording time in seconds.
  60275. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  60276. * @return A promise callback at the end of the recording with the video data in Blob.
  60277. */
  60278. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  60279. /**
  60280. * Releases internal resources used during the recording.
  60281. */
  60282. dispose(): void;
  60283. private _handleDataAvailable;
  60284. private _handleError;
  60285. private _handleStop;
  60286. }
  60287. }
  60288. declare module BABYLON {
  60289. /**
  60290. * Class containing a set of static utilities functions for screenshots
  60291. */
  60292. export class ScreenshotTools {
  60293. /**
  60294. * Captures a screenshot of the current rendering
  60295. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  60296. * @param engine defines the rendering engine
  60297. * @param camera defines the source camera
  60298. * @param size This parameter can be set to a single number or to an object with the
  60299. * following (optional) properties: precision, width, height. If a single number is passed,
  60300. * it will be used for both width and height. If an object is passed, the screenshot size
  60301. * will be derived from the parameters. The precision property is a multiplier allowing
  60302. * rendering at a higher or lower resolution
  60303. * @param successCallback defines the callback receives a single parameter which contains the
  60304. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  60305. * src parameter of an <img> to display it
  60306. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  60307. * Check your browser for supported MIME types
  60308. */
  60309. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  60310. /**
  60311. * Captures a screenshot of the current rendering
  60312. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  60313. * @param engine defines the rendering engine
  60314. * @param camera defines the source camera
  60315. * @param size This parameter can be set to a single number or to an object with the
  60316. * following (optional) properties: precision, width, height. If a single number is passed,
  60317. * it will be used for both width and height. If an object is passed, the screenshot size
  60318. * will be derived from the parameters. The precision property is a multiplier allowing
  60319. * rendering at a higher or lower resolution
  60320. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  60321. * Check your browser for supported MIME types
  60322. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  60323. * to the src parameter of an <img> to display it
  60324. */
  60325. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  60326. /**
  60327. * Generates an image screenshot from the specified camera.
  60328. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  60329. * @param engine The engine to use for rendering
  60330. * @param camera The camera to use for rendering
  60331. * @param size This parameter can be set to a single number or to an object with the
  60332. * following (optional) properties: precision, width, height. If a single number is passed,
  60333. * it will be used for both width and height. If an object is passed, the screenshot size
  60334. * will be derived from the parameters. The precision property is a multiplier allowing
  60335. * rendering at a higher or lower resolution
  60336. * @param successCallback The callback receives a single parameter which contains the
  60337. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  60338. * src parameter of an <img> to display it
  60339. * @param mimeType The MIME type of the screenshot image (default: image/png).
  60340. * Check your browser for supported MIME types
  60341. * @param samples Texture samples (default: 1)
  60342. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  60343. * @param fileName A name for for the downloaded file.
  60344. */
  60345. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  60346. /**
  60347. * Generates an image screenshot from the specified camera.
  60348. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  60349. * @param engine The engine to use for rendering
  60350. * @param camera The camera to use for rendering
  60351. * @param size This parameter can be set to a single number or to an object with the
  60352. * following (optional) properties: precision, width, height. If a single number is passed,
  60353. * it will be used for both width and height. If an object is passed, the screenshot size
  60354. * will be derived from the parameters. The precision property is a multiplier allowing
  60355. * rendering at a higher or lower resolution
  60356. * @param mimeType The MIME type of the screenshot image (default: image/png).
  60357. * Check your browser for supported MIME types
  60358. * @param samples Texture samples (default: 1)
  60359. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  60360. * @param fileName A name for for the downloaded file.
  60361. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  60362. * to the src parameter of an <img> to display it
  60363. */
  60364. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  60365. /**
  60366. * Gets height and width for screenshot size
  60367. * @private
  60368. */
  60369. private static _getScreenshotSize;
  60370. }
  60371. }
  60372. declare module BABYLON {
  60373. /**
  60374. * A cursor which tracks a point on a path
  60375. */
  60376. export class PathCursor {
  60377. private path;
  60378. /**
  60379. * Stores path cursor callbacks for when an onchange event is triggered
  60380. */
  60381. private _onchange;
  60382. /**
  60383. * The value of the path cursor
  60384. */
  60385. value: number;
  60386. /**
  60387. * The animation array of the path cursor
  60388. */
  60389. animations: Animation[];
  60390. /**
  60391. * Initializes the path cursor
  60392. * @param path The path to track
  60393. */
  60394. constructor(path: Path2);
  60395. /**
  60396. * Gets the cursor point on the path
  60397. * @returns A point on the path cursor at the cursor location
  60398. */
  60399. getPoint(): Vector3;
  60400. /**
  60401. * Moves the cursor ahead by the step amount
  60402. * @param step The amount to move the cursor forward
  60403. * @returns This path cursor
  60404. */
  60405. moveAhead(step?: number): PathCursor;
  60406. /**
  60407. * Moves the cursor behind by the step amount
  60408. * @param step The amount to move the cursor back
  60409. * @returns This path cursor
  60410. */
  60411. moveBack(step?: number): PathCursor;
  60412. /**
  60413. * Moves the cursor by the step amount
  60414. * If the step amount is greater than one, an exception is thrown
  60415. * @param step The amount to move the cursor
  60416. * @returns This path cursor
  60417. */
  60418. move(step: number): PathCursor;
  60419. /**
  60420. * Ensures that the value is limited between zero and one
  60421. * @returns This path cursor
  60422. */
  60423. private ensureLimits;
  60424. /**
  60425. * Runs onchange callbacks on change (used by the animation engine)
  60426. * @returns This path cursor
  60427. */
  60428. private raiseOnChange;
  60429. /**
  60430. * Executes a function on change
  60431. * @param f A path cursor onchange callback
  60432. * @returns This path cursor
  60433. */
  60434. onchange(f: (cursor: PathCursor) => void): PathCursor;
  60435. }
  60436. }
  60437. declare module BABYLON {
  60438. /** @hidden */
  60439. export var blurPixelShader: {
  60440. name: string;
  60441. shader: string;
  60442. };
  60443. }
  60444. declare module BABYLON {
  60445. /** @hidden */
  60446. export var pointCloudVertexDeclaration: {
  60447. name: string;
  60448. shader: string;
  60449. };
  60450. }
  60451. // Mixins
  60452. interface Window {
  60453. mozIndexedDB: IDBFactory;
  60454. webkitIndexedDB: IDBFactory;
  60455. msIndexedDB: IDBFactory;
  60456. webkitURL: typeof URL;
  60457. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  60458. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  60459. WebGLRenderingContext: WebGLRenderingContext;
  60460. MSGesture: MSGesture;
  60461. CANNON: any;
  60462. AudioContext: AudioContext;
  60463. webkitAudioContext: AudioContext;
  60464. PointerEvent: any;
  60465. Math: Math;
  60466. Uint8Array: Uint8ArrayConstructor;
  60467. Float32Array: Float32ArrayConstructor;
  60468. mozURL: typeof URL;
  60469. msURL: typeof URL;
  60470. VRFrameData: any; // WebVR, from specs 1.1
  60471. DracoDecoderModule: any;
  60472. setImmediate(handler: (...args: any[]) => void): number;
  60473. }
  60474. interface HTMLCanvasElement {
  60475. requestPointerLock(): void;
  60476. msRequestPointerLock?(): void;
  60477. mozRequestPointerLock?(): void;
  60478. webkitRequestPointerLock?(): void;
  60479. /** Track wether a record is in progress */
  60480. isRecording: boolean;
  60481. /** Capture Stream method defined by some browsers */
  60482. captureStream(fps?: number): MediaStream;
  60483. }
  60484. interface CanvasRenderingContext2D {
  60485. msImageSmoothingEnabled: boolean;
  60486. }
  60487. interface MouseEvent {
  60488. mozMovementX: number;
  60489. mozMovementY: number;
  60490. webkitMovementX: number;
  60491. webkitMovementY: number;
  60492. msMovementX: number;
  60493. msMovementY: number;
  60494. }
  60495. interface Navigator {
  60496. mozGetVRDevices: (any: any) => any;
  60497. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  60498. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  60499. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  60500. webkitGetGamepads(): Gamepad[];
  60501. msGetGamepads(): Gamepad[];
  60502. webkitGamepads(): Gamepad[];
  60503. }
  60504. interface HTMLVideoElement {
  60505. mozSrcObject: any;
  60506. }
  60507. interface Math {
  60508. fround(x: number): number;
  60509. imul(a: number, b: number): number;
  60510. }
  60511. interface WebGLRenderingContext {
  60512. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  60513. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  60514. vertexAttribDivisor(index: number, divisor: number): void;
  60515. createVertexArray(): any;
  60516. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  60517. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  60518. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  60519. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  60520. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  60521. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  60522. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  60523. // Queries
  60524. createQuery(): WebGLQuery;
  60525. deleteQuery(query: WebGLQuery): void;
  60526. beginQuery(target: number, query: WebGLQuery): void;
  60527. endQuery(target: number): void;
  60528. getQueryParameter(query: WebGLQuery, pname: number): any;
  60529. getQuery(target: number, pname: number): any;
  60530. MAX_SAMPLES: number;
  60531. RGBA8: number;
  60532. READ_FRAMEBUFFER: number;
  60533. DRAW_FRAMEBUFFER: number;
  60534. UNIFORM_BUFFER: number;
  60535. HALF_FLOAT_OES: number;
  60536. RGBA16F: number;
  60537. RGBA32F: number;
  60538. R32F: number;
  60539. RG32F: number;
  60540. RGB32F: number;
  60541. R16F: number;
  60542. RG16F: number;
  60543. RGB16F: number;
  60544. RED: number;
  60545. RG: number;
  60546. R8: number;
  60547. RG8: number;
  60548. UNSIGNED_INT_24_8: number;
  60549. DEPTH24_STENCIL8: number;
  60550. /* Multiple Render Targets */
  60551. drawBuffers(buffers: number[]): void;
  60552. readBuffer(src: number): void;
  60553. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  60554. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  60555. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  60556. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  60557. // Occlusion Query
  60558. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  60559. ANY_SAMPLES_PASSED: number;
  60560. QUERY_RESULT_AVAILABLE: number;
  60561. QUERY_RESULT: number;
  60562. }
  60563. interface WebGLProgram { private __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  60564. }
  60565. interface EXT_disjoint_timer_query {
  60566. QUERY_COUNTER_BITS_EXT: number;
  60567. TIME_ELAPSED_EXT: number;
  60568. TIMESTAMP_EXT: number;
  60569. GPU_DISJOINT_EXT: number;
  60570. QUERY_RESULT_EXT: number;
  60571. QUERY_RESULT_AVAILABLE_EXT: number;
  60572. queryCounterEXT(query: WebGLQuery, target: number): void;
  60573. createQueryEXT(): WebGLQuery;
  60574. beginQueryEXT(target: number, query: WebGLQuery): void;
  60575. endQueryEXT(target: number): void;
  60576. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  60577. deleteQueryEXT(query: WebGLQuery): void;
  60578. }
  60579. interface WebGLUniformLocation { private _currentState: any;
  60580. }
  60581. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  60582. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  60583. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  60584. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  60585. interface WebGLRenderingContext {
  60586. readonly RASTERIZER_DISCARD: number;
  60587. readonly DEPTH_COMPONENT24: number;
  60588. readonly TEXTURE_3D: number;
  60589. readonly TEXTURE_2D_ARRAY: number;
  60590. readonly TEXTURE_COMPARE_FUNC: number;
  60591. readonly TEXTURE_COMPARE_MODE: number;
  60592. readonly COMPARE_REF_TO_TEXTURE: number;
  60593. readonly TEXTURE_WRAP_R: number;
  60594. readonly HALF_FLOAT: number;
  60595. readonly RGB8: number;
  60596. readonly RED_INTEGER: number;
  60597. readonly RG_INTEGER: number;
  60598. readonly RGB_INTEGER: number;
  60599. readonly RGBA_INTEGER: number;
  60600. readonly R8_SNORM: number;
  60601. readonly RG8_SNORM: number;
  60602. readonly RGB8_SNORM: number;
  60603. readonly RGBA8_SNORM: number;
  60604. readonly R8I: number;
  60605. readonly RG8I: number;
  60606. readonly RGB8I: number;
  60607. readonly RGBA8I: number;
  60608. readonly R8UI: number;
  60609. readonly RG8UI: number;
  60610. readonly RGB8UI: number;
  60611. readonly RGBA8UI: number;
  60612. readonly R16I: number;
  60613. readonly RG16I: number;
  60614. readonly RGB16I: number;
  60615. readonly RGBA16I: number;
  60616. readonly R16UI: number;
  60617. readonly RG16UI: number;
  60618. readonly RGB16UI: number;
  60619. readonly RGBA16UI: number;
  60620. readonly R32I: number;
  60621. readonly RG32I: number;
  60622. readonly RGB32I: number;
  60623. readonly RGBA32I: number;
  60624. readonly R32UI: number;
  60625. readonly RG32UI: number;
  60626. readonly RGB32UI: number;
  60627. readonly RGBA32UI: number;
  60628. readonly RGB10_A2UI: number;
  60629. readonly R11F_G11F_B10F: number;
  60630. readonly RGB9_E5: number;
  60631. readonly RGB10_A2: number;
  60632. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  60633. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  60634. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  60635. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  60636. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  60637. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  60638. 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;
  60639. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  60640. readonly TRANSFORM_FEEDBACK: number;
  60641. readonly INTERLEAVED_ATTRIBS: number;
  60642. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  60643. createTransformFeedback(): WebGLTransformFeedback;
  60644. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  60645. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  60646. beginTransformFeedback(primitiveMode: number): void;
  60647. endTransformFeedback(): void;
  60648. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  60649. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  60650. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  60651. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  60652. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  60653. }
  60654. interface ImageBitmap {
  60655. readonly width: number;
  60656. readonly height: number;
  60657. close(): void;
  60658. }
  60659. interface WebGLQuery extends WebGLObject {
  60660. }
  60661. declare var WebGLQuery: {
  60662. prototype: WebGLQuery;
  60663. new(): WebGLQuery;
  60664. };
  60665. interface WebGLSampler extends WebGLObject {
  60666. }
  60667. declare var WebGLSampler: {
  60668. prototype: WebGLSampler;
  60669. new(): WebGLSampler;
  60670. };
  60671. interface WebGLSync extends WebGLObject {
  60672. }
  60673. declare var WebGLSync: {
  60674. prototype: WebGLSync;
  60675. new(): WebGLSync;
  60676. };
  60677. interface WebGLTransformFeedback extends WebGLObject {
  60678. }
  60679. declare var WebGLTransformFeedback: {
  60680. prototype: WebGLTransformFeedback;
  60681. new(): WebGLTransformFeedback;
  60682. };
  60683. interface WebGLVertexArrayObject extends WebGLObject {
  60684. }
  60685. declare var WebGLVertexArrayObject: {
  60686. prototype: WebGLVertexArrayObject;
  60687. new(): WebGLVertexArrayObject;
  60688. };
  60689. // Type definitions for WebVR API
  60690. // Project: https://w3c.github.io/webvr/
  60691. // Definitions by: six a <https://github.com/lostfictions>
  60692. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  60693. interface VRDisplay extends EventTarget {
  60694. /**
  60695. * Dictionary of capabilities describing the VRDisplay.
  60696. */
  60697. readonly capabilities: VRDisplayCapabilities;
  60698. /**
  60699. * z-depth defining the far plane of the eye view frustum
  60700. * enables mapping of values in the render target depth
  60701. * attachment to scene coordinates. Initially set to 10000.0.
  60702. */
  60703. depthFar: number;
  60704. /**
  60705. * z-depth defining the near plane of the eye view frustum
  60706. * enables mapping of values in the render target depth
  60707. * attachment to scene coordinates. Initially set to 0.01.
  60708. */
  60709. depthNear: number;
  60710. /**
  60711. * An identifier for this distinct VRDisplay. Used as an
  60712. * association point in the Gamepad API.
  60713. */
  60714. readonly displayId: number;
  60715. /**
  60716. * A display name, a user-readable name identifying it.
  60717. */
  60718. readonly displayName: string;
  60719. readonly isConnected: boolean;
  60720. readonly isPresenting: boolean;
  60721. /**
  60722. * If this VRDisplay supports room-scale experiences, the optional
  60723. * stage attribute contains details on the room-scale parameters.
  60724. */
  60725. readonly stageParameters: VRStageParameters | null;
  60726. /**
  60727. * Passing the value returned by `requestAnimationFrame` to
  60728. * `cancelAnimationFrame` will unregister the callback.
  60729. * @param handle Define the hanle of the request to cancel
  60730. */
  60731. cancelAnimationFrame(handle: number): void;
  60732. /**
  60733. * Stops presenting to the VRDisplay.
  60734. * @returns a promise to know when it stopped
  60735. */
  60736. exitPresent(): Promise<void>;
  60737. /**
  60738. * Return the current VREyeParameters for the given eye.
  60739. * @param whichEye Define the eye we want the parameter for
  60740. * @returns the eye parameters
  60741. */
  60742. getEyeParameters(whichEye: string): VREyeParameters;
  60743. /**
  60744. * Populates the passed VRFrameData with the information required to render
  60745. * the current frame.
  60746. * @param frameData Define the data structure to populate
  60747. * @returns true if ok otherwise false
  60748. */
  60749. getFrameData(frameData: VRFrameData): boolean;
  60750. /**
  60751. * Get the layers currently being presented.
  60752. * @returns the list of VR layers
  60753. */
  60754. getLayers(): VRLayer[];
  60755. /**
  60756. * Return a VRPose containing the future predicted pose of the VRDisplay
  60757. * when the current frame will be presented. The value returned will not
  60758. * change until JavaScript has returned control to the browser.
  60759. *
  60760. * The VRPose will contain the position, orientation, velocity,
  60761. * and acceleration of each of these properties.
  60762. * @returns the pose object
  60763. */
  60764. getPose(): VRPose;
  60765. /**
  60766. * Return the current instantaneous pose of the VRDisplay, with no
  60767. * prediction applied.
  60768. * @returns the current instantaneous pose
  60769. */
  60770. getImmediatePose(): VRPose;
  60771. /**
  60772. * The callback passed to `requestAnimationFrame` will be called
  60773. * any time a new frame should be rendered. When the VRDisplay is
  60774. * presenting the callback will be called at the native refresh
  60775. * rate of the HMD. When not presenting this function acts
  60776. * identically to how window.requestAnimationFrame acts. Content should
  60777. * make no assumptions of frame rate or vsync behavior as the HMD runs
  60778. * asynchronously from other displays and at differing refresh rates.
  60779. * @param callback Define the eaction to run next frame
  60780. * @returns the request handle it
  60781. */
  60782. requestAnimationFrame(callback: FrameRequestCallback): number;
  60783. /**
  60784. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  60785. * Repeat calls while already presenting will update the VRLayers being displayed.
  60786. * @param layers Define the list of layer to present
  60787. * @returns a promise to know when the request has been fulfilled
  60788. */
  60789. requestPresent(layers: VRLayer[]): Promise<void>;
  60790. /**
  60791. * Reset the pose for this display, treating its current position and
  60792. * orientation as the "origin/zero" values. VRPose.position,
  60793. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  60794. * updated when calling resetPose(). This should be called in only
  60795. * sitting-space experiences.
  60796. */
  60797. resetPose(): void;
  60798. /**
  60799. * The VRLayer provided to the VRDisplay will be captured and presented
  60800. * in the HMD. Calling this function has the same effect on the source
  60801. * canvas as any other operation that uses its source image, and canvases
  60802. * created without preserveDrawingBuffer set to true will be cleared.
  60803. * @param pose Define the pose to submit
  60804. */
  60805. submitFrame(pose?: VRPose): void;
  60806. }
  60807. declare var VRDisplay: {
  60808. prototype: VRDisplay;
  60809. new(): VRDisplay;
  60810. };
  60811. interface VRLayer {
  60812. leftBounds?: number[] | Float32Array | null;
  60813. rightBounds?: number[] | Float32Array | null;
  60814. source?: HTMLCanvasElement | null;
  60815. }
  60816. interface VRDisplayCapabilities {
  60817. readonly canPresent: boolean;
  60818. readonly hasExternalDisplay: boolean;
  60819. readonly hasOrientation: boolean;
  60820. readonly hasPosition: boolean;
  60821. readonly maxLayers: number;
  60822. }
  60823. interface VREyeParameters {
  60824. /** @deprecated */
  60825. readonly fieldOfView: VRFieldOfView;
  60826. readonly offset: Float32Array;
  60827. readonly renderHeight: number;
  60828. readonly renderWidth: number;
  60829. }
  60830. interface VRFieldOfView {
  60831. readonly downDegrees: number;
  60832. readonly leftDegrees: number;
  60833. readonly rightDegrees: number;
  60834. readonly upDegrees: number;
  60835. }
  60836. interface VRFrameData {
  60837. readonly leftProjectionMatrix: Float32Array;
  60838. readonly leftViewMatrix: Float32Array;
  60839. readonly pose: VRPose;
  60840. readonly rightProjectionMatrix: Float32Array;
  60841. readonly rightViewMatrix: Float32Array;
  60842. readonly timestamp: number;
  60843. }
  60844. interface VRPose {
  60845. readonly angularAcceleration: Float32Array | null;
  60846. readonly angularVelocity: Float32Array | null;
  60847. readonly linearAcceleration: Float32Array | null;
  60848. readonly linearVelocity: Float32Array | null;
  60849. readonly orientation: Float32Array | null;
  60850. readonly position: Float32Array | null;
  60851. readonly timestamp: number;
  60852. }
  60853. interface VRStageParameters {
  60854. sittingToStandingTransform?: Float32Array;
  60855. sizeX?: number;
  60856. sizeY?: number;
  60857. }
  60858. interface Navigator {
  60859. getVRDisplays(): Promise<VRDisplay[]>;
  60860. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  60861. }
  60862. interface Window {
  60863. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  60864. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  60865. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  60866. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  60867. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  60868. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  60869. }
  60870. interface Gamepad {
  60871. readonly displayId: number;
  60872. }
  60873. type XRSessionMode =
  60874. | "inline"
  60875. | "immersive-vr"
  60876. | "immersive-ar";
  60877. type XRReferenceSpaceType =
  60878. | "viewer"
  60879. | "local"
  60880. | "local-floor"
  60881. | "bounded-floor"
  60882. | "unbounded";
  60883. type XREnvironmentBlendMode =
  60884. | "opaque"
  60885. | "additive"
  60886. | "alpha-blend";
  60887. type XRVisibilityState =
  60888. | "visible"
  60889. | "visible-blurred"
  60890. | "hidden";
  60891. type XRHandedness =
  60892. | "none"
  60893. | "left"
  60894. | "right";
  60895. type XRTargetRayMode =
  60896. | "gaze"
  60897. | "tracked-pointer"
  60898. | "screen";
  60899. type XREye =
  60900. | "none"
  60901. | "left"
  60902. | "right";
  60903. interface XRSpace extends EventTarget {
  60904. }
  60905. interface XRRenderState {
  60906. depthNear?: number;
  60907. depthFar?: number;
  60908. inlineVerticalFieldOfView?: number;
  60909. baseLayer?: XRWebGLLayer;
  60910. }
  60911. interface XRInputSource {
  60912. handedness: XRHandedness;
  60913. targetRayMode: XRTargetRayMode;
  60914. targetRaySpace: XRSpace;
  60915. gripSpace: XRSpace | undefined;
  60916. gamepad: Gamepad | undefined;
  60917. profiles: Array<string>;
  60918. }
  60919. interface XRSession {
  60920. addEventListener: Function;
  60921. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  60922. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  60923. requestAnimationFrame: Function;
  60924. end(): Promise<void>;
  60925. renderState: XRRenderState;
  60926. inputSources: Array<XRInputSource>;
  60927. }
  60928. interface XRReferenceSpace extends XRSpace {
  60929. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  60930. onreset: any;
  60931. }
  60932. interface XRFrame {
  60933. session: XRSession;
  60934. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  60935. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  60936. }
  60937. interface XRViewerPose extends XRPose {
  60938. views: Array<XRView>;
  60939. }
  60940. interface XRPose {
  60941. transform: XRRigidTransform;
  60942. emulatedPosition: boolean;
  60943. }
  60944. declare var XRWebGLLayer: {
  60945. prototype: XRWebGLLayer;
  60946. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  60947. };
  60948. interface XRWebGLLayer {
  60949. framebuffer: WebGLFramebuffer;
  60950. framebufferWidth: number;
  60951. framebufferHeight: number;
  60952. getViewport: Function;
  60953. }
  60954. interface XRRigidTransform {
  60955. position: DOMPointReadOnly;
  60956. orientation: DOMPointReadOnly;
  60957. matrix: Float32Array;
  60958. inverse: XRRigidTransform;
  60959. }
  60960. interface XRView {
  60961. eye: XREye;
  60962. projectionMatrix: Float32Array;
  60963. transform: XRRigidTransform;
  60964. }
  60965. interface XRInputSourceChangeEvent {
  60966. session: XRSession;
  60967. removed: Array<XRInputSource>;
  60968. added: Array<XRInputSource>;
  60969. }
  60970. declare module BABYLON.GUI {
  60971. /**
  60972. * Class used to specific a value and its associated unit
  60973. */
  60974. export class ValueAndUnit {
  60975. /** defines the unit to store */
  60976. unit: number;
  60977. /** defines a boolean indicating if the value can be negative */
  60978. negativeValueAllowed: boolean;
  60979. private _value;
  60980. private _originalUnit;
  60981. /**
  60982. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  60983. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60984. */
  60985. ignoreAdaptiveScaling: boolean;
  60986. /**
  60987. * Creates a new ValueAndUnit
  60988. * @param value defines the value to store
  60989. * @param unit defines the unit to store
  60990. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  60991. */
  60992. constructor(value: number,
  60993. /** defines the unit to store */
  60994. unit?: number,
  60995. /** defines a boolean indicating if the value can be negative */
  60996. negativeValueAllowed?: boolean);
  60997. /** Gets a boolean indicating if the value is a percentage */
  60998. readonly isPercentage: boolean;
  60999. /** Gets a boolean indicating if the value is store as pixel */
  61000. readonly isPixel: boolean;
  61001. /** Gets direct internal value */
  61002. readonly internalValue: number;
  61003. /**
  61004. * Gets value as pixel
  61005. * @param host defines the root host
  61006. * @param refValue defines the reference value for percentages
  61007. * @returns the value as pixel
  61008. */
  61009. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  61010. /**
  61011. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  61012. * @param value defines the value to store
  61013. * @param unit defines the unit to store
  61014. * @returns the current ValueAndUnit
  61015. */
  61016. updateInPlace(value: number, unit?: number): ValueAndUnit;
  61017. /**
  61018. * Gets the value accordingly to its unit
  61019. * @param host defines the root host
  61020. * @returns the value
  61021. */
  61022. getValue(host: AdvancedDynamicTexture): number;
  61023. /**
  61024. * Gets a string representation of the value
  61025. * @param host defines the root host
  61026. * @param decimals defines an optional number of decimals to display
  61027. * @returns a string
  61028. */
  61029. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  61030. /**
  61031. * Store a value parsed from a string
  61032. * @param source defines the source string
  61033. * @returns true if the value was successfully parsed
  61034. */
  61035. fromString(source: string | number): boolean;
  61036. private static _Regex;
  61037. private static _UNITMODE_PERCENTAGE;
  61038. private static _UNITMODE_PIXEL;
  61039. /** UNITMODE_PERCENTAGE */
  61040. static readonly UNITMODE_PERCENTAGE: number;
  61041. /** UNITMODE_PIXEL */
  61042. static readonly UNITMODE_PIXEL: number;
  61043. }
  61044. }
  61045. declare module BABYLON.GUI {
  61046. /**
  61047. * Define a style used by control to automatically setup properties based on a template.
  61048. * Only support font related properties so far
  61049. */
  61050. export class Style implements BABYLON.IDisposable {
  61051. private _fontFamily;
  61052. private _fontStyle;
  61053. private _fontWeight;
  61054. /** @hidden */ private _host: AdvancedDynamicTexture;
  61055. /** @hidden */ private _fontSize: ValueAndUnit;
  61056. /**
  61057. * BABYLON.Observable raised when the style values are changed
  61058. */
  61059. onChangedObservable: BABYLON.Observable<Style>;
  61060. /**
  61061. * Creates a new style object
  61062. * @param host defines the AdvancedDynamicTexture which hosts this style
  61063. */
  61064. constructor(host: AdvancedDynamicTexture);
  61065. /**
  61066. * Gets or sets the font size
  61067. */
  61068. fontSize: string | number;
  61069. /**
  61070. * Gets or sets the font family
  61071. */
  61072. fontFamily: string;
  61073. /**
  61074. * Gets or sets the font style
  61075. */
  61076. fontStyle: string;
  61077. /** Gets or sets font weight */
  61078. fontWeight: string;
  61079. /** Dispose all associated resources */
  61080. dispose(): void;
  61081. }
  61082. }
  61083. declare module BABYLON.GUI {
  61084. /**
  61085. * Class used to transport BABYLON.Vector2 information for pointer events
  61086. */
  61087. export class Vector2WithInfo extends BABYLON.Vector2 {
  61088. /** defines the current mouse button index */
  61089. buttonIndex: number;
  61090. /**
  61091. * Creates a new Vector2WithInfo
  61092. * @param source defines the vector2 data to transport
  61093. * @param buttonIndex defines the current mouse button index
  61094. */
  61095. constructor(source: BABYLON.Vector2,
  61096. /** defines the current mouse button index */
  61097. buttonIndex?: number);
  61098. }
  61099. /** Class used to provide 2D matrix features */
  61100. export class Matrix2D {
  61101. /** Gets the internal array of 6 floats used to store matrix data */
  61102. m: Float32Array;
  61103. /**
  61104. * Creates a new matrix
  61105. * @param m00 defines value for (0, 0)
  61106. * @param m01 defines value for (0, 1)
  61107. * @param m10 defines value for (1, 0)
  61108. * @param m11 defines value for (1, 1)
  61109. * @param m20 defines value for (2, 0)
  61110. * @param m21 defines value for (2, 1)
  61111. */
  61112. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  61113. /**
  61114. * Fills the matrix from direct values
  61115. * @param m00 defines value for (0, 0)
  61116. * @param m01 defines value for (0, 1)
  61117. * @param m10 defines value for (1, 0)
  61118. * @param m11 defines value for (1, 1)
  61119. * @param m20 defines value for (2, 0)
  61120. * @param m21 defines value for (2, 1)
  61121. * @returns the current modified matrix
  61122. */
  61123. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  61124. /**
  61125. * Gets matrix determinant
  61126. * @returns the determinant
  61127. */
  61128. determinant(): number;
  61129. /**
  61130. * Inverses the matrix and stores it in a target matrix
  61131. * @param result defines the target matrix
  61132. * @returns the current matrix
  61133. */
  61134. invertToRef(result: Matrix2D): Matrix2D;
  61135. /**
  61136. * Multiplies the current matrix with another one
  61137. * @param other defines the second operand
  61138. * @param result defines the target matrix
  61139. * @returns the current matrix
  61140. */
  61141. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  61142. /**
  61143. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  61144. * @param x defines the x coordinate to transform
  61145. * @param y defines the x coordinate to transform
  61146. * @param result defines the target vector2
  61147. * @returns the current matrix
  61148. */
  61149. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  61150. /**
  61151. * Creates an identity matrix
  61152. * @returns a new matrix
  61153. */
  61154. static Identity(): Matrix2D;
  61155. /**
  61156. * Creates a translation matrix and stores it in a target matrix
  61157. * @param x defines the x coordinate of the translation
  61158. * @param y defines the y coordinate of the translation
  61159. * @param result defines the target matrix
  61160. */
  61161. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  61162. /**
  61163. * Creates a scaling matrix and stores it in a target matrix
  61164. * @param x defines the x coordinate of the scaling
  61165. * @param y defines the y coordinate of the scaling
  61166. * @param result defines the target matrix
  61167. */
  61168. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  61169. /**
  61170. * Creates a rotation matrix and stores it in a target matrix
  61171. * @param angle defines the rotation angle
  61172. * @param result defines the target matrix
  61173. */
  61174. static RotationToRef(angle: number, result: Matrix2D): void;
  61175. private static _TempPreTranslationMatrix;
  61176. private static _TempPostTranslationMatrix;
  61177. private static _TempRotationMatrix;
  61178. private static _TempScalingMatrix;
  61179. private static _TempCompose0;
  61180. private static _TempCompose1;
  61181. private static _TempCompose2;
  61182. /**
  61183. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  61184. * @param tx defines the x coordinate of the translation
  61185. * @param ty defines the y coordinate of the translation
  61186. * @param angle defines the rotation angle
  61187. * @param scaleX defines the x coordinate of the scaling
  61188. * @param scaleY defines the y coordinate of the scaling
  61189. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  61190. * @param result defines the target matrix
  61191. */
  61192. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  61193. }
  61194. }
  61195. declare module BABYLON.GUI {
  61196. /**
  61197. * Class used to store 2D control sizes
  61198. */
  61199. export class Measure {
  61200. /** defines left coordinate */
  61201. left: number;
  61202. /** defines top coordinate */
  61203. top: number;
  61204. /** defines width dimension */
  61205. width: number;
  61206. /** defines height dimension */
  61207. height: number;
  61208. /**
  61209. * Creates a new measure
  61210. * @param left defines left coordinate
  61211. * @param top defines top coordinate
  61212. * @param width defines width dimension
  61213. * @param height defines height dimension
  61214. */
  61215. constructor(
  61216. /** defines left coordinate */
  61217. left: number,
  61218. /** defines top coordinate */
  61219. top: number,
  61220. /** defines width dimension */
  61221. width: number,
  61222. /** defines height dimension */
  61223. height: number);
  61224. /**
  61225. * Copy from another measure
  61226. * @param other defines the other measure to copy from
  61227. */
  61228. copyFrom(other: Measure): void;
  61229. /**
  61230. * Copy from a group of 4 floats
  61231. * @param left defines left coordinate
  61232. * @param top defines top coordinate
  61233. * @param width defines width dimension
  61234. * @param height defines height dimension
  61235. */
  61236. copyFromFloats(left: number, top: number, width: number, height: number): void;
  61237. /**
  61238. * Computes the axis aligned bounding box measure for two given measures
  61239. * @param a Input measure
  61240. * @param b Input measure
  61241. * @param result the resulting bounding measure
  61242. */
  61243. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  61244. /**
  61245. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  61246. * @param transform the matrix to transform the measure before computing the AABB
  61247. * @param result the resulting AABB
  61248. */
  61249. transformToRef(transform: Matrix2D, result: Measure): void;
  61250. /**
  61251. * Check equality between this measure and another one
  61252. * @param other defines the other measures
  61253. * @returns true if both measures are equals
  61254. */
  61255. isEqualsTo(other: Measure): boolean;
  61256. /**
  61257. * Creates an empty measure
  61258. * @returns a new measure
  61259. */
  61260. static Empty(): Measure;
  61261. }
  61262. }
  61263. declare module BABYLON.GUI {
  61264. /**
  61265. * Interface used to define a control that can receive focus
  61266. */
  61267. export interface IFocusableControl {
  61268. /**
  61269. * Function called when the control receives the focus
  61270. */
  61271. onFocus(): void;
  61272. /**
  61273. * Function called when the control loses the focus
  61274. */
  61275. onBlur(): void;
  61276. /**
  61277. * Function called to let the control handle keyboard events
  61278. * @param evt defines the current keyboard event
  61279. */
  61280. processKeyboard(evt: KeyboardEvent): void;
  61281. /**
  61282. * Function called to get the list of controls that should not steal the focus from this control
  61283. * @returns an array of controls
  61284. */
  61285. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  61286. }
  61287. /**
  61288. * Class used to create texture to support 2D GUI elements
  61289. * @see http://doc.babylonjs.com/how_to/gui
  61290. */
  61291. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  61292. private _isDirty;
  61293. private _renderObserver;
  61294. private _resizeObserver;
  61295. private _preKeyboardObserver;
  61296. private _pointerMoveObserver;
  61297. private _pointerObserver;
  61298. private _canvasPointerOutObserver;
  61299. private _background;
  61300. /** @hidden */ private _rootContainer: Container;
  61301. /** @hidden */ private _lastPickedControl: Control;
  61302. /** @hidden */ private _lastControlOver: {
  61303. [pointerId: number]: Control;
  61304. };
  61305. /** @hidden */ private _lastControlDown: {
  61306. [pointerId: number]: Control;
  61307. };
  61308. /** @hidden */ private _capturingControl: {
  61309. [pointerId: number]: Control;
  61310. };
  61311. /** @hidden */ private _shouldBlockPointer: boolean;
  61312. /** @hidden */ private _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  61313. /** @hidden */ private _linkedControls: Control[];
  61314. private _isFullscreen;
  61315. private _fullscreenViewport;
  61316. private _idealWidth;
  61317. private _idealHeight;
  61318. private _useSmallestIdeal;
  61319. private _renderAtIdealSize;
  61320. private _focusedControl;
  61321. private _blockNextFocusCheck;
  61322. private _renderScale;
  61323. private _rootCanvas;
  61324. private _cursorChanged;
  61325. /**
  61326. * Define type to string to ensure compatibility across browsers
  61327. * Safari doesn't support DataTransfer constructor
  61328. */
  61329. private _clipboardData;
  61330. /**
  61331. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  61332. */
  61333. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  61334. /**
  61335. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  61336. */
  61337. onControlPickedObservable: BABYLON.Observable<Control>;
  61338. /**
  61339. * BABYLON.Observable event triggered before layout is evaluated
  61340. */
  61341. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  61342. /**
  61343. * BABYLON.Observable event triggered after the layout was evaluated
  61344. */
  61345. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  61346. /**
  61347. * BABYLON.Observable event triggered before the texture is rendered
  61348. */
  61349. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  61350. /**
  61351. * BABYLON.Observable event triggered after the texture was rendered
  61352. */
  61353. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  61354. /**
  61355. * Gets or sets a boolean defining if alpha is stored as premultiplied
  61356. */
  61357. premulAlpha: boolean;
  61358. /**
  61359. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  61360. * Useful when you want more antialiasing
  61361. */
  61362. renderScale: number;
  61363. /** Gets or sets the background color */
  61364. background: string;
  61365. /**
  61366. * Gets or sets the ideal width used to design controls.
  61367. * The GUI will then rescale everything accordingly
  61368. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  61369. */
  61370. idealWidth: number;
  61371. /**
  61372. * Gets or sets the ideal height used to design controls.
  61373. * The GUI will then rescale everything accordingly
  61374. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  61375. */
  61376. idealHeight: number;
  61377. /**
  61378. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  61379. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  61380. */
  61381. useSmallestIdeal: boolean;
  61382. /**
  61383. * Gets or sets a boolean indicating if adaptive scaling must be used
  61384. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  61385. */
  61386. renderAtIdealSize: boolean;
  61387. /**
  61388. * Gets the underlying layer used to render the texture when in fullscreen mode
  61389. */
  61390. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  61391. /**
  61392. * Gets the root container control
  61393. */
  61394. readonly rootContainer: Container;
  61395. /**
  61396. * Returns an array containing the root container.
  61397. * This is mostly used to let the Inspector introspects the ADT
  61398. * @returns an array containing the rootContainer
  61399. */
  61400. getChildren(): Array<Container>;
  61401. /**
  61402. * Will return all controls that are inside this texture
  61403. * @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
  61404. * @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
  61405. * @return all child controls
  61406. */
  61407. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  61408. /**
  61409. * Gets or sets the current focused control
  61410. */
  61411. focusedControl: BABYLON.Nullable<IFocusableControl>;
  61412. /**
  61413. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  61414. */
  61415. isForeground: boolean;
  61416. /**
  61417. * Gets or set information about clipboardData
  61418. */
  61419. clipboardData: string;
  61420. /**
  61421. * Creates a new AdvancedDynamicTexture
  61422. * @param name defines the name of the texture
  61423. * @param width defines the width of the texture
  61424. * @param height defines the height of the texture
  61425. * @param scene defines the hosting scene
  61426. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  61427. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  61428. */
  61429. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  61430. /**
  61431. * Get the current class name of the texture useful for serialization or dynamic coding.
  61432. * @returns "AdvancedDynamicTexture"
  61433. */
  61434. getClassName(): string;
  61435. /**
  61436. * Function used to execute a function on all controls
  61437. * @param func defines the function to execute
  61438. * @param container defines the container where controls belong. If null the root container will be used
  61439. */
  61440. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  61441. private _useInvalidateRectOptimization;
  61442. /**
  61443. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  61444. */
  61445. useInvalidateRectOptimization: boolean;
  61446. private _invalidatedRectangle;
  61447. /**
  61448. * Invalidates a rectangle area on the gui texture
  61449. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  61450. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  61451. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  61452. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  61453. */
  61454. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  61455. /**
  61456. * Marks the texture as dirty forcing a complete update
  61457. */
  61458. markAsDirty(): void;
  61459. /**
  61460. * Helper function used to create a new style
  61461. * @returns a new style
  61462. * @see http://doc.babylonjs.com/how_to/gui#styles
  61463. */
  61464. createStyle(): Style;
  61465. /**
  61466. * Adds a new control to the root container
  61467. * @param control defines the control to add
  61468. * @returns the current texture
  61469. */
  61470. addControl(control: Control): AdvancedDynamicTexture;
  61471. /**
  61472. * Removes a control from the root container
  61473. * @param control defines the control to remove
  61474. * @returns the current texture
  61475. */
  61476. removeControl(control: Control): AdvancedDynamicTexture;
  61477. /**
  61478. * Release all resources
  61479. */
  61480. dispose(): void;
  61481. private _onResize;
  61482. /** @hidden */ private _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  61483. /**
  61484. * Get screen coordinates for a vector3
  61485. * @param position defines the position to project
  61486. * @param worldMatrix defines the world matrix to use
  61487. * @returns the projected position
  61488. */
  61489. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  61490. private _checkUpdate;
  61491. private _clearMeasure;
  61492. private _render;
  61493. /** @hidden */ private _changeCursor(cursor: string): void;
  61494. /** @hidden */ private _registerLastControlDown(control: Control, pointerId: number): void;
  61495. private _doPicking;
  61496. /** @hidden */ private _cleanControlAfterRemovalFromList(list: {
  61497. [pointerId: number]: Control;
  61498. }, control: Control): void;
  61499. /** @hidden */ private _cleanControlAfterRemoval(control: Control): void;
  61500. /** Attach to all scene events required to support pointer events */
  61501. attach(): void;
  61502. /** @hidden */
  61503. private onClipboardCopy;
  61504. /** @hidden */
  61505. private onClipboardCut;
  61506. /** @hidden */
  61507. private onClipboardPaste;
  61508. /**
  61509. * Register the clipboard Events onto the canvas
  61510. */
  61511. registerClipboardEvents(): void;
  61512. /**
  61513. * Unregister the clipboard Events from the canvas
  61514. */
  61515. unRegisterClipboardEvents(): void;
  61516. /**
  61517. * Connect the texture to a hosting mesh to enable interactions
  61518. * @param mesh defines the mesh to attach to
  61519. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  61520. */
  61521. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  61522. /**
  61523. * Move the focus to a specific control
  61524. * @param control defines the control which will receive the focus
  61525. */
  61526. moveFocusToControl(control: IFocusableControl): void;
  61527. private _manageFocus;
  61528. private _attachToOnPointerOut;
  61529. /**
  61530. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  61531. * @param mesh defines the mesh which will receive the texture
  61532. * @param width defines the texture width (1024 by default)
  61533. * @param height defines the texture height (1024 by default)
  61534. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  61535. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  61536. * @returns a new AdvancedDynamicTexture
  61537. */
  61538. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  61539. /**
  61540. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  61541. * In this mode the texture will rely on a layer for its rendering.
  61542. * This allows it to be treated like any other layer.
  61543. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  61544. * LayerMask is set through advancedTexture.layer.layerMask
  61545. * @param name defines name for the texture
  61546. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  61547. * @param scene defines the hsoting scene
  61548. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  61549. * @returns a new AdvancedDynamicTexture
  61550. */
  61551. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  61552. }
  61553. }
  61554. declare module BABYLON.GUI {
  61555. /**
  61556. * Root class used for all 2D controls
  61557. * @see http://doc.babylonjs.com/how_to/gui#controls
  61558. */
  61559. export class Control {
  61560. /** defines the name of the control */
  61561. name?: string | undefined;
  61562. /**
  61563. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  61564. */
  61565. static AllowAlphaInheritance: boolean;
  61566. private _alpha;
  61567. private _alphaSet;
  61568. private _zIndex;
  61569. /** @hidden */ private _host: AdvancedDynamicTexture;
  61570. /** Gets or sets the control parent */
  61571. parent: BABYLON.Nullable<Container>;
  61572. /** @hidden */ private _currentMeasure: Measure;
  61573. private _fontFamily;
  61574. private _fontStyle;
  61575. private _fontWeight;
  61576. private _fontSize;
  61577. private _font;
  61578. /** @hidden */ private _width: ValueAndUnit;
  61579. /** @hidden */ private _height: ValueAndUnit;
  61580. /** @hidden */
  61581. protected _fontOffset: {
  61582. ascent: number;
  61583. height: number;
  61584. descent: number;
  61585. };
  61586. private _color;
  61587. private _style;
  61588. private _styleObserver;
  61589. /** @hidden */
  61590. protected _horizontalAlignment: number;
  61591. /** @hidden */
  61592. protected _verticalAlignment: number;
  61593. /** @hidden */
  61594. protected _isDirty: boolean;
  61595. /** @hidden */
  61596. protected _wasDirty: boolean;
  61597. /** @hidden */ private _tempParentMeasure: Measure;
  61598. /** @hidden */ private _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  61599. /** @hidden */
  61600. protected _cachedParentMeasure: Measure;
  61601. private _paddingLeft;
  61602. private _paddingRight;
  61603. private _paddingTop;
  61604. private _paddingBottom;
  61605. /** @hidden */ private _left: ValueAndUnit;
  61606. /** @hidden */ private _top: ValueAndUnit;
  61607. private _scaleX;
  61608. private _scaleY;
  61609. private _rotation;
  61610. private _transformCenterX;
  61611. private _transformCenterY;
  61612. /** @hidden */ private _transformMatrix: Matrix2D;
  61613. /** @hidden */
  61614. protected _invertTransformMatrix: Matrix2D;
  61615. /** @hidden */
  61616. protected _transformedPosition: BABYLON.Vector2;
  61617. private _isMatrixDirty;
  61618. private _cachedOffsetX;
  61619. private _cachedOffsetY;
  61620. private _isVisible;
  61621. private _isHighlighted;
  61622. /** @hidden */ private _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  61623. private _fontSet;
  61624. private _dummyVector2;
  61625. private _downCount;
  61626. private _enterCount;
  61627. private _doNotRender;
  61628. private _downPointerIds;
  61629. protected _isEnabled: boolean;
  61630. protected _disabledColor: string;
  61631. /** @hidden */
  61632. protected _rebuildLayout: boolean;
  61633. /** @hidden */ private _isClipped: boolean;
  61634. /** @hidden */ private _tag: any;
  61635. /**
  61636. * 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
  61637. */
  61638. uniqueId: number;
  61639. /**
  61640. * Gets or sets an object used to store user defined information for the node
  61641. */
  61642. metadata: any;
  61643. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  61644. isHitTestVisible: boolean;
  61645. /** Gets or sets a boolean indicating if the control can block pointer events */
  61646. isPointerBlocker: boolean;
  61647. /** Gets or sets a boolean indicating if the control can be focusable */
  61648. isFocusInvisible: boolean;
  61649. /**
  61650. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  61651. * 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
  61652. */
  61653. clipChildren: boolean;
  61654. /**
  61655. * Gets or sets a boolean indicating that control content must be clipped
  61656. * 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
  61657. */
  61658. clipContent: boolean;
  61659. /**
  61660. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  61661. */
  61662. useBitmapCache: boolean;
  61663. private _cacheData;
  61664. private _shadowOffsetX;
  61665. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  61666. shadowOffsetX: number;
  61667. private _shadowOffsetY;
  61668. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  61669. shadowOffsetY: number;
  61670. private _shadowBlur;
  61671. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  61672. shadowBlur: number;
  61673. private _shadowColor;
  61674. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  61675. shadowColor: string;
  61676. /** Gets or sets the cursor to use when the control is hovered */
  61677. hoverCursor: string;
  61678. /** @hidden */
  61679. protected _linkOffsetX: ValueAndUnit;
  61680. /** @hidden */
  61681. protected _linkOffsetY: ValueAndUnit;
  61682. /** Gets the control type name */
  61683. readonly typeName: string;
  61684. /**
  61685. * Get the current class name of the control.
  61686. * @returns current class name
  61687. */
  61688. getClassName(): string;
  61689. /**
  61690. * An event triggered when the pointer move over the control.
  61691. */
  61692. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  61693. /**
  61694. * An event triggered when the pointer move out of the control.
  61695. */
  61696. onPointerOutObservable: BABYLON.Observable<Control>;
  61697. /**
  61698. * An event triggered when the pointer taps the control
  61699. */
  61700. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  61701. /**
  61702. * An event triggered when pointer up
  61703. */
  61704. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  61705. /**
  61706. * An event triggered when a control is clicked on
  61707. */
  61708. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  61709. /**
  61710. * An event triggered when pointer enters the control
  61711. */
  61712. onPointerEnterObservable: BABYLON.Observable<Control>;
  61713. /**
  61714. * An event triggered when the control is marked as dirty
  61715. */
  61716. onDirtyObservable: BABYLON.Observable<Control>;
  61717. /**
  61718. * An event triggered before drawing the control
  61719. */
  61720. onBeforeDrawObservable: BABYLON.Observable<Control>;
  61721. /**
  61722. * An event triggered after the control was drawn
  61723. */
  61724. onAfterDrawObservable: BABYLON.Observable<Control>;
  61725. /**
  61726. * Get the hosting AdvancedDynamicTexture
  61727. */
  61728. readonly host: AdvancedDynamicTexture;
  61729. /** Gets or set information about font offsets (used to render and align text) */
  61730. fontOffset: {
  61731. ascent: number;
  61732. height: number;
  61733. descent: number;
  61734. };
  61735. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  61736. alpha: number;
  61737. /**
  61738. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  61739. */
  61740. isHighlighted: boolean;
  61741. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  61742. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61743. */
  61744. scaleX: number;
  61745. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  61746. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61747. */
  61748. scaleY: number;
  61749. /** Gets or sets the rotation angle (0 by default)
  61750. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61751. */
  61752. rotation: number;
  61753. /** Gets or sets the transformation center on Y axis (0 by default)
  61754. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61755. */
  61756. transformCenterY: number;
  61757. /** Gets or sets the transformation center on X axis (0 by default)
  61758. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61759. */
  61760. transformCenterX: number;
  61761. /**
  61762. * Gets or sets the horizontal alignment
  61763. * @see http://doc.babylonjs.com/how_to/gui#alignments
  61764. */
  61765. horizontalAlignment: number;
  61766. /**
  61767. * Gets or sets the vertical alignment
  61768. * @see http://doc.babylonjs.com/how_to/gui#alignments
  61769. */
  61770. verticalAlignment: number;
  61771. /**
  61772. * Gets or sets control width
  61773. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61774. */
  61775. width: string | number;
  61776. /**
  61777. * Gets or sets the control width in pixel
  61778. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61779. */
  61780. widthInPixels: number;
  61781. /**
  61782. * Gets or sets control height
  61783. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61784. */
  61785. height: string | number;
  61786. /**
  61787. * Gets or sets control height in pixel
  61788. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61789. */
  61790. heightInPixels: number;
  61791. /** Gets or set font family */
  61792. fontFamily: string;
  61793. /** Gets or sets font style */
  61794. fontStyle: string;
  61795. /** Gets or sets font weight */
  61796. fontWeight: string;
  61797. /**
  61798. * Gets or sets style
  61799. * @see http://doc.babylonjs.com/how_to/gui#styles
  61800. */
  61801. style: BABYLON.Nullable<Style>;
  61802. /** @hidden */ protected readonly _isFontSizeInPercentage: boolean;
  61803. /** Gets or sets font size in pixels */
  61804. fontSizeInPixels: number;
  61805. /** Gets or sets font size */
  61806. fontSize: string | number;
  61807. /** Gets or sets foreground color */
  61808. color: string;
  61809. /** Gets or sets z index which is used to reorder controls on the z axis */
  61810. zIndex: number;
  61811. /** Gets or sets a boolean indicating if the control can be rendered */
  61812. notRenderable: boolean;
  61813. /** Gets or sets a boolean indicating if the control is visible */
  61814. isVisible: boolean;
  61815. /** Gets a boolean indicating that the control needs to update its rendering */
  61816. readonly isDirty: boolean;
  61817. /**
  61818. * Gets the current linked mesh (or null if none)
  61819. */
  61820. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  61821. /**
  61822. * Gets or sets a value indicating the padding to use on the left of the control
  61823. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61824. */
  61825. paddingLeft: string | number;
  61826. /**
  61827. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  61828. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61829. */
  61830. paddingLeftInPixels: number;
  61831. /**
  61832. * Gets or sets a value indicating the padding to use on the right of the control
  61833. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61834. */
  61835. paddingRight: string | number;
  61836. /**
  61837. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  61838. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61839. */
  61840. paddingRightInPixels: number;
  61841. /**
  61842. * Gets or sets a value indicating the padding to use on the top of the control
  61843. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61844. */
  61845. paddingTop: string | number;
  61846. /**
  61847. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  61848. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61849. */
  61850. paddingTopInPixels: number;
  61851. /**
  61852. * Gets or sets a value indicating the padding to use on the bottom of the control
  61853. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61854. */
  61855. paddingBottom: string | number;
  61856. /**
  61857. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  61858. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61859. */
  61860. paddingBottomInPixels: number;
  61861. /**
  61862. * Gets or sets a value indicating the left coordinate of the control
  61863. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61864. */
  61865. left: string | number;
  61866. /**
  61867. * Gets or sets a value indicating the left coordinate in pixels of the control
  61868. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61869. */
  61870. leftInPixels: number;
  61871. /**
  61872. * Gets or sets a value indicating the top coordinate of the control
  61873. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61874. */
  61875. top: string | number;
  61876. /**
  61877. * Gets or sets a value indicating the top coordinate in pixels of the control
  61878. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61879. */
  61880. topInPixels: number;
  61881. /**
  61882. * Gets or sets a value indicating the offset on X axis to the linked mesh
  61883. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61884. */
  61885. linkOffsetX: string | number;
  61886. /**
  61887. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  61888. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61889. */
  61890. linkOffsetXInPixels: number;
  61891. /**
  61892. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  61893. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61894. */
  61895. linkOffsetY: string | number;
  61896. /**
  61897. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  61898. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61899. */
  61900. linkOffsetYInPixels: number;
  61901. /** Gets the center coordinate on X axis */
  61902. readonly centerX: number;
  61903. /** Gets the center coordinate on Y axis */
  61904. readonly centerY: number;
  61905. /** Gets or sets if control is Enabled*/
  61906. isEnabled: boolean;
  61907. /** Gets or sets background color of control if it's disabled*/
  61908. disabledColor: string;
  61909. /**
  61910. * Creates a new control
  61911. * @param name defines the name of the control
  61912. */
  61913. constructor(
  61914. /** defines the name of the control */
  61915. name?: string | undefined);
  61916. /** @hidden */
  61917. protected _getTypeName(): string;
  61918. /**
  61919. * Gets the first ascendant in the hierarchy of the given type
  61920. * @param className defines the required type
  61921. * @returns the ascendant or null if not found
  61922. */
  61923. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  61924. /** @hidden */ private _resetFontCache(): void;
  61925. /**
  61926. * Determines if a container is an ascendant of the current control
  61927. * @param container defines the container to look for
  61928. * @returns true if the container is one of the ascendant of the control
  61929. */
  61930. isAscendant(container: Control): boolean;
  61931. /**
  61932. * Gets coordinates in local control space
  61933. * @param globalCoordinates defines the coordinates to transform
  61934. * @returns the new coordinates in local space
  61935. */
  61936. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  61937. /**
  61938. * Gets coordinates in local control space
  61939. * @param globalCoordinates defines the coordinates to transform
  61940. * @param result defines the target vector2 where to store the result
  61941. * @returns the current control
  61942. */
  61943. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  61944. /**
  61945. * Gets coordinates in parent local control space
  61946. * @param globalCoordinates defines the coordinates to transform
  61947. * @returns the new coordinates in parent local space
  61948. */
  61949. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  61950. /**
  61951. * Move the current control to a vector3 position projected onto the screen.
  61952. * @param position defines the target position
  61953. * @param scene defines the hosting scene
  61954. */
  61955. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  61956. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  61957. /**
  61958. * Will return all controls that have this control as ascendant
  61959. * @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
  61960. * @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
  61961. * @return all child controls
  61962. */
  61963. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  61964. /**
  61965. * Link current control with a target mesh
  61966. * @param mesh defines the mesh to link with
  61967. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61968. */
  61969. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  61970. /** @hidden */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  61971. /** @hidden */ private _offsetLeft(offset: number): void;
  61972. /** @hidden */ private _offsetTop(offset: number): void;
  61973. /** @hidden */ private _markMatrixAsDirty(): void;
  61974. /** @hidden */ private _flagDescendantsAsMatrixDirty(): void;
  61975. /** @hidden */ private _intersectsRect(rect: Measure): boolean;
  61976. /** @hidden */
  61977. protected invalidateRect(): void;
  61978. /** @hidden */ private _markAsDirty(force?: boolean): void;
  61979. /** @hidden */ private _markAllAsDirty(): void;
  61980. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  61981. /** @hidden */
  61982. protected _transform(context?: CanvasRenderingContext2D): void;
  61983. /** @hidden */ private _renderHighlight(context: CanvasRenderingContext2D): void;
  61984. /** @hidden */ private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  61985. /** @hidden */
  61986. protected _applyStates(context: CanvasRenderingContext2D): void;
  61987. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  61988. /** @hidden */
  61989. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61990. protected _evaluateClippingState(parentMeasure: Measure): void;
  61991. /** @hidden */ private _measure(): void;
  61992. /** @hidden */
  61993. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61994. /** @hidden */
  61995. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61996. /** @hidden */
  61997. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61998. /** @hidden */
  61999. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  62000. private static _ClipMeasure;
  62001. private _tmpMeasureA;
  62002. private _clip;
  62003. /** @hidden */ private _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  62004. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  62005. /**
  62006. * Tests if a given coordinates belong to the current control
  62007. * @param x defines x coordinate to test
  62008. * @param y defines y coordinate to test
  62009. * @returns true if the coordinates are inside the control
  62010. */
  62011. contains(x: number, y: number): boolean;
  62012. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  62013. /** @hidden */ private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  62014. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  62015. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  62016. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62017. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  62018. /** @hidden */ private _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  62019. /** @hidden */ private _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  62020. private _prepareFont;
  62021. /** Releases associated resources */
  62022. dispose(): void;
  62023. private static _HORIZONTAL_ALIGNMENT_LEFT;
  62024. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  62025. private static _HORIZONTAL_ALIGNMENT_CENTER;
  62026. private static _VERTICAL_ALIGNMENT_TOP;
  62027. private static _VERTICAL_ALIGNMENT_BOTTOM;
  62028. private static _VERTICAL_ALIGNMENT_CENTER;
  62029. /** HORIZONTAL_ALIGNMENT_LEFT */
  62030. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  62031. /** HORIZONTAL_ALIGNMENT_RIGHT */
  62032. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  62033. /** HORIZONTAL_ALIGNMENT_CENTER */
  62034. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  62035. /** VERTICAL_ALIGNMENT_TOP */
  62036. static readonly VERTICAL_ALIGNMENT_TOP: number;
  62037. /** VERTICAL_ALIGNMENT_BOTTOM */
  62038. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  62039. /** VERTICAL_ALIGNMENT_CENTER */
  62040. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  62041. private static _FontHeightSizes;
  62042. /** @hidden */ private static _GetFontOffset(font: string): {
  62043. ascent: number;
  62044. height: number;
  62045. descent: number;
  62046. };
  62047. /**
  62048. * Creates a stack panel that can be used to render headers
  62049. * @param control defines the control to associate with the header
  62050. * @param text defines the text of the header
  62051. * @param size defines the size of the header
  62052. * @param options defines options used to configure the header
  62053. * @returns a new StackPanel
  62054. * @ignore
  62055. * @hidden
  62056. */
  62057. static AddHeader: (control: Control, text: string, size: string | number, options: {
  62058. isHorizontal: boolean;
  62059. controlFirst: boolean;
  62060. }) => any;
  62061. /** @hidden */
  62062. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  62063. }
  62064. }
  62065. declare module BABYLON.GUI {
  62066. /**
  62067. * Root class for 2D containers
  62068. * @see http://doc.babylonjs.com/how_to/gui#containers
  62069. */
  62070. export class Container extends Control {
  62071. name?: string | undefined;
  62072. /** @hidden */
  62073. protected _children: Control[];
  62074. /** @hidden */
  62075. protected _measureForChildren: Measure;
  62076. /** @hidden */
  62077. protected _background: string;
  62078. /** @hidden */
  62079. protected _adaptWidthToChildren: boolean;
  62080. /** @hidden */
  62081. protected _adaptHeightToChildren: boolean;
  62082. /**
  62083. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  62084. */
  62085. logLayoutCycleErrors: boolean;
  62086. /**
  62087. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  62088. */
  62089. maxLayoutCycle: number;
  62090. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  62091. adaptHeightToChildren: boolean;
  62092. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  62093. adaptWidthToChildren: boolean;
  62094. /** Gets or sets background color */
  62095. background: string;
  62096. /** Gets the list of children */
  62097. readonly children: Control[];
  62098. /**
  62099. * Creates a new Container
  62100. * @param name defines the name of the container
  62101. */
  62102. constructor(name?: string | undefined);
  62103. protected _getTypeName(): string; private _flagDescendantsAsMatrixDirty(): void;
  62104. /**
  62105. * Gets a child using its name
  62106. * @param name defines the child name to look for
  62107. * @returns the child control if found
  62108. */
  62109. getChildByName(name: string): BABYLON.Nullable<Control>;
  62110. /**
  62111. * Gets a child using its type and its name
  62112. * @param name defines the child name to look for
  62113. * @param type defines the child type to look for
  62114. * @returns the child control if found
  62115. */
  62116. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  62117. /**
  62118. * Search for a specific control in children
  62119. * @param control defines the control to look for
  62120. * @returns true if the control is in child list
  62121. */
  62122. containsControl(control: Control): boolean;
  62123. /**
  62124. * Adds a new control to the current container
  62125. * @param control defines the control to add
  62126. * @returns the current container
  62127. */
  62128. addControl(control: BABYLON.Nullable<Control>): Container;
  62129. /**
  62130. * Removes all controls from the current container
  62131. * @returns the current container
  62132. */
  62133. clearControls(): Container;
  62134. /**
  62135. * Removes a control from the current container
  62136. * @param control defines the control to remove
  62137. * @returns the current container
  62138. */
  62139. removeControl(control: Control): Container;
  62140. /** @hidden */ private _reOrderControl(control: Control): void;
  62141. /** @hidden */ private _offsetLeft(offset: number): void;
  62142. /** @hidden */ private _offsetTop(offset: number): void;
  62143. /** @hidden */ private _markAllAsDirty(): void;
  62144. /** @hidden */
  62145. protected _localDraw(context: CanvasRenderingContext2D): void;
  62146. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  62147. /** @hidden */
  62148. protected _beforeLayout(): void;
  62149. /** @hidden */
  62150. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62151. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  62152. protected _postMeasure(): void;
  62153. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  62154. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  62155. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  62156. /** @hidden */
  62157. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62158. /** Releases associated resources */
  62159. dispose(): void;
  62160. }
  62161. }
  62162. declare module BABYLON.GUI {
  62163. /** Class used to create rectangle container */
  62164. export class Rectangle extends Container {
  62165. name?: string | undefined;
  62166. private _thickness;
  62167. private _cornerRadius;
  62168. /** Gets or sets border thickness */
  62169. thickness: number;
  62170. /** Gets or sets the corner radius angle */
  62171. cornerRadius: number;
  62172. /**
  62173. * Creates a new Rectangle
  62174. * @param name defines the control name
  62175. */
  62176. constructor(name?: string | undefined);
  62177. protected _getTypeName(): string;
  62178. protected _localDraw(context: CanvasRenderingContext2D): void;
  62179. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62180. private _drawRoundedRect;
  62181. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  62182. }
  62183. }
  62184. declare module BABYLON.GUI {
  62185. /**
  62186. * Enum that determines the text-wrapping mode to use.
  62187. */
  62188. export enum TextWrapping {
  62189. /**
  62190. * Clip the text when it's larger than Control.width; this is the default mode.
  62191. */
  62192. Clip = 0,
  62193. /**
  62194. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  62195. */
  62196. WordWrap = 1,
  62197. /**
  62198. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  62199. */
  62200. Ellipsis = 2
  62201. }
  62202. /**
  62203. * Class used to create text block control
  62204. */
  62205. export class TextBlock extends Control {
  62206. /**
  62207. * Defines the name of the control
  62208. */
  62209. name?: string | undefined;
  62210. private _text;
  62211. private _textWrapping;
  62212. private _textHorizontalAlignment;
  62213. private _textVerticalAlignment;
  62214. private _lines;
  62215. private _resizeToFit;
  62216. private _lineSpacing;
  62217. private _outlineWidth;
  62218. private _outlineColor;
  62219. /**
  62220. * An event triggered after the text is changed
  62221. */
  62222. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  62223. /**
  62224. * An event triggered after the text was broken up into lines
  62225. */
  62226. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  62227. /**
  62228. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  62229. */
  62230. readonly lines: any[];
  62231. /**
  62232. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  62233. */
  62234. /**
  62235. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  62236. */
  62237. resizeToFit: boolean;
  62238. /**
  62239. * Gets or sets a boolean indicating if text must be wrapped
  62240. */
  62241. /**
  62242. * Gets or sets a boolean indicating if text must be wrapped
  62243. */
  62244. textWrapping: TextWrapping | boolean;
  62245. /**
  62246. * Gets or sets text to display
  62247. */
  62248. /**
  62249. * Gets or sets text to display
  62250. */
  62251. text: string;
  62252. /**
  62253. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  62254. */
  62255. /**
  62256. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  62257. */
  62258. textHorizontalAlignment: number;
  62259. /**
  62260. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  62261. */
  62262. /**
  62263. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  62264. */
  62265. textVerticalAlignment: number;
  62266. /**
  62267. * Gets or sets line spacing value
  62268. */
  62269. /**
  62270. * Gets or sets line spacing value
  62271. */
  62272. lineSpacing: string | number;
  62273. /**
  62274. * Gets or sets outlineWidth of the text to display
  62275. */
  62276. /**
  62277. * Gets or sets outlineWidth of the text to display
  62278. */
  62279. outlineWidth: number;
  62280. /**
  62281. * Gets or sets outlineColor of the text to display
  62282. */
  62283. /**
  62284. * Gets or sets outlineColor of the text to display
  62285. */
  62286. outlineColor: string;
  62287. /**
  62288. * Creates a new TextBlock object
  62289. * @param name defines the name of the control
  62290. * @param text defines the text to display (emptry string by default)
  62291. */
  62292. constructor(
  62293. /**
  62294. * Defines the name of the control
  62295. */
  62296. name?: string | undefined, text?: string);
  62297. protected _getTypeName(): string;
  62298. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62299. private _drawText;
  62300. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  62301. protected _applyStates(context: CanvasRenderingContext2D): void;
  62302. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  62303. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  62304. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  62305. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  62306. protected _renderLines(context: CanvasRenderingContext2D): void;
  62307. /**
  62308. * Given a width constraint applied on the text block, find the expected height
  62309. * @returns expected height
  62310. */
  62311. computeExpectedHeight(): number;
  62312. dispose(): void;
  62313. }
  62314. }
  62315. declare module BABYLON.GUI {
  62316. /**
  62317. * Class used to create 2D images
  62318. */
  62319. export class Image extends Control {
  62320. name?: string | undefined;
  62321. private static _WorkingCanvas;
  62322. private _domImage;
  62323. private _imageWidth;
  62324. private _imageHeight;
  62325. private _loaded;
  62326. private _stretch;
  62327. private _source;
  62328. private _autoScale;
  62329. private _sourceLeft;
  62330. private _sourceTop;
  62331. private _sourceWidth;
  62332. private _sourceHeight;
  62333. private _cellWidth;
  62334. private _cellHeight;
  62335. private _cellId;
  62336. private _populateNinePatchSlicesFromImage;
  62337. private _sliceLeft;
  62338. private _sliceRight;
  62339. private _sliceTop;
  62340. private _sliceBottom;
  62341. private _detectPointerOnOpaqueOnly;
  62342. /**
  62343. * BABYLON.Observable notified when the content is loaded
  62344. */
  62345. onImageLoadedObservable: BABYLON.Observable<Image>;
  62346. /**
  62347. * Gets a boolean indicating that the content is loaded
  62348. */
  62349. readonly isLoaded: boolean;
  62350. /**
  62351. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  62352. */
  62353. populateNinePatchSlicesFromImage: boolean;
  62354. /**
  62355. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  62356. * Beware using this as this will comsume more memory as the image has to be stored twice
  62357. */
  62358. detectPointerOnOpaqueOnly: boolean;
  62359. /**
  62360. * Gets or sets the left value for slicing (9-patch)
  62361. */
  62362. sliceLeft: number;
  62363. /**
  62364. * Gets or sets the right value for slicing (9-patch)
  62365. */
  62366. sliceRight: number;
  62367. /**
  62368. * Gets or sets the top value for slicing (9-patch)
  62369. */
  62370. sliceTop: number;
  62371. /**
  62372. * Gets or sets the bottom value for slicing (9-patch)
  62373. */
  62374. sliceBottom: number;
  62375. /**
  62376. * Gets or sets the left coordinate in the source image
  62377. */
  62378. sourceLeft: number;
  62379. /**
  62380. * Gets or sets the top coordinate in the source image
  62381. */
  62382. sourceTop: number;
  62383. /**
  62384. * Gets or sets the width to capture in the source image
  62385. */
  62386. sourceWidth: number;
  62387. /**
  62388. * Gets or sets the height to capture in the source image
  62389. */
  62390. sourceHeight: number;
  62391. /**
  62392. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  62393. * @see http://doc.babylonjs.com/how_to/gui#image
  62394. */
  62395. autoScale: boolean;
  62396. /** Gets or sets the streching mode used by the image */
  62397. stretch: number;
  62398. /**
  62399. * Gets or sets the internal DOM image used to render the control
  62400. */
  62401. domImage: HTMLImageElement;
  62402. private _onImageLoaded;
  62403. private _extractNinePatchSliceDataFromImage;
  62404. /**
  62405. * Gets or sets image source url
  62406. */
  62407. source: BABYLON.Nullable<string>;
  62408. /**
  62409. * Gets or sets the cell width to use when animation sheet is enabled
  62410. * @see http://doc.babylonjs.com/how_to/gui#image
  62411. */
  62412. cellWidth: number;
  62413. /**
  62414. * Gets or sets the cell height to use when animation sheet is enabled
  62415. * @see http://doc.babylonjs.com/how_to/gui#image
  62416. */
  62417. cellHeight: number;
  62418. /**
  62419. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  62420. * @see http://doc.babylonjs.com/how_to/gui#image
  62421. */
  62422. cellId: number;
  62423. /**
  62424. * Creates a new Image
  62425. * @param name defines the control name
  62426. * @param url defines the image url
  62427. */
  62428. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  62429. /**
  62430. * Tests if a given coordinates belong to the current control
  62431. * @param x defines x coordinate to test
  62432. * @param y defines y coordinate to test
  62433. * @returns true if the coordinates are inside the control
  62434. */
  62435. contains(x: number, y: number): boolean;
  62436. protected _getTypeName(): string;
  62437. /** Force the control to synchronize with its content */
  62438. synchronizeSizeWithContent(): void;
  62439. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62440. private _prepareWorkingCanvasForOpaqueDetection;
  62441. private _drawImage; private _draw(context: CanvasRenderingContext2D): void;
  62442. private _renderCornerPatch;
  62443. private _renderNinePatch;
  62444. dispose(): void;
  62445. /** STRETCH_NONE */
  62446. static readonly STRETCH_NONE: number;
  62447. /** STRETCH_FILL */
  62448. static readonly STRETCH_FILL: number;
  62449. /** STRETCH_UNIFORM */
  62450. static readonly STRETCH_UNIFORM: number;
  62451. /** STRETCH_EXTEND */
  62452. static readonly STRETCH_EXTEND: number;
  62453. /** NINE_PATCH */
  62454. static readonly STRETCH_NINE_PATCH: number;
  62455. }
  62456. }
  62457. declare module BABYLON.GUI {
  62458. /**
  62459. * Class used to create 2D buttons
  62460. */
  62461. export class Button extends Rectangle {
  62462. name?: string | undefined;
  62463. /**
  62464. * Function called to generate a pointer enter animation
  62465. */
  62466. pointerEnterAnimation: () => void;
  62467. /**
  62468. * Function called to generate a pointer out animation
  62469. */
  62470. pointerOutAnimation: () => void;
  62471. /**
  62472. * Function called to generate a pointer down animation
  62473. */
  62474. pointerDownAnimation: () => void;
  62475. /**
  62476. * Function called to generate a pointer up animation
  62477. */
  62478. pointerUpAnimation: () => void;
  62479. /**
  62480. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  62481. */
  62482. delegatePickingToChildren: boolean;
  62483. private _image;
  62484. /**
  62485. * Returns the image part of the button (if any)
  62486. */
  62487. readonly image: BABYLON.Nullable<Image>;
  62488. private _textBlock;
  62489. /**
  62490. * Returns the image part of the button (if any)
  62491. */
  62492. readonly textBlock: BABYLON.Nullable<TextBlock>;
  62493. /**
  62494. * Creates a new Button
  62495. * @param name defines the name of the button
  62496. */
  62497. constructor(name?: string | undefined);
  62498. protected _getTypeName(): string;
  62499. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  62500. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  62501. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  62502. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62503. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  62504. /**
  62505. * Creates a new button made with an image and a text
  62506. * @param name defines the name of the button
  62507. * @param text defines the text of the button
  62508. * @param imageUrl defines the url of the image
  62509. * @returns a new Button
  62510. */
  62511. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  62512. /**
  62513. * Creates a new button made with an image
  62514. * @param name defines the name of the button
  62515. * @param imageUrl defines the url of the image
  62516. * @returns a new Button
  62517. */
  62518. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  62519. /**
  62520. * Creates a new button made with a text
  62521. * @param name defines the name of the button
  62522. * @param text defines the text of the button
  62523. * @returns a new Button
  62524. */
  62525. static CreateSimpleButton(name: string, text: string): Button;
  62526. /**
  62527. * Creates a new button made with an image and a centered text
  62528. * @param name defines the name of the button
  62529. * @param text defines the text of the button
  62530. * @param imageUrl defines the url of the image
  62531. * @returns a new Button
  62532. */
  62533. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  62534. }
  62535. }
  62536. declare module BABYLON.GUI {
  62537. /**
  62538. * Class used to create a 2D stack panel container
  62539. */
  62540. export class StackPanel extends Container {
  62541. name?: string | undefined;
  62542. private _isVertical;
  62543. private _manualWidth;
  62544. private _manualHeight;
  62545. private _doNotTrackManualChanges;
  62546. /**
  62547. * Gets or sets a boolean indicating that layou warnings should be ignored
  62548. */
  62549. ignoreLayoutWarnings: boolean;
  62550. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  62551. isVertical: boolean;
  62552. /**
  62553. * Gets or sets panel width.
  62554. * This value should not be set when in horizontal mode as it will be computed automatically
  62555. */
  62556. width: string | number;
  62557. /**
  62558. * Gets or sets panel height.
  62559. * This value should not be set when in vertical mode as it will be computed automatically
  62560. */
  62561. height: string | number;
  62562. /**
  62563. * Creates a new StackPanel
  62564. * @param name defines control name
  62565. */
  62566. constructor(name?: string | undefined);
  62567. protected _getTypeName(): string;
  62568. /** @hidden */
  62569. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62570. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62571. protected _postMeasure(): void;
  62572. }
  62573. }
  62574. declare module BABYLON.GUI {
  62575. /**
  62576. * Class used to represent a 2D checkbox
  62577. */
  62578. export class Checkbox extends Control {
  62579. name?: string | undefined;
  62580. private _isChecked;
  62581. private _background;
  62582. private _checkSizeRatio;
  62583. private _thickness;
  62584. /** Gets or sets border thickness */
  62585. thickness: number;
  62586. /**
  62587. * BABYLON.Observable raised when isChecked property changes
  62588. */
  62589. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  62590. /** Gets or sets a value indicating the ratio between overall size and check size */
  62591. checkSizeRatio: number;
  62592. /** Gets or sets background color */
  62593. background: string;
  62594. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  62595. isChecked: boolean;
  62596. /**
  62597. * Creates a new CheckBox
  62598. * @param name defines the control name
  62599. */
  62600. constructor(name?: string | undefined);
  62601. protected _getTypeName(): string;
  62602. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  62603. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62604. /**
  62605. * Utility function to easily create a checkbox with a header
  62606. * @param title defines the label to use for the header
  62607. * @param onValueChanged defines the callback to call when value changes
  62608. * @returns a StackPanel containing the checkbox and a textBlock
  62609. */
  62610. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  62611. }
  62612. }
  62613. declare module BABYLON.GUI {
  62614. /**
  62615. * Class used to store key control properties
  62616. */
  62617. export class KeyPropertySet {
  62618. /** Width */
  62619. width?: string;
  62620. /** Height */
  62621. height?: string;
  62622. /** Left padding */
  62623. paddingLeft?: string;
  62624. /** Right padding */
  62625. paddingRight?: string;
  62626. /** Top padding */
  62627. paddingTop?: string;
  62628. /** Bottom padding */
  62629. paddingBottom?: string;
  62630. /** Foreground color */
  62631. color?: string;
  62632. /** Background color */
  62633. background?: string;
  62634. }
  62635. /**
  62636. * Class used to create virtual keyboard
  62637. */
  62638. export class VirtualKeyboard extends StackPanel {
  62639. /** BABYLON.Observable raised when a key is pressed */
  62640. onKeyPressObservable: BABYLON.Observable<string>;
  62641. /** Gets or sets default key button width */
  62642. defaultButtonWidth: string;
  62643. /** Gets or sets default key button height */
  62644. defaultButtonHeight: string;
  62645. /** Gets or sets default key button left padding */
  62646. defaultButtonPaddingLeft: string;
  62647. /** Gets or sets default key button right padding */
  62648. defaultButtonPaddingRight: string;
  62649. /** Gets or sets default key button top padding */
  62650. defaultButtonPaddingTop: string;
  62651. /** Gets or sets default key button bottom padding */
  62652. defaultButtonPaddingBottom: string;
  62653. /** Gets or sets default key button foreground color */
  62654. defaultButtonColor: string;
  62655. /** Gets or sets default key button background color */
  62656. defaultButtonBackground: string;
  62657. /** Gets or sets shift button foreground color */
  62658. shiftButtonColor: string;
  62659. /** Gets or sets shift button thickness*/
  62660. selectedShiftThickness: number;
  62661. /** Gets shift key state */
  62662. shiftState: number;
  62663. protected _getTypeName(): string;
  62664. private _createKey;
  62665. /**
  62666. * Adds a new row of keys
  62667. * @param keys defines the list of keys to add
  62668. * @param propertySets defines the associated property sets
  62669. */
  62670. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  62671. /**
  62672. * Set the shift key to a specific state
  62673. * @param shiftState defines the new shift state
  62674. */
  62675. applyShiftState(shiftState: number): void;
  62676. private _currentlyConnectedInputText;
  62677. private _connectedInputTexts;
  62678. private _onKeyPressObserver;
  62679. /** Gets the input text control currently attached to the keyboard */
  62680. readonly connectedInputText: BABYLON.Nullable<InputText>;
  62681. /**
  62682. * Connects the keyboard with an input text control
  62683. *
  62684. * @param input defines the target control
  62685. */
  62686. connect(input: InputText): void;
  62687. /**
  62688. * Disconnects the keyboard from connected InputText controls
  62689. *
  62690. * @param input optionally defines a target control, otherwise all are disconnected
  62691. */
  62692. disconnect(input?: InputText): void;
  62693. private _removeConnectedInputObservables;
  62694. /**
  62695. * Release all resources
  62696. */
  62697. dispose(): void;
  62698. /**
  62699. * Creates a new keyboard using a default layout
  62700. *
  62701. * @param name defines control name
  62702. * @returns a new VirtualKeyboard
  62703. */
  62704. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  62705. }
  62706. }
  62707. declare module BABYLON.GUI {
  62708. /**
  62709. * Class used to create input text control
  62710. */
  62711. export class InputText extends Control implements IFocusableControl {
  62712. name?: string | undefined;
  62713. private _text;
  62714. private _placeholderText;
  62715. private _background;
  62716. private _focusedBackground;
  62717. private _focusedColor;
  62718. private _placeholderColor;
  62719. private _thickness;
  62720. private _margin;
  62721. private _autoStretchWidth;
  62722. private _maxWidth;
  62723. private _isFocused;
  62724. private _blinkTimeout;
  62725. private _blinkIsEven;
  62726. private _cursorOffset;
  62727. private _scrollLeft;
  62728. private _textWidth;
  62729. private _clickedCoordinate;
  62730. private _deadKey;
  62731. private _addKey;
  62732. private _currentKey;
  62733. private _isTextHighlightOn;
  62734. private _textHighlightColor;
  62735. private _highligherOpacity;
  62736. private _highlightedText;
  62737. private _startHighlightIndex;
  62738. private _endHighlightIndex;
  62739. private _cursorIndex;
  62740. private _onFocusSelectAll;
  62741. private _isPointerDown;
  62742. private _onClipboardObserver;
  62743. private _onPointerDblTapObserver;
  62744. /** @hidden */ private _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  62745. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  62746. promptMessage: string;
  62747. /** Force disable prompt on mobile device */
  62748. disableMobilePrompt: boolean;
  62749. /** BABYLON.Observable raised when the text changes */
  62750. onTextChangedObservable: BABYLON.Observable<InputText>;
  62751. /** BABYLON.Observable raised just before an entered character is to be added */
  62752. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  62753. /** BABYLON.Observable raised when the control gets the focus */
  62754. onFocusObservable: BABYLON.Observable<InputText>;
  62755. /** BABYLON.Observable raised when the control loses the focus */
  62756. onBlurObservable: BABYLON.Observable<InputText>;
  62757. /**Observable raised when the text is highlighted */
  62758. onTextHighlightObservable: BABYLON.Observable<InputText>;
  62759. /**Observable raised when copy event is triggered */
  62760. onTextCopyObservable: BABYLON.Observable<InputText>;
  62761. /** BABYLON.Observable raised when cut event is triggered */
  62762. onTextCutObservable: BABYLON.Observable<InputText>;
  62763. /** BABYLON.Observable raised when paste event is triggered */
  62764. onTextPasteObservable: BABYLON.Observable<InputText>;
  62765. /** BABYLON.Observable raised when a key event was processed */
  62766. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  62767. /** Gets or sets the maximum width allowed by the control */
  62768. maxWidth: string | number;
  62769. /** Gets the maximum width allowed by the control in pixels */
  62770. readonly maxWidthInPixels: number;
  62771. /** Gets or sets the text highlighter transparency; default: 0.4 */
  62772. highligherOpacity: number;
  62773. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  62774. onFocusSelectAll: boolean;
  62775. /** Gets or sets the text hightlight color */
  62776. textHighlightColor: string;
  62777. /** Gets or sets control margin */
  62778. margin: string;
  62779. /** Gets control margin in pixels */
  62780. readonly marginInPixels: number;
  62781. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  62782. autoStretchWidth: boolean;
  62783. /** Gets or sets border thickness */
  62784. thickness: number;
  62785. /** Gets or sets the background color when focused */
  62786. focusedBackground: string;
  62787. /** Gets or sets the background color when focused */
  62788. focusedColor: string;
  62789. /** Gets or sets the background color */
  62790. background: string;
  62791. /** Gets or sets the placeholder color */
  62792. placeholderColor: string;
  62793. /** Gets or sets the text displayed when the control is empty */
  62794. placeholderText: string;
  62795. /** Gets or sets the dead key flag */
  62796. deadKey: boolean;
  62797. /** Gets or sets the highlight text */
  62798. highlightedText: string;
  62799. /** Gets or sets if the current key should be added */
  62800. addKey: boolean;
  62801. /** Gets or sets the value of the current key being entered */
  62802. currentKey: string;
  62803. /** Gets or sets the text displayed in the control */
  62804. text: string;
  62805. /** Gets or sets control width */
  62806. width: string | number;
  62807. /**
  62808. * Creates a new InputText
  62809. * @param name defines the control name
  62810. * @param text defines the text of the control
  62811. */
  62812. constructor(name?: string | undefined, text?: string);
  62813. /** @hidden */
  62814. onBlur(): void;
  62815. /** @hidden */
  62816. onFocus(): void;
  62817. protected _getTypeName(): string;
  62818. /**
  62819. * Function called to get the list of controls that should not steal the focus from this control
  62820. * @returns an array of controls
  62821. */
  62822. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  62823. /** @hidden */
  62824. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  62825. /** @hidden */
  62826. private _updateValueFromCursorIndex;
  62827. /** @hidden */
  62828. private _processDblClick;
  62829. /** @hidden */
  62830. private _selectAllText;
  62831. /**
  62832. * Handles the keyboard event
  62833. * @param evt Defines the KeyboardEvent
  62834. */
  62835. processKeyboard(evt: KeyboardEvent): void;
  62836. /** @hidden */
  62837. private _onCopyText;
  62838. /** @hidden */
  62839. private _onCutText;
  62840. /** @hidden */
  62841. private _onPasteText; private _draw(context: CanvasRenderingContext2D): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void; private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  62842. protected _beforeRenderText(text: string): string;
  62843. dispose(): void;
  62844. }
  62845. }
  62846. declare module BABYLON.GUI {
  62847. /**
  62848. * Class used to create a 2D grid container
  62849. */
  62850. export class Grid extends Container {
  62851. name?: string | undefined;
  62852. private _rowDefinitions;
  62853. private _columnDefinitions;
  62854. private _cells;
  62855. private _childControls;
  62856. /**
  62857. * Gets the number of columns
  62858. */
  62859. readonly columnCount: number;
  62860. /**
  62861. * Gets the number of rows
  62862. */
  62863. readonly rowCount: number;
  62864. /** Gets the list of children */
  62865. readonly children: Control[];
  62866. /** Gets the list of cells (e.g. the containers) */
  62867. readonly cells: {
  62868. [key: string]: Container;
  62869. };
  62870. /**
  62871. * Gets the definition of a specific row
  62872. * @param index defines the index of the row
  62873. * @returns the row definition
  62874. */
  62875. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  62876. /**
  62877. * Gets the definition of a specific column
  62878. * @param index defines the index of the column
  62879. * @returns the column definition
  62880. */
  62881. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  62882. /**
  62883. * Adds a new row to the grid
  62884. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  62885. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  62886. * @returns the current grid
  62887. */
  62888. addRowDefinition(height: number, isPixel?: boolean): Grid;
  62889. /**
  62890. * Adds a new column to the grid
  62891. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  62892. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  62893. * @returns the current grid
  62894. */
  62895. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  62896. /**
  62897. * Update a row definition
  62898. * @param index defines the index of the row to update
  62899. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  62900. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  62901. * @returns the current grid
  62902. */
  62903. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  62904. /**
  62905. * Update a column definition
  62906. * @param index defines the index of the column to update
  62907. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  62908. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  62909. * @returns the current grid
  62910. */
  62911. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  62912. /**
  62913. * Gets the list of children stored in a specific cell
  62914. * @param row defines the row to check
  62915. * @param column defines the column to check
  62916. * @returns the list of controls
  62917. */
  62918. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  62919. /**
  62920. * Gets a string representing the child cell info (row x column)
  62921. * @param child defines the control to get info from
  62922. * @returns a string containing the child cell info (row x column)
  62923. */
  62924. getChildCellInfo(child: Control): string;
  62925. private _removeCell;
  62926. private _offsetCell;
  62927. /**
  62928. * Remove a column definition at specified index
  62929. * @param index defines the index of the column to remove
  62930. * @returns the current grid
  62931. */
  62932. removeColumnDefinition(index: number): Grid;
  62933. /**
  62934. * Remove a row definition at specified index
  62935. * @param index defines the index of the row to remove
  62936. * @returns the current grid
  62937. */
  62938. removeRowDefinition(index: number): Grid;
  62939. /**
  62940. * Adds a new control to the current grid
  62941. * @param control defines the control to add
  62942. * @param row defines the row where to add the control (0 by default)
  62943. * @param column defines the column where to add the control (0 by default)
  62944. * @returns the current grid
  62945. */
  62946. addControl(control: Control, row?: number, column?: number): Grid;
  62947. /**
  62948. * Removes a control from the current container
  62949. * @param control defines the control to remove
  62950. * @returns the current container
  62951. */
  62952. removeControl(control: Control): Container;
  62953. /**
  62954. * Creates a new Grid
  62955. * @param name defines control name
  62956. */
  62957. constructor(name?: string | undefined);
  62958. protected _getTypeName(): string;
  62959. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  62960. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _flagDescendantsAsMatrixDirty(): void; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  62961. /** Releases associated resources */
  62962. dispose(): void;
  62963. }
  62964. }
  62965. declare module BABYLON.GUI {
  62966. /** Class used to create color pickers */
  62967. export class ColorPicker extends Control {
  62968. name?: string | undefined;
  62969. private static _Epsilon;
  62970. private _colorWheelCanvas;
  62971. private _value;
  62972. private _tmpColor;
  62973. private _pointerStartedOnSquare;
  62974. private _pointerStartedOnWheel;
  62975. private _squareLeft;
  62976. private _squareTop;
  62977. private _squareSize;
  62978. private _h;
  62979. private _s;
  62980. private _v;
  62981. private _lastPointerDownID;
  62982. /**
  62983. * BABYLON.Observable raised when the value changes
  62984. */
  62985. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  62986. /** Gets or sets the color of the color picker */
  62987. value: BABYLON.Color3;
  62988. /**
  62989. * Gets or sets control width
  62990. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62991. */
  62992. width: string | number;
  62993. /**
  62994. * Gets or sets control height
  62995. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62996. */
  62997. /** Gets or sets control height */
  62998. height: string | number;
  62999. /** Gets or sets control size */
  63000. size: string | number;
  63001. /**
  63002. * Creates a new ColorPicker
  63003. * @param name defines the control name
  63004. */
  63005. constructor(name?: string | undefined);
  63006. protected _getTypeName(): string;
  63007. /** @hidden */
  63008. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63009. private _updateSquareProps;
  63010. private _drawGradientSquare;
  63011. private _drawCircle;
  63012. private _createColorWheelCanvas;
  63013. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  63014. private _pointerIsDown;
  63015. private _updateValueFromPointer;
  63016. private _isPointOnSquare;
  63017. private _isPointOnWheel; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void; private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63018. /**
  63019. * This function expands the color picker by creating a color picker dialog with manual
  63020. * color value input and the ability to save colors into an array to be used later in
  63021. * subsequent launches of the dialogue.
  63022. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  63023. * @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.
  63024. * @returns picked color as a hex string and the saved colors array as hex strings.
  63025. */
  63026. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  63027. pickerWidth?: string;
  63028. pickerHeight?: string;
  63029. headerHeight?: string;
  63030. lastColor?: string;
  63031. swatchLimit?: number;
  63032. numSwatchesPerLine?: number;
  63033. savedColors?: Array<string>;
  63034. }): Promise<{
  63035. savedColors?: string[];
  63036. pickedColor: string;
  63037. }>;
  63038. }
  63039. }
  63040. declare module BABYLON.GUI {
  63041. /** Class used to create 2D ellipse containers */
  63042. export class Ellipse extends Container {
  63043. name?: string | undefined;
  63044. private _thickness;
  63045. /** Gets or sets border thickness */
  63046. thickness: number;
  63047. /**
  63048. * Creates a new Ellipse
  63049. * @param name defines the control name
  63050. */
  63051. constructor(name?: string | undefined);
  63052. protected _getTypeName(): string;
  63053. protected _localDraw(context: CanvasRenderingContext2D): void;
  63054. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63055. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  63056. }
  63057. }
  63058. declare module BABYLON.GUI {
  63059. /**
  63060. * Class used to create a password control
  63061. */
  63062. export class InputPassword extends InputText {
  63063. protected _beforeRenderText(text: string): string;
  63064. }
  63065. }
  63066. declare module BABYLON.GUI {
  63067. /** Class used to render 2D lines */
  63068. export class Line extends Control {
  63069. name?: string | undefined;
  63070. private _lineWidth;
  63071. private _x1;
  63072. private _y1;
  63073. private _x2;
  63074. private _y2;
  63075. private _dash;
  63076. private _connectedControl;
  63077. private _connectedControlDirtyObserver;
  63078. /** Gets or sets the dash pattern */
  63079. dash: Array<number>;
  63080. /** Gets or sets the control connected with the line end */
  63081. connectedControl: Control;
  63082. /** Gets or sets start coordinates on X axis */
  63083. x1: string | number;
  63084. /** Gets or sets start coordinates on Y axis */
  63085. y1: string | number;
  63086. /** Gets or sets end coordinates on X axis */
  63087. x2: string | number;
  63088. /** Gets or sets end coordinates on Y axis */
  63089. y2: string | number;
  63090. /** Gets or sets line width */
  63091. lineWidth: number;
  63092. /** Gets or sets horizontal alignment */
  63093. horizontalAlignment: number;
  63094. /** Gets or sets vertical alignment */
  63095. verticalAlignment: number;
  63096. private readonly _effectiveX2;
  63097. private readonly _effectiveY2;
  63098. /**
  63099. * Creates a new Line
  63100. * @param name defines the control name
  63101. */
  63102. constructor(name?: string | undefined);
  63103. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _measure(): void;
  63104. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63105. /**
  63106. * Move one end of the line given 3D cartesian coordinates.
  63107. * @param position Targeted world position
  63108. * @param scene BABYLON.Scene
  63109. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  63110. */
  63111. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  63112. /**
  63113. * Move one end of the line to a position in screen absolute space.
  63114. * @param projectedPosition Position in screen absolute space (X, Y)
  63115. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  63116. */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  63117. }
  63118. }
  63119. declare module BABYLON.GUI {
  63120. /**
  63121. * Class used to store a point for a MultiLine object.
  63122. * The point can be pure 2D coordinates, a mesh or a control
  63123. */
  63124. export class MultiLinePoint {
  63125. private _multiLine;
  63126. private _x;
  63127. private _y;
  63128. private _control;
  63129. private _mesh;
  63130. private _controlObserver;
  63131. private _meshObserver;
  63132. /** @hidden */ private _point: BABYLON.Vector2;
  63133. /**
  63134. * Creates a new MultiLinePoint
  63135. * @param multiLine defines the source MultiLine object
  63136. */
  63137. constructor(multiLine: MultiLine);
  63138. /** Gets or sets x coordinate */
  63139. x: string | number;
  63140. /** Gets or sets y coordinate */
  63141. y: string | number;
  63142. /** Gets or sets the control associated with this point */
  63143. control: BABYLON.Nullable<Control>;
  63144. /** Gets or sets the mesh associated with this point */
  63145. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63146. /** Resets links */
  63147. resetLinks(): void;
  63148. /**
  63149. * Gets a translation vector
  63150. * @returns the translation vector
  63151. */
  63152. translate(): BABYLON.Vector2;
  63153. private _translatePoint;
  63154. /** Release associated resources */
  63155. dispose(): void;
  63156. }
  63157. }
  63158. declare module BABYLON.GUI {
  63159. /**
  63160. * Class used to create multi line control
  63161. */
  63162. export class MultiLine extends Control {
  63163. name?: string | undefined;
  63164. private _lineWidth;
  63165. private _dash;
  63166. private _points;
  63167. private _minX;
  63168. private _minY;
  63169. private _maxX;
  63170. private _maxY;
  63171. /**
  63172. * Creates a new MultiLine
  63173. * @param name defines the control name
  63174. */
  63175. constructor(name?: string | undefined);
  63176. /** Gets or sets dash pattern */
  63177. dash: Array<number>;
  63178. /**
  63179. * Gets point stored at specified index
  63180. * @param index defines the index to look for
  63181. * @returns the requested point if found
  63182. */
  63183. getAt(index: number): MultiLinePoint;
  63184. /** Function called when a point is updated */
  63185. onPointUpdate: () => void;
  63186. /**
  63187. * Adds new points to the point collection
  63188. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  63189. * @returns the list of created MultiLinePoint
  63190. */
  63191. add(...items: (AbstractMesh | Control | {
  63192. x: string | number;
  63193. y: string | number;
  63194. })[]): MultiLinePoint[];
  63195. /**
  63196. * Adds a new point to the point collection
  63197. * @param item defines the item (mesh, control or 2d coordiantes) to add
  63198. * @returns the created MultiLinePoint
  63199. */
  63200. push(item?: (AbstractMesh | Control | {
  63201. x: string | number;
  63202. y: string | number;
  63203. })): MultiLinePoint;
  63204. /**
  63205. * Remove a specific value or point from the active point collection
  63206. * @param value defines the value or point to remove
  63207. */
  63208. remove(value: number | MultiLinePoint): void;
  63209. /**
  63210. * Resets this object to initial state (no point)
  63211. */
  63212. reset(): void;
  63213. /**
  63214. * Resets all links
  63215. */
  63216. resetLinks(): void;
  63217. /** Gets or sets line width */
  63218. lineWidth: number;
  63219. horizontalAlignment: number;
  63220. verticalAlignment: number;
  63221. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  63222. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _measure(): void;
  63223. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63224. dispose(): void;
  63225. }
  63226. }
  63227. declare module BABYLON.GUI {
  63228. /**
  63229. * Class used to create radio button controls
  63230. */
  63231. export class RadioButton extends Control {
  63232. name?: string | undefined;
  63233. private _isChecked;
  63234. private _background;
  63235. private _checkSizeRatio;
  63236. private _thickness;
  63237. /** Gets or sets border thickness */
  63238. thickness: number;
  63239. /** Gets or sets group name */
  63240. group: string;
  63241. /** BABYLON.Observable raised when isChecked is changed */
  63242. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  63243. /** Gets or sets a value indicating the ratio between overall size and check size */
  63244. checkSizeRatio: number;
  63245. /** Gets or sets background color */
  63246. background: string;
  63247. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  63248. isChecked: boolean;
  63249. /**
  63250. * Creates a new RadioButton
  63251. * @param name defines the control name
  63252. */
  63253. constructor(name?: string | undefined);
  63254. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63255. /**
  63256. * Utility function to easily create a radio button with a header
  63257. * @param title defines the label to use for the header
  63258. * @param group defines the group to use for the radio button
  63259. * @param isChecked defines the initial state of the radio button
  63260. * @param onValueChanged defines the callback to call when value changes
  63261. * @returns a StackPanel containing the radio button and a textBlock
  63262. */
  63263. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  63264. }
  63265. }
  63266. declare module BABYLON.GUI {
  63267. /**
  63268. * Class used to create slider controls
  63269. */
  63270. export class BaseSlider extends Control {
  63271. name?: string | undefined;
  63272. protected _thumbWidth: ValueAndUnit;
  63273. private _minimum;
  63274. private _maximum;
  63275. private _value;
  63276. private _isVertical;
  63277. protected _barOffset: ValueAndUnit;
  63278. private _isThumbClamped;
  63279. protected _displayThumb: boolean;
  63280. private _step;
  63281. private _lastPointerDownID;
  63282. protected _effectiveBarOffset: number;
  63283. protected _renderLeft: number;
  63284. protected _renderTop: number;
  63285. protected _renderWidth: number;
  63286. protected _renderHeight: number;
  63287. protected _backgroundBoxLength: number;
  63288. protected _backgroundBoxThickness: number;
  63289. protected _effectiveThumbThickness: number;
  63290. /** BABYLON.Observable raised when the sldier value changes */
  63291. onValueChangedObservable: BABYLON.Observable<number>;
  63292. /** Gets or sets a boolean indicating if the thumb must be rendered */
  63293. displayThumb: boolean;
  63294. /** Gets or sets a step to apply to values (0 by default) */
  63295. step: number;
  63296. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  63297. barOffset: string | number;
  63298. /** Gets main bar offset in pixels*/
  63299. readonly barOffsetInPixels: number;
  63300. /** Gets or sets thumb width */
  63301. thumbWidth: string | number;
  63302. /** Gets thumb width in pixels */
  63303. readonly thumbWidthInPixels: number;
  63304. /** Gets or sets minimum value */
  63305. minimum: number;
  63306. /** Gets or sets maximum value */
  63307. maximum: number;
  63308. /** Gets or sets current value */
  63309. value: number;
  63310. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  63311. isVertical: boolean;
  63312. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  63313. isThumbClamped: boolean;
  63314. /**
  63315. * Creates a new BaseSlider
  63316. * @param name defines the control name
  63317. */
  63318. constructor(name?: string | undefined);
  63319. protected _getTypeName(): string;
  63320. protected _getThumbPosition(): number;
  63321. protected _getThumbThickness(type: string): number;
  63322. protected _prepareRenderingData(type: string): void;
  63323. private _pointerIsDown;
  63324. /** @hidden */
  63325. protected _updateValueFromPointer(x: number, y: number): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void; private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63326. }
  63327. }
  63328. declare module BABYLON.GUI {
  63329. /**
  63330. * Class used to create slider controls
  63331. */
  63332. export class Slider extends BaseSlider {
  63333. name?: string | undefined;
  63334. private _background;
  63335. private _borderColor;
  63336. private _isThumbCircle;
  63337. protected _displayValueBar: boolean;
  63338. /** Gets or sets a boolean indicating if the value bar must be rendered */
  63339. displayValueBar: boolean;
  63340. /** Gets or sets border color */
  63341. borderColor: string;
  63342. /** Gets or sets background color */
  63343. background: string;
  63344. /** Gets or sets a boolean indicating if the thumb should be round or square */
  63345. isThumbCircle: boolean;
  63346. /**
  63347. * Creates a new Slider
  63348. * @param name defines the control name
  63349. */
  63350. constructor(name?: string | undefined);
  63351. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  63352. }
  63353. }
  63354. declare module BABYLON.GUI {
  63355. /** Class used to create a RadioGroup
  63356. * which contains groups of radio buttons
  63357. */
  63358. export class SelectorGroup {
  63359. /** name of SelectorGroup */
  63360. name: string;
  63361. private _groupPanel;
  63362. private _selectors;
  63363. private _groupHeader;
  63364. /**
  63365. * Creates a new SelectorGroup
  63366. * @param name of group, used as a group heading
  63367. */
  63368. constructor(
  63369. /** name of SelectorGroup */
  63370. name: string);
  63371. /** Gets the groupPanel of the SelectorGroup */
  63372. readonly groupPanel: StackPanel;
  63373. /** Gets the selectors array */
  63374. readonly selectors: StackPanel[];
  63375. /** Gets and sets the group header */
  63376. header: string;
  63377. /** @hidden */
  63378. private _addGroupHeader;
  63379. /** @hidden*/ private _getSelector(selectorNb: number): StackPanel | undefined;
  63380. /** Removes the selector at the given position
  63381. * @param selectorNb the position of the selector within the group
  63382. */
  63383. removeSelector(selectorNb: number): void;
  63384. }
  63385. /** Class used to create a CheckboxGroup
  63386. * which contains groups of checkbox buttons
  63387. */
  63388. export class CheckboxGroup extends SelectorGroup {
  63389. /** Adds a checkbox as a control
  63390. * @param text is the label for the selector
  63391. * @param func is the function called when the Selector is checked
  63392. * @param checked is true when Selector is checked
  63393. */
  63394. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  63395. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  63396. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  63397. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  63398. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  63399. }
  63400. /** Class used to create a RadioGroup
  63401. * which contains groups of radio buttons
  63402. */
  63403. export class RadioGroup extends SelectorGroup {
  63404. private _selectNb;
  63405. /** Adds a radio button as a control
  63406. * @param label is the label for the selector
  63407. * @param func is the function called when the Selector is checked
  63408. * @param checked is true when Selector is checked
  63409. */
  63410. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  63411. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  63412. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  63413. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  63414. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  63415. }
  63416. /** Class used to create a SliderGroup
  63417. * which contains groups of slider buttons
  63418. */
  63419. export class SliderGroup extends SelectorGroup {
  63420. /**
  63421. * Adds a slider to the SelectorGroup
  63422. * @param label is the label for the SliderBar
  63423. * @param func is the function called when the Slider moves
  63424. * @param unit is a string describing the units used, eg degrees or metres
  63425. * @param min is the minimum value for the Slider
  63426. * @param max is the maximum value for the Slider
  63427. * @param value is the start value for the Slider between min and max
  63428. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  63429. */
  63430. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  63431. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  63432. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  63433. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  63434. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  63435. }
  63436. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  63437. * @see http://doc.babylonjs.com/how_to/selector
  63438. */
  63439. export class SelectionPanel extends Rectangle {
  63440. /** name of SelectionPanel */
  63441. name: string;
  63442. /** an array of SelectionGroups */
  63443. groups: SelectorGroup[];
  63444. private _panel;
  63445. private _buttonColor;
  63446. private _buttonBackground;
  63447. private _headerColor;
  63448. private _barColor;
  63449. private _barHeight;
  63450. private _spacerHeight;
  63451. private _labelColor;
  63452. private _groups;
  63453. private _bars;
  63454. /**
  63455. * Creates a new SelectionPanel
  63456. * @param name of SelectionPanel
  63457. * @param groups is an array of SelectionGroups
  63458. */
  63459. constructor(
  63460. /** name of SelectionPanel */
  63461. name: string,
  63462. /** an array of SelectionGroups */
  63463. groups?: SelectorGroup[]);
  63464. protected _getTypeName(): string;
  63465. /** Gets or sets the headerColor */
  63466. headerColor: string;
  63467. private _setHeaderColor;
  63468. /** Gets or sets the button color */
  63469. buttonColor: string;
  63470. private _setbuttonColor;
  63471. /** Gets or sets the label color */
  63472. labelColor: string;
  63473. private _setLabelColor;
  63474. /** Gets or sets the button background */
  63475. buttonBackground: string;
  63476. private _setButtonBackground;
  63477. /** Gets or sets the color of separator bar */
  63478. barColor: string;
  63479. private _setBarColor;
  63480. /** Gets or sets the height of separator bar */
  63481. barHeight: string;
  63482. private _setBarHeight;
  63483. /** Gets or sets the height of spacers*/
  63484. spacerHeight: string;
  63485. private _setSpacerHeight;
  63486. /** Adds a bar between groups */
  63487. private _addSpacer;
  63488. /** Add a group to the selection panel
  63489. * @param group is the selector group to add
  63490. */
  63491. addGroup(group: SelectorGroup): void;
  63492. /** Remove the group from the given position
  63493. * @param groupNb is the position of the group in the list
  63494. */
  63495. removeGroup(groupNb: number): void;
  63496. /** Change a group header label
  63497. * @param label is the new group header label
  63498. * @param groupNb is the number of the group to relabel
  63499. * */
  63500. setHeaderName(label: string, groupNb: number): void;
  63501. /** Change selector label to the one given
  63502. * @param label is the new selector label
  63503. * @param groupNb is the number of the groupcontaining the selector
  63504. * @param selectorNb is the number of the selector within a group to relabel
  63505. * */
  63506. relabel(label: string, groupNb: number, selectorNb: number): void;
  63507. /** For a given group position remove the selector at the given position
  63508. * @param groupNb is the number of the group to remove the selector from
  63509. * @param selectorNb is the number of the selector within the group
  63510. */
  63511. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  63512. /** For a given group position of correct type add a checkbox button
  63513. * @param groupNb is the number of the group to remove the selector from
  63514. * @param label is the label for the selector
  63515. * @param func is the function called when the Selector is checked
  63516. * @param checked is true when Selector is checked
  63517. */
  63518. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  63519. /** For a given group position of correct type add a radio button
  63520. * @param groupNb is the number of the group to remove the selector from
  63521. * @param label is the label for the selector
  63522. * @param func is the function called when the Selector is checked
  63523. * @param checked is true when Selector is checked
  63524. */
  63525. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  63526. /**
  63527. * For a given slider group add a slider
  63528. * @param groupNb is the number of the group to add the slider to
  63529. * @param label is the label for the Slider
  63530. * @param func is the function called when the Slider moves
  63531. * @param unit is a string describing the units used, eg degrees or metres
  63532. * @param min is the minimum value for the Slider
  63533. * @param max is the maximum value for the Slider
  63534. * @param value is the start value for the Slider between min and max
  63535. * @param onVal is the function used to format the value displayed, eg radians to degrees
  63536. */
  63537. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  63538. }
  63539. }
  63540. declare module BABYLON.GUI {
  63541. /**
  63542. * Class used to hold a the container for ScrollViewer
  63543. * @hidden
  63544. */
  63545. export class _ScrollViewerWindow extends Container {
  63546. parentClientWidth: number;
  63547. parentClientHeight: number;
  63548. /**
  63549. * Creates a new ScrollViewerWindow
  63550. * @param name of ScrollViewerWindow
  63551. */
  63552. constructor(name?: string);
  63553. protected _getTypeName(): string;
  63554. /** @hidden */
  63555. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63556. protected _postMeasure(): void;
  63557. }
  63558. }
  63559. declare module BABYLON.GUI {
  63560. /**
  63561. * Class used to create slider controls
  63562. */
  63563. export class ScrollBar extends BaseSlider {
  63564. name?: string | undefined;
  63565. private _background;
  63566. private _borderColor;
  63567. private _thumbMeasure;
  63568. /** Gets or sets border color */
  63569. borderColor: string;
  63570. /** Gets or sets background color */
  63571. background: string;
  63572. /**
  63573. * Creates a new Slider
  63574. * @param name defines the control name
  63575. */
  63576. constructor(name?: string | undefined);
  63577. protected _getTypeName(): string;
  63578. protected _getThumbThickness(): number; private _draw(context: CanvasRenderingContext2D): void;
  63579. private _first;
  63580. private _originX;
  63581. private _originY;
  63582. /** @hidden */
  63583. protected _updateValueFromPointer(x: number, y: number): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63584. }
  63585. }
  63586. declare module BABYLON.GUI {
  63587. /**
  63588. * Class used to hold a viewer window and sliders in a grid
  63589. */
  63590. export class ScrollViewer extends Rectangle {
  63591. private _grid;
  63592. private _horizontalBarSpace;
  63593. private _verticalBarSpace;
  63594. private _dragSpace;
  63595. private _horizontalBar;
  63596. private _verticalBar;
  63597. private _barColor;
  63598. private _barBackground;
  63599. private _barSize;
  63600. private _endLeft;
  63601. private _endTop;
  63602. private _window;
  63603. private _pointerIsOver;
  63604. private _wheelPrecision;
  63605. private _onPointerObserver;
  63606. private _clientWidth;
  63607. private _clientHeight;
  63608. /**
  63609. * Gets the horizontal scrollbar
  63610. */
  63611. readonly horizontalBar: ScrollBar;
  63612. /**
  63613. * Gets the vertical scrollbar
  63614. */
  63615. readonly verticalBar: ScrollBar;
  63616. /**
  63617. * Adds a new control to the current container
  63618. * @param control defines the control to add
  63619. * @returns the current container
  63620. */
  63621. addControl(control: BABYLON.Nullable<Control>): Container;
  63622. /**
  63623. * Removes a control from the current container
  63624. * @param control defines the control to remove
  63625. * @returns the current container
  63626. */
  63627. removeControl(control: Control): Container;
  63628. /** Gets the list of children */
  63629. readonly children: Control[]; private _flagDescendantsAsMatrixDirty(): void;
  63630. /**
  63631. * Creates a new ScrollViewer
  63632. * @param name of ScrollViewer
  63633. */
  63634. constructor(name?: string);
  63635. /** Reset the scroll viewer window to initial size */
  63636. resetWindow(): void;
  63637. protected _getTypeName(): string;
  63638. private _buildClientSizes;
  63639. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63640. protected _postMeasure(): void;
  63641. /**
  63642. * Gets or sets the mouse wheel precision
  63643. * from 0 to 1 with a default value of 0.05
  63644. * */
  63645. wheelPrecision: number;
  63646. /** Gets or sets the bar color */
  63647. barColor: string;
  63648. /** Gets or sets the size of the bar */
  63649. barSize: number;
  63650. /** Gets or sets the bar background */
  63651. barBackground: string;
  63652. /** @hidden */
  63653. private _updateScroller; private _link(host: AdvancedDynamicTexture): void;
  63654. /** @hidden */
  63655. private _attachWheel; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  63656. /** Releases associated resources */
  63657. dispose(): void;
  63658. }
  63659. }
  63660. declare module BABYLON.GUI {
  63661. /** Class used to render a grid */
  63662. export class DisplayGrid extends Control {
  63663. name?: string | undefined;
  63664. private _cellWidth;
  63665. private _cellHeight;
  63666. private _minorLineTickness;
  63667. private _minorLineColor;
  63668. private _majorLineTickness;
  63669. private _majorLineColor;
  63670. private _majorLineFrequency;
  63671. private _background;
  63672. private _displayMajorLines;
  63673. private _displayMinorLines;
  63674. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  63675. displayMinorLines: boolean;
  63676. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  63677. displayMajorLines: boolean;
  63678. /** Gets or sets background color (Black by default) */
  63679. background: string;
  63680. /** Gets or sets the width of each cell (20 by default) */
  63681. cellWidth: number;
  63682. /** Gets or sets the height of each cell (20 by default) */
  63683. cellHeight: number;
  63684. /** Gets or sets the tickness of minor lines (1 by default) */
  63685. minorLineTickness: number;
  63686. /** Gets or sets the color of minor lines (DarkGray by default) */
  63687. minorLineColor: string;
  63688. /** Gets or sets the tickness of major lines (2 by default) */
  63689. majorLineTickness: number;
  63690. /** Gets or sets the color of major lines (White by default) */
  63691. majorLineColor: string;
  63692. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  63693. majorLineFrequency: number;
  63694. /**
  63695. * Creates a new GridDisplayRectangle
  63696. * @param name defines the control name
  63697. */
  63698. constructor(name?: string | undefined); private _draw(context: CanvasRenderingContext2D): void;
  63699. protected _getTypeName(): string;
  63700. }
  63701. }
  63702. declare module BABYLON.GUI {
  63703. /**
  63704. * Class used to create slider controls based on images
  63705. */
  63706. export class ImageBasedSlider extends BaseSlider {
  63707. name?: string | undefined;
  63708. private _backgroundImage;
  63709. private _thumbImage;
  63710. private _valueBarImage;
  63711. private _tempMeasure;
  63712. displayThumb: boolean;
  63713. /**
  63714. * Gets or sets the image used to render the background
  63715. */
  63716. backgroundImage: Image;
  63717. /**
  63718. * Gets or sets the image used to render the value bar
  63719. */
  63720. valueBarImage: Image;
  63721. /**
  63722. * Gets or sets the image used to render the thumb
  63723. */
  63724. thumbImage: Image;
  63725. /**
  63726. * Creates a new ImageBasedSlider
  63727. * @param name defines the control name
  63728. */
  63729. constructor(name?: string | undefined);
  63730. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  63731. }
  63732. }
  63733. declare module BABYLON.GUI {
  63734. /**
  63735. * Forcing an export so that this code will execute
  63736. * @hidden
  63737. */
  63738. const name = "Statics";
  63739. }
  63740. declare module BABYLON.GUI {
  63741. /**
  63742. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  63743. */
  63744. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  63745. /**
  63746. * Define the instrumented AdvancedDynamicTexture.
  63747. */
  63748. texture: AdvancedDynamicTexture;
  63749. private _captureRenderTime;
  63750. private _renderTime;
  63751. private _captureLayoutTime;
  63752. private _layoutTime;
  63753. private _onBeginRenderObserver;
  63754. private _onEndRenderObserver;
  63755. private _onBeginLayoutObserver;
  63756. private _onEndLayoutObserver;
  63757. /**
  63758. * Gets the perf counter used to capture render time
  63759. */
  63760. readonly renderTimeCounter: BABYLON.PerfCounter;
  63761. /**
  63762. * Gets the perf counter used to capture layout time
  63763. */
  63764. readonly layoutTimeCounter: BABYLON.PerfCounter;
  63765. /**
  63766. * Enable or disable the render time capture
  63767. */
  63768. captureRenderTime: boolean;
  63769. /**
  63770. * Enable or disable the layout time capture
  63771. */
  63772. captureLayoutTime: boolean;
  63773. /**
  63774. * Instantiates a new advanced dynamic texture instrumentation.
  63775. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  63776. * @param texture Defines the AdvancedDynamicTexture to instrument
  63777. */
  63778. constructor(
  63779. /**
  63780. * Define the instrumented AdvancedDynamicTexture.
  63781. */
  63782. texture: AdvancedDynamicTexture);
  63783. /**
  63784. * Dispose and release associated resources.
  63785. */
  63786. dispose(): void;
  63787. }
  63788. }
  63789. declare module BABYLON.GUI {
  63790. /**
  63791. * Class used to create containers for controls
  63792. */
  63793. export class Container3D extends Control3D {
  63794. private _blockLayout;
  63795. /**
  63796. * Gets the list of child controls
  63797. */
  63798. protected _children: Control3D[];
  63799. /**
  63800. * Gets the list of child controls
  63801. */
  63802. readonly children: Array<Control3D>;
  63803. /**
  63804. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  63805. * This is helpful to optimize layout operation when adding multiple children in a row
  63806. */
  63807. blockLayout: boolean;
  63808. /**
  63809. * Creates a new container
  63810. * @param name defines the container name
  63811. */
  63812. constructor(name?: string);
  63813. /**
  63814. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  63815. * @returns the current container
  63816. */
  63817. updateLayout(): Container3D;
  63818. /**
  63819. * Gets a boolean indicating if the given control is in the children of this control
  63820. * @param control defines the control to check
  63821. * @returns true if the control is in the child list
  63822. */
  63823. containsControl(control: Control3D): boolean;
  63824. /**
  63825. * Adds a control to the children of this control
  63826. * @param control defines the control to add
  63827. * @returns the current container
  63828. */
  63829. addControl(control: Control3D): Container3D;
  63830. /**
  63831. * This function will be called everytime a new control is added
  63832. */
  63833. protected _arrangeChildren(): void;
  63834. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  63835. /**
  63836. * Removes a control from the children of this control
  63837. * @param control defines the control to remove
  63838. * @returns the current container
  63839. */
  63840. removeControl(control: Control3D): Container3D;
  63841. protected _getTypeName(): string;
  63842. /**
  63843. * Releases all associated resources
  63844. */
  63845. dispose(): void;
  63846. /** Control rotation will remain unchanged */
  63847. static readonly UNSET_ORIENTATION: number;
  63848. /** Control will rotate to make it look at sphere central axis */
  63849. static readonly FACEORIGIN_ORIENTATION: number;
  63850. /** Control will rotate to make it look back at sphere central axis */
  63851. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  63852. /** Control will rotate to look at z axis (0, 0, 1) */
  63853. static readonly FACEFORWARD_ORIENTATION: number;
  63854. /** Control will rotate to look at negative z axis (0, 0, -1) */
  63855. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  63856. }
  63857. }
  63858. declare module BABYLON.GUI {
  63859. /**
  63860. * Class used to manage 3D user interface
  63861. * @see http://doc.babylonjs.com/how_to/gui3d
  63862. */
  63863. export class GUI3DManager implements BABYLON.IDisposable {
  63864. private _scene;
  63865. private _sceneDisposeObserver;
  63866. private _utilityLayer;
  63867. private _rootContainer;
  63868. private _pointerObserver;
  63869. private _pointerOutObserver;
  63870. /** @hidden */ private _lastPickedControl: Control3D;
  63871. /** @hidden */ private _lastControlOver: {
  63872. [pointerId: number]: Control3D;
  63873. };
  63874. /** @hidden */ private _lastControlDown: {
  63875. [pointerId: number]: Control3D;
  63876. };
  63877. /**
  63878. * BABYLON.Observable raised when the point picked by the pointer events changed
  63879. */
  63880. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  63881. /** @hidden */ private _sharedMaterials: {
  63882. [key: string]: BABYLON.Material;
  63883. };
  63884. /** Gets the hosting scene */
  63885. readonly scene: BABYLON.Scene;
  63886. /** Gets associated utility layer */
  63887. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  63888. /**
  63889. * Creates a new GUI3DManager
  63890. * @param scene
  63891. */
  63892. constructor(scene?: BABYLON.Scene);
  63893. private _handlePointerOut;
  63894. private _doPicking;
  63895. /**
  63896. * Gets the root container
  63897. */
  63898. readonly rootContainer: Container3D;
  63899. /**
  63900. * Gets a boolean indicating if the given control is in the root child list
  63901. * @param control defines the control to check
  63902. * @returns true if the control is in the root child list
  63903. */
  63904. containsControl(control: Control3D): boolean;
  63905. /**
  63906. * Adds a control to the root child list
  63907. * @param control defines the control to add
  63908. * @returns the current manager
  63909. */
  63910. addControl(control: Control3D): GUI3DManager;
  63911. /**
  63912. * Removes a control from the root child list
  63913. * @param control defines the control to remove
  63914. * @returns the current container
  63915. */
  63916. removeControl(control: Control3D): GUI3DManager;
  63917. /**
  63918. * Releases all associated resources
  63919. */
  63920. dispose(): void;
  63921. }
  63922. }
  63923. declare module BABYLON.GUI {
  63924. /**
  63925. * Class used to transport BABYLON.Vector3 information for pointer events
  63926. */
  63927. export class Vector3WithInfo extends BABYLON.Vector3 {
  63928. /** defines the current mouse button index */
  63929. buttonIndex: number;
  63930. /**
  63931. * Creates a new Vector3WithInfo
  63932. * @param source defines the vector3 data to transport
  63933. * @param buttonIndex defines the current mouse button index
  63934. */
  63935. constructor(source: BABYLON.Vector3,
  63936. /** defines the current mouse button index */
  63937. buttonIndex?: number);
  63938. }
  63939. }
  63940. declare module BABYLON.GUI {
  63941. /**
  63942. * Class used as base class for controls
  63943. */
  63944. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  63945. /** Defines the control name */
  63946. name?: string | undefined;
  63947. /** @hidden */ private _host: GUI3DManager;
  63948. private _node;
  63949. private _downCount;
  63950. private _enterCount;
  63951. private _downPointerIds;
  63952. private _isVisible;
  63953. /** Gets or sets the control position in world space */
  63954. position: BABYLON.Vector3;
  63955. /** Gets or sets the control scaling in world space */
  63956. scaling: BABYLON.Vector3;
  63957. /** Callback used to start pointer enter animation */
  63958. pointerEnterAnimation: () => void;
  63959. /** Callback used to start pointer out animation */
  63960. pointerOutAnimation: () => void;
  63961. /** Callback used to start pointer down animation */
  63962. pointerDownAnimation: () => void;
  63963. /** Callback used to start pointer up animation */
  63964. pointerUpAnimation: () => void;
  63965. /**
  63966. * An event triggered when the pointer move over the control
  63967. */
  63968. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  63969. /**
  63970. * An event triggered when the pointer move out of the control
  63971. */
  63972. onPointerOutObservable: BABYLON.Observable<Control3D>;
  63973. /**
  63974. * An event triggered when the pointer taps the control
  63975. */
  63976. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  63977. /**
  63978. * An event triggered when pointer is up
  63979. */
  63980. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  63981. /**
  63982. * An event triggered when a control is clicked on (with a mouse)
  63983. */
  63984. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  63985. /**
  63986. * An event triggered when pointer enters the control
  63987. */
  63988. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  63989. /**
  63990. * Gets or sets the parent container
  63991. */
  63992. parent: BABYLON.Nullable<Container3D>;
  63993. private _behaviors;
  63994. /**
  63995. * Gets the list of attached behaviors
  63996. * @see http://doc.babylonjs.com/features/behaviour
  63997. */
  63998. readonly behaviors: BABYLON.Behavior<Control3D>[];
  63999. /**
  64000. * Attach a behavior to the control
  64001. * @see http://doc.babylonjs.com/features/behaviour
  64002. * @param behavior defines the behavior to attach
  64003. * @returns the current control
  64004. */
  64005. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  64006. /**
  64007. * Remove an attached behavior
  64008. * @see http://doc.babylonjs.com/features/behaviour
  64009. * @param behavior defines the behavior to attach
  64010. * @returns the current control
  64011. */
  64012. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  64013. /**
  64014. * Gets an attached behavior by name
  64015. * @param name defines the name of the behavior to look for
  64016. * @see http://doc.babylonjs.com/features/behaviour
  64017. * @returns null if behavior was not found else the requested behavior
  64018. */
  64019. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  64020. /** Gets or sets a boolean indicating if the control is visible */
  64021. isVisible: boolean;
  64022. /**
  64023. * Creates a new control
  64024. * @param name defines the control name
  64025. */
  64026. constructor(
  64027. /** Defines the control name */
  64028. name?: string | undefined);
  64029. /**
  64030. * Gets a string representing the class name
  64031. */
  64032. readonly typeName: string;
  64033. /**
  64034. * Get the current class name of the control.
  64035. * @returns current class name
  64036. */
  64037. getClassName(): string;
  64038. protected _getTypeName(): string;
  64039. /**
  64040. * Gets the transform node used by this control
  64041. */
  64042. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  64043. /**
  64044. * Gets the mesh used to render this control
  64045. */
  64046. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64047. /**
  64048. * Link the control as child of the given node
  64049. * @param node defines the node to link to. Use null to unlink the control
  64050. * @returns the current control
  64051. */
  64052. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  64053. /** @hidden **/ private _prepareNode(scene: BABYLON.Scene): void;
  64054. /**
  64055. * Node creation.
  64056. * Can be overriden by children
  64057. * @param scene defines the scene where the node must be attached
  64058. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  64059. */
  64060. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  64061. /**
  64062. * Affect a material to the given mesh
  64063. * @param mesh defines the mesh which will represent the control
  64064. */
  64065. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  64066. /** @hidden */ private _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  64067. /** @hidden */ private _onPointerEnter(target: Control3D): boolean;
  64068. /** @hidden */ private _onPointerOut(target: Control3D): void;
  64069. /** @hidden */ private _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  64070. /** @hidden */ private _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64071. /** @hidden */
  64072. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  64073. /** @hidden */ private _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  64074. /** @hidden */ private _disposeNode(): void;
  64075. /**
  64076. * Releases all associated resources
  64077. */
  64078. dispose(): void;
  64079. }
  64080. }
  64081. declare module BABYLON.GUI {
  64082. /**
  64083. * Class used as a root to all buttons
  64084. */
  64085. export class AbstractButton3D extends Control3D {
  64086. /**
  64087. * Creates a new button
  64088. * @param name defines the control name
  64089. */
  64090. constructor(name?: string);
  64091. protected _getTypeName(): string;
  64092. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  64093. }
  64094. }
  64095. declare module BABYLON.GUI {
  64096. /**
  64097. * Class used to create a button in 3D
  64098. */
  64099. export class Button3D extends AbstractButton3D {
  64100. /** @hidden */
  64101. protected _currentMaterial: BABYLON.Material;
  64102. private _facadeTexture;
  64103. private _content;
  64104. private _contentResolution;
  64105. private _contentScaleRatio;
  64106. /**
  64107. * Gets or sets the texture resolution used to render content (512 by default)
  64108. */
  64109. contentResolution: BABYLON.int;
  64110. /**
  64111. * Gets or sets the texture scale ratio used to render content (2 by default)
  64112. */
  64113. contentScaleRatio: number;
  64114. protected _disposeFacadeTexture(): void;
  64115. protected _resetContent(): void;
  64116. /**
  64117. * Creates a new button
  64118. * @param name defines the control name
  64119. */
  64120. constructor(name?: string);
  64121. /**
  64122. * Gets or sets the GUI 2D content used to display the button's facade
  64123. */
  64124. content: Control;
  64125. /**
  64126. * Apply the facade texture (created from the content property).
  64127. * This function can be overloaded by child classes
  64128. * @param facadeTexture defines the AdvancedDynamicTexture to use
  64129. */
  64130. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  64131. protected _getTypeName(): string;
  64132. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  64133. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  64134. /**
  64135. * Releases all associated resources
  64136. */
  64137. dispose(): void;
  64138. }
  64139. }
  64140. declare module BABYLON.GUI {
  64141. /**
  64142. * Abstract class used to create a container panel deployed on the surface of a volume
  64143. */
  64144. export abstract class VolumeBasedPanel extends Container3D {
  64145. private _columns;
  64146. private _rows;
  64147. private _rowThenColum;
  64148. private _orientation;
  64149. protected _cellWidth: number;
  64150. protected _cellHeight: number;
  64151. /**
  64152. * Gets or sets the distance between elements
  64153. */
  64154. margin: number;
  64155. /**
  64156. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  64157. * | Value | Type | Description |
  64158. * | ----- | ----------------------------------- | ----------- |
  64159. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  64160. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  64161. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  64162. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  64163. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  64164. */
  64165. orientation: number;
  64166. /**
  64167. * Gets or sets the number of columns requested (10 by default).
  64168. * The panel will automatically compute the number of rows based on number of child controls.
  64169. */
  64170. columns: BABYLON.int;
  64171. /**
  64172. * Gets or sets a the number of rows requested.
  64173. * The panel will automatically compute the number of columns based on number of child controls.
  64174. */
  64175. rows: BABYLON.int;
  64176. /**
  64177. * Creates new VolumeBasedPanel
  64178. */
  64179. constructor();
  64180. protected _arrangeChildren(): void;
  64181. /** Child classes must implement this function to provide correct control positioning */
  64182. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  64183. /** Child classes can implement this function to provide additional processing */
  64184. protected _finalProcessing(): void;
  64185. }
  64186. }
  64187. declare module BABYLON.GUI {
  64188. /**
  64189. * Class used to create a container panel deployed on the surface of a cylinder
  64190. */
  64191. export class CylinderPanel extends VolumeBasedPanel {
  64192. private _radius;
  64193. /**
  64194. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  64195. */
  64196. radius: BABYLON.float;
  64197. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  64198. private _cylindricalMapping;
  64199. }
  64200. }
  64201. declare module BABYLON.GUI {
  64202. /** @hidden */
  64203. export var fluentVertexShader: {
  64204. name: string;
  64205. shader: string;
  64206. };
  64207. }
  64208. declare module BABYLON.GUI {
  64209. /** @hidden */
  64210. export var fluentPixelShader: {
  64211. name: string;
  64212. shader: string;
  64213. };
  64214. }
  64215. declare module BABYLON.GUI {
  64216. /** @hidden */
  64217. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  64218. INNERGLOW: boolean;
  64219. BORDER: boolean;
  64220. HOVERLIGHT: boolean;
  64221. TEXTURE: boolean;
  64222. constructor();
  64223. }
  64224. /**
  64225. * Class used to render controls with fluent desgin
  64226. */
  64227. export class FluentMaterial extends BABYLON.PushMaterial {
  64228. /**
  64229. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  64230. */
  64231. innerGlowColorIntensity: number;
  64232. /**
  64233. * Gets or sets the inner glow color (white by default)
  64234. */
  64235. innerGlowColor: BABYLON.Color3;
  64236. /**
  64237. * Gets or sets alpha value (default is 1.0)
  64238. */
  64239. alpha: number;
  64240. /**
  64241. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  64242. */
  64243. albedoColor: BABYLON.Color3;
  64244. /**
  64245. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  64246. */
  64247. renderBorders: boolean;
  64248. /**
  64249. * Gets or sets border width (default is 0.5)
  64250. */
  64251. borderWidth: number;
  64252. /**
  64253. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  64254. */
  64255. edgeSmoothingValue: number;
  64256. /**
  64257. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  64258. */
  64259. borderMinValue: number;
  64260. /**
  64261. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  64262. */
  64263. renderHoverLight: boolean;
  64264. /**
  64265. * Gets or sets the radius used to render the hover light (default is 1.0)
  64266. */
  64267. hoverRadius: number;
  64268. /**
  64269. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  64270. */
  64271. hoverColor: BABYLON.Color4;
  64272. /**
  64273. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  64274. */
  64275. hoverPosition: BABYLON.Vector3;
  64276. private _albedoTexture;
  64277. /** Gets or sets the texture to use for albedo color */
  64278. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  64279. /**
  64280. * Creates a new Fluent material
  64281. * @param name defines the name of the material
  64282. * @param scene defines the hosting scene
  64283. */
  64284. constructor(name: string, scene: BABYLON.Scene);
  64285. needAlphaBlending(): boolean;
  64286. needAlphaTesting(): boolean;
  64287. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64288. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64289. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64290. getActiveTextures(): BABYLON.BaseTexture[];
  64291. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64292. dispose(forceDisposeEffect?: boolean): void;
  64293. clone(name: string): FluentMaterial;
  64294. serialize(): any;
  64295. getClassName(): string;
  64296. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  64297. }
  64298. }
  64299. declare module BABYLON.GUI {
  64300. /**
  64301. * Class used to create a holographic button in 3D
  64302. */
  64303. export class HolographicButton extends Button3D {
  64304. private _backPlate;
  64305. private _textPlate;
  64306. private _frontPlate;
  64307. private _text;
  64308. private _imageUrl;
  64309. private _shareMaterials;
  64310. private _frontMaterial;
  64311. private _backMaterial;
  64312. private _plateMaterial;
  64313. private _pickedPointObserver;
  64314. private _tooltipFade;
  64315. private _tooltipTextBlock;
  64316. private _tooltipTexture;
  64317. private _tooltipMesh;
  64318. private _tooltipHoverObserver;
  64319. private _tooltipOutObserver;
  64320. private _disposeTooltip;
  64321. /**
  64322. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  64323. */
  64324. tooltipText: BABYLON.Nullable<string>;
  64325. /**
  64326. * Gets or sets text for the button
  64327. */
  64328. text: string;
  64329. /**
  64330. * Gets or sets the image url for the button
  64331. */
  64332. imageUrl: string;
  64333. /**
  64334. * Gets the back material used by this button
  64335. */
  64336. readonly backMaterial: FluentMaterial;
  64337. /**
  64338. * Gets the front material used by this button
  64339. */
  64340. readonly frontMaterial: FluentMaterial;
  64341. /**
  64342. * Gets the plate material used by this button
  64343. */
  64344. readonly plateMaterial: BABYLON.StandardMaterial;
  64345. /**
  64346. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  64347. */
  64348. readonly shareMaterials: boolean;
  64349. /**
  64350. * Creates a new button
  64351. * @param name defines the control name
  64352. */
  64353. constructor(name?: string, shareMaterials?: boolean);
  64354. protected _getTypeName(): string;
  64355. private _rebuildContent;
  64356. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  64357. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  64358. private _createBackMaterial;
  64359. private _createFrontMaterial;
  64360. private _createPlateMaterial;
  64361. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  64362. /**
  64363. * Releases all associated resources
  64364. */
  64365. dispose(): void;
  64366. }
  64367. }
  64368. declare module BABYLON.GUI {
  64369. /**
  64370. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  64371. */
  64372. export class MeshButton3D extends Button3D {
  64373. /** @hidden */
  64374. protected _currentMesh: BABYLON.Mesh;
  64375. /**
  64376. * Creates a new 3D button based on a mesh
  64377. * @param mesh mesh to become a 3D button
  64378. * @param name defines the control name
  64379. */
  64380. constructor(mesh: BABYLON.Mesh, name?: string);
  64381. protected _getTypeName(): string;
  64382. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  64383. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  64384. }
  64385. }
  64386. declare module BABYLON.GUI {
  64387. /**
  64388. * Class used to create a container panel deployed on the surface of a plane
  64389. */
  64390. export class PlanePanel extends VolumeBasedPanel {
  64391. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  64392. }
  64393. }
  64394. declare module BABYLON.GUI {
  64395. /**
  64396. * Class used to create a container panel where items get randomized planar mapping
  64397. */
  64398. export class ScatterPanel extends VolumeBasedPanel {
  64399. private _iteration;
  64400. /**
  64401. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  64402. */
  64403. iteration: BABYLON.float;
  64404. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  64405. private _scatterMapping;
  64406. protected _finalProcessing(): void;
  64407. }
  64408. }
  64409. declare module BABYLON.GUI {
  64410. /**
  64411. * Class used to create a container panel deployed on the surface of a sphere
  64412. */
  64413. export class SpherePanel extends VolumeBasedPanel {
  64414. private _radius;
  64415. /**
  64416. * Gets or sets the radius of the sphere where to project controls (5 by default)
  64417. */
  64418. radius: BABYLON.float;
  64419. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  64420. private _sphericalMapping;
  64421. }
  64422. }
  64423. declare module BABYLON.GUI {
  64424. /**
  64425. * Class used to create a stack panel in 3D on XY plane
  64426. */
  64427. export class StackPanel3D extends Container3D {
  64428. private _isVertical;
  64429. /**
  64430. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  64431. */
  64432. isVertical: boolean;
  64433. /**
  64434. * Gets or sets the distance between elements
  64435. */
  64436. margin: number;
  64437. /**
  64438. * Creates new StackPanel
  64439. * @param isVertical
  64440. */
  64441. constructor(isVertical?: boolean);
  64442. protected _arrangeChildren(): void;
  64443. }
  64444. }
  64445. declare module BABYLON {
  64446. /**
  64447. * Mode that determines the coordinate system to use.
  64448. */
  64449. export enum GLTFLoaderCoordinateSystemMode {
  64450. /**
  64451. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  64452. */
  64453. AUTO = 0,
  64454. /**
  64455. * Sets the useRightHandedSystem flag on the scene.
  64456. */
  64457. FORCE_RIGHT_HANDED = 1
  64458. }
  64459. /**
  64460. * Mode that determines what animations will start.
  64461. */
  64462. export enum GLTFLoaderAnimationStartMode {
  64463. /**
  64464. * No animation will start.
  64465. */
  64466. NONE = 0,
  64467. /**
  64468. * The first animation will start.
  64469. */
  64470. FIRST = 1,
  64471. /**
  64472. * All animations will start.
  64473. */
  64474. ALL = 2
  64475. }
  64476. /**
  64477. * Interface that contains the data for the glTF asset.
  64478. */
  64479. export interface IGLTFLoaderData {
  64480. /**
  64481. * Object that represents the glTF JSON.
  64482. */
  64483. json: Object;
  64484. /**
  64485. * The BIN chunk of a binary glTF.
  64486. */
  64487. bin: Nullable<ArrayBufferView>;
  64488. }
  64489. /**
  64490. * Interface for extending the loader.
  64491. */
  64492. export interface IGLTFLoaderExtension {
  64493. /**
  64494. * The name of this extension.
  64495. */
  64496. readonly name: string;
  64497. /**
  64498. * Defines whether this extension is enabled.
  64499. */
  64500. enabled: boolean;
  64501. }
  64502. /**
  64503. * Loader state.
  64504. */
  64505. export enum GLTFLoaderState {
  64506. /**
  64507. * The asset is loading.
  64508. */
  64509. LOADING = 0,
  64510. /**
  64511. * The asset is ready for rendering.
  64512. */
  64513. READY = 1,
  64514. /**
  64515. * The asset is completely loaded.
  64516. */
  64517. COMPLETE = 2
  64518. }
  64519. /** @hidden */
  64520. export interface IGLTFLoader extends IDisposable {
  64521. readonly state: Nullable<GLTFLoaderState>;
  64522. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  64523. meshes: AbstractMesh[];
  64524. particleSystems: IParticleSystem[];
  64525. skeletons: Skeleton[];
  64526. animationGroups: AnimationGroup[];
  64527. }>;
  64528. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  64529. }
  64530. /**
  64531. * File loader for loading glTF files into a scene.
  64532. */
  64533. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  64534. /** @hidden */ private static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  64535. /** @hidden */ private static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  64536. /**
  64537. * Raised when the asset has been parsed
  64538. */
  64539. onParsedObservable: Observable<IGLTFLoaderData>;
  64540. private _onParsedObserver;
  64541. /**
  64542. * Raised when the asset has been parsed
  64543. */
  64544. onParsed: (loaderData: IGLTFLoaderData) => void;
  64545. /**
  64546. * 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.
  64547. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  64548. * Defaults to true.
  64549. * @hidden
  64550. */
  64551. static IncrementalLoading: boolean;
  64552. /**
  64553. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  64554. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  64555. * @hidden
  64556. */
  64557. static HomogeneousCoordinates: boolean;
  64558. /**
  64559. * The coordinate system mode. Defaults to AUTO.
  64560. */
  64561. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  64562. /**
  64563. * The animation start mode. Defaults to FIRST.
  64564. */
  64565. animationStartMode: GLTFLoaderAnimationStartMode;
  64566. /**
  64567. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  64568. */
  64569. compileMaterials: boolean;
  64570. /**
  64571. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  64572. */
  64573. useClipPlane: boolean;
  64574. /**
  64575. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  64576. */
  64577. compileShadowGenerators: boolean;
  64578. /**
  64579. * Defines if the Alpha blended materials are only applied as coverage.
  64580. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  64581. * If true, no extra effects are applied to transparent pixels.
  64582. */
  64583. transparencyAsCoverage: boolean;
  64584. /**
  64585. * Function called before loading a url referenced by the asset.
  64586. */
  64587. preprocessUrlAsync: (url: string) => Promise<string>;
  64588. /**
  64589. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  64590. */
  64591. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  64592. private _onMeshLoadedObserver;
  64593. /**
  64594. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  64595. */
  64596. onMeshLoaded: (mesh: AbstractMesh) => void;
  64597. /**
  64598. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  64599. */
  64600. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  64601. private _onTextureLoadedObserver;
  64602. /**
  64603. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  64604. */
  64605. onTextureLoaded: (texture: BaseTexture) => void;
  64606. /**
  64607. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  64608. */
  64609. readonly onMaterialLoadedObservable: Observable<Material>;
  64610. private _onMaterialLoadedObserver;
  64611. /**
  64612. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  64613. */
  64614. onMaterialLoaded: (material: Material) => void;
  64615. /**
  64616. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  64617. */
  64618. readonly onCameraLoadedObservable: Observable<Camera>;
  64619. private _onCameraLoadedObserver;
  64620. /**
  64621. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  64622. */
  64623. onCameraLoaded: (camera: Camera) => void;
  64624. /**
  64625. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  64626. * For assets with LODs, raised when all of the LODs are complete.
  64627. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  64628. */
  64629. readonly onCompleteObservable: Observable<void>;
  64630. private _onCompleteObserver;
  64631. /**
  64632. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  64633. * For assets with LODs, raised when all of the LODs are complete.
  64634. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  64635. */
  64636. onComplete: () => void;
  64637. /**
  64638. * Observable raised when an error occurs.
  64639. */
  64640. readonly onErrorObservable: Observable<any>;
  64641. private _onErrorObserver;
  64642. /**
  64643. * Callback raised when an error occurs.
  64644. */
  64645. onError: (reason: any) => void;
  64646. /**
  64647. * Observable raised after the loader is disposed.
  64648. */
  64649. readonly onDisposeObservable: Observable<void>;
  64650. private _onDisposeObserver;
  64651. /**
  64652. * Callback raised after the loader is disposed.
  64653. */
  64654. onDispose: () => void;
  64655. /**
  64656. * Observable raised after a loader extension is created.
  64657. * Set additional options for a loader extension in this event.
  64658. */
  64659. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  64660. private _onExtensionLoadedObserver;
  64661. /**
  64662. * Callback raised after a loader extension is created.
  64663. */
  64664. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  64665. /**
  64666. * Defines if the loader logging is enabled.
  64667. */
  64668. loggingEnabled: boolean;
  64669. /**
  64670. * Defines if the loader should capture performance counters.
  64671. */
  64672. capturePerformanceCounters: boolean;
  64673. /**
  64674. * Defines if the loader should validate the asset.
  64675. */
  64676. validate: boolean;
  64677. /**
  64678. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  64679. */
  64680. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  64681. private _onValidatedObserver;
  64682. /**
  64683. * Callback raised after a loader extension is created.
  64684. */
  64685. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  64686. private _loader;
  64687. /**
  64688. * Name of the loader ("gltf")
  64689. */
  64690. name: string;
  64691. /**
  64692. * Supported file extensions of the loader (.gltf, .glb)
  64693. */
  64694. extensions: ISceneLoaderPluginExtensions;
  64695. /**
  64696. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  64697. */
  64698. dispose(): void;
  64699. /** @hidden */ private _clear(): void;
  64700. /**
  64701. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  64702. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  64703. * @param scene the scene the meshes should be added to
  64704. * @param data the glTF data to load
  64705. * @param rootUrl root url to load from
  64706. * @param onProgress event that fires when loading progress has occured
  64707. * @param fileName Defines the name of the file to load
  64708. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  64709. */
  64710. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  64711. meshes: AbstractMesh[];
  64712. particleSystems: IParticleSystem[];
  64713. skeletons: Skeleton[];
  64714. animationGroups: AnimationGroup[];
  64715. }>;
  64716. /**
  64717. * Imports all objects from the loaded glTF data and adds them to the scene
  64718. * @param scene the scene the objects should be added to
  64719. * @param data the glTF data to load
  64720. * @param rootUrl root url to load from
  64721. * @param onProgress event that fires when loading progress has occured
  64722. * @param fileName Defines the name of the file to load
  64723. * @returns a promise which completes when objects have been loaded to the scene
  64724. */
  64725. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  64726. /**
  64727. * Load into an asset container.
  64728. * @param scene The scene to load into
  64729. * @param data The data to import
  64730. * @param rootUrl The root url for scene and resources
  64731. * @param onProgress The callback when the load progresses
  64732. * @param fileName Defines the name of the file to load
  64733. * @returns The loaded asset container
  64734. */
  64735. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  64736. /**
  64737. * If the data string can be loaded directly.
  64738. * @param data string contianing the file data
  64739. * @returns if the data can be loaded directly
  64740. */
  64741. canDirectLoad(data: string): boolean;
  64742. /**
  64743. * Rewrites a url by combining a root url and response url.
  64744. */
  64745. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  64746. /**
  64747. * Instantiates a glTF file loader plugin.
  64748. * @returns the created plugin
  64749. */
  64750. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  64751. /**
  64752. * The loader state or null if the loader is not active.
  64753. */
  64754. readonly loaderState: Nullable<GLTFLoaderState>;
  64755. /**
  64756. * Returns a promise that resolves when the asset is completely loaded.
  64757. * @returns a promise that resolves when the asset is completely loaded.
  64758. */
  64759. whenCompleteAsync(): Promise<void>;
  64760. private _parseAsync;
  64761. private _validateAsync;
  64762. private _getLoader;
  64763. private _unpackBinary;
  64764. private _unpackBinaryV1;
  64765. private _unpackBinaryV2;
  64766. private static _parseVersion;
  64767. private static _compareVersion;
  64768. private static _decodeBufferToText;
  64769. private static readonly _logSpaces;
  64770. private _logIndentLevel;
  64771. private _loggingEnabled;
  64772. /** @hidden */ private _log: (message: string) => void;
  64773. /** @hidden */ private _logOpen(message: string): void;
  64774. /** @hidden */ private _logClose(): void;
  64775. private _logEnabled;
  64776. private _logDisabled;
  64777. private _capturePerformanceCounters;
  64778. /** @hidden */ private _startPerformanceCounter: (counterName: string) => void;
  64779. /** @hidden */ private _endPerformanceCounter: (counterName: string) => void;
  64780. private _startPerformanceCounterEnabled;
  64781. private _startPerformanceCounterDisabled;
  64782. private _endPerformanceCounterEnabled;
  64783. private _endPerformanceCounterDisabled;
  64784. }
  64785. }
  64786. declare module BABYLON.GLTF1 {
  64787. /**
  64788. * Enums
  64789. * @hidden
  64790. */
  64791. export enum EComponentType {
  64792. BYTE = 5120,
  64793. UNSIGNED_BYTE = 5121,
  64794. SHORT = 5122,
  64795. UNSIGNED_SHORT = 5123,
  64796. FLOAT = 5126
  64797. }
  64798. /** @hidden */
  64799. export enum EShaderType {
  64800. FRAGMENT = 35632,
  64801. VERTEX = 35633
  64802. }
  64803. /** @hidden */
  64804. export enum EParameterType {
  64805. BYTE = 5120,
  64806. UNSIGNED_BYTE = 5121,
  64807. SHORT = 5122,
  64808. UNSIGNED_SHORT = 5123,
  64809. INT = 5124,
  64810. UNSIGNED_INT = 5125,
  64811. FLOAT = 5126,
  64812. FLOAT_VEC2 = 35664,
  64813. FLOAT_VEC3 = 35665,
  64814. FLOAT_VEC4 = 35666,
  64815. INT_VEC2 = 35667,
  64816. INT_VEC3 = 35668,
  64817. INT_VEC4 = 35669,
  64818. BOOL = 35670,
  64819. BOOL_VEC2 = 35671,
  64820. BOOL_VEC3 = 35672,
  64821. BOOL_VEC4 = 35673,
  64822. FLOAT_MAT2 = 35674,
  64823. FLOAT_MAT3 = 35675,
  64824. FLOAT_MAT4 = 35676,
  64825. SAMPLER_2D = 35678
  64826. }
  64827. /** @hidden */
  64828. export enum ETextureWrapMode {
  64829. CLAMP_TO_EDGE = 33071,
  64830. MIRRORED_REPEAT = 33648,
  64831. REPEAT = 10497
  64832. }
  64833. /** @hidden */
  64834. export enum ETextureFilterType {
  64835. NEAREST = 9728,
  64836. LINEAR = 9728,
  64837. NEAREST_MIPMAP_NEAREST = 9984,
  64838. LINEAR_MIPMAP_NEAREST = 9985,
  64839. NEAREST_MIPMAP_LINEAR = 9986,
  64840. LINEAR_MIPMAP_LINEAR = 9987
  64841. }
  64842. /** @hidden */
  64843. export enum ETextureFormat {
  64844. ALPHA = 6406,
  64845. RGB = 6407,
  64846. RGBA = 6408,
  64847. LUMINANCE = 6409,
  64848. LUMINANCE_ALPHA = 6410
  64849. }
  64850. /** @hidden */
  64851. export enum ECullingType {
  64852. FRONT = 1028,
  64853. BACK = 1029,
  64854. FRONT_AND_BACK = 1032
  64855. }
  64856. /** @hidden */
  64857. export enum EBlendingFunction {
  64858. ZERO = 0,
  64859. ONE = 1,
  64860. SRC_COLOR = 768,
  64861. ONE_MINUS_SRC_COLOR = 769,
  64862. DST_COLOR = 774,
  64863. ONE_MINUS_DST_COLOR = 775,
  64864. SRC_ALPHA = 770,
  64865. ONE_MINUS_SRC_ALPHA = 771,
  64866. DST_ALPHA = 772,
  64867. ONE_MINUS_DST_ALPHA = 773,
  64868. CONSTANT_COLOR = 32769,
  64869. ONE_MINUS_CONSTANT_COLOR = 32770,
  64870. CONSTANT_ALPHA = 32771,
  64871. ONE_MINUS_CONSTANT_ALPHA = 32772,
  64872. SRC_ALPHA_SATURATE = 776
  64873. }
  64874. /** @hidden */
  64875. export interface IGLTFProperty {
  64876. extensions?: {
  64877. [key: string]: any;
  64878. };
  64879. extras?: Object;
  64880. }
  64881. /** @hidden */
  64882. export interface IGLTFChildRootProperty extends IGLTFProperty {
  64883. name?: string;
  64884. }
  64885. /** @hidden */
  64886. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  64887. bufferView: string;
  64888. byteOffset: number;
  64889. byteStride: number;
  64890. count: number;
  64891. type: string;
  64892. componentType: EComponentType;
  64893. max?: number[];
  64894. min?: number[];
  64895. name?: string;
  64896. }
  64897. /** @hidden */
  64898. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  64899. buffer: string;
  64900. byteOffset: number;
  64901. byteLength: number;
  64902. byteStride: number;
  64903. target?: number;
  64904. }
  64905. /** @hidden */
  64906. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  64907. uri: string;
  64908. byteLength?: number;
  64909. type?: string;
  64910. }
  64911. /** @hidden */
  64912. export interface IGLTFShader extends IGLTFChildRootProperty {
  64913. uri: string;
  64914. type: EShaderType;
  64915. }
  64916. /** @hidden */
  64917. export interface IGLTFProgram extends IGLTFChildRootProperty {
  64918. attributes: string[];
  64919. fragmentShader: string;
  64920. vertexShader: string;
  64921. }
  64922. /** @hidden */
  64923. export interface IGLTFTechniqueParameter {
  64924. type: number;
  64925. count?: number;
  64926. semantic?: string;
  64927. node?: string;
  64928. value?: number | boolean | string | Array<any>;
  64929. source?: string;
  64930. babylonValue?: any;
  64931. }
  64932. /** @hidden */
  64933. export interface IGLTFTechniqueCommonProfile {
  64934. lightingModel: string;
  64935. texcoordBindings: Object;
  64936. parameters?: Array<any>;
  64937. }
  64938. /** @hidden */
  64939. export interface IGLTFTechniqueStatesFunctions {
  64940. blendColor?: number[];
  64941. blendEquationSeparate?: number[];
  64942. blendFuncSeparate?: number[];
  64943. colorMask: boolean[];
  64944. cullFace: number[];
  64945. }
  64946. /** @hidden */
  64947. export interface IGLTFTechniqueStates {
  64948. enable: number[];
  64949. functions: IGLTFTechniqueStatesFunctions;
  64950. }
  64951. /** @hidden */
  64952. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  64953. parameters: {
  64954. [key: string]: IGLTFTechniqueParameter;
  64955. };
  64956. program: string;
  64957. attributes: {
  64958. [key: string]: string;
  64959. };
  64960. uniforms: {
  64961. [key: string]: string;
  64962. };
  64963. states: IGLTFTechniqueStates;
  64964. }
  64965. /** @hidden */
  64966. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  64967. technique?: string;
  64968. values: string[];
  64969. }
  64970. /** @hidden */
  64971. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  64972. attributes: {
  64973. [key: string]: string;
  64974. };
  64975. indices: string;
  64976. material: string;
  64977. mode?: number;
  64978. }
  64979. /** @hidden */
  64980. export interface IGLTFMesh extends IGLTFChildRootProperty {
  64981. primitives: IGLTFMeshPrimitive[];
  64982. }
  64983. /** @hidden */
  64984. export interface IGLTFImage extends IGLTFChildRootProperty {
  64985. uri: string;
  64986. }
  64987. /** @hidden */
  64988. export interface IGLTFSampler extends IGLTFChildRootProperty {
  64989. magFilter?: number;
  64990. minFilter?: number;
  64991. wrapS?: number;
  64992. wrapT?: number;
  64993. }
  64994. /** @hidden */
  64995. export interface IGLTFTexture extends IGLTFChildRootProperty {
  64996. sampler: string;
  64997. source: string;
  64998. format?: ETextureFormat;
  64999. internalFormat?: ETextureFormat;
  65000. target?: number;
  65001. type?: number;
  65002. babylonTexture?: Texture;
  65003. }
  65004. /** @hidden */
  65005. export interface IGLTFAmbienLight {
  65006. color?: number[];
  65007. }
  65008. /** @hidden */
  65009. export interface IGLTFDirectionalLight {
  65010. color?: number[];
  65011. }
  65012. /** @hidden */
  65013. export interface IGLTFPointLight {
  65014. color?: number[];
  65015. constantAttenuation?: number;
  65016. linearAttenuation?: number;
  65017. quadraticAttenuation?: number;
  65018. }
  65019. /** @hidden */
  65020. export interface IGLTFSpotLight {
  65021. color?: number[];
  65022. constantAttenuation?: number;
  65023. fallOfAngle?: number;
  65024. fallOffExponent?: number;
  65025. linearAttenuation?: number;
  65026. quadraticAttenuation?: number;
  65027. }
  65028. /** @hidden */
  65029. export interface IGLTFLight extends IGLTFChildRootProperty {
  65030. type: string;
  65031. }
  65032. /** @hidden */
  65033. export interface IGLTFCameraOrthographic {
  65034. xmag: number;
  65035. ymag: number;
  65036. zfar: number;
  65037. znear: number;
  65038. }
  65039. /** @hidden */
  65040. export interface IGLTFCameraPerspective {
  65041. aspectRatio: number;
  65042. yfov: number;
  65043. zfar: number;
  65044. znear: number;
  65045. }
  65046. /** @hidden */
  65047. export interface IGLTFCamera extends IGLTFChildRootProperty {
  65048. type: string;
  65049. }
  65050. /** @hidden */
  65051. export interface IGLTFAnimationChannelTarget {
  65052. id: string;
  65053. path: string;
  65054. }
  65055. /** @hidden */
  65056. export interface IGLTFAnimationChannel {
  65057. sampler: string;
  65058. target: IGLTFAnimationChannelTarget;
  65059. }
  65060. /** @hidden */
  65061. export interface IGLTFAnimationSampler {
  65062. input: string;
  65063. output: string;
  65064. interpolation?: string;
  65065. }
  65066. /** @hidden */
  65067. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  65068. channels?: IGLTFAnimationChannel[];
  65069. parameters?: {
  65070. [key: string]: string;
  65071. };
  65072. samplers?: {
  65073. [key: string]: IGLTFAnimationSampler;
  65074. };
  65075. }
  65076. /** @hidden */
  65077. export interface IGLTFNodeInstanceSkin {
  65078. skeletons: string[];
  65079. skin: string;
  65080. meshes: string[];
  65081. }
  65082. /** @hidden */
  65083. export interface IGLTFSkins extends IGLTFChildRootProperty {
  65084. bindShapeMatrix: number[];
  65085. inverseBindMatrices: string;
  65086. jointNames: string[];
  65087. babylonSkeleton?: Skeleton;
  65088. }
  65089. /** @hidden */
  65090. export interface IGLTFNode extends IGLTFChildRootProperty {
  65091. camera?: string;
  65092. children: string[];
  65093. skin?: string;
  65094. jointName?: string;
  65095. light?: string;
  65096. matrix: number[];
  65097. mesh?: string;
  65098. meshes?: string[];
  65099. rotation?: number[];
  65100. scale?: number[];
  65101. translation?: number[];
  65102. babylonNode?: Node;
  65103. }
  65104. /** @hidden */
  65105. export interface IGLTFScene extends IGLTFChildRootProperty {
  65106. nodes: string[];
  65107. }
  65108. /** @hidden */
  65109. export interface IGLTFRuntime {
  65110. extensions: {
  65111. [key: string]: any;
  65112. };
  65113. accessors: {
  65114. [key: string]: IGLTFAccessor;
  65115. };
  65116. buffers: {
  65117. [key: string]: IGLTFBuffer;
  65118. };
  65119. bufferViews: {
  65120. [key: string]: IGLTFBufferView;
  65121. };
  65122. meshes: {
  65123. [key: string]: IGLTFMesh;
  65124. };
  65125. lights: {
  65126. [key: string]: IGLTFLight;
  65127. };
  65128. cameras: {
  65129. [key: string]: IGLTFCamera;
  65130. };
  65131. nodes: {
  65132. [key: string]: IGLTFNode;
  65133. };
  65134. images: {
  65135. [key: string]: IGLTFImage;
  65136. };
  65137. textures: {
  65138. [key: string]: IGLTFTexture;
  65139. };
  65140. shaders: {
  65141. [key: string]: IGLTFShader;
  65142. };
  65143. programs: {
  65144. [key: string]: IGLTFProgram;
  65145. };
  65146. samplers: {
  65147. [key: string]: IGLTFSampler;
  65148. };
  65149. techniques: {
  65150. [key: string]: IGLTFTechnique;
  65151. };
  65152. materials: {
  65153. [key: string]: IGLTFMaterial;
  65154. };
  65155. animations: {
  65156. [key: string]: IGLTFAnimation;
  65157. };
  65158. skins: {
  65159. [key: string]: IGLTFSkins;
  65160. };
  65161. currentScene?: Object;
  65162. scenes: {
  65163. [key: string]: IGLTFScene;
  65164. };
  65165. extensionsUsed: string[];
  65166. extensionsRequired?: string[];
  65167. buffersCount: number;
  65168. shaderscount: number;
  65169. scene: Scene;
  65170. rootUrl: string;
  65171. loadedBufferCount: number;
  65172. loadedBufferViews: {
  65173. [name: string]: ArrayBufferView;
  65174. };
  65175. loadedShaderCount: number;
  65176. importOnlyMeshes: boolean;
  65177. importMeshesNames?: string[];
  65178. dummyNodes: Node[];
  65179. }
  65180. /** @hidden */
  65181. export interface INodeToRoot {
  65182. bone: Bone;
  65183. node: IGLTFNode;
  65184. id: string;
  65185. }
  65186. /** @hidden */
  65187. export interface IJointNode {
  65188. node: IGLTFNode;
  65189. id: string;
  65190. }
  65191. }
  65192. declare module BABYLON.GLTF1 {
  65193. /**
  65194. * Utils functions for GLTF
  65195. * @hidden
  65196. */
  65197. export class GLTFUtils {
  65198. /**
  65199. * Sets the given "parameter" matrix
  65200. * @param scene: the Scene object
  65201. * @param source: the source node where to pick the matrix
  65202. * @param parameter: the GLTF technique parameter
  65203. * @param uniformName: the name of the shader's uniform
  65204. * @param shaderMaterial: the shader material
  65205. */
  65206. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  65207. /**
  65208. * Sets the given "parameter" matrix
  65209. * @param shaderMaterial: the shader material
  65210. * @param uniform: the name of the shader's uniform
  65211. * @param value: the value of the uniform
  65212. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  65213. */
  65214. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  65215. /**
  65216. * Returns the wrap mode of the texture
  65217. * @param mode: the mode value
  65218. */
  65219. static GetWrapMode(mode: number): number;
  65220. /**
  65221. * Returns the byte stride giving an accessor
  65222. * @param accessor: the GLTF accessor objet
  65223. */
  65224. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  65225. /**
  65226. * Returns the texture filter mode giving a mode value
  65227. * @param mode: the filter mode value
  65228. */
  65229. static GetTextureFilterMode(mode: number): ETextureFilterType;
  65230. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  65231. /**
  65232. * Returns a buffer from its accessor
  65233. * @param gltfRuntime: the GLTF runtime
  65234. * @param accessor: the GLTF accessor
  65235. */
  65236. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  65237. /**
  65238. * Decodes a buffer view into a string
  65239. * @param view: the buffer view
  65240. */
  65241. static DecodeBufferToText(view: ArrayBufferView): string;
  65242. /**
  65243. * Returns the default material of gltf. Related to
  65244. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  65245. * @param scene: the Babylon.js scene
  65246. */
  65247. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  65248. private static _DefaultMaterial;
  65249. }
  65250. }
  65251. declare module BABYLON.GLTF1 {
  65252. /**
  65253. * Implementation of the base glTF spec
  65254. * @hidden
  65255. */
  65256. export class GLTFLoaderBase {
  65257. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  65258. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  65259. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  65260. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  65261. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  65262. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  65263. }
  65264. /**
  65265. * glTF V1 Loader
  65266. * @hidden
  65267. */
  65268. export class GLTFLoader implements IGLTFLoader {
  65269. static Extensions: {
  65270. [name: string]: GLTFLoaderExtension;
  65271. };
  65272. static RegisterExtension(extension: GLTFLoaderExtension): void;
  65273. state: Nullable<GLTFLoaderState>;
  65274. dispose(): void;
  65275. private _importMeshAsync;
  65276. /**
  65277. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  65278. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  65279. * @param scene the scene the meshes should be added to
  65280. * @param data gltf data containing information of the meshes in a loaded file
  65281. * @param rootUrl root url to load from
  65282. * @param onProgress event that fires when loading progress has occured
  65283. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  65284. */
  65285. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  65286. meshes: AbstractMesh[];
  65287. particleSystems: IParticleSystem[];
  65288. skeletons: Skeleton[];
  65289. animationGroups: AnimationGroup[];
  65290. }>;
  65291. private _loadAsync;
  65292. /**
  65293. * Imports all objects from a loaded gltf file and adds them to the scene
  65294. * @param scene the scene the objects should be added to
  65295. * @param data gltf data containing information of the meshes in a loaded file
  65296. * @param rootUrl root url to load from
  65297. * @param onProgress event that fires when loading progress has occured
  65298. * @returns a promise which completes when objects have been loaded to the scene
  65299. */
  65300. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  65301. private _loadShadersAsync;
  65302. private _loadBuffersAsync;
  65303. private _createNodes;
  65304. }
  65305. /** @hidden */
  65306. export abstract class GLTFLoaderExtension {
  65307. private _name;
  65308. constructor(name: string);
  65309. readonly name: string;
  65310. /**
  65311. * Defines an override for loading the runtime
  65312. * Return true to stop further extensions from loading the runtime
  65313. */
  65314. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  65315. /**
  65316. * Defines an onverride for creating gltf runtime
  65317. * Return true to stop further extensions from creating the runtime
  65318. */
  65319. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  65320. /**
  65321. * Defines an override for loading buffers
  65322. * Return true to stop further extensions from loading this buffer
  65323. */
  65324. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  65325. /**
  65326. * Defines an override for loading texture buffers
  65327. * Return true to stop further extensions from loading this texture data
  65328. */
  65329. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  65330. /**
  65331. * Defines an override for creating textures
  65332. * Return true to stop further extensions from loading this texture
  65333. */
  65334. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  65335. /**
  65336. * Defines an override for loading shader strings
  65337. * Return true to stop further extensions from loading this shader data
  65338. */
  65339. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  65340. /**
  65341. * Defines an override for loading materials
  65342. * Return true to stop further extensions from loading this material
  65343. */
  65344. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  65345. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  65346. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  65347. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  65348. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  65349. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  65350. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  65351. private static LoadTextureBufferAsync;
  65352. private static CreateTextureAsync;
  65353. private static ApplyExtensions;
  65354. }
  65355. }
  65356. declare module BABYLON.GLTF1 {
  65357. /** @hidden */
  65358. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  65359. private _bin;
  65360. constructor();
  65361. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  65362. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  65363. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  65364. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  65365. }
  65366. }
  65367. declare module BABYLON.GLTF1 {
  65368. /** @hidden */
  65369. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  65370. constructor();
  65371. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  65372. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  65373. private _loadTexture;
  65374. }
  65375. }
  65376. declare module BABYLON.GLTF2.Loader {
  65377. /**
  65378. * Loader interface with an index field.
  65379. */
  65380. export interface IArrayItem {
  65381. /**
  65382. * The index of this item in the array.
  65383. */
  65384. index: number;
  65385. }
  65386. /**
  65387. * Loader interface with additional members.
  65388. */
  65389. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  65390. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  65391. /** @hidden */ private _babylonVertexBuffer?: Promise<VertexBuffer>;
  65392. }
  65393. /**
  65394. * Loader interface with additional members.
  65395. */
  65396. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  65397. }
  65398. /** @hidden */
  65399. export interface _IAnimationSamplerData {
  65400. input: Float32Array;
  65401. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  65402. output: Float32Array;
  65403. }
  65404. /**
  65405. * Loader interface with additional members.
  65406. */
  65407. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  65408. /** @hidden */ private _data?: Promise<_IAnimationSamplerData>;
  65409. }
  65410. /**
  65411. * Loader interface with additional members.
  65412. */
  65413. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  65414. channels: IAnimationChannel[];
  65415. samplers: IAnimationSampler[];
  65416. /** @hidden */ private _babylonAnimationGroup?: AnimationGroup;
  65417. }
  65418. /**
  65419. * Loader interface with additional members.
  65420. */
  65421. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  65422. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  65423. }
  65424. /**
  65425. * Loader interface with additional members.
  65426. */
  65427. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  65428. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  65429. /** @hidden */ private _babylonBuffer?: Promise<Buffer>;
  65430. }
  65431. /**
  65432. * Loader interface with additional members.
  65433. */
  65434. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  65435. }
  65436. /**
  65437. * Loader interface with additional members.
  65438. */
  65439. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  65440. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  65441. }
  65442. /**
  65443. * Loader interface with additional members.
  65444. */
  65445. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  65446. }
  65447. /**
  65448. * Loader interface with additional members.
  65449. */
  65450. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  65451. }
  65452. /**
  65453. * Loader interface with additional members.
  65454. */
  65455. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  65456. baseColorTexture?: ITextureInfo;
  65457. metallicRoughnessTexture?: ITextureInfo;
  65458. }
  65459. /**
  65460. * Loader interface with additional members.
  65461. */
  65462. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  65463. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  65464. normalTexture?: IMaterialNormalTextureInfo;
  65465. occlusionTexture?: IMaterialOcclusionTextureInfo;
  65466. emissiveTexture?: ITextureInfo;
  65467. /** @hidden */ private _data?: {
  65468. [babylonDrawMode: number]: {
  65469. babylonMaterial: Material;
  65470. babylonMeshes: AbstractMesh[];
  65471. promise: Promise<void>;
  65472. };
  65473. };
  65474. }
  65475. /**
  65476. * Loader interface with additional members.
  65477. */
  65478. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  65479. primitives: IMeshPrimitive[];
  65480. }
  65481. /**
  65482. * Loader interface with additional members.
  65483. */
  65484. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  65485. /** @hidden */ private _instanceData?: {
  65486. babylonSourceMesh: Mesh;
  65487. promise: Promise<any>;
  65488. };
  65489. }
  65490. /**
  65491. * Loader interface with additional members.
  65492. */
  65493. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  65494. /**
  65495. * The parent glTF node.
  65496. */
  65497. parent?: INode;
  65498. /** @hidden */ private _babylonTransformNode?: TransformNode;
  65499. /** @hidden */ private _primitiveBabylonMeshes?: AbstractMesh[];
  65500. /** @hidden */ private _babylonBones?: Bone[];
  65501. /** @hidden */ private _numMorphTargets?: number;
  65502. }
  65503. /** @hidden */
  65504. export interface _ISamplerData {
  65505. noMipMaps: boolean;
  65506. samplingMode: number;
  65507. wrapU: number;
  65508. wrapV: number;
  65509. }
  65510. /**
  65511. * Loader interface with additional members.
  65512. */
  65513. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  65514. /** @hidden */ private _data?: _ISamplerData;
  65515. }
  65516. /**
  65517. * Loader interface with additional members.
  65518. */
  65519. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  65520. }
  65521. /**
  65522. * Loader interface with additional members.
  65523. */
  65524. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  65525. /** @hidden */ private _data?: {
  65526. babylonSkeleton: Skeleton;
  65527. promise: Promise<void>;
  65528. };
  65529. }
  65530. /**
  65531. * Loader interface with additional members.
  65532. */
  65533. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  65534. }
  65535. /**
  65536. * Loader interface with additional members.
  65537. */
  65538. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  65539. }
  65540. /**
  65541. * Loader interface with additional members.
  65542. */
  65543. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  65544. accessors?: IAccessor[];
  65545. animations?: IAnimation[];
  65546. buffers?: IBuffer[];
  65547. bufferViews?: IBufferView[];
  65548. cameras?: ICamera[];
  65549. images?: IImage[];
  65550. materials?: IMaterial[];
  65551. meshes?: IMesh[];
  65552. nodes?: INode[];
  65553. samplers?: ISampler[];
  65554. scenes?: IScene[];
  65555. skins?: ISkin[];
  65556. textures?: ITexture[];
  65557. }
  65558. }
  65559. declare module BABYLON.GLTF2 {
  65560. /**
  65561. * Interface for a glTF loader extension.
  65562. */
  65563. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  65564. /**
  65565. * Called after the loader state changes to LOADING.
  65566. */
  65567. onLoading?(): void;
  65568. /**
  65569. * Called after the loader state changes to READY.
  65570. */
  65571. onReady?(): void;
  65572. /**
  65573. * Define this method to modify the default behavior when loading scenes.
  65574. * @param context The context when loading the asset
  65575. * @param scene The glTF scene property
  65576. * @returns A promise that resolves when the load is complete or null if not handled
  65577. */
  65578. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  65579. /**
  65580. * Define this method to modify the default behavior when loading nodes.
  65581. * @param context The context when loading the asset
  65582. * @param node The glTF node property
  65583. * @param assign A function called synchronously after parsing the glTF properties
  65584. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  65585. */
  65586. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65587. /**
  65588. * Define this method to modify the default behavior when loading cameras.
  65589. * @param context The context when loading the asset
  65590. * @param camera The glTF camera property
  65591. * @param assign A function called synchronously after parsing the glTF properties
  65592. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  65593. */
  65594. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  65595. /**
  65596. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  65597. * @param context The context when loading the asset
  65598. * @param primitive The glTF mesh primitive property
  65599. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  65600. */ private _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  65601. /**
  65602. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  65603. * @param context The context when loading the asset
  65604. * @param name The mesh name when loading the asset
  65605. * @param node The glTF node when loading the asset
  65606. * @param mesh The glTF mesh when loading the asset
  65607. * @param primitive The glTF mesh primitive property
  65608. * @param assign A function called synchronously after parsing the glTF properties
  65609. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  65610. */ private _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  65611. /**
  65612. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  65613. * @param context The context when loading the asset
  65614. * @param material The glTF material property
  65615. * @param assign A function called synchronously after parsing the glTF properties
  65616. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  65617. */ private _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  65618. /**
  65619. * Define this method to modify the default behavior when creating materials.
  65620. * @param context The context when loading the asset
  65621. * @param material The glTF material property
  65622. * @param babylonDrawMode The draw mode for the Babylon material
  65623. * @returns The Babylon material or null if not handled
  65624. */
  65625. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  65626. /**
  65627. * Define this method to modify the default behavior when loading material properties.
  65628. * @param context The context when loading the asset
  65629. * @param material The glTF material property
  65630. * @param babylonMaterial The Babylon material
  65631. * @returns A promise that resolves when the load is complete or null if not handled
  65632. */
  65633. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65634. /**
  65635. * Define this method to modify the default behavior when loading texture infos.
  65636. * @param context The context when loading the asset
  65637. * @param textureInfo The glTF texture info property
  65638. * @param assign A function called synchronously after parsing the glTF properties
  65639. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  65640. */
  65641. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  65642. /**
  65643. * Define this method to modify the default behavior when loading animations.
  65644. * @param context The context when loading the asset
  65645. * @param animation The glTF animation property
  65646. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  65647. */
  65648. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  65649. /**
  65650. * @hidden Define this method to modify the default behavior when loading skins.
  65651. * @param context The context when loading the asset
  65652. * @param node The glTF node property
  65653. * @param skin The glTF skin property
  65654. * @returns A promise that resolves when the load is complete or null if not handled
  65655. */ private _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  65656. /**
  65657. * @hidden Define this method to modify the default behavior when loading uris.
  65658. * @param context The context when loading the asset
  65659. * @param property The glTF property associated with the uri
  65660. * @param uri The uri to load
  65661. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  65662. */ private _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  65663. }
  65664. }
  65665. declare module BABYLON.GLTF2 {
  65666. /**
  65667. * Helper class for working with arrays when loading the glTF asset
  65668. */
  65669. export class ArrayItem {
  65670. /**
  65671. * Gets an item from the given array.
  65672. * @param context The context when loading the asset
  65673. * @param array The array to get the item from
  65674. * @param index The index to the array
  65675. * @returns The array item
  65676. */
  65677. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  65678. /**
  65679. * Assign an `index` field to each item of the given array.
  65680. * @param array The array of items
  65681. */
  65682. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  65683. }
  65684. /**
  65685. * The glTF 2.0 loader
  65686. */
  65687. export class GLTFLoader implements IGLTFLoader {
  65688. /** @hidden */ private _completePromises: Promise<any>[];
  65689. private _disposed;
  65690. private _parent;
  65691. private _state;
  65692. private _extensions;
  65693. private _rootUrl;
  65694. private _fileName;
  65695. private _uniqueRootUrl;
  65696. private _gltf;
  65697. private _babylonScene;
  65698. private _rootBabylonMesh;
  65699. private _defaultBabylonMaterialData;
  65700. private _progressCallback?;
  65701. private _requests;
  65702. private static readonly _DefaultSampler;
  65703. private static _ExtensionNames;
  65704. private static _ExtensionFactories;
  65705. /**
  65706. * Registers a loader extension.
  65707. * @param name The name of the loader extension.
  65708. * @param factory The factory function that creates the loader extension.
  65709. */
  65710. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  65711. /**
  65712. * Unregisters a loader extension.
  65713. * @param name The name of the loader extenion.
  65714. * @returns A boolean indicating whether the extension has been unregistered
  65715. */
  65716. static UnregisterExtension(name: string): boolean;
  65717. /**
  65718. * Gets the loader state.
  65719. */
  65720. readonly state: Nullable<GLTFLoaderState>;
  65721. /**
  65722. * The glTF object parsed from the JSON.
  65723. */
  65724. readonly gltf: IGLTF;
  65725. /**
  65726. * The Babylon scene when loading the asset.
  65727. */
  65728. readonly babylonScene: Scene;
  65729. /**
  65730. * The root Babylon mesh when loading the asset.
  65731. */
  65732. readonly rootBabylonMesh: Mesh;
  65733. /** @hidden */
  65734. constructor(parent: GLTFFileLoader);
  65735. /** @hidden */
  65736. dispose(): void;
  65737. /** @hidden */
  65738. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  65739. meshes: AbstractMesh[];
  65740. particleSystems: IParticleSystem[];
  65741. skeletons: Skeleton[];
  65742. animationGroups: AnimationGroup[];
  65743. }>;
  65744. /** @hidden */
  65745. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  65746. private _loadAsync;
  65747. private _loadData;
  65748. private _setupData;
  65749. private _loadExtensions;
  65750. private _checkExtensions;
  65751. private _setState;
  65752. private _createRootNode;
  65753. /**
  65754. * Loads a glTF scene.
  65755. * @param context The context when loading the asset
  65756. * @param scene The glTF scene property
  65757. * @returns A promise that resolves when the load is complete
  65758. */
  65759. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  65760. private _forEachPrimitive;
  65761. private _getMeshes;
  65762. private _getSkeletons;
  65763. private _getAnimationGroups;
  65764. private _startAnimations;
  65765. /**
  65766. * Loads a glTF node.
  65767. * @param context The context when loading the asset
  65768. * @param node The glTF node property
  65769. * @param assign A function called synchronously after parsing the glTF properties
  65770. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  65771. */
  65772. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  65773. private _loadMeshAsync;
  65774. /**
  65775. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  65776. * @param context The context when loading the asset
  65777. * @param name The mesh name when loading the asset
  65778. * @param node The glTF node when loading the asset
  65779. * @param mesh The glTF mesh when loading the asset
  65780. * @param primitive The glTF mesh primitive property
  65781. * @param assign A function called synchronously after parsing the glTF properties
  65782. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  65783. */ private _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  65784. private _loadVertexDataAsync;
  65785. private _createMorphTargets;
  65786. private _loadMorphTargetsAsync;
  65787. private _loadMorphTargetVertexDataAsync;
  65788. private static _LoadTransform;
  65789. private _loadSkinAsync;
  65790. private _loadBones;
  65791. private _loadBone;
  65792. private _loadSkinInverseBindMatricesDataAsync;
  65793. private _updateBoneMatrices;
  65794. private _getNodeMatrix;
  65795. /**
  65796. * Loads a glTF camera.
  65797. * @param context The context when loading the asset
  65798. * @param camera The glTF camera property
  65799. * @param assign A function called synchronously after parsing the glTF properties
  65800. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  65801. */
  65802. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  65803. private _loadAnimationsAsync;
  65804. /**
  65805. * Loads a glTF animation.
  65806. * @param context The context when loading the asset
  65807. * @param animation The glTF animation property
  65808. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  65809. */
  65810. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  65811. /**
  65812. * @hidden Loads a glTF animation channel.
  65813. * @param context The context when loading the asset
  65814. * @param animationContext The context of the animation when loading the asset
  65815. * @param animation The glTF animation property
  65816. * @param channel The glTF animation channel property
  65817. * @param babylonAnimationGroup The babylon animation group property
  65818. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  65819. * @returns A void promise when the channel load is complete
  65820. */ private _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  65821. private _loadAnimationSamplerAsync;
  65822. private _loadBufferAsync;
  65823. /**
  65824. * Loads a glTF buffer view.
  65825. * @param context The context when loading the asset
  65826. * @param bufferView The glTF buffer view property
  65827. * @returns A promise that resolves with the loaded data when the load is complete
  65828. */
  65829. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  65830. private _loadAccessorAsync;
  65831. private _loadFloatAccessorAsync;
  65832. private _loadIndicesAccessorAsync;
  65833. private _loadVertexBufferViewAsync;
  65834. private _loadVertexAccessorAsync;
  65835. private _loadMaterialMetallicRoughnessPropertiesAsync;
  65836. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  65837. private _createDefaultMaterial;
  65838. /**
  65839. * Creates a Babylon material from a glTF material.
  65840. * @param context The context when loading the asset
  65841. * @param material The glTF material property
  65842. * @param babylonDrawMode The draw mode for the Babylon material
  65843. * @returns The Babylon material
  65844. */
  65845. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  65846. /**
  65847. * Loads properties from a glTF material into a Babylon material.
  65848. * @param context The context when loading the asset
  65849. * @param material The glTF material property
  65850. * @param babylonMaterial The Babylon material
  65851. * @returns A promise that resolves when the load is complete
  65852. */
  65853. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  65854. /**
  65855. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  65856. * @param context The context when loading the asset
  65857. * @param material The glTF material property
  65858. * @param babylonMaterial The Babylon material
  65859. * @returns A promise that resolves when the load is complete
  65860. */
  65861. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  65862. /**
  65863. * Loads the alpha properties from a glTF material into a Babylon material.
  65864. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  65865. * @param context The context when loading the asset
  65866. * @param material The glTF material property
  65867. * @param babylonMaterial The Babylon material
  65868. */
  65869. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  65870. /**
  65871. * Loads a glTF texture info.
  65872. * @param context The context when loading the asset
  65873. * @param textureInfo The glTF texture info property
  65874. * @param assign A function called synchronously after parsing the glTF properties
  65875. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  65876. */
  65877. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  65878. private _loadTextureAsync;
  65879. private _loadSampler;
  65880. /**
  65881. * Loads a glTF image.
  65882. * @param context The context when loading the asset
  65883. * @param image The glTF image property
  65884. * @returns A promise that resolves with the loaded data when the load is complete
  65885. */
  65886. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  65887. /**
  65888. * Loads a glTF uri.
  65889. * @param context The context when loading the asset
  65890. * @param property The glTF property associated with the uri
  65891. * @param uri The base64 or relative uri
  65892. * @returns A promise that resolves with the loaded data when the load is complete
  65893. */
  65894. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  65895. private _onProgress;
  65896. /**
  65897. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  65898. * @param babylonObject the Babylon object with metadata
  65899. * @param pointer the JSON pointer
  65900. */
  65901. static AddPointerMetadata(babylonObject: {
  65902. metadata: any;
  65903. }, pointer: string): void;
  65904. private static _GetTextureWrapMode;
  65905. private static _GetTextureSamplingMode;
  65906. private static _GetTypedArrayConstructor;
  65907. private static _GetTypedArray;
  65908. private static _GetNumComponents;
  65909. private static _ValidateUri;
  65910. private static _GetDrawMode;
  65911. private _compileMaterialsAsync;
  65912. private _compileShadowGeneratorsAsync;
  65913. private _forEachExtensions;
  65914. private _applyExtensions;
  65915. private _extensionsOnLoading;
  65916. private _extensionsOnReady;
  65917. private _extensionsLoadSceneAsync;
  65918. private _extensionsLoadNodeAsync;
  65919. private _extensionsLoadCameraAsync;
  65920. private _extensionsLoadVertexDataAsync;
  65921. private _extensionsLoadMeshPrimitiveAsync;
  65922. private _extensionsLoadMaterialAsync;
  65923. private _extensionsCreateMaterial;
  65924. private _extensionsLoadMaterialPropertiesAsync;
  65925. private _extensionsLoadTextureInfoAsync;
  65926. private _extensionsLoadAnimationAsync;
  65927. private _extensionsLoadSkinAsync;
  65928. private _extensionsLoadUriAsync;
  65929. /**
  65930. * Helper method called by a loader extension to load an glTF extension.
  65931. * @param context The context when loading the asset
  65932. * @param property The glTF property to load the extension from
  65933. * @param extensionName The name of the extension to load
  65934. * @param actionAsync The action to run
  65935. * @returns The promise returned by actionAsync or null if the extension does not exist
  65936. */
  65937. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  65938. /**
  65939. * Helper method called by a loader extension to load a glTF extra.
  65940. * @param context The context when loading the asset
  65941. * @param property The glTF property to load the extra from
  65942. * @param extensionName The name of the extension to load
  65943. * @param actionAsync The action to run
  65944. * @returns The promise returned by actionAsync or null if the extra does not exist
  65945. */
  65946. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  65947. /**
  65948. * Increments the indentation level and logs a message.
  65949. * @param message The message to log
  65950. */
  65951. logOpen(message: string): void;
  65952. /**
  65953. * Decrements the indentation level.
  65954. */
  65955. logClose(): void;
  65956. /**
  65957. * Logs a message
  65958. * @param message The message to log
  65959. */
  65960. log(message: string): void;
  65961. /**
  65962. * Starts a performance counter.
  65963. * @param counterName The name of the performance counter
  65964. */
  65965. startPerformanceCounter(counterName: string): void;
  65966. /**
  65967. * Ends a performance counter.
  65968. * @param counterName The name of the performance counter
  65969. */
  65970. endPerformanceCounter(counterName: string): void;
  65971. }
  65972. }
  65973. declare module BABYLON.GLTF2.Loader.Extensions {
  65974. /**
  65975. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  65976. */
  65977. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  65978. /** The name of this extension. */
  65979. readonly name: string;
  65980. /** Defines whether this extension is enabled. */
  65981. enabled: boolean;
  65982. private _loader;
  65983. private _lights?;
  65984. /** @hidden */
  65985. constructor(loader: GLTFLoader);
  65986. /** @hidden */
  65987. dispose(): void;
  65988. /** @hidden */
  65989. onLoading(): void;
  65990. /** @hidden */
  65991. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  65992. private _loadLightAsync;
  65993. }
  65994. }
  65995. declare module BABYLON.GLTF2.Loader.Extensions {
  65996. /**
  65997. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  65998. */
  65999. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  66000. /** The name of this extension. */
  66001. readonly name: string;
  66002. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  66003. dracoCompression?: DracoCompression;
  66004. /** Defines whether this extension is enabled. */
  66005. enabled: boolean;
  66006. private _loader;
  66007. /** @hidden */
  66008. constructor(loader: GLTFLoader);
  66009. /** @hidden */
  66010. dispose(): void;
  66011. /** @hidden */ private _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  66012. }
  66013. }
  66014. declare module BABYLON.GLTF2.Loader.Extensions {
  66015. /**
  66016. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  66017. */
  66018. export class KHR_lights implements IGLTFLoaderExtension {
  66019. /** The name of this extension. */
  66020. readonly name: string;
  66021. /** Defines whether this extension is enabled. */
  66022. enabled: boolean;
  66023. private _loader;
  66024. private _lights?;
  66025. /** @hidden */
  66026. constructor(loader: GLTFLoader);
  66027. /** @hidden */
  66028. dispose(): void;
  66029. /** @hidden */
  66030. onLoading(): void;
  66031. /** @hidden */
  66032. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66033. }
  66034. }
  66035. declare module BABYLON.GLTF2.Loader.Extensions {
  66036. /**
  66037. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  66038. */
  66039. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  66040. /** The name of this extension. */
  66041. readonly name: string;
  66042. /** Defines whether this extension is enabled. */
  66043. enabled: boolean;
  66044. private _loader;
  66045. /** @hidden */
  66046. constructor(loader: GLTFLoader);
  66047. /** @hidden */
  66048. dispose(): void;
  66049. /** @hidden */
  66050. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  66051. private _loadSpecularGlossinessPropertiesAsync;
  66052. }
  66053. }
  66054. declare module BABYLON.GLTF2.Loader.Extensions {
  66055. /**
  66056. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  66057. */
  66058. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  66059. /** The name of this extension. */
  66060. readonly name: string;
  66061. /** Defines whether this extension is enabled. */
  66062. enabled: boolean;
  66063. private _loader;
  66064. /** @hidden */
  66065. constructor(loader: GLTFLoader);
  66066. /** @hidden */
  66067. dispose(): void;
  66068. /** @hidden */
  66069. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  66070. private _loadUnlitPropertiesAsync;
  66071. }
  66072. }
  66073. declare module BABYLON.GLTF2.Loader.Extensions {
  66074. /**
  66075. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  66076. */
  66077. export class KHR_texture_transform implements IGLTFLoaderExtension {
  66078. /** The name of this extension. */
  66079. readonly name: string;
  66080. /** Defines whether this extension is enabled. */
  66081. enabled: boolean;
  66082. private _loader;
  66083. /** @hidden */
  66084. constructor(loader: GLTFLoader);
  66085. /** @hidden */
  66086. dispose(): void;
  66087. /** @hidden */
  66088. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  66089. }
  66090. }
  66091. declare module BABYLON.GLTF2.Loader.Extensions {
  66092. /**
  66093. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  66094. */
  66095. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  66096. /** The name of this extension. */
  66097. readonly name: string;
  66098. /** Defines whether this extension is enabled. */
  66099. enabled: boolean;
  66100. private _loader;
  66101. private _clips;
  66102. private _emitters;
  66103. /** @hidden */
  66104. constructor(loader: GLTFLoader);
  66105. /** @hidden */
  66106. dispose(): void;
  66107. /** @hidden */
  66108. onLoading(): void;
  66109. /** @hidden */
  66110. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  66111. /** @hidden */
  66112. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66113. /** @hidden */
  66114. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  66115. private _loadClipAsync;
  66116. private _loadEmitterAsync;
  66117. private _getEventAction;
  66118. private _loadAnimationEventAsync;
  66119. }
  66120. }
  66121. declare module BABYLON.GLTF2.Loader.Extensions {
  66122. /**
  66123. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  66124. */
  66125. export class MSFT_lod implements IGLTFLoaderExtension {
  66126. /** The name of this extension. */
  66127. readonly name: string;
  66128. /** Defines whether this extension is enabled. */
  66129. enabled: boolean;
  66130. /**
  66131. * Maximum number of LODs to load, starting from the lowest LOD.
  66132. */
  66133. maxLODsToLoad: number;
  66134. /**
  66135. * Observable raised when all node LODs of one level are loaded.
  66136. * The event data is the index of the loaded LOD starting from zero.
  66137. * Dispose the loader to cancel the loading of the next level of LODs.
  66138. */
  66139. onNodeLODsLoadedObservable: Observable<number>;
  66140. /**
  66141. * Observable raised when all material LODs of one level are loaded.
  66142. * The event data is the index of the loaded LOD starting from zero.
  66143. * Dispose the loader to cancel the loading of the next level of LODs.
  66144. */
  66145. onMaterialLODsLoadedObservable: Observable<number>;
  66146. private _loader;
  66147. private _nodeIndexLOD;
  66148. private _nodeSignalLODs;
  66149. private _nodePromiseLODs;
  66150. private _materialIndexLOD;
  66151. private _materialSignalLODs;
  66152. private _materialPromiseLODs;
  66153. /** @hidden */
  66154. constructor(loader: GLTFLoader);
  66155. /** @hidden */
  66156. dispose(): void;
  66157. /** @hidden */
  66158. onReady(): void;
  66159. /** @hidden */
  66160. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66161. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  66162. /** @hidden */ private _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  66163. /**
  66164. * Gets an array of LOD properties from lowest to highest.
  66165. */
  66166. private _getLODs;
  66167. private _disposeUnusedMaterials;
  66168. }
  66169. }
  66170. declare module BABYLON.GLTF2.Loader.Extensions {
  66171. /** @hidden */
  66172. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  66173. readonly name: string;
  66174. enabled: boolean;
  66175. private _loader;
  66176. constructor(loader: GLTFLoader);
  66177. dispose(): void;
  66178. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  66179. }
  66180. }
  66181. declare module BABYLON.GLTF2.Loader.Extensions {
  66182. /** @hidden */
  66183. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  66184. readonly name: string;
  66185. enabled: boolean;
  66186. private _loader;
  66187. constructor(loader: GLTFLoader);
  66188. dispose(): void;
  66189. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  66190. }
  66191. }
  66192. declare module BABYLON.GLTF2.Loader.Extensions {
  66193. /**
  66194. * Store glTF extras (if present) in BJS objects' metadata
  66195. */
  66196. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  66197. /** The name of this extension. */
  66198. readonly name: string;
  66199. /** Defines whether this extension is enabled. */
  66200. enabled: boolean;
  66201. private _loader;
  66202. private _assignExtras;
  66203. /** @hidden */
  66204. constructor(loader: GLTFLoader);
  66205. /** @hidden */
  66206. dispose(): void;
  66207. /** @hidden */
  66208. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66209. /** @hidden */
  66210. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  66211. /** @hidden */
  66212. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  66213. }
  66214. }
  66215. declare module BABYLON {
  66216. /**
  66217. * Class reading and parsing the MTL file bundled with the obj file.
  66218. */
  66219. export class MTLFileLoader {
  66220. /**
  66221. * All material loaded from the mtl will be set here
  66222. */
  66223. materials: StandardMaterial[];
  66224. /**
  66225. * This function will read the mtl file and create each material described inside
  66226. * This function could be improve by adding :
  66227. * -some component missing (Ni, Tf...)
  66228. * -including the specific options available
  66229. *
  66230. * @param scene defines the scene the material will be created in
  66231. * @param data defines the mtl data to parse
  66232. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  66233. */
  66234. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  66235. /**
  66236. * Gets the texture for the material.
  66237. *
  66238. * If the material is imported from input file,
  66239. * We sanitize the url to ensure it takes the textre from aside the material.
  66240. *
  66241. * @param rootUrl The root url to load from
  66242. * @param value The value stored in the mtl
  66243. * @return The Texture
  66244. */
  66245. private static _getTexture;
  66246. }
  66247. /**
  66248. * Options for loading OBJ/MTL files
  66249. */
  66250. type MeshLoadOptions = {
  66251. /**
  66252. * Defines if UVs are optimized by default during load.
  66253. */
  66254. OptimizeWithUV: boolean;
  66255. /**
  66256. * Defines custom scaling of UV coordinates of loaded meshes.
  66257. */
  66258. UVScaling: Vector2;
  66259. /**
  66260. * Invert model on y-axis (does a model scaling inversion)
  66261. */
  66262. InvertY: boolean;
  66263. /**
  66264. * Invert Y-Axis of referenced textures on load
  66265. */
  66266. InvertTextureY: boolean;
  66267. /**
  66268. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  66269. */
  66270. ImportVertexColors: boolean;
  66271. /**
  66272. * Compute the normals for the model, even if normals are present in the file.
  66273. */
  66274. ComputeNormals: boolean;
  66275. /**
  66276. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  66277. */
  66278. SkipMaterials: boolean;
  66279. /**
  66280. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  66281. */
  66282. MaterialLoadingFailsSilently: boolean;
  66283. };
  66284. /**
  66285. * OBJ file type loader.
  66286. * This is a babylon scene loader plugin.
  66287. */
  66288. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  66289. /**
  66290. * Defines if UVs are optimized by default during load.
  66291. */
  66292. static OPTIMIZE_WITH_UV: boolean;
  66293. /**
  66294. * Invert model on y-axis (does a model scaling inversion)
  66295. */
  66296. static INVERT_Y: boolean;
  66297. /**
  66298. * Invert Y-Axis of referenced textures on load
  66299. */
  66300. static INVERT_TEXTURE_Y: boolean;
  66301. /**
  66302. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  66303. */
  66304. static IMPORT_VERTEX_COLORS: boolean;
  66305. /**
  66306. * Compute the normals for the model, even if normals are present in the file.
  66307. */
  66308. static COMPUTE_NORMALS: boolean;
  66309. /**
  66310. * Defines custom scaling of UV coordinates of loaded meshes.
  66311. */
  66312. static UV_SCALING: Vector2;
  66313. /**
  66314. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  66315. */
  66316. static SKIP_MATERIALS: boolean;
  66317. /**
  66318. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  66319. *
  66320. * Defaults to true for backwards compatibility.
  66321. */
  66322. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  66323. /**
  66324. * Defines the name of the plugin.
  66325. */
  66326. name: string;
  66327. /**
  66328. * Defines the extension the plugin is able to load.
  66329. */
  66330. extensions: string;
  66331. /** @hidden */
  66332. obj: RegExp;
  66333. /** @hidden */
  66334. group: RegExp;
  66335. /** @hidden */
  66336. mtllib: RegExp;
  66337. /** @hidden */
  66338. usemtl: RegExp;
  66339. /** @hidden */
  66340. smooth: RegExp;
  66341. /** @hidden */
  66342. vertexPattern: RegExp;
  66343. /** @hidden */
  66344. normalPattern: RegExp;
  66345. /** @hidden */
  66346. uvPattern: RegExp;
  66347. /** @hidden */
  66348. facePattern1: RegExp;
  66349. /** @hidden */
  66350. facePattern2: RegExp;
  66351. /** @hidden */
  66352. facePattern3: RegExp;
  66353. /** @hidden */
  66354. facePattern4: RegExp;
  66355. /** @hidden */
  66356. facePattern5: RegExp;
  66357. private _meshLoadOptions;
  66358. /**
  66359. * Creates loader for .OBJ files
  66360. *
  66361. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  66362. */
  66363. constructor(meshLoadOptions?: MeshLoadOptions);
  66364. private static readonly currentMeshLoadOptions;
  66365. /**
  66366. * Calls synchronously the MTL file attached to this obj.
  66367. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  66368. * Without this function materials are not displayed in the first frame (but displayed after).
  66369. * In consequence it is impossible to get material information in your HTML file
  66370. *
  66371. * @param url The URL of the MTL file
  66372. * @param rootUrl
  66373. * @param onSuccess Callback function to be called when the MTL file is loaded
  66374. * @private
  66375. */
  66376. private _loadMTL;
  66377. /**
  66378. * Instantiates a OBJ file loader plugin.
  66379. * @returns the created plugin
  66380. */
  66381. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  66382. /**
  66383. * If the data string can be loaded directly.
  66384. *
  66385. * @param data string containing the file data
  66386. * @returns if the data can be loaded directly
  66387. */
  66388. canDirectLoad(data: string): boolean;
  66389. /**
  66390. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  66391. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  66392. * @param scene the scene the meshes should be added to
  66393. * @param data the OBJ data to load
  66394. * @param rootUrl root url to load from
  66395. * @param onProgress event that fires when loading progress has occured
  66396. * @param fileName Defines the name of the file to load
  66397. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  66398. */
  66399. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  66400. meshes: AbstractMesh[];
  66401. particleSystems: IParticleSystem[];
  66402. skeletons: Skeleton[];
  66403. animationGroups: AnimationGroup[];
  66404. }>;
  66405. /**
  66406. * Imports all objects from the loaded OBJ data and adds them to the scene
  66407. * @param scene the scene the objects should be added to
  66408. * @param data the OBJ data to load
  66409. * @param rootUrl root url to load from
  66410. * @param onProgress event that fires when loading progress has occured
  66411. * @param fileName Defines the name of the file to load
  66412. * @returns a promise which completes when objects have been loaded to the scene
  66413. */
  66414. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  66415. /**
  66416. * Load into an asset container.
  66417. * @param scene The scene to load into
  66418. * @param data The data to import
  66419. * @param rootUrl The root url for scene and resources
  66420. * @param onProgress The callback when the load progresses
  66421. * @param fileName Defines the name of the file to load
  66422. * @returns The loaded asset container
  66423. */
  66424. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  66425. /**
  66426. * Read the OBJ file and create an Array of meshes.
  66427. * Each mesh contains all information given by the OBJ and the MTL file.
  66428. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  66429. *
  66430. * @param meshesNames
  66431. * @param scene Scene The scene where are displayed the data
  66432. * @param data String The content of the obj file
  66433. * @param rootUrl String The path to the folder
  66434. * @returns Array<AbstractMesh>
  66435. * @private
  66436. */
  66437. private _parseSolid;
  66438. }
  66439. }
  66440. declare module BABYLON {
  66441. /**
  66442. * STL file type loader.
  66443. * This is a babylon scene loader plugin.
  66444. */
  66445. export class STLFileLoader implements ISceneLoaderPlugin {
  66446. /** @hidden */
  66447. solidPattern: RegExp;
  66448. /** @hidden */
  66449. facetsPattern: RegExp;
  66450. /** @hidden */
  66451. normalPattern: RegExp;
  66452. /** @hidden */
  66453. vertexPattern: RegExp;
  66454. /**
  66455. * Defines the name of the plugin.
  66456. */
  66457. name: string;
  66458. /**
  66459. * Defines the extensions the stl loader is able to load.
  66460. * force data to come in as an ArrayBuffer
  66461. * we'll convert to string if it looks like it's an ASCII .stl
  66462. */
  66463. extensions: ISceneLoaderPluginExtensions;
  66464. /**
  66465. * Import meshes into a scene.
  66466. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  66467. * @param scene The scene to import into
  66468. * @param data The data to import
  66469. * @param rootUrl The root url for scene and resources
  66470. * @param meshes The meshes array to import into
  66471. * @param particleSystems The particle systems array to import into
  66472. * @param skeletons The skeletons array to import into
  66473. * @param onError The callback when import fails
  66474. * @returns True if successful or false otherwise
  66475. */
  66476. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  66477. /**
  66478. * Load into a scene.
  66479. * @param scene The scene to load into
  66480. * @param data The data to import
  66481. * @param rootUrl The root url for scene and resources
  66482. * @param onError The callback when import fails
  66483. * @returns true if successful or false otherwise
  66484. */
  66485. load(scene: Scene, data: any, rootUrl: string): boolean;
  66486. /**
  66487. * Load into an asset container.
  66488. * @param scene The scene to load into
  66489. * @param data The data to import
  66490. * @param rootUrl The root url for scene and resources
  66491. * @param onError The callback when import fails
  66492. * @returns The loaded asset container
  66493. */
  66494. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  66495. private _isBinary;
  66496. private _parseBinary;
  66497. private _parseASCII;
  66498. }
  66499. }
  66500. declare module BABYLON {
  66501. /**
  66502. * Class for generating OBJ data from a Babylon scene.
  66503. */
  66504. export class OBJExport {
  66505. /**
  66506. * Exports the geometry of a Mesh array in .OBJ file format (text)
  66507. * @param mesh defines the list of meshes to serialize
  66508. * @param materials defines if materials should be exported
  66509. * @param matlibname defines the name of the associated mtl file
  66510. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  66511. * @returns the OBJ content
  66512. */
  66513. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  66514. /**
  66515. * Exports the material(s) of a mesh in .MTL file format (text)
  66516. * @param mesh defines the mesh to extract the material from
  66517. * @returns the mtl content
  66518. */
  66519. static MTL(mesh: Mesh): string;
  66520. }
  66521. }
  66522. declare module BABYLON {
  66523. /** @hidden */
  66524. export var __IGLTFExporterExtension: number;
  66525. /**
  66526. * Interface for extending the exporter
  66527. * @hidden
  66528. */
  66529. export interface IGLTFExporterExtension {
  66530. /**
  66531. * The name of this extension
  66532. */
  66533. readonly name: string;
  66534. /**
  66535. * Defines whether this extension is enabled
  66536. */
  66537. enabled: boolean;
  66538. /**
  66539. * Defines whether this extension is required
  66540. */
  66541. required: boolean;
  66542. }
  66543. }
  66544. declare module BABYLON.GLTF2.Exporter {
  66545. /** @hidden */
  66546. export var __IGLTFExporterExtensionV2: number;
  66547. /**
  66548. * Interface for a glTF exporter extension
  66549. * @hidden
  66550. */
  66551. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  66552. /**
  66553. * Define this method to modify the default behavior before exporting a texture
  66554. * @param context The context when loading the asset
  66555. * @param babylonTexture The glTF texture info property
  66556. * @param mimeType The mime-type of the generated image
  66557. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  66558. */
  66559. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  66560. /**
  66561. * Define this method to modify the default behavior when exporting texture info
  66562. * @param context The context when loading the asset
  66563. * @param meshPrimitive glTF mesh primitive
  66564. * @param babylonSubMesh Babylon submesh
  66565. * @param binaryWriter glTF serializer binary writer instance
  66566. * @returns nullable IMeshPrimitive promise
  66567. */
  66568. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  66569. /**
  66570. * Define this method to modify the default behavior when exporting a node
  66571. * @param context The context when exporting the node
  66572. * @param node glTF node
  66573. * @param babylonNode BabylonJS node
  66574. * @returns nullable INode promise
  66575. */
  66576. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  66577. /**
  66578. * Called after the exporter state changes to EXPORTING
  66579. */
  66580. onExporting?(): void;
  66581. }
  66582. }
  66583. declare module BABYLON.GLTF2.Exporter {
  66584. /**
  66585. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  66586. * @hidden
  66587. */
  66588. export class _GLTFMaterialExporter {
  66589. /**
  66590. * Represents the dielectric specular values for R, G and B
  66591. */
  66592. private static readonly _DielectricSpecular;
  66593. /**
  66594. * Allows the maximum specular power to be defined for material calculations
  66595. */
  66596. private static readonly _MaxSpecularPower;
  66597. /**
  66598. * Mapping to store textures
  66599. */
  66600. private _textureMap;
  66601. /**
  66602. * Numeric tolerance value
  66603. */
  66604. private static readonly _Epsilon;
  66605. /**
  66606. * Reference to the glTF Exporter
  66607. */
  66608. private _exporter;
  66609. constructor(exporter: _Exporter);
  66610. /**
  66611. * Specifies if two colors are approximately equal in value
  66612. * @param color1 first color to compare to
  66613. * @param color2 second color to compare to
  66614. * @param epsilon threshold value
  66615. */
  66616. private static FuzzyEquals;
  66617. /**
  66618. * Gets the materials from a Babylon scene and converts them to glTF materials
  66619. * @param scene babylonjs scene
  66620. * @param mimeType texture mime type
  66621. * @param images array of images
  66622. * @param textures array of textures
  66623. * @param materials array of materials
  66624. * @param imageData mapping of texture names to base64 textures
  66625. * @param hasTextureCoords specifies if texture coordinates are present on the material
  66626. */ private _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  66627. /**
  66628. * Makes a copy of the glTF material without the texture parameters
  66629. * @param originalMaterial original glTF material
  66630. * @returns glTF material without texture parameters
  66631. */ private _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  66632. /**
  66633. * Specifies if the material has any texture parameters present
  66634. * @param material glTF Material
  66635. * @returns boolean specifying if texture parameters are present
  66636. */ private _hasTexturesPresent(material: IMaterial): boolean;
  66637. /**
  66638. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  66639. * @param babylonStandardMaterial
  66640. * @returns glTF Metallic Roughness Material representation
  66641. */ private _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  66642. /**
  66643. * Computes the metallic factor
  66644. * @param diffuse diffused value
  66645. * @param specular specular value
  66646. * @param oneMinusSpecularStrength one minus the specular strength
  66647. * @returns metallic value
  66648. */ private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  66649. /**
  66650. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  66651. * @param glTFMaterial glTF material
  66652. * @param babylonMaterial Babylon material
  66653. */
  66654. private static _SetAlphaMode;
  66655. /**
  66656. * Converts a Babylon Standard Material to a glTF Material
  66657. * @param babylonStandardMaterial BJS Standard Material
  66658. * @param mimeType mime type to use for the textures
  66659. * @param images array of glTF image interfaces
  66660. * @param textures array of glTF texture interfaces
  66661. * @param materials array of glTF material interfaces
  66662. * @param imageData map of image file name to data
  66663. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  66664. */ private _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  66665. /**
  66666. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  66667. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  66668. * @param mimeType mime type to use for the textures
  66669. * @param images array of glTF image interfaces
  66670. * @param textures array of glTF texture interfaces
  66671. * @param materials array of glTF material interfaces
  66672. * @param imageData map of image file name to data
  66673. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  66674. */ private _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  66675. /**
  66676. * Converts an image typed array buffer to a base64 image
  66677. * @param buffer typed array buffer
  66678. * @param width width of the image
  66679. * @param height height of the image
  66680. * @param mimeType mimetype of the image
  66681. * @returns base64 image string
  66682. */
  66683. private _createBase64FromCanvasAsync;
  66684. /**
  66685. * Generates a white texture based on the specified width and height
  66686. * @param width width of the texture in pixels
  66687. * @param height height of the texture in pixels
  66688. * @param scene babylonjs scene
  66689. * @returns white texture
  66690. */
  66691. private _createWhiteTexture;
  66692. /**
  66693. * 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
  66694. * @param texture1 first texture to resize
  66695. * @param texture2 second texture to resize
  66696. * @param scene babylonjs scene
  66697. * @returns resized textures or null
  66698. */
  66699. private _resizeTexturesToSameDimensions;
  66700. /**
  66701. * Converts an array of pixels to a Float32Array
  66702. * Throws an error if the pixel format is not supported
  66703. * @param pixels - array buffer containing pixel values
  66704. * @returns Float32 of pixels
  66705. */
  66706. private _convertPixelArrayToFloat32;
  66707. /**
  66708. * Convert Specular Glossiness Textures to Metallic Roughness
  66709. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  66710. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  66711. * @param diffuseTexture texture used to store diffuse information
  66712. * @param specularGlossinessTexture texture used to store specular and glossiness information
  66713. * @param factors specular glossiness material factors
  66714. * @param mimeType the mime type to use for the texture
  66715. * @returns pbr metallic roughness interface or null
  66716. */
  66717. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  66718. /**
  66719. * Converts specular glossiness material properties to metallic roughness
  66720. * @param specularGlossiness interface with specular glossiness material properties
  66721. * @returns interface with metallic roughness material properties
  66722. */
  66723. private _convertSpecularGlossinessToMetallicRoughness;
  66724. /**
  66725. * Calculates the surface reflectance, independent of lighting conditions
  66726. * @param color Color source to calculate brightness from
  66727. * @returns number representing the perceived brightness, or zero if color is undefined
  66728. */
  66729. private _getPerceivedBrightness;
  66730. /**
  66731. * Returns the maximum color component value
  66732. * @param color
  66733. * @returns maximum color component value, or zero if color is null or undefined
  66734. */
  66735. private _getMaxComponent;
  66736. /**
  66737. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  66738. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  66739. * @param mimeType mime type to use for the textures
  66740. * @param images array of glTF image interfaces
  66741. * @param textures array of glTF texture interfaces
  66742. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  66743. * @param imageData map of image file name to data
  66744. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  66745. * @returns glTF PBR Metallic Roughness factors
  66746. */
  66747. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  66748. private _getGLTFTextureSampler;
  66749. private _getGLTFTextureWrapMode;
  66750. private _getGLTFTextureWrapModesSampler;
  66751. /**
  66752. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  66753. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  66754. * @param mimeType mime type to use for the textures
  66755. * @param images array of glTF image interfaces
  66756. * @param textures array of glTF texture interfaces
  66757. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  66758. * @param imageData map of image file name to data
  66759. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  66760. * @returns glTF PBR Metallic Roughness factors
  66761. */
  66762. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  66763. /**
  66764. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  66765. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  66766. * @param mimeType mime type to use for the textures
  66767. * @param images array of glTF image interfaces
  66768. * @param textures array of glTF texture interfaces
  66769. * @param materials array of glTF material interfaces
  66770. * @param imageData map of image file name to data
  66771. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  66772. */ private _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  66773. private setMetallicRoughnessPbrMaterial;
  66774. private getPixelsFromTexture;
  66775. /**
  66776. * Extracts a texture from a Babylon texture into file data and glTF data
  66777. * @param babylonTexture Babylon texture to extract
  66778. * @param mimeType Mime Type of the babylonTexture
  66779. * @return glTF texture info, or null if the texture format is not supported
  66780. */ private _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>; private _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  66781. /**
  66782. * Builds a texture from base64 string
  66783. * @param base64Texture base64 texture string
  66784. * @param baseTextureName Name to use for the texture
  66785. * @param mimeType image mime type for the texture
  66786. * @param images array of images
  66787. * @param textures array of textures
  66788. * @param imageData map of image data
  66789. * @returns glTF texture info, or null if the texture format is not supported
  66790. */
  66791. private _getTextureInfoFromBase64;
  66792. }
  66793. }
  66794. declare module BABYLON {
  66795. /**
  66796. * Class for holding and downloading glTF file data
  66797. */
  66798. export class GLTFData {
  66799. /**
  66800. * Object which contains the file name as the key and its data as the value
  66801. */
  66802. glTFFiles: {
  66803. [fileName: string]: string | Blob;
  66804. };
  66805. /**
  66806. * Initializes the glTF file object
  66807. */
  66808. constructor();
  66809. /**
  66810. * Downloads the glTF data as files based on their names and data
  66811. */
  66812. downloadFiles(): void;
  66813. }
  66814. }
  66815. declare module BABYLON {
  66816. /**
  66817. * Holds a collection of exporter options and parameters
  66818. */
  66819. export interface IExportOptions {
  66820. /**
  66821. * Function which indicates whether a babylon node should be exported or not
  66822. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  66823. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  66824. */
  66825. shouldExportNode?(node: Node): boolean;
  66826. /**
  66827. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  66828. * @param metadata source metadata to read from
  66829. * @returns the data to store to glTF node extras
  66830. */
  66831. metadataSelector?(metadata: any): any;
  66832. /**
  66833. * The sample rate to bake animation curves
  66834. */
  66835. animationSampleRate?: number;
  66836. /**
  66837. * Begin serialization without waiting for the scene to be ready
  66838. */
  66839. exportWithoutWaitingForScene?: boolean;
  66840. }
  66841. /**
  66842. * Class for generating glTF data from a Babylon scene.
  66843. */
  66844. export class GLTF2Export {
  66845. /**
  66846. * Exports the geometry of the scene to .gltf file format asynchronously
  66847. * @param scene Babylon scene with scene hierarchy information
  66848. * @param filePrefix File prefix to use when generating the glTF file
  66849. * @param options Exporter options
  66850. * @returns Returns an object with a .gltf file and associates texture names
  66851. * as keys and their data and paths as values
  66852. */
  66853. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  66854. private static _PreExportAsync;
  66855. private static _PostExportAsync;
  66856. /**
  66857. * Exports the geometry of the scene to .glb file format asychronously
  66858. * @param scene Babylon scene with scene hierarchy information
  66859. * @param filePrefix File prefix to use when generating glb file
  66860. * @param options Exporter options
  66861. * @returns Returns an object with a .glb filename as key and data as value
  66862. */
  66863. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  66864. }
  66865. }
  66866. declare module BABYLON.GLTF2.Exporter {
  66867. /**
  66868. * @hidden
  66869. */
  66870. export class _GLTFUtilities {
  66871. /**
  66872. * Creates a buffer view based on the supplied arguments
  66873. * @param bufferIndex index value of the specified buffer
  66874. * @param byteOffset byte offset value
  66875. * @param byteLength byte length of the bufferView
  66876. * @param byteStride byte distance between conequential elements
  66877. * @param name name of the buffer view
  66878. * @returns bufferView for glTF
  66879. */ private static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  66880. /**
  66881. * Creates an accessor based on the supplied arguments
  66882. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  66883. * @param name The name of the accessor
  66884. * @param type The type of the accessor
  66885. * @param componentType The datatype of components in the attribute
  66886. * @param count The number of attributes referenced by this accessor
  66887. * @param byteOffset The offset relative to the start of the bufferView in bytes
  66888. * @param min Minimum value of each component in this attribute
  66889. * @param max Maximum value of each component in this attribute
  66890. * @returns accessor for glTF
  66891. */ private static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  66892. /**
  66893. * Calculates the minimum and maximum values of an array of position floats
  66894. * @param positions Positions array of a mesh
  66895. * @param vertexStart Starting vertex offset to calculate min and max values
  66896. * @param vertexCount Number of vertices to check for min and max values
  66897. * @returns min number array and max number array
  66898. */ private static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  66899. min: number[];
  66900. max: number[];
  66901. };
  66902. /**
  66903. * Converts a new right-handed Vector3
  66904. * @param vector vector3 array
  66905. * @returns right-handed Vector3
  66906. */ private static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  66907. /**
  66908. * Converts a Vector3 to right-handed
  66909. * @param vector Vector3 to convert to right-handed
  66910. */ private static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  66911. /**
  66912. * Converts a three element number array to right-handed
  66913. * @param vector number array to convert to right-handed
  66914. */ private static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  66915. /**
  66916. * Converts a new right-handed Vector3
  66917. * @param vector vector3 array
  66918. * @returns right-handed Vector3
  66919. */ private static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  66920. /**
  66921. * Converts a Vector3 to right-handed
  66922. * @param vector Vector3 to convert to right-handed
  66923. */ private static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  66924. /**
  66925. * Converts a three element number array to right-handed
  66926. * @param vector number array to convert to right-handed
  66927. */ private static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  66928. /**
  66929. * Converts a Vector4 to right-handed
  66930. * @param vector Vector4 to convert to right-handed
  66931. */ private static _GetRightHandedVector4FromRef(vector: Vector4): void;
  66932. /**
  66933. * Converts a Vector4 to right-handed
  66934. * @param vector Vector4 to convert to right-handed
  66935. */ private static _GetRightHandedArray4FromRef(vector: number[]): void;
  66936. /**
  66937. * Converts a Quaternion to right-handed
  66938. * @param quaternion Source quaternion to convert to right-handed
  66939. */ private static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  66940. /**
  66941. * Converts a Quaternion to right-handed
  66942. * @param quaternion Source quaternion to convert to right-handed
  66943. */ private static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void; private static _NormalizeTangentFromRef(tangent: Vector4): void;
  66944. }
  66945. }
  66946. declare module BABYLON.GLTF2.Exporter {
  66947. /**
  66948. * Converts Babylon Scene into glTF 2.0.
  66949. * @hidden
  66950. */
  66951. export class _Exporter {
  66952. /**
  66953. * Stores the glTF to export
  66954. */ private _glTF: IGLTF;
  66955. /**
  66956. * Stores all generated buffer views, which represents views into the main glTF buffer data
  66957. */ private _bufferViews: IBufferView[];
  66958. /**
  66959. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  66960. */ private _accessors: IAccessor[];
  66961. /**
  66962. * Stores all the generated nodes, which contains transform and/or mesh information per node
  66963. */
  66964. private _nodes;
  66965. /**
  66966. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  66967. */
  66968. private _scenes;
  66969. /**
  66970. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  66971. */
  66972. private _meshes;
  66973. /**
  66974. * Stores all the generated material information, which represents the appearance of each primitive
  66975. */ private _materials: IMaterial[]; private _materialMap: {
  66976. [materialID: number]: number;
  66977. };
  66978. /**
  66979. * Stores all the generated texture information, which is referenced by glTF materials
  66980. */ private _textures: ITexture[];
  66981. /**
  66982. * Stores all the generated image information, which is referenced by glTF textures
  66983. */ private _images: IImage[];
  66984. /**
  66985. * Stores all the texture samplers
  66986. */ private _samplers: ISampler[];
  66987. /**
  66988. * Stores all the generated animation samplers, which is referenced by glTF animations
  66989. */
  66990. /**
  66991. * Stores the animations for glTF models
  66992. */
  66993. private _animations;
  66994. /**
  66995. * Stores the total amount of bytes stored in the glTF buffer
  66996. */
  66997. private _totalByteLength;
  66998. /**
  66999. * Stores a reference to the Babylon scene containing the source geometry and material information
  67000. */ private _babylonScene: Scene;
  67001. /**
  67002. * Stores a map of the image data, where the key is the file name and the value
  67003. * is the image data
  67004. */ private _imageData: {
  67005. [fileName: string]: {
  67006. data: Uint8Array;
  67007. mimeType: ImageMimeType;
  67008. };
  67009. };
  67010. /**
  67011. * Stores a map of the unique id of a node to its index in the node array
  67012. */
  67013. private _nodeMap;
  67014. /**
  67015. * Specifies if the Babylon scene should be converted to right-handed on export
  67016. */ private _convertToRightHandedSystem: boolean;
  67017. /**
  67018. * Baked animation sample rate
  67019. */
  67020. private _animationSampleRate;
  67021. private _options;
  67022. private _localEngine; private _glTFMaterialExporter: _GLTFMaterialExporter;
  67023. private _extensions;
  67024. private static _ExtensionNames;
  67025. private static _ExtensionFactories;
  67026. private _applyExtensions; private _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>; private _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>; private _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  67027. private _forEachExtensions;
  67028. private _extensionsOnExporting;
  67029. /**
  67030. * Load glTF serializer extensions
  67031. */
  67032. private _loadExtensions;
  67033. /**
  67034. * Creates a glTF Exporter instance, which can accept optional exporter options
  67035. * @param babylonScene Babylon scene object
  67036. * @param options Options to modify the behavior of the exporter
  67037. */
  67038. constructor(babylonScene: Scene, options?: IExportOptions);
  67039. /**
  67040. * Registers a glTF exporter extension
  67041. * @param name Name of the extension to export
  67042. * @param factory The factory function that creates the exporter extension
  67043. */
  67044. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  67045. /**
  67046. * Un-registers an exporter extension
  67047. * @param name The name fo the exporter extension
  67048. * @returns A boolean indicating whether the extension has been un-registered
  67049. */
  67050. static UnregisterExtension(name: string): boolean;
  67051. /**
  67052. * Lazy load a local engine with premultiplied alpha set to false
  67053. */ private _getLocalEngine(): Engine;
  67054. private reorderIndicesBasedOnPrimitiveMode;
  67055. /**
  67056. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  67057. * clock-wise during export to glTF
  67058. * @param submesh BabylonJS submesh
  67059. * @param primitiveMode Primitive mode of the mesh
  67060. * @param sideOrientation the winding order of the submesh
  67061. * @param vertexBufferKind The type of vertex attribute
  67062. * @param meshAttributeArray The vertex attribute data
  67063. * @param byteOffset The offset to the binary data
  67064. * @param binaryWriter The binary data for the glTF file
  67065. */
  67066. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  67067. /**
  67068. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  67069. * clock-wise during export to glTF
  67070. * @param submesh BabylonJS submesh
  67071. * @param primitiveMode Primitive mode of the mesh
  67072. * @param sideOrientation the winding order of the submesh
  67073. * @param vertexBufferKind The type of vertex attribute
  67074. * @param meshAttributeArray The vertex attribute data
  67075. * @param byteOffset The offset to the binary data
  67076. * @param binaryWriter The binary data for the glTF file
  67077. */
  67078. private reorderTriangleFillMode;
  67079. /**
  67080. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  67081. * clock-wise during export to glTF
  67082. * @param submesh BabylonJS submesh
  67083. * @param primitiveMode Primitive mode of the mesh
  67084. * @param sideOrientation the winding order of the submesh
  67085. * @param vertexBufferKind The type of vertex attribute
  67086. * @param meshAttributeArray The vertex attribute data
  67087. * @param byteOffset The offset to the binary data
  67088. * @param binaryWriter The binary data for the glTF file
  67089. */
  67090. private reorderTriangleStripDrawMode;
  67091. /**
  67092. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  67093. * clock-wise during export to glTF
  67094. * @param submesh BabylonJS submesh
  67095. * @param primitiveMode Primitive mode of the mesh
  67096. * @param sideOrientation the winding order of the submesh
  67097. * @param vertexBufferKind The type of vertex attribute
  67098. * @param meshAttributeArray The vertex attribute data
  67099. * @param byteOffset The offset to the binary data
  67100. * @param binaryWriter The binary data for the glTF file
  67101. */
  67102. private reorderTriangleFanMode;
  67103. /**
  67104. * Writes the vertex attribute data to binary
  67105. * @param vertices The vertices to write to the binary writer
  67106. * @param byteOffset The offset into the binary writer to overwrite binary data
  67107. * @param vertexAttributeKind The vertex attribute type
  67108. * @param meshAttributeArray The vertex attribute data
  67109. * @param binaryWriter The writer containing the binary data
  67110. */
  67111. private writeVertexAttributeData;
  67112. /**
  67113. * Writes mesh attribute data to a data buffer
  67114. * Returns the bytelength of the data
  67115. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  67116. * @param meshAttributeArray Array containing the attribute data
  67117. * @param binaryWriter The buffer to write the binary data to
  67118. * @param indices Used to specify the order of the vertex data
  67119. */
  67120. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  67121. /**
  67122. * Generates glTF json data
  67123. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  67124. * @param glTFPrefix Text to use when prefixing a glTF file
  67125. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  67126. * @returns json data as string
  67127. */
  67128. private generateJSON;
  67129. /**
  67130. * Generates data for .gltf and .bin files based on the glTF prefix string
  67131. * @param glTFPrefix Text to use when prefixing a glTF file
  67132. * @returns GLTFData with glTF file data
  67133. */ private _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  67134. /**
  67135. * Creates a binary buffer for glTF
  67136. * @returns array buffer for binary data
  67137. */
  67138. private _generateBinaryAsync;
  67139. /**
  67140. * Pads the number to a multiple of 4
  67141. * @param num number to pad
  67142. * @returns padded number
  67143. */
  67144. private _getPadding;
  67145. /**
  67146. * Generates a glb file from the json and binary data
  67147. * Returns an object with the glb file name as the key and data as the value
  67148. * @param glTFPrefix
  67149. * @returns object with glb filename as key and data as value
  67150. */ private _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  67151. /**
  67152. * Sets the TRS for each node
  67153. * @param node glTF Node for storing the transformation data
  67154. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  67155. */
  67156. private setNodeTransformation;
  67157. private getVertexBufferFromMesh;
  67158. /**
  67159. * Creates a bufferview based on the vertices type for the Babylon mesh
  67160. * @param kind Indicates the type of vertices data
  67161. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  67162. * @param binaryWriter The buffer to write the bufferview data to
  67163. */
  67164. private createBufferViewKind;
  67165. /**
  67166. * The primitive mode of the Babylon mesh
  67167. * @param babylonMesh The BabylonJS mesh
  67168. */
  67169. private getMeshPrimitiveMode;
  67170. /**
  67171. * Sets the primitive mode of the glTF mesh primitive
  67172. * @param meshPrimitive glTF mesh primitive
  67173. * @param primitiveMode The primitive mode
  67174. */
  67175. private setPrimitiveMode;
  67176. /**
  67177. * Sets the vertex attribute accessor based of the glTF mesh primitive
  67178. * @param meshPrimitive glTF mesh primitive
  67179. * @param attributeKind vertex attribute
  67180. * @returns boolean specifying if uv coordinates are present
  67181. */
  67182. private setAttributeKind;
  67183. /**
  67184. * Sets data for the primitive attributes of each submesh
  67185. * @param mesh glTF Mesh object to store the primitive attribute information
  67186. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  67187. * @param binaryWriter Buffer to write the attribute data to
  67188. */
  67189. private setPrimitiveAttributesAsync;
  67190. /**
  67191. * Creates a glTF scene based on the array of meshes
  67192. * Returns the the total byte offset
  67193. * @param babylonScene Babylon scene to get the mesh data from
  67194. * @param binaryWriter Buffer to write binary data to
  67195. */
  67196. private createSceneAsync;
  67197. /**
  67198. * Creates a mapping of Node unique id to node index and handles animations
  67199. * @param babylonScene Babylon Scene
  67200. * @param nodes Babylon transform nodes
  67201. * @param binaryWriter Buffer to write binary data to
  67202. * @returns Node mapping of unique id to index
  67203. */
  67204. private createNodeMapAndAnimationsAsync;
  67205. /**
  67206. * Creates a glTF node from a Babylon mesh
  67207. * @param babylonMesh Source Babylon mesh
  67208. * @param binaryWriter Buffer for storing geometry data
  67209. * @returns glTF node
  67210. */
  67211. private createNodeAsync;
  67212. }
  67213. /**
  67214. * @hidden
  67215. *
  67216. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  67217. */
  67218. export class _BinaryWriter {
  67219. /**
  67220. * Array buffer which stores all binary data
  67221. */
  67222. private _arrayBuffer;
  67223. /**
  67224. * View of the array buffer
  67225. */
  67226. private _dataView;
  67227. /**
  67228. * byte offset of data in array buffer
  67229. */
  67230. private _byteOffset;
  67231. /**
  67232. * Initialize binary writer with an initial byte length
  67233. * @param byteLength Initial byte length of the array buffer
  67234. */
  67235. constructor(byteLength: number);
  67236. /**
  67237. * Resize the array buffer to the specified byte length
  67238. * @param byteLength
  67239. */
  67240. private resizeBuffer;
  67241. /**
  67242. * Get an array buffer with the length of the byte offset
  67243. * @returns ArrayBuffer resized to the byte offset
  67244. */
  67245. getArrayBuffer(): ArrayBuffer;
  67246. /**
  67247. * Get the byte offset of the array buffer
  67248. * @returns byte offset
  67249. */
  67250. getByteOffset(): number;
  67251. /**
  67252. * Stores an UInt8 in the array buffer
  67253. * @param entry
  67254. * @param byteOffset If defined, specifies where to set the value as an offset.
  67255. */
  67256. setUInt8(entry: number, byteOffset?: number): void;
  67257. /**
  67258. * Gets an UInt32 in the array buffer
  67259. * @param entry
  67260. * @param byteOffset If defined, specifies where to set the value as an offset.
  67261. */
  67262. getUInt32(byteOffset: number): number;
  67263. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  67264. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  67265. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  67266. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  67267. /**
  67268. * Stores a Float32 in the array buffer
  67269. * @param entry
  67270. */
  67271. setFloat32(entry: number, byteOffset?: number): void;
  67272. /**
  67273. * Stores an UInt32 in the array buffer
  67274. * @param entry
  67275. * @param byteOffset If defined, specifies where to set the value as an offset.
  67276. */
  67277. setUInt32(entry: number, byteOffset?: number): void;
  67278. }
  67279. }
  67280. declare module BABYLON.GLTF2.Exporter {
  67281. /**
  67282. * @hidden
  67283. * Interface to store animation data.
  67284. */
  67285. export interface _IAnimationData {
  67286. /**
  67287. * Keyframe data.
  67288. */
  67289. inputs: number[];
  67290. /**
  67291. * Value data.
  67292. */
  67293. outputs: number[][];
  67294. /**
  67295. * Animation interpolation data.
  67296. */
  67297. samplerInterpolation: AnimationSamplerInterpolation;
  67298. /**
  67299. * Minimum keyframe value.
  67300. */
  67301. inputsMin: number;
  67302. /**
  67303. * Maximum keyframe value.
  67304. */
  67305. inputsMax: number;
  67306. }
  67307. /**
  67308. * @hidden
  67309. */
  67310. export interface _IAnimationInfo {
  67311. /**
  67312. * The target channel for the animation
  67313. */
  67314. animationChannelTargetPath: AnimationChannelTargetPath;
  67315. /**
  67316. * The glTF accessor type for the data.
  67317. */
  67318. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  67319. /**
  67320. * Specifies if quaternions should be used.
  67321. */
  67322. useQuaternion: boolean;
  67323. }
  67324. /**
  67325. * @hidden
  67326. * Utility class for generating glTF animation data from BabylonJS.
  67327. */
  67328. export class _GLTFAnimation {
  67329. /**
  67330. * @ignore
  67331. *
  67332. * Creates glTF channel animation from BabylonJS animation.
  67333. * @param babylonTransformNode - BabylonJS mesh.
  67334. * @param animation - animation.
  67335. * @param animationChannelTargetPath - The target animation channel.
  67336. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  67337. * @param useQuaternion - Specifies if quaternions are used.
  67338. * @returns nullable IAnimationData
  67339. */ private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  67340. private static _DeduceAnimationInfo;
  67341. /**
  67342. * @ignore
  67343. * Create node animations from the transform node animations
  67344. * @param babylonNode
  67345. * @param runtimeGLTFAnimation
  67346. * @param idleGLTFAnimations
  67347. * @param nodeMap
  67348. * @param nodes
  67349. * @param binaryWriter
  67350. * @param bufferViews
  67351. * @param accessors
  67352. * @param convertToRightHandedSystem
  67353. */ private static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  67354. [key: number]: number;
  67355. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  67356. /**
  67357. * @ignore
  67358. * Create node animations from the animation groups
  67359. * @param babylonScene
  67360. * @param glTFAnimations
  67361. * @param nodeMap
  67362. * @param nodes
  67363. * @param binaryWriter
  67364. * @param bufferViews
  67365. * @param accessors
  67366. * @param convertToRightHandedSystem
  67367. */ private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  67368. [key: number]: number;
  67369. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  67370. private static AddAnimation;
  67371. /**
  67372. * Create a baked animation
  67373. * @param babylonTransformNode BabylonJS mesh
  67374. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  67375. * @param animationChannelTargetPath animation target channel
  67376. * @param minFrame minimum animation frame
  67377. * @param maxFrame maximum animation frame
  67378. * @param fps frames per second of the animation
  67379. * @param inputs input key frames of the animation
  67380. * @param outputs output key frame data of the animation
  67381. * @param convertToRightHandedSystem converts the values to right-handed
  67382. * @param useQuaternion specifies if quaternions should be used
  67383. */
  67384. private static _CreateBakedAnimation;
  67385. private static _ConvertFactorToVector3OrQuaternion;
  67386. private static _SetInterpolatedValue;
  67387. /**
  67388. * Creates linear animation from the animation key frames
  67389. * @param babylonTransformNode BabylonJS mesh
  67390. * @param animation BabylonJS animation
  67391. * @param animationChannelTargetPath The target animation channel
  67392. * @param frameDelta The difference between the last and first frame of the animation
  67393. * @param inputs Array to store the key frame times
  67394. * @param outputs Array to store the key frame data
  67395. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  67396. * @param useQuaternion Specifies if quaternions are used in the animation
  67397. */
  67398. private static _CreateLinearOrStepAnimation;
  67399. /**
  67400. * Creates cubic spline animation from the animation key frames
  67401. * @param babylonTransformNode BabylonJS mesh
  67402. * @param animation BabylonJS animation
  67403. * @param animationChannelTargetPath The target animation channel
  67404. * @param frameDelta The difference between the last and first frame of the animation
  67405. * @param inputs Array to store the key frame times
  67406. * @param outputs Array to store the key frame data
  67407. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  67408. * @param useQuaternion Specifies if quaternions are used in the animation
  67409. */
  67410. private static _CreateCubicSplineAnimation;
  67411. private static _GetBasePositionRotationOrScale;
  67412. /**
  67413. * Adds a key frame value
  67414. * @param keyFrame
  67415. * @param animation
  67416. * @param outputs
  67417. * @param animationChannelTargetPath
  67418. * @param basePositionRotationOrScale
  67419. * @param convertToRightHandedSystem
  67420. * @param useQuaternion
  67421. */
  67422. private static _AddKeyframeValue;
  67423. /**
  67424. * Determine the interpolation based on the key frames
  67425. * @param keyFrames
  67426. * @param animationChannelTargetPath
  67427. * @param useQuaternion
  67428. */
  67429. private static _DeduceInterpolation;
  67430. /**
  67431. * Adds an input tangent or output tangent to the output data
  67432. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  67433. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  67434. * @param outputs The animation data by keyframe
  67435. * @param animationChannelTargetPath The target animation channel
  67436. * @param interpolation The interpolation type
  67437. * @param keyFrame The key frame with the animation data
  67438. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  67439. * @param useQuaternion Specifies if quaternions are used
  67440. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  67441. */
  67442. private static AddSplineTangent;
  67443. /**
  67444. * Get the minimum and maximum key frames' frame values
  67445. * @param keyFrames animation key frames
  67446. * @returns the minimum and maximum key frame value
  67447. */
  67448. private static calculateMinMaxKeyFrames;
  67449. }
  67450. }
  67451. declare module BABYLON.GLTF2.Exporter {
  67452. /** @hidden */
  67453. export var textureTransformPixelShader: {
  67454. name: string;
  67455. shader: string;
  67456. };
  67457. }
  67458. declare module BABYLON.GLTF2.Exporter.Extensions {
  67459. /**
  67460. * @hidden
  67461. */
  67462. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  67463. /** Name of this extension */
  67464. readonly name: string;
  67465. /** Defines whether this extension is enabled */
  67466. enabled: boolean;
  67467. /** Defines whether this extension is required */
  67468. required: boolean;
  67469. /** Reference to the glTF exporter */
  67470. private _exporter;
  67471. constructor(exporter: _Exporter);
  67472. dispose(): void;
  67473. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  67474. /**
  67475. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  67476. * @param babylonTexture
  67477. * @param offset
  67478. * @param rotation
  67479. * @param scale
  67480. * @param scene
  67481. */
  67482. private _textureTransformTextureAsync;
  67483. }
  67484. }
  67485. declare module BABYLON.GLTF2.Exporter.Extensions {
  67486. /**
  67487. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  67488. */
  67489. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  67490. /** The name of this extension. */
  67491. readonly name: string;
  67492. /** Defines whether this extension is enabled. */
  67493. enabled: boolean;
  67494. /** Defines whether this extension is required */
  67495. required: boolean;
  67496. /** Reference to the glTF exporter */
  67497. private _exporter;
  67498. private _lights;
  67499. /** @hidden */
  67500. constructor(exporter: _Exporter);
  67501. /** @hidden */
  67502. dispose(): void;
  67503. /** @hidden */
  67504. onExporting(): void;
  67505. /**
  67506. * Define this method to modify the default behavior when exporting a node
  67507. * @param context The context when exporting the node
  67508. * @param node glTF node
  67509. * @param babylonNode BabylonJS node
  67510. * @returns nullable INode promise
  67511. */
  67512. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  67513. }
  67514. }
  67515. declare module BABYLON {
  67516. /**
  67517. * Class for generating STL data from a Babylon scene.
  67518. */
  67519. export class STLExport {
  67520. /**
  67521. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  67522. * @param meshes list defines the mesh to serialize
  67523. * @param download triggers the automatic download of the file.
  67524. * @param fileName changes the downloads fileName.
  67525. * @param binary changes the STL to a binary type.
  67526. * @param isLittleEndian toggle for binary type exporter.
  67527. * @returns the STL as UTF8 string
  67528. */
  67529. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  67530. }
  67531. }
  67532. /**
  67533. * @ignoreChildren
  67534. * @ignore
  67535. */
  67536. declare module "babylonjs-gltf2interface" {
  67537. export = BABYLON.GLTF2;
  67538. }
  67539. /**
  67540. * Module for glTF 2.0 Interface
  67541. * @ignoreChildren
  67542. * @ignore
  67543. */
  67544. declare module BABYLON.GLTF2 {
  67545. /**
  67546. * The datatype of the components in the attribute
  67547. */
  67548. const enum AccessorComponentType {
  67549. /**
  67550. * Byte
  67551. */
  67552. BYTE = 5120,
  67553. /**
  67554. * Unsigned Byte
  67555. */
  67556. UNSIGNED_BYTE = 5121,
  67557. /**
  67558. * Short
  67559. */
  67560. SHORT = 5122,
  67561. /**
  67562. * Unsigned Short
  67563. */
  67564. UNSIGNED_SHORT = 5123,
  67565. /**
  67566. * Unsigned Int
  67567. */
  67568. UNSIGNED_INT = 5125,
  67569. /**
  67570. * Float
  67571. */
  67572. FLOAT = 5126,
  67573. }
  67574. /**
  67575. * Specifies if the attirbute is a scalar, vector, or matrix
  67576. */
  67577. const enum AccessorType {
  67578. /**
  67579. * Scalar
  67580. */
  67581. SCALAR = "SCALAR",
  67582. /**
  67583. * Vector2
  67584. */
  67585. VEC2 = "VEC2",
  67586. /**
  67587. * Vector3
  67588. */
  67589. VEC3 = "VEC3",
  67590. /**
  67591. * Vector4
  67592. */
  67593. VEC4 = "VEC4",
  67594. /**
  67595. * Matrix2x2
  67596. */
  67597. MAT2 = "MAT2",
  67598. /**
  67599. * Matrix3x3
  67600. */
  67601. MAT3 = "MAT3",
  67602. /**
  67603. * Matrix4x4
  67604. */
  67605. MAT4 = "MAT4",
  67606. }
  67607. /**
  67608. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  67609. */
  67610. const enum AnimationChannelTargetPath {
  67611. /**
  67612. * Translation
  67613. */
  67614. TRANSLATION = "translation",
  67615. /**
  67616. * Rotation
  67617. */
  67618. ROTATION = "rotation",
  67619. /**
  67620. * Scale
  67621. */
  67622. SCALE = "scale",
  67623. /**
  67624. * Weights
  67625. */
  67626. WEIGHTS = "weights",
  67627. }
  67628. /**
  67629. * Interpolation algorithm
  67630. */
  67631. const enum AnimationSamplerInterpolation {
  67632. /**
  67633. * The animated values are linearly interpolated between keyframes
  67634. */
  67635. LINEAR = "LINEAR",
  67636. /**
  67637. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  67638. */
  67639. STEP = "STEP",
  67640. /**
  67641. * The animation's interpolation is computed using a cubic spline with specified tangents
  67642. */
  67643. CUBICSPLINE = "CUBICSPLINE",
  67644. }
  67645. /**
  67646. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  67647. */
  67648. const enum CameraType {
  67649. /**
  67650. * A perspective camera containing properties to create a perspective projection matrix
  67651. */
  67652. PERSPECTIVE = "perspective",
  67653. /**
  67654. * An orthographic camera containing properties to create an orthographic projection matrix
  67655. */
  67656. ORTHOGRAPHIC = "orthographic",
  67657. }
  67658. /**
  67659. * The mime-type of the image
  67660. */
  67661. const enum ImageMimeType {
  67662. /**
  67663. * JPEG Mime-type
  67664. */
  67665. JPEG = "image/jpeg",
  67666. /**
  67667. * PNG Mime-type
  67668. */
  67669. PNG = "image/png",
  67670. }
  67671. /**
  67672. * The alpha rendering mode of the material
  67673. */
  67674. const enum MaterialAlphaMode {
  67675. /**
  67676. * The alpha value is ignored and the rendered output is fully opaque
  67677. */
  67678. OPAQUE = "OPAQUE",
  67679. /**
  67680. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  67681. */
  67682. MASK = "MASK",
  67683. /**
  67684. * 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)
  67685. */
  67686. BLEND = "BLEND",
  67687. }
  67688. /**
  67689. * The type of the primitives to render
  67690. */
  67691. const enum MeshPrimitiveMode {
  67692. /**
  67693. * Points
  67694. */
  67695. POINTS = 0,
  67696. /**
  67697. * Lines
  67698. */
  67699. LINES = 1,
  67700. /**
  67701. * Line Loop
  67702. */
  67703. LINE_LOOP = 2,
  67704. /**
  67705. * Line Strip
  67706. */
  67707. LINE_STRIP = 3,
  67708. /**
  67709. * Triangles
  67710. */
  67711. TRIANGLES = 4,
  67712. /**
  67713. * Triangle Strip
  67714. */
  67715. TRIANGLE_STRIP = 5,
  67716. /**
  67717. * Triangle Fan
  67718. */
  67719. TRIANGLE_FAN = 6,
  67720. }
  67721. /**
  67722. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  67723. */
  67724. const enum TextureMagFilter {
  67725. /**
  67726. * Nearest
  67727. */
  67728. NEAREST = 9728,
  67729. /**
  67730. * Linear
  67731. */
  67732. LINEAR = 9729,
  67733. }
  67734. /**
  67735. * Minification filter. All valid values correspond to WebGL enums
  67736. */
  67737. const enum TextureMinFilter {
  67738. /**
  67739. * Nearest
  67740. */
  67741. NEAREST = 9728,
  67742. /**
  67743. * Linear
  67744. */
  67745. LINEAR = 9729,
  67746. /**
  67747. * Nearest Mip-Map Nearest
  67748. */
  67749. NEAREST_MIPMAP_NEAREST = 9984,
  67750. /**
  67751. * Linear Mipmap Nearest
  67752. */
  67753. LINEAR_MIPMAP_NEAREST = 9985,
  67754. /**
  67755. * Nearest Mipmap Linear
  67756. */
  67757. NEAREST_MIPMAP_LINEAR = 9986,
  67758. /**
  67759. * Linear Mipmap Linear
  67760. */
  67761. LINEAR_MIPMAP_LINEAR = 9987,
  67762. }
  67763. /**
  67764. * S (U) wrapping mode. All valid values correspond to WebGL enums
  67765. */
  67766. const enum TextureWrapMode {
  67767. /**
  67768. * Clamp to Edge
  67769. */
  67770. CLAMP_TO_EDGE = 33071,
  67771. /**
  67772. * Mirrored Repeat
  67773. */
  67774. MIRRORED_REPEAT = 33648,
  67775. /**
  67776. * Repeat
  67777. */
  67778. REPEAT = 10497,
  67779. }
  67780. /**
  67781. * glTF Property
  67782. */
  67783. interface IProperty {
  67784. /**
  67785. * Dictionary object with extension-specific objects
  67786. */
  67787. extensions?: {
  67788. [key: string]: any;
  67789. };
  67790. /**
  67791. * Application-Specific data
  67792. */
  67793. extras?: any;
  67794. }
  67795. /**
  67796. * glTF Child of Root Property
  67797. */
  67798. interface IChildRootProperty extends IProperty {
  67799. /**
  67800. * The user-defined name of this object
  67801. */
  67802. name?: string;
  67803. }
  67804. /**
  67805. * Indices of those attributes that deviate from their initialization value
  67806. */
  67807. interface IAccessorSparseIndices extends IProperty {
  67808. /**
  67809. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  67810. */
  67811. bufferView: number;
  67812. /**
  67813. * The offset relative to the start of the bufferView in bytes. Must be aligned
  67814. */
  67815. byteOffset?: number;
  67816. /**
  67817. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  67818. */
  67819. componentType: AccessorComponentType;
  67820. }
  67821. /**
  67822. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  67823. */
  67824. interface IAccessorSparseValues extends IProperty {
  67825. /**
  67826. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  67827. */
  67828. bufferView: number;
  67829. /**
  67830. * The offset relative to the start of the bufferView in bytes. Must be aligned
  67831. */
  67832. byteOffset?: number;
  67833. }
  67834. /**
  67835. * Sparse storage of attributes that deviate from their initialization value
  67836. */
  67837. interface IAccessorSparse extends IProperty {
  67838. /**
  67839. * The number of attributes encoded in this sparse accessor
  67840. */
  67841. count: number;
  67842. /**
  67843. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  67844. */
  67845. indices: IAccessorSparseIndices;
  67846. /**
  67847. * 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
  67848. */
  67849. values: IAccessorSparseValues;
  67850. }
  67851. /**
  67852. * 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
  67853. */
  67854. interface IAccessor extends IChildRootProperty {
  67855. /**
  67856. * The index of the bufferview
  67857. */
  67858. bufferView?: number;
  67859. /**
  67860. * The offset relative to the start of the bufferView in bytes
  67861. */
  67862. byteOffset?: number;
  67863. /**
  67864. * The datatype of components in the attribute
  67865. */
  67866. componentType: AccessorComponentType;
  67867. /**
  67868. * Specifies whether integer data values should be normalized
  67869. */
  67870. normalized?: boolean;
  67871. /**
  67872. * The number of attributes referenced by this accessor
  67873. */
  67874. count: number;
  67875. /**
  67876. * Specifies if the attribute is a scalar, vector, or matrix
  67877. */
  67878. type: AccessorType;
  67879. /**
  67880. * Maximum value of each component in this attribute
  67881. */
  67882. max?: number[];
  67883. /**
  67884. * Minimum value of each component in this attribute
  67885. */
  67886. min?: number[];
  67887. /**
  67888. * Sparse storage of attributes that deviate from their initialization value
  67889. */
  67890. sparse?: IAccessorSparse;
  67891. }
  67892. /**
  67893. * Targets an animation's sampler at a node's property
  67894. */
  67895. interface IAnimationChannel extends IProperty {
  67896. /**
  67897. * The index of a sampler in this animation used to compute the value for the target
  67898. */
  67899. sampler: number;
  67900. /**
  67901. * The index of the node and TRS property to target
  67902. */
  67903. target: IAnimationChannelTarget;
  67904. }
  67905. /**
  67906. * The index of the node and TRS property that an animation channel targets
  67907. */
  67908. interface IAnimationChannelTarget extends IProperty {
  67909. /**
  67910. * The index of the node to target
  67911. */
  67912. node: number;
  67913. /**
  67914. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  67915. */
  67916. path: AnimationChannelTargetPath;
  67917. }
  67918. /**
  67919. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  67920. */
  67921. interface IAnimationSampler extends IProperty {
  67922. /**
  67923. * The index of an accessor containing keyframe input values, e.g., time
  67924. */
  67925. input: number;
  67926. /**
  67927. * Interpolation algorithm
  67928. */
  67929. interpolation?: AnimationSamplerInterpolation;
  67930. /**
  67931. * The index of an accessor, containing keyframe output values
  67932. */
  67933. output: number;
  67934. }
  67935. /**
  67936. * A keyframe animation
  67937. */
  67938. interface IAnimation extends IChildRootProperty {
  67939. /**
  67940. * An array of channels, each of which targets an animation's sampler at a node's property
  67941. */
  67942. channels: IAnimationChannel[];
  67943. /**
  67944. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  67945. */
  67946. samplers: IAnimationSampler[];
  67947. }
  67948. /**
  67949. * Metadata about the glTF asset
  67950. */
  67951. interface IAsset extends IChildRootProperty {
  67952. /**
  67953. * A copyright message suitable for display to credit the content creator
  67954. */
  67955. copyright?: string;
  67956. /**
  67957. * Tool that generated this glTF model. Useful for debugging
  67958. */
  67959. generator?: string;
  67960. /**
  67961. * The glTF version that this asset targets
  67962. */
  67963. version: string;
  67964. /**
  67965. * The minimum glTF version that this asset targets
  67966. */
  67967. minVersion?: string;
  67968. }
  67969. /**
  67970. * A buffer points to binary geometry, animation, or skins
  67971. */
  67972. interface IBuffer extends IChildRootProperty {
  67973. /**
  67974. * 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
  67975. */
  67976. uri?: string;
  67977. /**
  67978. * The length of the buffer in bytes
  67979. */
  67980. byteLength: number;
  67981. }
  67982. /**
  67983. * A view into a buffer generally representing a subset of the buffer
  67984. */
  67985. interface IBufferView extends IChildRootProperty {
  67986. /**
  67987. * The index of the buffer
  67988. */
  67989. buffer: number;
  67990. /**
  67991. * The offset into the buffer in bytes
  67992. */
  67993. byteOffset?: number;
  67994. /**
  67995. * The lenth of the bufferView in bytes
  67996. */
  67997. byteLength: number;
  67998. /**
  67999. * The stride, in bytes
  68000. */
  68001. byteStride?: number;
  68002. }
  68003. /**
  68004. * An orthographic camera containing properties to create an orthographic projection matrix
  68005. */
  68006. interface ICameraOrthographic extends IProperty {
  68007. /**
  68008. * The floating-point horizontal magnification of the view. Must not be zero
  68009. */
  68010. xmag: number;
  68011. /**
  68012. * The floating-point vertical magnification of the view. Must not be zero
  68013. */
  68014. ymag: number;
  68015. /**
  68016. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  68017. */
  68018. zfar: number;
  68019. /**
  68020. * The floating-point distance to the near clipping plane
  68021. */
  68022. znear: number;
  68023. }
  68024. /**
  68025. * A perspective camera containing properties to create a perspective projection matrix
  68026. */
  68027. interface ICameraPerspective extends IProperty {
  68028. /**
  68029. * The floating-point aspect ratio of the field of view
  68030. */
  68031. aspectRatio?: number;
  68032. /**
  68033. * The floating-point vertical field of view in radians
  68034. */
  68035. yfov: number;
  68036. /**
  68037. * The floating-point distance to the far clipping plane
  68038. */
  68039. zfar?: number;
  68040. /**
  68041. * The floating-point distance to the near clipping plane
  68042. */
  68043. znear: number;
  68044. }
  68045. /**
  68046. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  68047. */
  68048. interface ICamera extends IChildRootProperty {
  68049. /**
  68050. * An orthographic camera containing properties to create an orthographic projection matrix
  68051. */
  68052. orthographic?: ICameraOrthographic;
  68053. /**
  68054. * A perspective camera containing properties to create a perspective projection matrix
  68055. */
  68056. perspective?: ICameraPerspective;
  68057. /**
  68058. * Specifies if the camera uses a perspective or orthographic projection
  68059. */
  68060. type: CameraType;
  68061. }
  68062. /**
  68063. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  68064. */
  68065. interface IImage extends IChildRootProperty {
  68066. /**
  68067. * 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
  68068. */
  68069. uri?: string;
  68070. /**
  68071. * The image's MIME type
  68072. */
  68073. mimeType?: ImageMimeType;
  68074. /**
  68075. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  68076. */
  68077. bufferView?: number;
  68078. }
  68079. /**
  68080. * Material Normal Texture Info
  68081. */
  68082. interface IMaterialNormalTextureInfo extends ITextureInfo {
  68083. /**
  68084. * The scalar multiplier applied to each normal vector of the normal texture
  68085. */
  68086. scale?: number;
  68087. }
  68088. /**
  68089. * Material Occlusion Texture Info
  68090. */
  68091. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  68092. /**
  68093. * A scalar multiplier controlling the amount of occlusion applied
  68094. */
  68095. strength?: number;
  68096. }
  68097. /**
  68098. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  68099. */
  68100. interface IMaterialPbrMetallicRoughness {
  68101. /**
  68102. * The material's base color factor
  68103. */
  68104. baseColorFactor?: number[];
  68105. /**
  68106. * The base color texture
  68107. */
  68108. baseColorTexture?: ITextureInfo;
  68109. /**
  68110. * The metalness of the material
  68111. */
  68112. metallicFactor?: number;
  68113. /**
  68114. * The roughness of the material
  68115. */
  68116. roughnessFactor?: number;
  68117. /**
  68118. * The metallic-roughness texture
  68119. */
  68120. metallicRoughnessTexture?: ITextureInfo;
  68121. }
  68122. /**
  68123. * The material appearance of a primitive
  68124. */
  68125. interface IMaterial extends IChildRootProperty {
  68126. /**
  68127. * 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
  68128. */
  68129. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  68130. /**
  68131. * The normal map texture
  68132. */
  68133. normalTexture?: IMaterialNormalTextureInfo;
  68134. /**
  68135. * The occlusion map texture
  68136. */
  68137. occlusionTexture?: IMaterialOcclusionTextureInfo;
  68138. /**
  68139. * The emissive map texture
  68140. */
  68141. emissiveTexture?: ITextureInfo;
  68142. /**
  68143. * 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
  68144. */
  68145. emissiveFactor?: number[];
  68146. /**
  68147. * The alpha rendering mode of the material
  68148. */
  68149. alphaMode?: MaterialAlphaMode;
  68150. /**
  68151. * The alpha cutoff value of the material
  68152. */
  68153. alphaCutoff?: number;
  68154. /**
  68155. * Specifies whether the material is double sided
  68156. */
  68157. doubleSided?: boolean;
  68158. }
  68159. /**
  68160. * Geometry to be rendered with the given material
  68161. */
  68162. interface IMeshPrimitive extends IProperty {
  68163. /**
  68164. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  68165. */
  68166. attributes: {
  68167. [name: string]: number;
  68168. };
  68169. /**
  68170. * The index of the accessor that contains the indices
  68171. */
  68172. indices?: number;
  68173. /**
  68174. * The index of the material to apply to this primitive when rendering
  68175. */
  68176. material?: number;
  68177. /**
  68178. * The type of primitives to render. All valid values correspond to WebGL enums
  68179. */
  68180. mode?: MeshPrimitiveMode;
  68181. /**
  68182. * 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
  68183. */
  68184. targets?: {
  68185. [name: string]: number;
  68186. }[];
  68187. }
  68188. /**
  68189. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  68190. */
  68191. interface IMesh extends IChildRootProperty {
  68192. /**
  68193. * An array of primitives, each defining geometry to be rendered with a material
  68194. */
  68195. primitives: IMeshPrimitive[];
  68196. /**
  68197. * Array of weights to be applied to the Morph Targets
  68198. */
  68199. weights?: number[];
  68200. }
  68201. /**
  68202. * A node in the node hierarchy
  68203. */
  68204. interface INode extends IChildRootProperty {
  68205. /**
  68206. * The index of the camera referenced by this node
  68207. */
  68208. camera?: number;
  68209. /**
  68210. * The indices of this node's children
  68211. */
  68212. children?: number[];
  68213. /**
  68214. * The index of the skin referenced by this node
  68215. */
  68216. skin?: number;
  68217. /**
  68218. * A floating-point 4x4 transformation matrix stored in column-major order
  68219. */
  68220. matrix?: number[];
  68221. /**
  68222. * The index of the mesh in this node
  68223. */
  68224. mesh?: number;
  68225. /**
  68226. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  68227. */
  68228. rotation?: number[];
  68229. /**
  68230. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  68231. */
  68232. scale?: number[];
  68233. /**
  68234. * The node's translation along the x, y, and z axes
  68235. */
  68236. translation?: number[];
  68237. /**
  68238. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  68239. */
  68240. weights?: number[];
  68241. }
  68242. /**
  68243. * Texture sampler properties for filtering and wrapping modes
  68244. */
  68245. interface ISampler extends IChildRootProperty {
  68246. /**
  68247. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  68248. */
  68249. magFilter?: TextureMagFilter;
  68250. /**
  68251. * Minification filter. All valid values correspond to WebGL enums
  68252. */
  68253. minFilter?: TextureMinFilter;
  68254. /**
  68255. * S (U) wrapping mode. All valid values correspond to WebGL enums
  68256. */
  68257. wrapS?: TextureWrapMode;
  68258. /**
  68259. * T (V) wrapping mode. All valid values correspond to WebGL enums
  68260. */
  68261. wrapT?: TextureWrapMode;
  68262. }
  68263. /**
  68264. * The root nodes of a scene
  68265. */
  68266. interface IScene extends IChildRootProperty {
  68267. /**
  68268. * The indices of each root node
  68269. */
  68270. nodes: number[];
  68271. }
  68272. /**
  68273. * Joints and matrices defining a skin
  68274. */
  68275. interface ISkin extends IChildRootProperty {
  68276. /**
  68277. * 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
  68278. */
  68279. inverseBindMatrices?: number;
  68280. /**
  68281. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  68282. */
  68283. skeleton?: number;
  68284. /**
  68285. * 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)
  68286. */
  68287. joints: number[];
  68288. }
  68289. /**
  68290. * A texture and its sampler
  68291. */
  68292. interface ITexture extends IChildRootProperty {
  68293. /**
  68294. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  68295. */
  68296. sampler?: number;
  68297. /**
  68298. * The index of the image used by this texture
  68299. */
  68300. source: number;
  68301. }
  68302. /**
  68303. * Reference to a texture
  68304. */
  68305. interface ITextureInfo extends IProperty {
  68306. /**
  68307. * The index of the texture
  68308. */
  68309. index: number;
  68310. /**
  68311. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  68312. */
  68313. texCoord?: number;
  68314. }
  68315. /**
  68316. * The root object for a glTF asset
  68317. */
  68318. interface IGLTF extends IProperty {
  68319. /**
  68320. * An array of accessors. An accessor is a typed view into a bufferView
  68321. */
  68322. accessors?: IAccessor[];
  68323. /**
  68324. * An array of keyframe animations
  68325. */
  68326. animations?: IAnimation[];
  68327. /**
  68328. * Metadata about the glTF asset
  68329. */
  68330. asset: IAsset;
  68331. /**
  68332. * An array of buffers. A buffer points to binary geometry, animation, or skins
  68333. */
  68334. buffers?: IBuffer[];
  68335. /**
  68336. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  68337. */
  68338. bufferViews?: IBufferView[];
  68339. /**
  68340. * An array of cameras
  68341. */
  68342. cameras?: ICamera[];
  68343. /**
  68344. * Names of glTF extensions used somewhere in this asset
  68345. */
  68346. extensionsUsed?: string[];
  68347. /**
  68348. * Names of glTF extensions required to properly load this asset
  68349. */
  68350. extensionsRequired?: string[];
  68351. /**
  68352. * An array of images. An image defines data used to create a texture
  68353. */
  68354. images?: IImage[];
  68355. /**
  68356. * An array of materials. A material defines the appearance of a primitive
  68357. */
  68358. materials?: IMaterial[];
  68359. /**
  68360. * An array of meshes. A mesh is a set of primitives to be rendered
  68361. */
  68362. meshes?: IMesh[];
  68363. /**
  68364. * An array of nodes
  68365. */
  68366. nodes?: INode[];
  68367. /**
  68368. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  68369. */
  68370. samplers?: ISampler[];
  68371. /**
  68372. * The index of the default scene
  68373. */
  68374. scene?: number;
  68375. /**
  68376. * An array of scenes
  68377. */
  68378. scenes?: IScene[];
  68379. /**
  68380. * An array of skins. A skin is defined by joints and matrices
  68381. */
  68382. skins?: ISkin[];
  68383. /**
  68384. * An array of textures
  68385. */
  68386. textures?: ITexture[];
  68387. }
  68388. /**
  68389. * The glTF validation results
  68390. */
  68391. interface IGLTFValidationResults {
  68392. info: {
  68393. generator: string;
  68394. hasAnimations: boolean;
  68395. hasDefaultScene: boolean;
  68396. hasMaterials: boolean;
  68397. hasMorphTargets: boolean;
  68398. hasSkins: boolean;
  68399. hasTextures: boolean;
  68400. maxAttributesUsed: number;
  68401. primitivesCount: number
  68402. };
  68403. issues: {
  68404. messages: Array<string>;
  68405. numErrors: number;
  68406. numHints: number;
  68407. numInfos: number;
  68408. numWarnings: number;
  68409. truncated: boolean
  68410. };
  68411. mimeType: string;
  68412. uri: string;
  68413. validatedAt: string;
  68414. validatorVersion: string;
  68415. }
  68416. /**
  68417. * The glTF validation options
  68418. */
  68419. interface IGLTFValidationOptions {
  68420. uri?: string;
  68421. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  68422. validateAccessorData?: boolean;
  68423. maxIssues?: number;
  68424. ignoredIssues?: Array<string>;
  68425. severityOverrides?: Object;
  68426. }
  68427. /**
  68428. * The glTF validator object
  68429. */
  68430. interface IGLTFValidator {
  68431. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  68432. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  68433. }
  68434. }
  68435. declare module BABYLON {
  68436. /** @hidden */
  68437. export var cellPixelShader: {
  68438. name: string;
  68439. shader: string;
  68440. };
  68441. }
  68442. declare module BABYLON {
  68443. /** @hidden */
  68444. export var cellVertexShader: {
  68445. name: string;
  68446. shader: string;
  68447. };
  68448. }
  68449. declare module BABYLON {
  68450. export class CellMaterial extends BABYLON.PushMaterial {
  68451. private _diffuseTexture;
  68452. diffuseTexture: BABYLON.BaseTexture;
  68453. diffuseColor: BABYLON.Color3; private _computeHighLevel: boolean;
  68454. computeHighLevel: boolean;
  68455. private _disableLighting;
  68456. disableLighting: boolean;
  68457. private _maxSimultaneousLights;
  68458. maxSimultaneousLights: number;
  68459. private _renderId;
  68460. constructor(name: string, scene: BABYLON.Scene);
  68461. needAlphaBlending(): boolean;
  68462. needAlphaTesting(): boolean;
  68463. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68464. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68465. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68466. getAnimatables(): BABYLON.IAnimatable[];
  68467. getActiveTextures(): BABYLON.BaseTexture[];
  68468. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68469. dispose(forceDisposeEffect?: boolean): void;
  68470. getClassName(): string;
  68471. clone(name: string): CellMaterial;
  68472. serialize(): any;
  68473. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  68474. }
  68475. }
  68476. declare module BABYLON {
  68477. export class CustomShaderStructure {
  68478. FragmentStore: string;
  68479. VertexStore: string;
  68480. constructor();
  68481. }
  68482. export class ShaderSpecialParts {
  68483. constructor();
  68484. Fragment_Begin: string;
  68485. Fragment_Definitions: string;
  68486. Fragment_MainBegin: string;
  68487. Fragment_Custom_Diffuse: string;
  68488. Fragment_Before_Lights: string;
  68489. Fragment_Before_Fog: string;
  68490. Fragment_Custom_Alpha: string;
  68491. Fragment_Before_FragColor: string;
  68492. Vertex_Begin: string;
  68493. Vertex_Definitions: string;
  68494. Vertex_MainBegin: string;
  68495. Vertex_Before_PositionUpdated: string;
  68496. Vertex_Before_NormalUpdated: string;
  68497. Vertex_MainEnd: string;
  68498. }
  68499. export class CustomMaterial extends BABYLON.StandardMaterial {
  68500. static ShaderIndexer: number;
  68501. CustomParts: ShaderSpecialParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  68502. FragmentShader: string;
  68503. VertexShader: string;
  68504. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  68505. ReviewUniform(name: string, arr: string[]): string[];
  68506. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  68507. constructor(name: string, scene: BABYLON.Scene);
  68508. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  68509. Fragment_Begin(shaderPart: string): CustomMaterial;
  68510. Fragment_Definitions(shaderPart: string): CustomMaterial;
  68511. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  68512. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  68513. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  68514. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  68515. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  68516. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  68517. Vertex_Begin(shaderPart: string): CustomMaterial;
  68518. Vertex_Definitions(shaderPart: string): CustomMaterial;
  68519. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  68520. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  68521. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  68522. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  68523. }
  68524. }
  68525. declare module BABYLON {
  68526. export class ShaderAlebdoParts {
  68527. constructor();
  68528. Fragment_Begin: string;
  68529. Fragment_Definitions: string;
  68530. Fragment_MainBegin: string;
  68531. Fragment_Custom_Albedo: string;
  68532. Fragment_Before_Lights: string;
  68533. Fragment_Custom_MetallicRoughness: string;
  68534. Fragment_Custom_MicroSurface: string;
  68535. Fragment_Before_Fog: string;
  68536. Fragment_Custom_Alpha: string;
  68537. Fragment_Before_FragColor: string;
  68538. Vertex_Begin: string;
  68539. Vertex_Definitions: string;
  68540. Vertex_MainBegin: string;
  68541. Vertex_Before_PositionUpdated: string;
  68542. Vertex_Before_NormalUpdated: string;
  68543. Vertex_MainEnd: string;
  68544. }
  68545. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  68546. static ShaderIndexer: number;
  68547. CustomParts: ShaderAlebdoParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  68548. FragmentShader: string;
  68549. VertexShader: string;
  68550. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  68551. ReviewUniform(name: string, arr: string[]): string[];
  68552. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  68553. constructor(name: string, scene: BABYLON.Scene);
  68554. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  68555. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  68556. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  68557. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  68558. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  68559. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  68560. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  68561. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  68562. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  68563. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  68564. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  68565. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  68566. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  68567. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  68568. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  68569. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  68570. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  68571. }
  68572. }
  68573. declare module BABYLON {
  68574. /** @hidden */
  68575. export var firePixelShader: {
  68576. name: string;
  68577. shader: string;
  68578. };
  68579. }
  68580. declare module BABYLON {
  68581. /** @hidden */
  68582. export var fireVertexShader: {
  68583. name: string;
  68584. shader: string;
  68585. };
  68586. }
  68587. declare module BABYLON {
  68588. export class FireMaterial extends BABYLON.PushMaterial {
  68589. private _diffuseTexture;
  68590. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  68591. private _distortionTexture;
  68592. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  68593. private _opacityTexture;
  68594. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  68595. diffuseColor: BABYLON.Color3;
  68596. speed: number;
  68597. private _scaledDiffuse;
  68598. private _renderId;
  68599. private _lastTime;
  68600. constructor(name: string, scene: BABYLON.Scene);
  68601. needAlphaBlending(): boolean;
  68602. needAlphaTesting(): boolean;
  68603. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68604. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68605. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68606. getAnimatables(): BABYLON.IAnimatable[];
  68607. getActiveTextures(): BABYLON.BaseTexture[];
  68608. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68609. getClassName(): string;
  68610. dispose(forceDisposeEffect?: boolean): void;
  68611. clone(name: string): FireMaterial;
  68612. serialize(): any;
  68613. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  68614. }
  68615. }
  68616. declare module BABYLON {
  68617. /** @hidden */
  68618. export var furPixelShader: {
  68619. name: string;
  68620. shader: string;
  68621. };
  68622. }
  68623. declare module BABYLON {
  68624. /** @hidden */
  68625. export var furVertexShader: {
  68626. name: string;
  68627. shader: string;
  68628. };
  68629. }
  68630. declare module BABYLON {
  68631. export class FurMaterial extends BABYLON.PushMaterial {
  68632. private _diffuseTexture;
  68633. diffuseTexture: BABYLON.BaseTexture;
  68634. private _heightTexture;
  68635. heightTexture: BABYLON.BaseTexture;
  68636. diffuseColor: BABYLON.Color3;
  68637. furLength: number;
  68638. furAngle: number;
  68639. furColor: BABYLON.Color3;
  68640. furOffset: number;
  68641. furSpacing: number;
  68642. furGravity: BABYLON.Vector3;
  68643. furSpeed: number;
  68644. furDensity: number;
  68645. furOcclusion: number;
  68646. furTexture: BABYLON.DynamicTexture;
  68647. private _disableLighting;
  68648. disableLighting: boolean;
  68649. private _maxSimultaneousLights;
  68650. maxSimultaneousLights: number;
  68651. highLevelFur: boolean; private _meshes: BABYLON.AbstractMesh[];
  68652. private _renderId;
  68653. private _furTime;
  68654. constructor(name: string, scene: BABYLON.Scene);
  68655. furTime: number;
  68656. needAlphaBlending(): boolean;
  68657. needAlphaTesting(): boolean;
  68658. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68659. updateFur(): void;
  68660. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68661. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68662. getAnimatables(): BABYLON.IAnimatable[];
  68663. getActiveTextures(): BABYLON.BaseTexture[];
  68664. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68665. dispose(forceDisposeEffect?: boolean): void;
  68666. clone(name: string): FurMaterial;
  68667. serialize(): any;
  68668. getClassName(): string;
  68669. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  68670. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  68671. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  68672. }
  68673. }
  68674. declare module BABYLON {
  68675. /** @hidden */
  68676. export var gradientPixelShader: {
  68677. name: string;
  68678. shader: string;
  68679. };
  68680. }
  68681. declare module BABYLON {
  68682. /** @hidden */
  68683. export var gradientVertexShader: {
  68684. name: string;
  68685. shader: string;
  68686. };
  68687. }
  68688. declare module BABYLON {
  68689. export class GradientMaterial extends BABYLON.PushMaterial {
  68690. private _maxSimultaneousLights;
  68691. maxSimultaneousLights: number;
  68692. topColor: BABYLON.Color3;
  68693. topColorAlpha: number;
  68694. bottomColor: BABYLON.Color3;
  68695. bottomColorAlpha: number;
  68696. offset: number;
  68697. scale: number;
  68698. smoothness: number;
  68699. private _disableLighting;
  68700. disableLighting: boolean;
  68701. private _renderId;
  68702. constructor(name: string, scene: BABYLON.Scene);
  68703. needAlphaBlending(): boolean;
  68704. needAlphaTesting(): boolean;
  68705. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68706. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68707. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68708. getAnimatables(): BABYLON.IAnimatable[];
  68709. dispose(forceDisposeEffect?: boolean): void;
  68710. clone(name: string): GradientMaterial;
  68711. serialize(): any;
  68712. getClassName(): string;
  68713. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  68714. }
  68715. }
  68716. declare module BABYLON {
  68717. /** @hidden */
  68718. export var gridPixelShader: {
  68719. name: string;
  68720. shader: string;
  68721. };
  68722. }
  68723. declare module BABYLON {
  68724. /** @hidden */
  68725. export var gridVertexShader: {
  68726. name: string;
  68727. shader: string;
  68728. };
  68729. }
  68730. declare module BABYLON {
  68731. /**
  68732. * The grid materials allows you to wrap any shape with a grid.
  68733. * Colors are customizable.
  68734. */
  68735. export class GridMaterial extends BABYLON.PushMaterial {
  68736. /**
  68737. * Main color of the grid (e.g. between lines)
  68738. */
  68739. mainColor: BABYLON.Color3;
  68740. /**
  68741. * Color of the grid lines.
  68742. */
  68743. lineColor: BABYLON.Color3;
  68744. /**
  68745. * The scale of the grid compared to unit.
  68746. */
  68747. gridRatio: number;
  68748. /**
  68749. * Allows setting an offset for the grid lines.
  68750. */
  68751. gridOffset: BABYLON.Vector3;
  68752. /**
  68753. * The frequency of thicker lines.
  68754. */
  68755. majorUnitFrequency: number;
  68756. /**
  68757. * The visibility of minor units in the grid.
  68758. */
  68759. minorUnitVisibility: number;
  68760. /**
  68761. * The grid opacity outside of the lines.
  68762. */
  68763. opacity: number;
  68764. /**
  68765. * Determine RBG output is premultiplied by alpha value.
  68766. */
  68767. preMultiplyAlpha: boolean;
  68768. private _opacityTexture;
  68769. opacityTexture: BABYLON.BaseTexture;
  68770. private _gridControl;
  68771. private _renderId;
  68772. /**
  68773. * constructor
  68774. * @param name The name given to the material in order to identify it afterwards.
  68775. * @param scene The scene the material is used in.
  68776. */
  68777. constructor(name: string, scene: BABYLON.Scene);
  68778. /**
  68779. * Returns wehter or not the grid requires alpha blending.
  68780. */
  68781. needAlphaBlending(): boolean;
  68782. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  68783. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68784. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68785. /**
  68786. * Dispose the material and its associated resources.
  68787. * @param forceDisposeEffect will also dispose the used effect when true
  68788. */
  68789. dispose(forceDisposeEffect?: boolean): void;
  68790. clone(name: string): GridMaterial;
  68791. serialize(): any;
  68792. getClassName(): string;
  68793. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  68794. }
  68795. }
  68796. declare module BABYLON {
  68797. /** @hidden */
  68798. export var lavaPixelShader: {
  68799. name: string;
  68800. shader: string;
  68801. };
  68802. }
  68803. declare module BABYLON {
  68804. /** @hidden */
  68805. export var lavaVertexShader: {
  68806. name: string;
  68807. shader: string;
  68808. };
  68809. }
  68810. declare module BABYLON {
  68811. export class LavaMaterial extends BABYLON.PushMaterial {
  68812. private _diffuseTexture;
  68813. diffuseTexture: BABYLON.BaseTexture;
  68814. noiseTexture: BABYLON.BaseTexture;
  68815. fogColor: BABYLON.Color3;
  68816. speed: number;
  68817. movingSpeed: number;
  68818. lowFrequencySpeed: number;
  68819. fogDensity: number;
  68820. private _lastTime;
  68821. diffuseColor: BABYLON.Color3;
  68822. private _disableLighting;
  68823. disableLighting: boolean;
  68824. private _unlit;
  68825. unlit: boolean;
  68826. private _maxSimultaneousLights;
  68827. maxSimultaneousLights: number;
  68828. private _scaledDiffuse;
  68829. private _renderId;
  68830. constructor(name: string, scene: BABYLON.Scene);
  68831. needAlphaBlending(): boolean;
  68832. needAlphaTesting(): boolean;
  68833. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68834. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68835. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68836. getAnimatables(): BABYLON.IAnimatable[];
  68837. getActiveTextures(): BABYLON.BaseTexture[];
  68838. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68839. dispose(forceDisposeEffect?: boolean): void;
  68840. clone(name: string): LavaMaterial;
  68841. serialize(): any;
  68842. getClassName(): string;
  68843. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  68844. }
  68845. }
  68846. declare module BABYLON {
  68847. /** @hidden */
  68848. export var mixPixelShader: {
  68849. name: string;
  68850. shader: string;
  68851. };
  68852. }
  68853. declare module BABYLON {
  68854. /** @hidden */
  68855. export var mixVertexShader: {
  68856. name: string;
  68857. shader: string;
  68858. };
  68859. }
  68860. declare module BABYLON {
  68861. export class MixMaterial extends BABYLON.PushMaterial {
  68862. /**
  68863. * Mix textures
  68864. */
  68865. private _mixTexture1;
  68866. mixTexture1: BABYLON.BaseTexture;
  68867. private _mixTexture2;
  68868. mixTexture2: BABYLON.BaseTexture;
  68869. /**
  68870. * Diffuse textures
  68871. */
  68872. private _diffuseTexture1;
  68873. diffuseTexture1: BABYLON.Texture;
  68874. private _diffuseTexture2;
  68875. diffuseTexture2: BABYLON.Texture;
  68876. private _diffuseTexture3;
  68877. diffuseTexture3: BABYLON.Texture;
  68878. private _diffuseTexture4;
  68879. diffuseTexture4: BABYLON.Texture;
  68880. private _diffuseTexture5;
  68881. diffuseTexture5: BABYLON.Texture;
  68882. private _diffuseTexture6;
  68883. diffuseTexture6: BABYLON.Texture;
  68884. private _diffuseTexture7;
  68885. diffuseTexture7: BABYLON.Texture;
  68886. private _diffuseTexture8;
  68887. diffuseTexture8: BABYLON.Texture;
  68888. /**
  68889. * Uniforms
  68890. */
  68891. diffuseColor: BABYLON.Color3;
  68892. specularColor: BABYLON.Color3;
  68893. specularPower: number;
  68894. private _disableLighting;
  68895. disableLighting: boolean;
  68896. private _maxSimultaneousLights;
  68897. maxSimultaneousLights: number;
  68898. private _renderId;
  68899. constructor(name: string, scene: BABYLON.Scene);
  68900. needAlphaBlending(): boolean;
  68901. needAlphaTesting(): boolean;
  68902. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68903. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68904. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68905. getAnimatables(): BABYLON.IAnimatable[];
  68906. getActiveTextures(): BABYLON.BaseTexture[];
  68907. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68908. dispose(forceDisposeEffect?: boolean): void;
  68909. clone(name: string): MixMaterial;
  68910. serialize(): any;
  68911. getClassName(): string;
  68912. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  68913. }
  68914. }
  68915. declare module BABYLON {
  68916. /** @hidden */
  68917. export var normalPixelShader: {
  68918. name: string;
  68919. shader: string;
  68920. };
  68921. }
  68922. declare module BABYLON {
  68923. /** @hidden */
  68924. export var normalVertexShader: {
  68925. name: string;
  68926. shader: string;
  68927. };
  68928. }
  68929. declare module BABYLON {
  68930. export class NormalMaterial extends BABYLON.PushMaterial {
  68931. private _diffuseTexture;
  68932. diffuseTexture: BABYLON.BaseTexture;
  68933. diffuseColor: BABYLON.Color3;
  68934. private _disableLighting;
  68935. disableLighting: boolean;
  68936. private _maxSimultaneousLights;
  68937. maxSimultaneousLights: number;
  68938. private _renderId;
  68939. constructor(name: string, scene: BABYLON.Scene);
  68940. needAlphaBlending(): boolean;
  68941. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  68942. needAlphaTesting(): boolean;
  68943. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68944. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68945. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68946. getAnimatables(): BABYLON.IAnimatable[];
  68947. getActiveTextures(): BABYLON.BaseTexture[];
  68948. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68949. dispose(forceDisposeEffect?: boolean): void;
  68950. clone(name: string): NormalMaterial;
  68951. serialize(): any;
  68952. getClassName(): string;
  68953. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  68954. }
  68955. }
  68956. declare module BABYLON {
  68957. /** @hidden */
  68958. export var shadowOnlyPixelShader: {
  68959. name: string;
  68960. shader: string;
  68961. };
  68962. }
  68963. declare module BABYLON {
  68964. /** @hidden */
  68965. export var shadowOnlyVertexShader: {
  68966. name: string;
  68967. shader: string;
  68968. };
  68969. }
  68970. declare module BABYLON {
  68971. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  68972. private _renderId;
  68973. private _activeLight;
  68974. constructor(name: string, scene: BABYLON.Scene);
  68975. shadowColor: BABYLON.Color3;
  68976. needAlphaBlending(): boolean;
  68977. needAlphaTesting(): boolean;
  68978. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68979. activeLight: BABYLON.IShadowLight;
  68980. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68981. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68982. clone(name: string): ShadowOnlyMaterial;
  68983. serialize(): any;
  68984. getClassName(): string;
  68985. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  68986. }
  68987. }
  68988. declare module BABYLON {
  68989. /** @hidden */
  68990. export var simplePixelShader: {
  68991. name: string;
  68992. shader: string;
  68993. };
  68994. }
  68995. declare module BABYLON {
  68996. /** @hidden */
  68997. export var simpleVertexShader: {
  68998. name: string;
  68999. shader: string;
  69000. };
  69001. }
  69002. declare module BABYLON {
  69003. export class SimpleMaterial extends BABYLON.PushMaterial {
  69004. private _diffuseTexture;
  69005. diffuseTexture: BABYLON.BaseTexture;
  69006. diffuseColor: BABYLON.Color3;
  69007. private _disableLighting;
  69008. disableLighting: boolean;
  69009. private _maxSimultaneousLights;
  69010. maxSimultaneousLights: number;
  69011. private _renderId;
  69012. constructor(name: string, scene: BABYLON.Scene);
  69013. needAlphaBlending(): boolean;
  69014. needAlphaTesting(): boolean;
  69015. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69016. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69017. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69018. getAnimatables(): BABYLON.IAnimatable[];
  69019. getActiveTextures(): BABYLON.BaseTexture[];
  69020. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69021. dispose(forceDisposeEffect?: boolean): void;
  69022. clone(name: string): SimpleMaterial;
  69023. serialize(): any;
  69024. getClassName(): string;
  69025. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  69026. }
  69027. }
  69028. declare module BABYLON {
  69029. /** @hidden */
  69030. export var skyPixelShader: {
  69031. name: string;
  69032. shader: string;
  69033. };
  69034. }
  69035. declare module BABYLON {
  69036. /** @hidden */
  69037. export var skyVertexShader: {
  69038. name: string;
  69039. shader: string;
  69040. };
  69041. }
  69042. declare module BABYLON {
  69043. /**
  69044. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  69045. * @see https://doc.babylonjs.com/extensions/sky
  69046. */
  69047. export class SkyMaterial extends BABYLON.PushMaterial {
  69048. /**
  69049. * Defines the overall luminance of sky in interval ]0, 1[.
  69050. */
  69051. luminance: number;
  69052. /**
  69053. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  69054. */
  69055. turbidity: number;
  69056. /**
  69057. * Defines the sky appearance (light intensity).
  69058. */
  69059. rayleigh: number;
  69060. /**
  69061. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  69062. */
  69063. mieCoefficient: number;
  69064. /**
  69065. * Defines the amount of haze particles following the Mie scattering theory.
  69066. */
  69067. mieDirectionalG: number;
  69068. /**
  69069. * Defines the distance of the sun according to the active scene camera.
  69070. */
  69071. distance: number;
  69072. /**
  69073. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  69074. * "inclined".
  69075. */
  69076. inclination: number;
  69077. /**
  69078. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  69079. * an object direction and a reference direction.
  69080. */
  69081. azimuth: number;
  69082. /**
  69083. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  69084. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  69085. */
  69086. sunPosition: BABYLON.Vector3;
  69087. /**
  69088. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  69089. * .sunPosition property.
  69090. */
  69091. useSunPosition: boolean;
  69092. /**
  69093. * Defines an offset vector used to get a horizon offset.
  69094. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  69095. */
  69096. cameraOffset: BABYLON.Vector3;
  69097. private _cameraPosition;
  69098. private _renderId;
  69099. /**
  69100. * Instantiates a new sky material.
  69101. * This material allows to create dynamic and texture free
  69102. * effects for skyboxes by taking care of the atmosphere state.
  69103. * @see https://doc.babylonjs.com/extensions/sky
  69104. * @param name Define the name of the material in the scene
  69105. * @param scene Define the scene the material belong to
  69106. */
  69107. constructor(name: string, scene: BABYLON.Scene);
  69108. /**
  69109. * Specifies if the material will require alpha blending
  69110. * @returns a boolean specifying if alpha blending is needed
  69111. */
  69112. needAlphaBlending(): boolean;
  69113. /**
  69114. * Specifies if this material should be rendered in alpha test mode
  69115. * @returns false as the sky material doesn't need alpha testing.
  69116. */
  69117. needAlphaTesting(): boolean;
  69118. /**
  69119. * Get the texture used for alpha test purpose.
  69120. * @returns null as the sky material has no texture.
  69121. */
  69122. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69123. /**
  69124. * Get if the submesh is ready to be used and all its information available.
  69125. * Child classes can use it to update shaders
  69126. * @param mesh defines the mesh to check
  69127. * @param subMesh defines which submesh to check
  69128. * @param useInstances specifies that instances should be used
  69129. * @returns a boolean indicating that the submesh is ready or not
  69130. */
  69131. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69132. /**
  69133. * Binds the submesh to this material by preparing the effect and shader to draw
  69134. * @param world defines the world transformation matrix
  69135. * @param mesh defines the mesh containing the submesh
  69136. * @param subMesh defines the submesh to bind the material to
  69137. */
  69138. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69139. /**
  69140. * Get the list of animatables in the material.
  69141. * @returns the list of animatables object used in the material
  69142. */
  69143. getAnimatables(): BABYLON.IAnimatable[];
  69144. /**
  69145. * Disposes the material
  69146. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  69147. */
  69148. dispose(forceDisposeEffect?: boolean): void;
  69149. /**
  69150. * Makes a duplicate of the material, and gives it a new name
  69151. * @param name defines the new name for the duplicated material
  69152. * @returns the cloned material
  69153. */
  69154. clone(name: string): SkyMaterial;
  69155. /**
  69156. * Serializes this material in a JSON representation
  69157. * @returns the serialized material object
  69158. */
  69159. serialize(): any;
  69160. /**
  69161. * Gets the current class name of the material e.g. "SkyMaterial"
  69162. * Mainly use in serialization.
  69163. * @returns the class name
  69164. */
  69165. getClassName(): string;
  69166. /**
  69167. * Creates a sky material from parsed material data
  69168. * @param source defines the JSON representation of the material
  69169. * @param scene defines the hosting scene
  69170. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69171. * @returns a new sky material
  69172. */
  69173. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  69174. }
  69175. }
  69176. declare module BABYLON {
  69177. /** @hidden */
  69178. export var terrainPixelShader: {
  69179. name: string;
  69180. shader: string;
  69181. };
  69182. }
  69183. declare module BABYLON {
  69184. /** @hidden */
  69185. export var terrainVertexShader: {
  69186. name: string;
  69187. shader: string;
  69188. };
  69189. }
  69190. declare module BABYLON {
  69191. export class TerrainMaterial extends BABYLON.PushMaterial {
  69192. private _mixTexture;
  69193. mixTexture: BABYLON.BaseTexture;
  69194. private _diffuseTexture1;
  69195. diffuseTexture1: BABYLON.Texture;
  69196. private _diffuseTexture2;
  69197. diffuseTexture2: BABYLON.Texture;
  69198. private _diffuseTexture3;
  69199. diffuseTexture3: BABYLON.Texture;
  69200. private _bumpTexture1;
  69201. bumpTexture1: BABYLON.Texture;
  69202. private _bumpTexture2;
  69203. bumpTexture2: BABYLON.Texture;
  69204. private _bumpTexture3;
  69205. bumpTexture3: BABYLON.Texture;
  69206. diffuseColor: BABYLON.Color3;
  69207. specularColor: BABYLON.Color3;
  69208. specularPower: number;
  69209. private _disableLighting;
  69210. disableLighting: boolean;
  69211. private _maxSimultaneousLights;
  69212. maxSimultaneousLights: number;
  69213. private _renderId;
  69214. constructor(name: string, scene: BABYLON.Scene);
  69215. needAlphaBlending(): boolean;
  69216. needAlphaTesting(): boolean;
  69217. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69218. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69219. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69220. getAnimatables(): BABYLON.IAnimatable[];
  69221. getActiveTextures(): BABYLON.BaseTexture[];
  69222. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69223. dispose(forceDisposeEffect?: boolean): void;
  69224. clone(name: string): TerrainMaterial;
  69225. serialize(): any;
  69226. getClassName(): string;
  69227. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  69228. }
  69229. }
  69230. declare module BABYLON {
  69231. /** @hidden */
  69232. export var triplanarPixelShader: {
  69233. name: string;
  69234. shader: string;
  69235. };
  69236. }
  69237. declare module BABYLON {
  69238. /** @hidden */
  69239. export var triplanarVertexShader: {
  69240. name: string;
  69241. shader: string;
  69242. };
  69243. }
  69244. declare module BABYLON {
  69245. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  69246. mixTexture: BABYLON.BaseTexture;
  69247. private _diffuseTextureX;
  69248. diffuseTextureX: BABYLON.BaseTexture;
  69249. private _diffuseTextureY;
  69250. diffuseTextureY: BABYLON.BaseTexture;
  69251. private _diffuseTextureZ;
  69252. diffuseTextureZ: BABYLON.BaseTexture;
  69253. private _normalTextureX;
  69254. normalTextureX: BABYLON.BaseTexture;
  69255. private _normalTextureY;
  69256. normalTextureY: BABYLON.BaseTexture;
  69257. private _normalTextureZ;
  69258. normalTextureZ: BABYLON.BaseTexture;
  69259. tileSize: number;
  69260. diffuseColor: BABYLON.Color3;
  69261. specularColor: BABYLON.Color3;
  69262. specularPower: number;
  69263. private _disableLighting;
  69264. disableLighting: boolean;
  69265. private _maxSimultaneousLights;
  69266. maxSimultaneousLights: number;
  69267. private _renderId;
  69268. constructor(name: string, scene: BABYLON.Scene);
  69269. needAlphaBlending(): boolean;
  69270. needAlphaTesting(): boolean;
  69271. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69272. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69273. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69274. getAnimatables(): BABYLON.IAnimatable[];
  69275. getActiveTextures(): BABYLON.BaseTexture[];
  69276. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69277. dispose(forceDisposeEffect?: boolean): void;
  69278. clone(name: string): TriPlanarMaterial;
  69279. serialize(): any;
  69280. getClassName(): string;
  69281. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  69282. }
  69283. }
  69284. declare module BABYLON {
  69285. /** @hidden */
  69286. export var waterPixelShader: {
  69287. name: string;
  69288. shader: string;
  69289. };
  69290. }
  69291. declare module BABYLON {
  69292. /** @hidden */
  69293. export var waterVertexShader: {
  69294. name: string;
  69295. shader: string;
  69296. };
  69297. }
  69298. declare module BABYLON {
  69299. export class WaterMaterial extends BABYLON.PushMaterial {
  69300. renderTargetSize: BABYLON.Vector2;
  69301. private _bumpTexture;
  69302. bumpTexture: BABYLON.BaseTexture;
  69303. diffuseColor: BABYLON.Color3;
  69304. specularColor: BABYLON.Color3;
  69305. specularPower: number;
  69306. private _disableLighting;
  69307. disableLighting: boolean;
  69308. private _maxSimultaneousLights;
  69309. maxSimultaneousLights: number;
  69310. /**
  69311. * @param {number}: Represents the wind force
  69312. */
  69313. windForce: number;
  69314. /**
  69315. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  69316. */
  69317. windDirection: BABYLON.Vector2;
  69318. /**
  69319. * @param {number}: Wave height, represents the height of the waves
  69320. */
  69321. waveHeight: number;
  69322. /**
  69323. * @param {number}: Bump height, represents the bump height related to the bump map
  69324. */
  69325. bumpHeight: number;
  69326. /**
  69327. * @param {boolean}: Add a smaller moving bump to less steady waves.
  69328. */
  69329. private _bumpSuperimpose;
  69330. bumpSuperimpose: boolean;
  69331. /**
  69332. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  69333. */
  69334. private _fresnelSeparate;
  69335. fresnelSeparate: boolean;
  69336. /**
  69337. * @param {boolean}: bump Waves modify the reflection.
  69338. */
  69339. private _bumpAffectsReflection;
  69340. bumpAffectsReflection: boolean;
  69341. /**
  69342. * @param {number}: The water color blended with the refraction (near)
  69343. */
  69344. waterColor: BABYLON.Color3;
  69345. /**
  69346. * @param {number}: The blend factor related to the water color
  69347. */
  69348. colorBlendFactor: number;
  69349. /**
  69350. * @param {number}: The water color blended with the reflection (far)
  69351. */
  69352. waterColor2: BABYLON.Color3;
  69353. /**
  69354. * @param {number}: The blend factor related to the water color (reflection, far)
  69355. */
  69356. colorBlendFactor2: number;
  69357. /**
  69358. * @param {number}: Represents the maximum length of a wave
  69359. */
  69360. waveLength: number;
  69361. /**
  69362. * @param {number}: Defines the waves speed
  69363. */
  69364. waveSpeed: number;
  69365. /**
  69366. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  69367. * will avoid calculating useless pixels in the pixel shader of the water material.
  69368. */
  69369. disableClipPlane: boolean;
  69370. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  69371. private _mesh;
  69372. private _refractionRTT;
  69373. private _reflectionRTT;
  69374. private _reflectionTransform;
  69375. private _lastTime;
  69376. private _lastDeltaTime;
  69377. private _renderId;
  69378. private _useLogarithmicDepth;
  69379. private _waitingRenderList;
  69380. private _imageProcessingConfiguration;
  69381. private _imageProcessingObserver;
  69382. /**
  69383. * Gets a boolean indicating that current material needs to register RTT
  69384. */
  69385. readonly hasRenderTargetTextures: boolean;
  69386. /**
  69387. * Constructor
  69388. */
  69389. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  69390. useLogarithmicDepth: boolean;
  69391. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  69392. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  69393. addToRenderList(node: any): void;
  69394. enableRenderTargets(enable: boolean): void;
  69395. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  69396. readonly renderTargetsEnabled: boolean;
  69397. needAlphaBlending(): boolean;
  69398. needAlphaTesting(): boolean;
  69399. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69400. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69401. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69402. private _createRenderTargets;
  69403. getAnimatables(): BABYLON.IAnimatable[];
  69404. getActiveTextures(): BABYLON.BaseTexture[];
  69405. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69406. dispose(forceDisposeEffect?: boolean): void;
  69407. clone(name: string): WaterMaterial;
  69408. serialize(): any;
  69409. getClassName(): string;
  69410. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  69411. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  69412. }
  69413. }
  69414. declare module BABYLON {
  69415. /** @hidden */
  69416. export var asciiartPixelShader: {
  69417. name: string;
  69418. shader: string;
  69419. };
  69420. }
  69421. declare module BABYLON {
  69422. /**
  69423. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  69424. *
  69425. * It basically takes care rendering the font front the given font size to a texture.
  69426. * This is used later on in the postprocess.
  69427. */
  69428. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  69429. private _font;
  69430. private _text;
  69431. private _charSize;
  69432. /**
  69433. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  69434. */
  69435. readonly charSize: number;
  69436. /**
  69437. * Create a new instance of the Ascii Art FontTexture class
  69438. * @param name the name of the texture
  69439. * @param font the font to use, use the W3C CSS notation
  69440. * @param text the caracter set to use in the rendering.
  69441. * @param scene the scene that owns the texture
  69442. */
  69443. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  69444. /**
  69445. * Gets the max char width of a font.
  69446. * @param font the font to use, use the W3C CSS notation
  69447. * @return the max char width
  69448. */
  69449. private getFontWidth;
  69450. /**
  69451. * Gets the max char height of a font.
  69452. * @param font the font to use, use the W3C CSS notation
  69453. * @return the max char height
  69454. */
  69455. private getFontHeight;
  69456. /**
  69457. * Clones the current AsciiArtTexture.
  69458. * @return the clone of the texture.
  69459. */
  69460. clone(): AsciiArtFontTexture;
  69461. /**
  69462. * Parses a json object representing the texture and returns an instance of it.
  69463. * @param source the source JSON representation
  69464. * @param scene the scene to create the texture for
  69465. * @return the parsed texture
  69466. */
  69467. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  69468. }
  69469. /**
  69470. * Option available in the Ascii Art Post Process.
  69471. */
  69472. export interface IAsciiArtPostProcessOptions {
  69473. /**
  69474. * The font to use following the w3c font definition.
  69475. */
  69476. font?: string;
  69477. /**
  69478. * The character set to use in the postprocess.
  69479. */
  69480. characterSet?: string;
  69481. /**
  69482. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  69483. * This number is defined between 0 and 1;
  69484. */
  69485. mixToTile?: number;
  69486. /**
  69487. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  69488. * This number is defined between 0 and 1;
  69489. */
  69490. mixToNormal?: number;
  69491. }
  69492. /**
  69493. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  69494. *
  69495. * Simmply add it to your scene and let the nerd that lives in you have fun.
  69496. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  69497. */
  69498. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  69499. /**
  69500. * The font texture used to render the char in the post process.
  69501. */
  69502. private _asciiArtFontTexture;
  69503. /**
  69504. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  69505. * This number is defined between 0 and 1;
  69506. */
  69507. mixToTile: number;
  69508. /**
  69509. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  69510. * This number is defined between 0 and 1;
  69511. */
  69512. mixToNormal: number;
  69513. /**
  69514. * Instantiates a new Ascii Art Post Process.
  69515. * @param name the name to give to the postprocess
  69516. * @camera the camera to apply the post process to.
  69517. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  69518. */
  69519. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  69520. }
  69521. }
  69522. declare module BABYLON {
  69523. /** @hidden */
  69524. export var digitalrainPixelShader: {
  69525. name: string;
  69526. shader: string;
  69527. };
  69528. }
  69529. declare module BABYLON {
  69530. /**
  69531. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  69532. *
  69533. * It basically takes care rendering the font front the given font size to a texture.
  69534. * This is used later on in the postprocess.
  69535. */
  69536. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  69537. private _font;
  69538. private _text;
  69539. private _charSize;
  69540. /**
  69541. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  69542. */
  69543. readonly charSize: number;
  69544. /**
  69545. * Create a new instance of the Digital Rain FontTexture class
  69546. * @param name the name of the texture
  69547. * @param font the font to use, use the W3C CSS notation
  69548. * @param text the caracter set to use in the rendering.
  69549. * @param scene the scene that owns the texture
  69550. */
  69551. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  69552. /**
  69553. * Gets the max char width of a font.
  69554. * @param font the font to use, use the W3C CSS notation
  69555. * @return the max char width
  69556. */
  69557. private getFontWidth;
  69558. /**
  69559. * Gets the max char height of a font.
  69560. * @param font the font to use, use the W3C CSS notation
  69561. * @return the max char height
  69562. */
  69563. private getFontHeight;
  69564. /**
  69565. * Clones the current DigitalRainFontTexture.
  69566. * @return the clone of the texture.
  69567. */
  69568. clone(): DigitalRainFontTexture;
  69569. /**
  69570. * Parses a json object representing the texture and returns an instance of it.
  69571. * @param source the source JSON representation
  69572. * @param scene the scene to create the texture for
  69573. * @return the parsed texture
  69574. */
  69575. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  69576. }
  69577. /**
  69578. * Option available in the Digital Rain Post Process.
  69579. */
  69580. export interface IDigitalRainPostProcessOptions {
  69581. /**
  69582. * The font to use following the w3c font definition.
  69583. */
  69584. font?: string;
  69585. /**
  69586. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  69587. * This number is defined between 0 and 1;
  69588. */
  69589. mixToTile?: number;
  69590. /**
  69591. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  69592. * This number is defined between 0 and 1;
  69593. */
  69594. mixToNormal?: number;
  69595. }
  69596. /**
  69597. * DigitalRainPostProcess helps rendering everithing in digital rain.
  69598. *
  69599. * Simmply add it to your scene and let the nerd that lives in you have fun.
  69600. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  69601. */
  69602. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  69603. /**
  69604. * The font texture used to render the char in the post process.
  69605. */
  69606. private _digitalRainFontTexture;
  69607. /**
  69608. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  69609. * This number is defined between 0 and 1;
  69610. */
  69611. mixToTile: number;
  69612. /**
  69613. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  69614. * This number is defined between 0 and 1;
  69615. */
  69616. mixToNormal: number;
  69617. /**
  69618. * Instantiates a new Digital Rain Post Process.
  69619. * @param name the name to give to the postprocess
  69620. * @camera the camera to apply the post process to.
  69621. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  69622. */
  69623. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  69624. }
  69625. }
  69626. declare module BABYLON {
  69627. /** @hidden */
  69628. export var oceanPostProcessPixelShader: {
  69629. name: string;
  69630. shader: string;
  69631. };
  69632. }
  69633. declare module BABYLON {
  69634. /**
  69635. * Option available in the Ocean Post Process.
  69636. */
  69637. export interface IOceanPostProcessOptions {
  69638. /**
  69639. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  69640. */
  69641. reflectionSize?: number | {
  69642. width: number;
  69643. height: number;
  69644. } | {
  69645. ratio: number;
  69646. };
  69647. /**
  69648. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  69649. */
  69650. refractionSize?: number | {
  69651. width: number;
  69652. height: number;
  69653. } | {
  69654. ratio: number;
  69655. };
  69656. }
  69657. /**
  69658. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  69659. *
  69660. * Simmply add it to your scene and let the nerd that lives in you have fun.
  69661. * Example usage:
  69662. * var pp = new OceanPostProcess("myOcean", camera);
  69663. * pp.reflectionEnabled = true;
  69664. * pp.refractionEnabled = true;
  69665. */
  69666. export class OceanPostProcess extends BABYLON.PostProcess {
  69667. /**
  69668. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  69669. */
  69670. /**
  69671. * Sets weither or not the real-time reflection is enabled on the ocean.
  69672. * Is set to true, the reflection mirror texture will be used as reflection texture.
  69673. */
  69674. reflectionEnabled: boolean;
  69675. /**
  69676. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  69677. */
  69678. /**
  69679. * Sets weither or not the real-time refraction is enabled on the ocean.
  69680. * Is set to true, the refraction render target texture will be used as refraction texture.
  69681. */
  69682. refractionEnabled: boolean;
  69683. /**
  69684. * Gets wether or not the post-processes is supported by the running hardware.
  69685. * This requires draw buffer supports.
  69686. */
  69687. readonly isSupported: boolean;
  69688. /**
  69689. * This is the reflection mirror texture used to display reflections on the ocean.
  69690. * By default, render list is empty.
  69691. */
  69692. reflectionTexture: BABYLON.MirrorTexture;
  69693. /**
  69694. * This is the refraction render target texture used to display refraction on the ocean.
  69695. * By default, render list is empty.
  69696. */
  69697. refractionTexture: BABYLON.RenderTargetTexture;
  69698. private _time;
  69699. private _cameraRotation;
  69700. private _cameraViewMatrix;
  69701. private _reflectionEnabled;
  69702. private _refractionEnabled;
  69703. private _geometryRenderer;
  69704. /**
  69705. * Instantiates a new Ocean Post Process.
  69706. * @param name the name to give to the postprocess.
  69707. * @camera the camera to apply the post process to.
  69708. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  69709. */
  69710. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  69711. /**
  69712. * Returns the appropriate defines according to the current configuration.
  69713. */
  69714. private _getDefines;
  69715. /**
  69716. * Computes the current camera rotation as the shader requires a camera rotation.
  69717. */
  69718. private _computeCameraRotation;
  69719. }
  69720. }
  69721. declare module BABYLON {
  69722. /** @hidden */
  69723. export var brickProceduralTexturePixelShader: {
  69724. name: string;
  69725. shader: string;
  69726. };
  69727. }
  69728. declare module BABYLON {
  69729. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  69730. private _numberOfBricksHeight;
  69731. private _numberOfBricksWidth;
  69732. private _jointColor;
  69733. private _brickColor;
  69734. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69735. updateShaderUniforms(): void;
  69736. numberOfBricksHeight: number;
  69737. numberOfBricksWidth: number;
  69738. jointColor: BABYLON.Color3;
  69739. brickColor: BABYLON.Color3;
  69740. /**
  69741. * Serializes this brick procedural texture
  69742. * @returns a serialized brick procedural texture object
  69743. */
  69744. serialize(): any;
  69745. /**
  69746. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  69747. * @param parsedTexture defines parsed texture data
  69748. * @param scene defines the current scene
  69749. * @param rootUrl defines the root URL containing brick procedural texture information
  69750. * @returns a parsed Brick Procedural BABYLON.Texture
  69751. */
  69752. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  69753. }
  69754. }
  69755. declare module BABYLON {
  69756. /** @hidden */
  69757. export var cloudProceduralTexturePixelShader: {
  69758. name: string;
  69759. shader: string;
  69760. };
  69761. }
  69762. declare module BABYLON {
  69763. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  69764. private _skyColor;
  69765. private _cloudColor;
  69766. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69767. updateShaderUniforms(): void;
  69768. skyColor: BABYLON.Color4;
  69769. cloudColor: BABYLON.Color4;
  69770. /**
  69771. * Serializes this cloud procedural texture
  69772. * @returns a serialized cloud procedural texture object
  69773. */
  69774. serialize(): any;
  69775. /**
  69776. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  69777. * @param parsedTexture defines parsed texture data
  69778. * @param scene defines the current scene
  69779. * @param rootUrl defines the root URL containing cloud procedural texture information
  69780. * @returns a parsed Cloud Procedural BABYLON.Texture
  69781. */
  69782. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  69783. }
  69784. }
  69785. declare module BABYLON {
  69786. /** @hidden */
  69787. export var fireProceduralTexturePixelShader: {
  69788. name: string;
  69789. shader: string;
  69790. };
  69791. }
  69792. declare module BABYLON {
  69793. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  69794. private _time;
  69795. private _speed;
  69796. private _autoGenerateTime;
  69797. private _fireColors;
  69798. private _alphaThreshold;
  69799. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69800. updateShaderUniforms(): void;
  69801. render(useCameraPostProcess?: boolean): void;
  69802. static readonly PurpleFireColors: BABYLON.Color3[];
  69803. static readonly GreenFireColors: BABYLON.Color3[];
  69804. static readonly RedFireColors: BABYLON.Color3[];
  69805. static readonly BlueFireColors: BABYLON.Color3[];
  69806. autoGenerateTime: boolean;
  69807. fireColors: BABYLON.Color3[];
  69808. time: number;
  69809. speed: BABYLON.Vector2;
  69810. alphaThreshold: number;
  69811. /**
  69812. * Serializes this fire procedural texture
  69813. * @returns a serialized fire procedural texture object
  69814. */
  69815. serialize(): any;
  69816. /**
  69817. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  69818. * @param parsedTexture defines parsed texture data
  69819. * @param scene defines the current scene
  69820. * @param rootUrl defines the root URL containing fire procedural texture information
  69821. * @returns a parsed Fire Procedural BABYLON.Texture
  69822. */
  69823. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  69824. }
  69825. }
  69826. declare module BABYLON {
  69827. /** @hidden */
  69828. export var grassProceduralTexturePixelShader: {
  69829. name: string;
  69830. shader: string;
  69831. };
  69832. }
  69833. declare module BABYLON {
  69834. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  69835. private _grassColors;
  69836. private _groundColor;
  69837. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69838. updateShaderUniforms(): void;
  69839. grassColors: BABYLON.Color3[];
  69840. groundColor: BABYLON.Color3;
  69841. /**
  69842. * Serializes this grass procedural texture
  69843. * @returns a serialized grass procedural texture object
  69844. */
  69845. serialize(): any;
  69846. /**
  69847. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  69848. * @param parsedTexture defines parsed texture data
  69849. * @param scene defines the current scene
  69850. * @param rootUrl defines the root URL containing grass procedural texture information
  69851. * @returns a parsed Grass Procedural BABYLON.Texture
  69852. */
  69853. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  69854. }
  69855. }
  69856. declare module BABYLON {
  69857. /** @hidden */
  69858. export var marbleProceduralTexturePixelShader: {
  69859. name: string;
  69860. shader: string;
  69861. };
  69862. }
  69863. declare module BABYLON {
  69864. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  69865. private _numberOfTilesHeight;
  69866. private _numberOfTilesWidth;
  69867. private _amplitude;
  69868. private _jointColor;
  69869. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69870. updateShaderUniforms(): void;
  69871. numberOfTilesHeight: number;
  69872. amplitude: number;
  69873. numberOfTilesWidth: number;
  69874. jointColor: BABYLON.Color3;
  69875. /**
  69876. * Serializes this marble procedural texture
  69877. * @returns a serialized marble procedural texture object
  69878. */
  69879. serialize(): any;
  69880. /**
  69881. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  69882. * @param parsedTexture defines parsed texture data
  69883. * @param scene defines the current scene
  69884. * @param rootUrl defines the root URL containing marble procedural texture information
  69885. * @returns a parsed Marble Procedural BABYLON.Texture
  69886. */
  69887. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  69888. }
  69889. }
  69890. declare module BABYLON {
  69891. /** @hidden */
  69892. export var normalMapProceduralTexturePixelShader: {
  69893. name: string;
  69894. shader: string;
  69895. };
  69896. }
  69897. declare module BABYLON {
  69898. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  69899. private _baseTexture;
  69900. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69901. updateShaderUniforms(): void;
  69902. render(useCameraPostProcess?: boolean): void;
  69903. resize(size: any, generateMipMaps: any): void;
  69904. baseTexture: BABYLON.Texture;
  69905. /**
  69906. * Serializes this normal map procedural texture
  69907. * @returns a serialized normal map procedural texture object
  69908. */
  69909. serialize(): any;
  69910. /**
  69911. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  69912. * @param parsedTexture defines parsed texture data
  69913. * @param scene defines the current scene
  69914. * @param rootUrl defines the root URL containing normal map procedural texture information
  69915. * @returns a parsed Normal Map Procedural BABYLON.Texture
  69916. */
  69917. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  69918. }
  69919. }
  69920. declare module BABYLON {
  69921. /** @hidden */
  69922. export var perlinNoiseProceduralTexturePixelShader: {
  69923. name: string;
  69924. shader: string;
  69925. };
  69926. }
  69927. declare module BABYLON {
  69928. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  69929. time: number;
  69930. timeScale: number;
  69931. translationSpeed: number;
  69932. private _currentTranslation;
  69933. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69934. updateShaderUniforms(): void;
  69935. render(useCameraPostProcess?: boolean): void;
  69936. resize(size: any, generateMipMaps: any): void;
  69937. /**
  69938. * Serializes this perlin noise procedural texture
  69939. * @returns a serialized perlin noise procedural texture object
  69940. */
  69941. serialize(): any;
  69942. /**
  69943. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  69944. * @param parsedTexture defines parsed texture data
  69945. * @param scene defines the current scene
  69946. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  69947. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  69948. */
  69949. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  69950. }
  69951. }
  69952. declare module BABYLON {
  69953. /** @hidden */
  69954. export var roadProceduralTexturePixelShader: {
  69955. name: string;
  69956. shader: string;
  69957. };
  69958. }
  69959. declare module BABYLON {
  69960. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  69961. private _roadColor;
  69962. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69963. updateShaderUniforms(): void;
  69964. roadColor: BABYLON.Color3;
  69965. /**
  69966. * Serializes this road procedural texture
  69967. * @returns a serialized road procedural texture object
  69968. */
  69969. serialize(): any;
  69970. /**
  69971. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  69972. * @param parsedTexture defines parsed texture data
  69973. * @param scene defines the current scene
  69974. * @param rootUrl defines the root URL containing road procedural texture information
  69975. * @returns a parsed Road Procedural BABYLON.Texture
  69976. */
  69977. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  69978. }
  69979. }
  69980. declare module BABYLON {
  69981. /** @hidden */
  69982. export var starfieldProceduralTexturePixelShader: {
  69983. name: string;
  69984. shader: string;
  69985. };
  69986. }
  69987. declare module BABYLON {
  69988. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  69989. private _time;
  69990. private _alpha;
  69991. private _beta;
  69992. private _zoom;
  69993. private _formuparam;
  69994. private _stepsize;
  69995. private _tile;
  69996. private _brightness;
  69997. private _darkmatter;
  69998. private _distfading;
  69999. private _saturation;
  70000. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70001. updateShaderUniforms(): void;
  70002. time: number;
  70003. alpha: number;
  70004. beta: number;
  70005. formuparam: number;
  70006. stepsize: number;
  70007. zoom: number;
  70008. tile: number;
  70009. brightness: number;
  70010. darkmatter: number;
  70011. distfading: number;
  70012. saturation: number;
  70013. /**
  70014. * Serializes this starfield procedural texture
  70015. * @returns a serialized starfield procedural texture object
  70016. */
  70017. serialize(): any;
  70018. /**
  70019. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  70020. * @param parsedTexture defines parsed texture data
  70021. * @param scene defines the current scene
  70022. * @param rootUrl defines the root URL containing startfield procedural texture information
  70023. * @returns a parsed Starfield Procedural BABYLON.Texture
  70024. */
  70025. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  70026. }
  70027. }
  70028. declare module BABYLON {
  70029. /** @hidden */
  70030. export var woodProceduralTexturePixelShader: {
  70031. name: string;
  70032. shader: string;
  70033. };
  70034. }
  70035. declare module BABYLON {
  70036. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  70037. private _ampScale;
  70038. private _woodColor;
  70039. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70040. updateShaderUniforms(): void;
  70041. ampScale: number;
  70042. woodColor: BABYLON.Color3;
  70043. /**
  70044. * Serializes this wood procedural texture
  70045. * @returns a serialized wood procedural texture object
  70046. */
  70047. serialize(): any;
  70048. /**
  70049. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  70050. * @param parsedTexture defines parsed texture data
  70051. * @param scene defines the current scene
  70052. * @param rootUrl defines the root URL containing wood procedural texture information
  70053. * @returns a parsed Wood Procedural BABYLON.Texture
  70054. */
  70055. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  70056. }
  70057. }